Skip to content

Commit 480ed11

Browse files
committed
feat: eslint-bulk package
1 parent 1af7e81 commit 480ed11

27 files changed

Lines changed: 554 additions & 460 deletions

build-tests/eslint-bulk-suppressions-test/.eslint-bulk-suppressions.json

Lines changed: 0 additions & 209 deletions
This file was deleted.
Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1 @@
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-
require('local-node-rig/profiles/default/includes/eslint/patch/eslint-bulk-suppressions');
9-
10-
module.exports = {
11-
extends: [
12-
'local-node-rig/profiles/default/includes/eslint/profile/node-trusted-tool',
13-
'local-node-rig/profiles/default/includes/eslint/mixins/friendly-locals'
14-
],
15-
parserOptions: { tsconfigRootDir: __dirname },
16-
17-
overrides: [
18-
/**
19-
* Override the parser from @rushstack/eslint-config. Since the config is coming
20-
* from the workspace instead of the external NPM package, the versions of ESLint
21-
* and TypeScript that the config consumes will be resolved from the devDependencies
22-
* of the config instead of from the eslint-8-test package. Overriding the parser
23-
* ensures that the these dependencies come from the eslint-8-test package. See:
24-
* https://github.com/microsoft/rushstack/issues/3021
25-
*/
26-
{
27-
files: ['*.ts', '*.tsx'],
28-
parser: '@typescript-eslint/parser'
29-
}
30-
]
31-
};
1+
module.exports = {};
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"suppressions": [
3+
{
4+
"file": "src/index.ts",
5+
"scope": ".",
6+
"rule": "prefer-const"
7+
},
8+
{
9+
"file": "src/index.ts",
10+
"scope": ".exampleFunction",
11+
"rule": "@typescript-eslint/ban-types"
12+
}
13+
]
14+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
require('local-node-rig/profiles/default/includes/eslint/patch/eslint-bulk-suppressions');
9+
10+
module.exports = {
11+
extends: [
12+
'plugin:@typescript-eslint/recommended'
13+
// 'local-node-rig/profiles/default/includes/eslint/profile/node-trusted-tool',
14+
// 'local-node-rig/profiles/default/includes/eslint/mixins/friendly-locals'
15+
],
16+
ignorePatterns: ['.eslintrc.js'],
17+
18+
overrides: [
19+
/**
20+
* Override the parser from @rushstack/eslint-config. Since the config is coming
21+
* from the workspace instead of the external NPM package, the versions of ESLint
22+
* and TypeScript that the config consumes will be resolved from the devDependencies
23+
* of the config instead of from the eslint-8-test package. Overriding the parser
24+
* ensures that the these dependencies come from the eslint-8-test package. See:
25+
* https://github.com/microsoft/rushstack/issues/3021
26+
*/
27+
{
28+
files: ['**/*.ts', '**/*.tsx'],
29+
parser: '@typescript-eslint/parser',
30+
parserOptions: { project: '../tsconfig.json', tsconfigRootDir: __dirname }
31+
}
32+
]
33+
};
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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+
/* Top-level scope code samples */
5+
// scopeId: '.'
6+
let exampleString: string = 5 + '';
7+
8+
const exampleObject = {
9+
exampleString: exampleString
10+
};
11+
12+
/* Function scope code samples */
13+
export function exampleFunction() {
14+
const {}: Object = exampleObject;
15+
16+
// scopeId: '.exampleFunction'
17+
!!!exampleString as Boolean;
18+
}
19+
20+
// scope: '.ArrowFunctionExpression',
21+
// export const x = () => {},
22+
// // scopeId: '.y'
23+
// y = () => {},
24+
// // scopeId: '.z'
25+
// z = () => {};
26+
27+
// /* Class scope code samples */
28+
// export class ExampleClass {
29+
// // scopeId: '.ExampleClass'
30+
// exampleClassProperty: String = exampleString + '4';
31+
32+
// exampleMethod() {
33+
// // scopeId: '.exampleClass.exampleMethod'
34+
// var exampleVar;
35+
// return exampleVar;
36+
// }
37+
// }
38+
39+
// /* Variable and anonymous constructs code samples */
40+
// export const exampleArrowFunction = () => {
41+
// const exampleBoolean = true;
42+
// if (exampleBoolean) {
43+
// }
44+
45+
// exampleObject['exampleString'];
46+
// };
47+
48+
// export const exampleAnonymousClass = class {
49+
// exampleClassProperty = 'x' + 'y';
50+
51+
// // scopeId: '.exampleAnonymousClass.constructor'
52+
// constructor() {}
53+
54+
// set exampleSetGet(val: string) {
55+
// // scopeId: '.exampleAnonymousClass.exampleSetGet'
56+
// let exampleVariable: Number = 1;
57+
// this.exampleClassProperty = val + exampleVariable;
58+
// }
59+
60+
// get exampleSetGet() {
61+
// // scopeId: '.exampleAnonymousClass.exampleSetGet'
62+
// return this.exampleClassProperty as String as string;
63+
// }
64+
// };

build-tests/eslint-bulk-suppressions-test/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"scripts": {
77
"eslint": "eslint .",
88
"eslint-bulk-suppress-all": "ESLINT_BULK_SUPPRESS_RULES=* eslint .",
9-
"eslint-without-bulk-suppressions": "USE_ESLINT_BULK_SUPPRESSIONS=false eslint ."
9+
"eslint-without-bulk-suppressions": "USE_ESLINT_BULK_SUPPRESSIONS=false eslint .",
10+
"debug": "CLEANUP_ESLINT_BULK_SUPPRESSIONS=true eslint /Users/bytedance/rushstack/build-tests/eslint-bulk-suppressions-test/server"
1011
},
1112
"devDependencies": {
1213
"@rushstack/heft": "workspace:*",
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"suppressions": [
3+
{
4+
"file": "src/index.ts",
5+
"scope": ".exampleObject2.exampleObjectMethod",
6+
"rule": "@typescript-eslint/no-inferrable-types"
7+
},
8+
{
9+
"file": "src/index.ts",
10+
"scope": ".exampleObject2.exampleObjectProperty",
11+
"rule": "@typescript-eslint/no-empty-function"
12+
}
13+
]
14+
}

0 commit comments

Comments
 (0)