Skip to content

Commit

Permalink
fix(eslint-patch): automatic switching between ESLint version patches
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin-y-ang committed Oct 26, 2023
1 parent 738aec7 commit ec1fc14
Show file tree
Hide file tree
Showing 26 changed files with 993 additions and 409 deletions.
191 changes: 150 additions & 41 deletions build-tests/eslint-bulk-suppressions-test/.eslint-bulk-suppressions.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,98 +3,207 @@
{
"file": "src/test-lab.ts",
"scope": ".",
"target": ".",
"rule": "@typescript-eslint/no-namespace"
},
{
"file": "src/test-lab.ts",
"scope": ".",
"rule": "header/header"
},
{
"file": "src/test-lab.ts",
"scope": ".",
"rule": "prefer-const"
},
{
"file": "src/test-lab.ts",
"scope": ".ArrowFunctionExpression",
"target": ".x",
"rule": "@typescript-eslint/no-empty-function"
"scope": ".AbsurdClass.absurdClassMethod",
"rule": "@typescript-eslint/explicit-function-return-type"
},
{
"file": "src/test-lab.ts",
"scope": ".AbsurdClass.absurdClassMethod",
"rule": "@typescript-eslint/explicit-member-accessibility"
},
{
"file": "src/test-lab.ts",
"scope": ".AbsurdClass.absurdClassMethod.AbsurdClass2",
"rule": "@typescript-eslint/explicit-member-accessibility"
},
{
"file": "src/test-lab.ts",
"scope": ".ArrowFunctionExpression",
"target": ".y",
"rule": "@typescript-eslint/no-empty-function"
"scope": ".AbsurdClass.absurdClassMethod.AbsurdClass2",
"rule": "@typescript-eslint/typedef"
},
{
"file": "src/test-lab.ts",
"scope": ".ArrowFunctionExpression",
"target": ".z",
"rule": "@typescript-eslint/no-empty-function"
"scope": ".AbsurdClass.absurdClassMethod.AbsurdClass2.constructor",
"rule": "@typescript-eslint/explicit-member-accessibility"
},
{
"file": "src/test-lab.ts",
"scope": ".ClassDeclaration",
"target": ".ExampleClass",
"scope": ".AbsurdClass.absurdClassMethod.AbsurdClass2.constructor.absurdObject",
"rule": "@typescript-eslint/typedef"
},
{
"file": "src/test-lab.ts",
"scope": ".ExampleClass",
"rule": "@typescript-eslint/ban-types"
},
{
"file": "src/test-lab.ts",
"scope": ".ClassDeclaration.MethodDefinition",
"target": ".ExampleClass.exampleMethod",
"scope": ".ExampleClass",
"rule": "@typescript-eslint/explicit-member-accessibility"
},
{
"file": "src/test-lab.ts",
"scope": ".ExampleClass.exampleMethod",
"rule": "@typescript-eslint/explicit-function-return-type"
},
{
"file": "src/test-lab.ts",
"scope": ".ExampleClass.exampleMethod",
"rule": "@typescript-eslint/explicit-member-accessibility"
},
{
"file": "src/test-lab.ts",
"scope": ".ExampleClass.exampleMethod",
"rule": "@typescript-eslint/typedef"
},
{
"file": "src/test-lab.ts",
"scope": ".ExampleClass.exampleMethod",
"rule": "no-var"
},
{
"file": "src/test-lab.ts",
"scope": ".ClassDeclaration.MethodDefinition.ClassExpression.MethodDefinition.ObjectExpression.FunctionExpression",
"target": ".AbsurdClass.absurdClassMethod.AbsurdClass2.constructor.absurdObject.absurdObjectMethod",
"rule": "@typescript-eslint/no-empty-function"
"scope": ".ExampleEnum",
"rule": "dot-notation"
},
{
"file": "src/test-lab.ts",
"scope": ".ClassExpression.MethodDefinition",
"target": ".exampleAnonymousClass.constructor",
"rule": "@typescript-eslint/no-empty-function"
"scope": ".ExampleInterface",
"rule": "@typescript-eslint/naming-convention"
},
{
"file": "src/test-lab.ts",
"scope": ".ClassExpression.MethodDefinition",
"target": ".exampleAnonymousClass.exampleSetGet",
"scope": ".ExampleInterface2",
"rule": "@typescript-eslint/naming-convention"
},
{
"file": "src/test-lab.ts",
"scope": ".ExampleObjectType",
"rule": "@typescript-eslint/ban-types"
},
{
"file": "src/test-lab.ts",
"scope": ".FunctionDeclaration",
"target": ".exampleFunction",
"scope": ".ExampleObjectType",
"rule": "@typescript-eslint/consistent-type-definitions"
},
{
"file": "src/test-lab.ts",
"scope": ".exampleAnonymousClass",
"rule": "@typescript-eslint/explicit-member-accessibility"
},
{
"file": "src/test-lab.ts",
"scope": ".exampleAnonymousClass",
"rule": "@typescript-eslint/typedef"
},
{
"file": "src/test-lab.ts",
"scope": ".exampleAnonymousClass",
"rule": "no-useless-concat"
},
{
"file": "src/test-lab.ts",
"scope": ".exampleAnonymousClass.constructor",
"rule": "@typescript-eslint/explicit-member-accessibility"
},
{
"file": "src/test-lab.ts",
"scope": ".exampleAnonymousClass.exampleSetGet",
"rule": "@typescript-eslint/ban-types"
},
{
"file": "src/test-lab.ts",
"scope": ".ObjectExpression.ArrowFunctionExpression",
"target": ".exampleObject2.exampleObjectProperty",
"rule": "@typescript-eslint/no-empty-function"
"scope": ".exampleAnonymousClass.exampleSetGet",
"rule": "@typescript-eslint/explicit-function-return-type"
},
{
"file": "src/test-lab.ts",
"scope": ".ObjectExpression.FunctionExpression",
"target": ".exampleObject2.exampleObjectMethod",
"rule": "@typescript-eslint/no-inferrable-types"
"scope": ".exampleAnonymousClass.exampleSetGet",
"rule": "@typescript-eslint/explicit-member-accessibility"
},
{
"file": "src/test-lab.ts",
"scope": ".TSInterfaceDeclaration",
"target": ".ExampleInterface",
"rule": "@typescript-eslint/no-empty-interface"
"scope": ".exampleArrowFunction",
"rule": "@typescript-eslint/explicit-function-return-type"
},
{
"file": "src/test-lab.ts",
"scope": ".TSModuleDeclaration",
"target": ".ExampleModule",
"rule": "@typescript-eslint/no-namespace"
"scope": ".exampleArrowFunction",
"rule": "@typescript-eslint/typedef"
},
{
"file": "src/test-lab.ts",
"scope": ".exampleArrowFunction",
"rule": "dot-notation"
},
{
"file": "src/test-lab.ts",
"scope": ".exampleArrowFunction",
"rule": "no-empty"
},
{
"file": "src/test-lab.ts",
"scope": ".TSModuleDeclaration.TSInterfaceDeclaration",
"target": ".ExampleModule.ExampleInterface2",
"rule": "@typescript-eslint/no-empty-interface"
"scope": ".exampleArrowFunction",
"rule": "no-unused-expressions"
},
{
"file": "src/test-lab.ts",
"scope": ".TSTypeAliasDeclaration",
"target": ".ExampleObjectType",
"scope": ".exampleFunction",
"rule": "@typescript-eslint/ban-types"
},
{
"file": "src/test-lab.ts",
"scope": ".exampleFunction",
"rule": "@typescript-eslint/explicit-function-return-type"
},
{
"file": "src/test-lab.ts",
"scope": ".exampleFunction",
"rule": "no-empty-pattern"
},
{
"file": "src/test-lab.ts",
"scope": ".exampleFunction",
"rule": "no-extra-boolean-cast"
},
{
"file": "src/test-lab.ts",
"scope": ".exampleObject",
"rule": "@typescript-eslint/typedef"
},
{
"file": "src/test-lab.ts",
"scope": ".exampleObject2",
"rule": "@typescript-eslint/typedef"
},
{
"file": "src/test-lab.ts",
"scope": ".x",
"rule": "@typescript-eslint/explicit-function-return-type"
},
{
"file": "src/test-lab.ts",
"scope": ".y",
"rule": "@typescript-eslint/explicit-function-return-type"
},
{
"file": "src/test-lab.ts",
"scope": ".z",
"rule": "@typescript-eslint/explicit-function-return-type"
}
]
}
31 changes: 27 additions & 4 deletions build-tests/eslint-bulk-suppressions-test/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,31 @@
// 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('@rushstack/eslint-config/patch/modern-module-resolution');
require('@rushstack/eslint-config/patch/eslint-bulk-suppressions');
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: ['plugin:@typescript-eslint/recommended'],
parserOptions: { tsconfigRootDir: __dirname }
extends: [
'local-node-rig/profiles/default/includes/eslint/profile/node-trusted-tool',
'local-node-rig/profiles/default/includes/eslint/mixins/friendly-locals'
],
parserOptions: { tsconfigRootDir: __dirname },

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'
}
]
};
7 changes: 6 additions & 1 deletion build-tests/eslint-bulk-suppressions-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,14 @@
"eslint-without-bulk-suppressions": "USE_ESLINT_BULK_SUPPRESSIONS=false eslint ."
},
"devDependencies": {
"@rushstack/eslint-config": "workspace:*",
"@rushstack/heft": "workspace:*",
"local-node-rig": "workspace:*",
"@types/node": "18.17.15",
"@typescript-eslint/eslint-plugin": "~5.59.2",
"@typescript-eslint/parser": "~5.59.2",
"@typescript-eslint/scope-manager": "~5.59.2",
"@typescript-eslint/typescript-estree": "~5.59.2",
"@typescript-eslint/utils": "~5.59.2",
"eslint": "~8.7.0",
"typescript": "~5.0.4"
}
Expand Down
24 changes: 24 additions & 0 deletions build-tests/eslint-bulk-suppressions-test/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"$schema": "http://json.schemastore.org/tsconfig",

