Skip to content

Commit 9ce7570

Browse files
authored
Merge pull request #4374 from D4N14L/user/danade/FixEslint7
[eslint-patch] Fix patch compatibility with ESLint >=7.0.0 and <7.12.0
2 parents 336b528 + 5e98fee commit 9ce7570

File tree

23 files changed

+504
-196
lines changed

23 files changed

+504
-196
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ These GitHub repositories provide supplementary resources for Rush Stack:
137137
| [/build-tests/api-extractor-test-02](./build-tests/api-extractor-test-02/) | Building this project is a regression test for api-extractor |
138138
| [/build-tests/api-extractor-test-03](./build-tests/api-extractor-test-03/) | Building this project is a regression test for api-extractor |
139139
| [/build-tests/api-extractor-test-04](./build-tests/api-extractor-test-04/) | Building this project is a regression test for api-extractor |
140+
| [/build-tests/eslint-7-11-test](./build-tests/eslint-7-11-test/) | This project contains a build test to validate ESLint 7.11.0 compatibility with the latest version of @rushstack/eslint-config (and by extension, the ESLint plugin) |
141+
| [/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) |
140142
| [/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) |
141143
| [/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) |
142144
| [/build-tests/hashed-folder-copy-plugin-webpack4-test](./build-tests/hashed-folder-copy-plugin-webpack4-test/) | Building this project exercises @rushstack/hashed-folder-copy-plugin with Webpack 4. |
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2+
// See LICENSE in the project root for license information.
3+
4+
// This is a workaround for https://github.com/eslint/eslint/issues/3458
5+
require('local-node-rig/profiles/default/includes/eslint/patch/modern-module-resolution');
6+
// This is a workaround for https://github.com/microsoft/rushstack/issues/3021
7+
require('local-node-rig/profiles/default/includes/eslint/patch/custom-config-package-names');
8+
9+
module.exports = {
10+
extends: [
11+
'local-node-rig/profiles/default/includes/eslint/profile/node-trusted-tool',
12+
'local-node-rig/profiles/default/includes/eslint/mixins/friendly-locals'
13+
],
14+
parserOptions: { tsconfigRootDir: __dirname },
15+
16+
overrides: [
17+
/**
18+
* Override the parser from local-eslint-config. Since the config is coming
19+
* from the workspace instead of the external NPM package, the versions of ESLint
20+
* and TypeScript that the config consumes will be resolved from the devDependencies
21+
* of the config instead of from the eslint-7-test package. Overriding the parser
22+
* ensures that the these dependencies come from the eslint-7-test package. See:
23+
* https://github.com/microsoft/rushstack/issues/3021
24+
*/
25+
{
26+
files: ['*.ts', '*.tsx'],
27+
parser: '@typescript-eslint/parser'
28+
}
29+
]
30+
};
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# eslint-7-11-test
2+
3+
This project folder is one of the **build-tests** for the Rushstack [ESLint configuration](https://www.npmjs.com/package/@rushstack/eslint-config) (and by extension, the [ESLint plugin](https://www.npmjs.com/package/@rushstack/eslint-plugin))
4+
package. This project builds using ESLint v7.11.0 and contains a simple index file to ensure that the build runs ESLint successfully against source code.
5+
6+
Please see the [ESLint Heft task documentation](https://rushstack.io/pages/heft_tasks/eslint/) for documentation and tutorials.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
// The "rig.json" file directs tools to look for their config files in an external package.
3+
// Documentation for this system: https://www.npmjs.com/package/@rushstack/rig-package
4+
"$schema": "https://developer.microsoft.com/json-schemas/rig-package/rig.schema.json",
5+
6+
"rigPackageName": "local-node-rig"
7+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "eslint-7-11-test",
3+
"description": "This project contains a build test to validate ESLint 7.11.0 compatibility with the latest version of @rushstack/eslint-config (and by extension, the ESLint plugin)",
4+
"version": "1.0.0",
5+
"private": true,
6+
"main": "lib/index.js",
7+
"license": "MIT",
8+
"scripts": {
9+
"build": "heft build --clean",
10+
"_phase:build": "heft run --only build -- --clean"
11+
},
12+
"devDependencies": {
13+
"@rushstack/heft": "workspace:*",
14+
"local-node-rig": "workspace:*",
15+
"@types/node": "18.17.15",
16+
"@typescript-eslint/parser": "~5.59.2",
17+
"eslint": "7.11.0",
18+
"typescript": "~5.0.4"
19+
}
20+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2+
// See LICENSE in the project root for license information.
3+
4+
export class Foo {
5+
private _bar: string = 'bar';
6+
public baz: string = this._bar;
7+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"$schema": "http://json.schemastore.org/tsconfig",
3+
4+
"compilerOptions": {
5+
"outDir": "lib",
6+
"rootDir": "src",
7+
8+
"forceConsistentCasingInFileNames": true,
9+
"declaration": true,
10+
"sourceMap": true,
11+
"declarationMap": true,
12+
"inlineSources": true,
13+
"experimentalDecorators": true,
14+
"strictNullChecks": true,
15+
"noUnusedLocals": true,
16+
17+
"module": "esnext",
18+
"moduleResolution": "node",
19+
"target": "es5",
20+
"lib": ["es5"]
21+
},
22+
"include": ["src/**/*.ts", "src/**/*.tsx"],
23+
"exclude": ["node_modules", "lib"]
24+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2+
// See LICENSE in the project root for license information.
3+
4+
// This is a workaround for https://github.com/eslint/eslint/issues/3458
5+
require('local-node-rig/profiles/default/includes/eslint/patch/modern-module-resolution');
6+
// This is a workaround for https://github.com/microsoft/rushstack/issues/3021
7+
require('local-node-rig/profiles/default/includes/eslint/patch/custom-config-package-names');
8+
9+
module.exports = {
10+
extends: [
11+
'local-node-rig/profiles/default/includes/eslint/profile/node-trusted-tool',
12+
'local-node-rig/profiles/default/includes/eslint/mixins/friendly-locals'
13+
],
14+
parserOptions: { tsconfigRootDir: __dirname },
15+
16+
overrides: [
17+
/**
18+
* Override the parser from local-eslint-config. Since the config is coming
19+
* from the workspace instead of the external NPM package, the versions of ESLint
20+
* and TypeScript that the config consumes will be resolved from the devDependencies
21+
* of the config instead of from the eslint-7-test package. Overriding the parser
22+
* ensures that the these dependencies come from the eslint-7-test package. See:
23+
* https://github.com/microsoft/rushstack/issues/3021
24+
*/
25+
{
26+
files: ['*.ts', '*.tsx'],
27+
parser: '@typescript-eslint/parser'
28+
}
29+
]
30+
};

build-tests/eslint-7-7-test/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# eslint-7-7-test
2+
3+
This project folder is one of the **build-tests** for the Rushstack [ESLint configuration](https://www.npmjs.com/package/@rushstack/eslint-config) (and by extension, the [ESLint plugin](https://www.npmjs.com/package/@rushstack/eslint-plugin))
4+
package. This project builds using ESLint v7.7.0 and contains a simple index file to ensure that the build runs ESLint successfully against source code.
5+
6+
Please see the [ESLint Heft task documentation](https://rushstack.io/pages/heft_tasks/eslint/) for documentation and tutorials.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
// The "rig.json" file directs tools to look for their config files in an external package.
3+
// Documentation for this system: https://www.npmjs.com/package/@rushstack/rig-package
4+
"$schema": "https://developer.microsoft.com/json-schemas/rig-package/rig.schema.json",
5+
6+
"rigPackageName": "local-node-rig"
7+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "eslint-7-7-test",
3+
"description": "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)",
4+
"version": "1.0.0",
5+
"private": true,
6+
"main": "lib/index.js",
7+
"license": "MIT",
8+
"scripts": {
9+
"build": "heft build --clean",
10+
"_phase:build": "heft run --only build -- --clean"
11+
},
12+
"devDependencies": {
13+
"@rushstack/heft": "workspace:*",
14+
"local-node-rig": "workspace:*",
15+
"@types/node": "18.17.15",
16+
"@typescript-eslint/parser": "~5.59.2",
17+
"eslint": "7.7.0",
18+
"typescript": "~5.0.4"
19+
}
20+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2+
// See LICENSE in the project root for license information.
3+
4+
export class Foo {
5+
private _bar: string = 'bar';
6+
public baz: string = this._bar;
7+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"$schema": "http://json.schemastore.org/tsconfig",
3+
4+
"compilerOptions": {
5+
"outDir": "lib",
6+
"rootDir": "src",
7+
8+
"forceConsistentCasingInFileNames": true,
9+
"declaration": true,
10+
"sourceMap": true,
11+
"declarationMap": true,
12+
"inlineSources": true,
13+
"experimentalDecorators": true,
14+
"strictNullChecks": true,
15+
"noUnusedLocals": true,
16+
17+
"module": "esnext",
18+
"moduleResolution": "node",
19+
"target": "es5",
20+
"lib": ["es5"]
21+
},
22+
"include": ["src/**/*.ts", "src/**/*.tsx"],
23+
"exclude": ["node_modules", "lib"]
24+
}

build-tests/eslint-7-test/.eslintrc.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2+
// See LICENSE in the project root for license information.
3+
14
// This is a workaround for https://github.com/eslint/eslint/issues/3458
25
require('local-node-rig/profiles/default/includes/eslint/patch/modern-module-resolution');
36
// This is a workaround for https://github.com/microsoft/rushstack/issues/3021

build-tests/eslint-8-test/.eslintrc.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2+
// See LICENSE in the project root for license information.
3+
14
// This is a workaround for https://github.com/eslint/eslint/issues/3458
25
require('local-node-rig/profiles/default/includes/eslint/patch/modern-module-resolution');
36
// This is a workaround for https://github.com/microsoft/rushstack/issues/3021
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@rushstack/eslint-patch",
5+
"comment": "Fix patch compatibility with ESLint 7 for versions matching <7.12.0",
6+
"type": "patch"
7+
}
8+
],
9+
"packageName": "@rushstack/eslint-patch"
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@rushstack/tree-pattern",
5+
"comment": "",
6+
"type": "none"
7+
}
8+
],
9+
"packageName": "@rushstack/tree-pattern"
10+
}

common/config/rush/common-versions.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@
6161
*/
6262
"allowedAlternativeVersions": {
6363
/**
64-
* Used by build-tests/eslint-7-test
64+
* Used by build-tests/eslint-7-7-test, build-tests/eslint-7-11-test, and build-tests/eslint-7-test
6565
*/
66-
"eslint": ["~7.30.0"],
66+
"eslint": ["7.7.0", "7.11.0", "~7.30.0"],
6767
/**
6868
* For example, allow some projects to use an older TypeScript compiler
6969
* (in addition to whatever "usual" version is being used by other projects in the repo):

0 commit comments

Comments
 (0)