Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[eslint-patch] Implementation for ESLint Bulk Suppressions v0.1.0 #4366

Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
68ef7e2
feat: working prototype for eslint-global-suppressions
Aug 29, 2023
f70dd81
fix: small changes
kevin-y-ang Aug 30, 2023
4f3fc3c
fix: code cleanup
kevin-y-ang Aug 31, 2023
0a4b84d
fix(eslint-global-suppressions): support ESLint v8.7.0 and make that …
kevin-y-ang Sep 1, 2023
0cfab5a
fix(eslint-global-suppressions-test): remove spurious dependencies
kevin-y-ang Sep 1, 2023
8cba410
fix: restore accidentally deleted pre-commit hook
kevin-y-ang Sep 1, 2023
b9ec493
fix: rename from global suppressions to bulk suppressions
kevin-y-ang Sep 28, 2023
c7145a0
chore(eslint bulk suppressions): Add to eslint-patch README
kevin-y-ang Sep 28, 2023
1af7e81
fix(eslint-patch): automatic switching between ESLint version patches
kevin-y-ang Oct 5, 2023
480ed11
feat: eslint-bulk package
kevin-y-ang Oct 23, 2023
22a6514
fix: cleanup spurious changes
kevin-y-ang Oct 26, 2023
3e540b2
chore(eslint-bulk): add eslint-bulk README
kevin-y-ang Oct 26, 2023
cf00eb8
chore(eslint-bulk): run rush change
kevin-y-ang Oct 26, 2023
6a88182
chore(eslint-bulk): pass pipeline
kevin-y-ang Oct 26, 2023
dd1c64c
chore: update README
kevin-y-ang Oct 27, 2023
33a8c1c
chore: cleanup bulk suppresions build test
kevin-y-ang Oct 27, 2023
88c1eea
chore: cleanup PR
kevin-y-ang Oct 31, 2023
b1f2e91
feat: migrate from commander to inhouse CLI parser
kevin-y-ang Nov 1, 2023
56b5555
chore: find and console log patch path
kevin-y-ang Nov 1, 2023
44970c4
feat: move eslint-bulk CLI implementation to inside patch to have eas…
kevin-y-ang Nov 2, 2023
aace721
fix: remove unsafe eslint installation guessing
kevin-y-ang Nov 2, 2023
135e043
chore: clean up PR
kevin-y-ang Nov 2, 2023
b59537c
feat(eslint-bulk-suppressions): dynamically generate patches
kevin-y-ang Nov 6, 2023
01ea957
fix: change supported versions to tested versions
kevin-y-ang Nov 6, 2023
118c02c
fix(eslint-patch): fix the README to recommend using the eslint-bulk …
kevin-y-ang Nov 8, 2023
4ee97ef
chore: change @rushstack/eslint-bulk version to 0.1.0
kevin-y-ang Nov 21, 2023
5506aca
Move some non-browser packages out of browser-approved-packages.json
octogonz Nov 21, 2023
92664f8
Convert "eslint-bulk" to be a standard TypeScript project
octogonz Nov 21, 2023
0a2d142
Add LICENSE file
octogonz Nov 21, 2023
e288f77
Update project to use "local-node-rig"
octogonz Nov 21, 2023
ffb7917
TypeScript code now compiles without errors
octogonz Nov 21, 2023
91c397e
Update common/changes/@rushstack/eslint-patch/feat-working-prototype-…
kevin-y-ang Nov 21, 2023
08e89cf
The "tsconfig.tsbuildinfo" file should not be committed to Git
octogonz Nov 21, 2023
c28b3e8
Remove leftover file
octogonz Nov 21, 2023
b45b07d
Update README.md
kevin-y-ang Nov 21, 2023
0db8777
Turns out that "eslint-patch/bin/eslint-bulk" was actually being used…
octogonz Nov 21, 2023
d5acda0
Merge branch 'feat/working-prototype-for-eslint-bulk-suppressions' of…
octogonz Nov 21, 2023
bea0cdf
Properly escape the configuration string printed by eslint-patch; add…
octogonz Nov 21, 2023
d698ca7
Add a notice for borrowed code
octogonz Nov 21, 2023
a01c2e7
fix(eslint-bulk): change clean command to prune and update --help
kevin-y-ang Nov 21, 2023
2e9e0ed
fix: incorporate feedback
kevin-y-ang Nov 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,4 @@ dist
dist-storybook
*.scss.ts
*.sass.ts
*.tsbuildinfo
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ These GitHub repositories provide supplementary resources for Rush Stack:
| [/apps/rundown](./apps/rundown/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Frundown.svg)](https://badge.fury.io/js/%40rushstack%2Frundown) | [changelog](./apps/rundown/CHANGELOG.md) | [@rushstack/rundown](https://www.npmjs.com/package/@rushstack/rundown) |
| [/apps/rush](./apps/rush/) | [![npm version](https://badge.fury.io/js/%40microsoft%2Frush.svg)](https://badge.fury.io/js/%40microsoft%2Frush) | [changelog](./apps/rush/CHANGELOG.md) | [@microsoft/rush](https://www.npmjs.com/package/@microsoft/rush) |
| [/apps/trace-import](./apps/trace-import/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Ftrace-import.svg)](https://badge.fury.io/js/%40rushstack%2Ftrace-import) | [changelog](./apps/trace-import/CHANGELOG.md) | [@rushstack/trace-import](https://www.npmjs.com/package/@rushstack/trace-import) |
| [/eslint/eslint-bulk](./eslint/eslint-bulk/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Feslint-bulk.svg)](https://badge.fury.io/js/%40rushstack%2Feslint-bulk) | [changelog](./eslint/eslint-bulk/CHANGELOG.md) | [@rushstack/eslint-bulk](https://www.npmjs.com/package/@rushstack/eslint-bulk) |
| [/eslint/eslint-config](./eslint/eslint-config/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Feslint-config.svg)](https://badge.fury.io/js/%40rushstack%2Feslint-config) | [changelog](./eslint/eslint-config/CHANGELOG.md) | [@rushstack/eslint-config](https://www.npmjs.com/package/@rushstack/eslint-config) |
| [/eslint/eslint-patch](./eslint/eslint-patch/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Feslint-patch.svg)](https://badge.fury.io/js/%40rushstack%2Feslint-patch) | [changelog](./eslint/eslint-patch/CHANGELOG.md) | [@rushstack/eslint-patch](https://www.npmjs.com/package/@rushstack/eslint-patch) |
| [/eslint/eslint-plugin](./eslint/eslint-plugin/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Feslint-plugin.svg)](https://badge.fury.io/js/%40rushstack%2Feslint-plugin) | [changelog](./eslint/eslint-plugin/CHANGELOG.md) | [@rushstack/eslint-plugin](https://www.npmjs.com/package/@rushstack/eslint-plugin) |
Expand Down Expand Up @@ -143,6 +144,7 @@ These GitHub repositories provide supplementary resources for Rush Stack:
| [/build-tests/eslint-7-7-test](./build-tests/eslint-7-7-test/) | This project contains a build test to validate ESLint 7.7.0 compatibility with the latest version of @rushstack/eslint-config (and by extension, the ESLint plugin) |
| [/build-tests/eslint-7-test](./build-tests/eslint-7-test/) | This project contains a build test to validate ESLint 7 compatibility with the latest version of @rushstack/eslint-config (and by extension, the ESLint plugin) |
| [/build-tests/eslint-8-test](./build-tests/eslint-8-test/) | This project contains a build test to validate ESLint 8 compatibility with the latest version of @rushstack/eslint-config (and by extension, the ESLint plugin) |
| [/build-tests/eslint-bulk-suppressions-test](./build-tests/eslint-bulk-suppressions-test/) | Sample code to test eslint bulk suppressions |
| [/build-tests/hashed-folder-copy-plugin-webpack5-test](./build-tests/hashed-folder-copy-plugin-webpack5-test/) | Building this project exercises @rushstack/hashed-folder-copy-plugin with Webpack 5. NOTE - THIS TEST IS CURRENTLY EXPECTED TO BE BROKEN |
| [/build-tests/heft-copy-files-test](./build-tests/heft-copy-files-test/) | Building this project tests copying files with Heft |
| [/build-tests/heft-example-plugin-01](./build-tests/heft-example-plugin-01/) | This is an example heft plugin that exposes hooks for other plugins |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
{
"suppressions": [
{
"file": "src/index.ts",
"scopeId": ".",
"rule": "prefer-const"
},
{
"file": "src/index.ts",
"scopeId": ".ExampleClass",
"rule": "@typescript-eslint/ban-types"
},
{
"file": "src/index.ts",
"scopeId": ".ExampleClass",
"rule": "@typescript-eslint/explicit-member-accessibility"
},
{
"file": "src/index.ts",
"scopeId": ".ExampleClass.exampleMethod",
"rule": "@typescript-eslint/explicit-function-return-type"
},
{
"file": "src/index.ts",
"scopeId": ".ExampleClass.exampleMethod",
"rule": "@typescript-eslint/explicit-member-accessibility"
},
{
"file": "src/index.ts",
"scopeId": ".ExampleClass.exampleMethod",
"rule": "@typescript-eslint/typedef"
},
{
"file": "src/index.ts",
"scopeId": ".ExampleClass.exampleMethod",
"rule": "no-var"
},
{
"file": "src/index.ts",
"scopeId": ".exampleAnonymousClass",
"rule": "@typescript-eslint/explicit-member-accessibility"
},
{
"file": "src/index.ts",
"scopeId": ".exampleAnonymousClass",
"rule": "@typescript-eslint/typedef"
},
{
"file": "src/index.ts",
"scopeId": ".exampleAnonymousClass",
"rule": "no-useless-concat"
},
{
"file": "src/index.ts",
"scopeId": ".exampleAnonymousClass.constructor",
"rule": "@typescript-eslint/explicit-member-accessibility"
},
{
"file": "src/index.ts",
"scopeId": ".exampleAnonymousClass.exampleSetGet",
"rule": "@typescript-eslint/ban-types"
},
{
"file": "src/index.ts",
"scopeId": ".exampleAnonymousClass.exampleSetGet",
"rule": "@typescript-eslint/explicit-function-return-type"
},
{
"file": "src/index.ts",
"scopeId": ".exampleAnonymousClass.exampleSetGet",
"rule": "@typescript-eslint/explicit-member-accessibility"
},
{
"file": "src/index.ts",
"scopeId": ".exampleArrowFunction",
"rule": "@typescript-eslint/explicit-function-return-type"
},
{
"file": "src/index.ts",
"scopeId": ".exampleArrowFunction",
"rule": "@typescript-eslint/typedef"
},
{
"file": "src/index.ts",
"scopeId": ".exampleArrowFunction",
"rule": "dot-notation"
},
{
"file": "src/index.ts",
"scopeId": ".exampleArrowFunction",
"rule": "no-empty"
},
{
"file": "src/index.ts",
"scopeId": ".exampleArrowFunction",
"rule": "no-unused-expressions"
},
{
"file": "src/index.ts",
"scopeId": ".exampleFunction",
"rule": "@typescript-eslint/ban-types"
},
{
"file": "src/index.ts",
"scopeId": ".exampleFunction",
"rule": "@typescript-eslint/explicit-function-return-type"
},
{
"file": "src/index.ts",
"scopeId": ".exampleFunction",
"rule": "no-empty-pattern"
},
{
"file": "src/index.ts",
"scopeId": ".exampleFunction",
"rule": "no-extra-boolean-cast"
},
{
"file": "src/index.ts",
"scopeId": ".exampleObject",
"rule": "@typescript-eslint/typedef"
},
{
"file": "src/index.ts",
"scopeId": ".x",
"rule": "@typescript-eslint/explicit-function-return-type"
},
{
"file": "src/index.ts",
"scopeId": ".y",
"rule": "@typescript-eslint/explicit-function-return-type"
},
{
"file": "src/index.ts",
"scopeId": ".z",
"rule": "@typescript-eslint/explicit-function-return-type"
}
]
}
32 changes: 32 additions & 0 deletions build-tests/eslint-bulk-suppressions-test/client/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.

// This is a workaround for https://github.com/eslint/eslint/issues/3458
require('local-node-rig/profiles/default/includes/eslint/patch/modern-module-resolution');
// This is a workaround for https://github.com/microsoft/rushstack/issues/3021
require('local-node-rig/profiles/default/includes/eslint/patch/custom-config-package-names');
require('local-node-rig/profiles/default/includes/eslint/patch/eslint-bulk-suppressions');

module.exports = {
extends: [
'local-node-rig/profiles/default/includes/eslint/profile/node-trusted-tool',
'local-node-rig/profiles/default/includes/eslint/mixins/friendly-locals'
],
ignorePatterns: ['.eslintrc.js'],

overrides: [
/**
* Override the parser from @rushstack/eslint-config. Since the config is coming
* from the workspace instead of the external NPM package, the versions of ESLint
* and TypeScript that the config consumes will be resolved from the devDependencies
* of the config instead of from the eslint-8-test package. Overriding the parser
* ensures that the these dependencies come from the eslint-8-test package. See:
* https://github.com/microsoft/rushstack/issues/3021
*/
{
files: ['**/*.ts', '**/*.tsx'],
parser: '@typescript-eslint/parser',
parserOptions: { project: '../tsconfig.json', tsconfigRootDir: __dirname }
}
]
};
64 changes: 64 additions & 0 deletions build-tests/eslint-bulk-suppressions-test/client/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.

/* Top-level scope code samples */
// scopeId: '.'
let exampleString: string = 5 + '';

const exampleObject = {
exampleString: exampleString
};

/* Function scope code samples */
export function exampleFunction() {
const {}: Object = exampleObject;

// scopeId: '.exampleFunction'
!!!exampleString as Boolean;
}

// scope: '.ArrowFunctionExpression',
export const x = () => {},
// scopeId: '.y'
y = () => {},
// scopeId: '.z'
z = () => {};

/* Class scope code samples */
export class ExampleClass {
// scopeId: '.ExampleClass'
exampleClassProperty: String = exampleString + '4';

exampleMethod() {
// scopeId: '.exampleClass.exampleMethod'
var exampleVar;
return exampleVar;
}
}

/* Variable and anonymous constructs code samples */
export const exampleArrowFunction = () => {
const exampleBoolean = true;
if (exampleBoolean) {
}

exampleObject['exampleString'];
};

export const exampleAnonymousClass = class {
exampleClassProperty = 'x' + 'y';

// scopeId: '.exampleAnonymousClass.constructor'
constructor() {}

set exampleSetGet(val: string) {
// scopeId: '.exampleAnonymousClass.exampleSetGet'
let exampleVariable: Number = 1;
this.exampleClassProperty = val + exampleVariable;
}

get exampleSetGet() {
// scopeId: '.exampleAnonymousClass.exampleSetGet'
return this.exampleClassProperty as String as string;
}
};
7 changes: 7 additions & 0 deletions build-tests/eslint-bulk-suppressions-test/config/rig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
// The "rig.json" file directs tools to look for their config files in an external package.
// Documentation for this system: https://www.npmjs.com/package/@rushstack/rig-package
"$schema": "https://developer.microsoft.com/json-schemas/rig-package/rig.schema.json",

"rigPackageName": "local-node-rig"
}
16 changes: 16 additions & 0 deletions build-tests/eslint-bulk-suppressions-test/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "eslint-bulk-suppressions-test",
"description": "Sample code to test eslint bulk suppressions",
"version": "1.0.0",
"private": true,
"scripts": {
"lint": "eslint ."
},
"devDependencies": {
"@rushstack/heft": "workspace:*",
"local-node-rig": "workspace:*",
"@typescript-eslint/parser": "~5.59.2",
"eslint": "~8.7.0",
"typescript": "~5.0.4"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"suppressions": [
{
"file": "src/index.ts",
"scopeId": ".",
"rule": "@typescript-eslint/no-namespace"
},
{
"file": "src/index.ts",
"scopeId": ".AbsurdClass.absurdClassMethod",
"rule": "@typescript-eslint/explicit-function-return-type"
},
{
"file": "src/index.ts",
"scopeId": ".AbsurdClass.absurdClassMethod",
"rule": "@typescript-eslint/explicit-member-accessibility"
},
{
"file": "src/index.ts",
"scopeId": ".AbsurdClass.absurdClassMethod.AbsurdClass2",
"rule": "@typescript-eslint/explicit-member-accessibility"
},
{
"file": "src/index.ts",
"scopeId": ".AbsurdClass.absurdClassMethod.AbsurdClass2",
"rule": "@typescript-eslint/typedef"
},
{
"file": "src/index.ts",
"scopeId": ".AbsurdClass.absurdClassMethod.AbsurdClass2.constructor",
"rule": "@typescript-eslint/explicit-member-accessibility"
},
{
"file": "src/index.ts",
"scopeId": ".AbsurdClass.absurdClassMethod.AbsurdClass2.constructor.absurdObject",
"rule": "@typescript-eslint/typedef"
},
{
"file": "src/index.ts",
"scopeId": ".ExampleEnum",
"rule": "dot-notation"
},
{
"file": "src/index.ts",
"scopeId": ".ExampleInterface",
"rule": "@typescript-eslint/naming-convention"
},
{
"file": "src/index.ts",
"scopeId": ".ExampleInterface2",
"rule": "@typescript-eslint/naming-convention"
},
{
"file": "src/index.ts",
"scopeId": ".ExampleObjectType",
"rule": "@typescript-eslint/ban-types"
},
{
"file": "src/index.ts",
"scopeId": ".ExampleObjectType",
"rule": "@typescript-eslint/consistent-type-definitions"
},
{
"file": "src/index.ts",
"scopeId": ".exampleObject2",
"rule": "@typescript-eslint/typedef"
}
]
}
32 changes: 32 additions & 0 deletions build-tests/eslint-bulk-suppressions-test/server/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.

// This is a workaround for https://github.com/eslint/eslint/issues/3458
require('local-node-rig/profiles/default/includes/eslint/patch/modern-module-resolution');
// This is a workaround for https://github.com/microsoft/rushstack/issues/3021
require('local-node-rig/profiles/default/includes/eslint/patch/custom-config-package-names');
require('local-node-rig/profiles/default/includes/eslint/patch/eslint-bulk-suppressions');

module.exports = {
extends: [
'local-node-rig/profiles/default/includes/eslint/profile/node-trusted-tool',
'local-node-rig/profiles/default/includes/eslint/mixins/friendly-locals'
],
ignorePatterns: ['.eslintrc.js'],

overrides: [
/**
* Override the parser from @rushstack/eslint-config. Since the config is coming
* from the workspace instead of the external NPM package, the versions of ESLint
* and TypeScript that the config consumes will be resolved from the devDependencies
* of the config instead of from the eslint-8-test package. Overriding the parser
* ensures that the these dependencies come from the eslint-8-test package. See:
* https://github.com/microsoft/rushstack/issues/3021
*/
{
files: ['**/*.ts', '**/*.tsx'],
parser: '@typescript-eslint/parser',
parserOptions: { project: '../tsconfig.json', tsconfigRootDir: __dirname }
}
]
};
Loading
Loading