"compilerOptions": {
"outDir": "lib",
"rootDir": "src",
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"declaration": true,
"sourceMap": true,
"declarationMap": true,
"inlineSources": true,
"experimentalDecorators": true,
"strictNullChecks": true,
"noUnusedLocals": true,

"module": "esnext",
"moduleResolution": "node",
"target": "es5",
"lib": ["es5"]
},
"include": ["src/**/*.ts", "src/**/*.tsx"],
"exclude": ["node_modules", "lib"]
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion common/config/rush/browser-approved-packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@
"name": "@rushstack/rush-vscode-command-webview",
"allowedCategories": [ "vscode-extensions" ]
},
{
"name": "@typescript-eslint/scope-manager",
"allowedCategories": [ "libraries", "tests" ]
},
{
"name": "@typescript-eslint/type-utils",
"allowedCategories": [ "libraries" ]
Expand All @@ -56,7 +60,7 @@
},
{
"name": "@typescript-eslint/utils",
"allowedCategories": [ "libraries" ]
"allowedCategories": [ "libraries", "tests" ]
},
{
"name": "@vscode/test-electron",
Expand Down
10 changes: 5 additions & 5 deletions common/config/rush/nonbrowser-approved-packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@
},
{
"name": "@typescript-eslint/typescript-estree",
"allowedCategories": [ "libraries" ]
"allowedCategories": [ "libraries", "tests" ]
},
{
"name": "@yarnpkg/lockfile",
Expand Down Expand Up @@ -442,10 +442,6 @@
"name": "eslint",
"allowedCategories": [ "libraries", "tests", "vscode-extensions" ]
},
{
"name": "local-eslint-config",
"allowedCategories": [ "libraries", "tests", "vscode-extensions" ]
},
{
"name": "eslint-plugin-deprecation",
"allowedCategories": [ "libraries" ]
Expand Down Expand Up @@ -634,6 +630,10 @@
"name": "loader-utils",
"allowedCategories": [ "libraries" ]
},
{
"name": "local-eslint-config",
"allowedCategories": [ "libraries", "tests", "vscode-extensions" ]
},
{
"name": "local-node-rig",
"allowedCategories": [ "libraries", "tests", "vscode-extensions" ]
Expand Down
Loading

0 comments on commit ec1fc14

Please sign in to comment.