diff --git a/build-tests/eslint-bulk-suppressions-newest-test/client/.eslint-bulk-suppressions.json b/build-tests/eslint-bulk-suppressions-newest-test/client/.eslint-bulk-suppressions.json new file mode 100644 index 00000000000..40059c12365 --- /dev/null +++ b/build-tests/eslint-bulk-suppressions-newest-test/client/.eslint-bulk-suppressions.json @@ -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" + } + ] +} diff --git a/build-tests/eslint-bulk-suppressions-newest-test/client/.eslintrc.js b/build-tests/eslint-bulk-suppressions-newest-test/client/.eslintrc.js new file mode 100644 index 00000000000..5dd4b2dc03b --- /dev/null +++ b/build-tests/eslint-bulk-suppressions-newest-test/client/.eslintrc.js @@ -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 } + } + ] +}; diff --git a/build-tests/eslint-bulk-suppressions-newest-test/client/src/index.ts b/build-tests/eslint-bulk-suppressions-newest-test/client/src/index.ts new file mode 100644 index 00000000000..570229800d8 --- /dev/null +++ b/build-tests/eslint-bulk-suppressions-newest-test/client/src/index.ts @@ -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; + } +}; diff --git a/build-tests/eslint-bulk-suppressions-newest-test/config/rig.json b/build-tests/eslint-bulk-suppressions-newest-test/config/rig.json new file mode 100644 index 00000000000..165ffb001f5 --- /dev/null +++ b/build-tests/eslint-bulk-suppressions-newest-test/config/rig.json @@ -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" +} diff --git a/build-tests/eslint-bulk-suppressions-newest-test/package.json b/build-tests/eslint-bulk-suppressions-newest-test/package.json new file mode 100644 index 00000000000..e03685c3bdc --- /dev/null +++ b/build-tests/eslint-bulk-suppressions-newest-test/package.json @@ -0,0 +1,16 @@ +{ + "name": "eslint-bulk-suppressions-newest-test", + "description": "Sample code to test eslint bulk suppressions", + "version": "1.0.0", + "private": true, + "scripts": { + "_phase:build": "eslint ." + }, + "devDependencies": { + "@rushstack/heft": "workspace:*", + "local-node-rig": "workspace:*", + "@typescript-eslint/parser": "~6.19.0", + "eslint": "~8.23.1", + "typescript": "~5.3.3" + } +} diff --git a/build-tests/eslint-bulk-suppressions-newest-test/server/.eslint-bulk-suppressions.json b/build-tests/eslint-bulk-suppressions-newest-test/server/.eslint-bulk-suppressions.json new file mode 100644 index 00000000000..ab3846d907a --- /dev/null +++ b/build-tests/eslint-bulk-suppressions-newest-test/server/.eslint-bulk-suppressions.json @@ -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" + } + ] +} diff --git a/build-tests/eslint-bulk-suppressions-newest-test/server/.eslintrc.js b/build-tests/eslint-bulk-suppressions-newest-test/server/.eslintrc.js new file mode 100644 index 00000000000..5dd4b2dc03b --- /dev/null +++ b/build-tests/eslint-bulk-suppressions-newest-test/server/.eslintrc.js @@ -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 } + } + ] +}; diff --git a/build-tests/eslint-bulk-suppressions-newest-test/server/src/index.ts b/build-tests/eslint-bulk-suppressions-newest-test/server/src/index.ts new file mode 100644 index 00000000000..34328698008 --- /dev/null +++ b/build-tests/eslint-bulk-suppressions-newest-test/server/src/index.ts @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +// /* Object property and method code samples */ +export const exampleObject2 = { + // scopeId: '.exampleObject2.exampleObjectProperty + exampleObjectProperty: () => {}, + + exampleObjectMethod() { + // scopeId: '.exampleObject2.exampleObjectMethod' + const exampleUndefined: undefined = undefined; + return exampleUndefined; + } +}; + +/* Absurd examples */ +export class AbsurdClass { + absurdClassMethod() { + return class AbsurdClass2 { + absurdClassProperty; + constructor() { + const absurdObject = { + // scopeId: '.AbsurdClass.absurdClassMethod.AbsurdClass2.constructor.absurdObject.absurdObjectMethod' + absurdObjectMethod() {} + }; + this.absurdClassProperty = absurdObject; + } + }; + } +} + +/* Type, interface, enum code samples */ +export type ExampleObjectType = { + // scopeId: '.ExampleObjectType' + examplePropertyType: String; +}; + +// scopeId: '.ExampleInterface' +export interface ExampleInterface {} + +export enum ExampleEnum { + A = 0, + + B = 1, + + C = 'exampleStringValue'['length'], + + D = 1 +} + +/* Namespace, declare, module code samples */ +// scopeId: '.ExampleModule' +export namespace ExampleModule { + // scopeId: '.ExampleModule.ExampleInterface2' + export interface ExampleInterface2 {} +} diff --git a/build-tests/eslint-bulk-suppressions-newest-test/tsconfig.json b/build-tests/eslint-bulk-suppressions-newest-test/tsconfig.json new file mode 100644 index 00000000000..174bda15d5c --- /dev/null +++ b/build-tests/eslint-bulk-suppressions-newest-test/tsconfig.json @@ -0,0 +1,23 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + + "compilerOptions": { + "outDir": "lib", + "rootDir": "src", + "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": ["client/**/*.ts", "client/**/*.tsx", "server/**/*.ts", "server/**/*.tsx"], + "exclude": ["node_modules", "lib"] +} diff --git a/build-tests/eslint-bulk-suppressions-oldest-test/client/.eslint-bulk-suppressions.json b/build-tests/eslint-bulk-suppressions-oldest-test/client/.eslint-bulk-suppressions.json new file mode 100644 index 00000000000..40059c12365 --- /dev/null +++ b/build-tests/eslint-bulk-suppressions-oldest-test/client/.eslint-bulk-suppressions.json @@ -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" + } + ] +} diff --git a/build-tests/eslint-bulk-suppressions-oldest-test/client/.eslintrc.js b/build-tests/eslint-bulk-suppressions-oldest-test/client/.eslintrc.js new file mode 100644 index 00000000000..5dd4b2dc03b --- /dev/null +++ b/build-tests/eslint-bulk-suppressions-oldest-test/client/.eslintrc.js @@ -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 } + } + ] +}; diff --git a/build-tests/eslint-bulk-suppressions-oldest-test/client/src/index.ts b/build-tests/eslint-bulk-suppressions-oldest-test/client/src/index.ts new file mode 100644 index 00000000000..570229800d8 --- /dev/null +++ b/build-tests/eslint-bulk-suppressions-oldest-test/client/src/index.ts @@ -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; + } +}; diff --git a/build-tests/eslint-bulk-suppressions-oldest-test/config/rig.json b/build-tests/eslint-bulk-suppressions-oldest-test/config/rig.json new file mode 100644 index 00000000000..165ffb001f5 --- /dev/null +++ b/build-tests/eslint-bulk-suppressions-oldest-test/config/rig.json @@ -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" +} diff --git a/build-tests/eslint-bulk-suppressions-oldest-test/package.json b/build-tests/eslint-bulk-suppressions-oldest-test/package.json new file mode 100644 index 00000000000..ab24d2a5418 --- /dev/null +++ b/build-tests/eslint-bulk-suppressions-oldest-test/package.json @@ -0,0 +1,16 @@ +{ + "name": "eslint-bulk-suppressions-oldest-test", + "description": "Sample code to test eslint bulk suppressions", + "version": "1.0.0", + "private": true, + "scripts": { + "_phase:build": "eslint ." + }, + "devDependencies": { + "@rushstack/heft": "workspace:*", + "local-node-rig": "workspace:*", + "@typescript-eslint/parser": "~6.19.0", + "eslint": "8.6.0", + "typescript": "~5.3.3" + } +} diff --git a/build-tests/eslint-bulk-suppressions-oldest-test/server/.eslint-bulk-suppressions.json b/build-tests/eslint-bulk-suppressions-oldest-test/server/.eslint-bulk-suppressions.json new file mode 100644 index 00000000000..ab3846d907a --- /dev/null +++ b/build-tests/eslint-bulk-suppressions-oldest-test/server/.eslint-bulk-suppressions.json @@ -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" + } + ] +} diff --git a/build-tests/eslint-bulk-suppressions-oldest-test/server/.eslintrc.js b/build-tests/eslint-bulk-suppressions-oldest-test/server/.eslintrc.js new file mode 100644 index 00000000000..5dd4b2dc03b --- /dev/null +++ b/build-tests/eslint-bulk-suppressions-oldest-test/server/.eslintrc.js @@ -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 } + } + ] +}; diff --git a/build-tests/eslint-bulk-suppressions-oldest-test/server/src/index.ts b/build-tests/eslint-bulk-suppressions-oldest-test/server/src/index.ts new file mode 100644 index 00000000000..34328698008 --- /dev/null +++ b/build-tests/eslint-bulk-suppressions-oldest-test/server/src/index.ts @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +// /* Object property and method code samples */ +export const exampleObject2 = { + // scopeId: '.exampleObject2.exampleObjectProperty + exampleObjectProperty: () => {}, + + exampleObjectMethod() { + // scopeId: '.exampleObject2.exampleObjectMethod' + const exampleUndefined: undefined = undefined; + return exampleUndefined; + } +}; + +/* Absurd examples */ +export class AbsurdClass { + absurdClassMethod() { + return class AbsurdClass2 { + absurdClassProperty; + constructor() { + const absurdObject = { + // scopeId: '.AbsurdClass.absurdClassMethod.AbsurdClass2.constructor.absurdObject.absurdObjectMethod' + absurdObjectMethod() {} + }; + this.absurdClassProperty = absurdObject; + } + }; + } +} + +/* Type, interface, enum code samples */ +export type ExampleObjectType = { + // scopeId: '.ExampleObjectType' + examplePropertyType: String; +}; + +// scopeId: '.ExampleInterface' +export interface ExampleInterface {} + +export enum ExampleEnum { + A = 0, + + B = 1, + + C = 'exampleStringValue'['length'], + + D = 1 +} + +/* Namespace, declare, module code samples */ +// scopeId: '.ExampleModule' +export namespace ExampleModule { + // scopeId: '.ExampleModule.ExampleInterface2' + export interface ExampleInterface2 {} +} diff --git a/build-tests/eslint-bulk-suppressions-oldest-test/tsconfig.json b/build-tests/eslint-bulk-suppressions-oldest-test/tsconfig.json new file mode 100644 index 00000000000..174bda15d5c --- /dev/null +++ b/build-tests/eslint-bulk-suppressions-oldest-test/tsconfig.json @@ -0,0 +1,23 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + + "compilerOptions": { + "outDir": "lib", + "rootDir": "src", + "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": ["client/**/*.ts", "client/**/*.tsx", "server/**/*.ts", "server/**/*.tsx"], + "exclude": ["node_modules", "lib"] +} diff --git a/common/config/rush/common-versions.json b/common/config/rush/common-versions.json index 067c4fb5940..7ce0c193385 100644 --- a/common/config/rush/common-versions.json +++ b/common/config/rush/common-versions.json @@ -60,10 +60,13 @@ * This design avoids unnecessary churn in this file. */ "allowedAlternativeVersions": { - /** - * Used by build-tests/eslint-7-7-test, build-tests/eslint-7-11-test, and build-tests/eslint-7-test - */ - "eslint": ["7.7.0", "7.11.0", "~7.30.0"], + "eslint": [ + "7.7.0", // Used by build-tests/eslint-7-7-test + "7.11.0", // Used by build-tests/eslint-7-11-test + "~7.30.0", // Used by build-tests/eslint-7-test + "8.6.0", // Used by build-tests/eslint-bulk-suppressions-oldest-test + "~8.23.1" // Used by build-tests/eslint-bulk-suppressions-newest-test + ], /** * For example, allow some projects to use an older TypeScript compiler * (in addition to whatever "usual" version is being used by other projects in the repo): diff --git a/eslint/eslint-patch/src/eslint-bulk-suppressions/cli/utils/get-eslint-cli.ts b/eslint/eslint-patch/src/eslint-bulk-suppressions/cli/utils/get-eslint-cli.ts index 1c1fa829ed2..cd89709bfca 100755 --- a/eslint/eslint-patch/src/eslint-bulk-suppressions/cli/utils/get-eslint-cli.ts +++ b/eslint/eslint-patch/src/eslint-bulk-suppressions/cli/utils/get-eslint-cli.ts @@ -3,6 +3,8 @@ import path from 'path'; +// When this list is updated, update the `eslint-bulk-suppressions-newest-test` +// and/or the `eslint-bulk-suppressions-newest-test` projects' eslint dependencies. const TESTED_VERSIONS: Set = new Set(['8.6.0', '8.7.0', '8.21.0', '8.22.0', '8.23.0', '8.23.1']); export function getEslintPath(packagePath: string): string { diff --git a/rush.json b/rush.json index db73bf46ca0..d8e94e6dd0a 100644 --- a/rush.json +++ b/rush.json @@ -569,6 +569,18 @@ "reviewCategory": "tests", "shouldPublish": false }, + { + "packageName": "eslint-bulk-suppressions-newest-test", + "projectFolder": "build-tests/eslint-bulk-suppressions-newest-test", + "reviewCategory": "tests", + "shouldPublish": false + }, + { + "packageName": "eslint-bulk-suppressions-oldest-test", + "projectFolder": "build-tests/eslint-bulk-suppressions-oldest-test", + "reviewCategory": "tests", + "shouldPublish": false + }, { "packageName": "eslint-bulk-suppressions-test", "projectFolder": "build-tests/eslint-bulk-suppressions-test",