-
Notifications
You must be signed in to change notification settings - Fork 631
[eslint-config] Update TypeScript/ESLint Utilities and Refactor Linting #4883
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
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
02e7b02
Bump the version of eslint utils consumed by Rushstack
D4N14L b522dc9
Update lint rules for back compat
D4N14L 87d80a5
Update eslint tests for compatibility
D4N14L 1dddcd4
Bump cyclic versions and rush update
D4N14L 45f5593
Lint fix
D4N14L 707b86d
Refactor and cleanup of linters
D4N14L f70f20c
Bump peer dependency of eslint config package to consume 8.57.0 or gr…
D4N14L c6f9ec3
Rush change
D4N14L 918ff02
Fix install issues
D4N14L 6bba833
Fix install
D4N14L 568b2dc
Fix readme
D4N14L 75402bf
Merge branch 'main' of https://github.com/microsoft/rushstack into us…
D4N14L 82b27fd
Drop Node 16 support
D4N14L 5db6a9d
Add eslint 8.57.0 to legacy
D4N14L c3084f0
Rush update
D4N14L 137a0cd
PR feedback
D4N14L dc47542
Update user-danade-BumpEslintUtils_2024-08-13-00-25.json
D4N14L 30da67a
Empty change to trigger PR check analysis
D4N14L File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
build-tests/eslint-bulk-suppressions-test-legacy/build.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
// This project is a duplicate of "eslint-bulk-suppressions-test" intended to test eslint | ||
// against the older version of the TypeScript parser. Any modifications made to this project | ||
// should be reflected in "eslint-bulk-suppressions-test" as well. | ||
|
||
const { FileSystem, Executable, Text, Import } = require('@rushstack/node-core-library'); | ||
const path = require('path'); | ||
const { | ||
ESLINT_PACKAGE_NAME_ENV_VAR_NAME | ||
} = require('@rushstack/eslint-patch/lib/eslint-bulk-suppressions/constants'); | ||
|
||
const eslintBulkStartPath = Import.resolveModule({ | ||
modulePath: '@rushstack/eslint-bulk/lib/start', | ||
baseFolderPath: __dirname | ||
}); | ||
|
||
function tryLoadSuppressions(suppressionsJsonPath) { | ||
try { | ||
return Text.convertToLf(FileSystem.readFile(suppressionsJsonPath)).trim(); | ||
} catch (e) { | ||
if (FileSystem.isNotExistError(e)) { | ||
return ''; | ||
} else { | ||
throw e; | ||
} | ||
} | ||
} | ||
|
||
const RUN_FOLDER_PATHS = ['client', 'server']; | ||
const ESLINT_PACKAGE_NAMES = ['eslint', 'eslint-8.23', 'eslint-oldest']; | ||
|
||
const updateFilePaths = new Set(); | ||
|
||
for (const runFolderPath of RUN_FOLDER_PATHS) { | ||
const folderPath = `${__dirname}/${runFolderPath}`; | ||
const suppressionsJsonPath = `${folderPath}/.eslint-bulk-suppressions.json`; | ||
|
||
const folderItems = FileSystem.readFolderItems(folderPath); | ||
for (const folderItem of folderItems) { | ||
if (folderItem.isFile() && folderItem.name.match(/^\.eslint\-bulk\-suppressions\-[\d.]+\.json$/)) { | ||
const fullPath = `${folderPath}/${folderItem.name}`; | ||
updateFilePaths.add(fullPath); | ||
} | ||
} | ||
|
||
for (const eslintPackageName of ESLINT_PACKAGE_NAMES) { | ||
const { version: eslintVersion } = require(`${eslintPackageName}/package.json`); | ||
|
||
const startLoggingMessage = `-- Running eslint-bulk-suppressions for eslint@${eslintVersion} in ${runFolderPath} --`; | ||
console.log(startLoggingMessage); | ||
const referenceSuppressionsJsonPath = `${folderPath}/.eslint-bulk-suppressions-${eslintVersion}.json`; | ||
const existingSuppressions = tryLoadSuppressions(referenceSuppressionsJsonPath); | ||
|
||
// The eslint-bulk-suppressions patch expects to find "eslint" in the shell PATH. To ensure deterministic | ||
// test behavior, we need to designate an explicit "node_modules/.bin" folder. | ||
// | ||
// Use the ".bin" folder from @rushstack/eslint-patch as a workaround for this PNPM bug: | ||
// https://github.com/pnpm/pnpm/issues/7833 | ||
const dependencyBinFolder = path.join( | ||
__dirname, | ||
'node_modules', | ||
'@rushstack', | ||
'eslint-patch', | ||
'node_modules', | ||
'.bin' | ||
); | ||
const shellPathWithEslint = `${dependencyBinFolder}${path.delimiter}${process.env['PATH']}`; | ||
|
||
const executableResult = Executable.spawnSync( | ||
process.argv0, | ||
[eslintBulkStartPath, 'suppress', '--all', 'src'], | ||
{ | ||
currentWorkingDirectory: folderPath, | ||
environment: { | ||
...process.env, | ||
PATH: shellPathWithEslint, | ||
[ESLINT_PACKAGE_NAME_ENV_VAR_NAME]: eslintPackageName | ||
} | ||
} | ||
); | ||
|
||
if (executableResult.status !== 0) { | ||
console.error('The eslint-bulk-suppressions command failed.'); | ||
console.error('STDOUT:'); | ||
console.error(executableResult.stdout.toString()); | ||
console.error('STDERR:'); | ||
console.error(executableResult.stderr.toString()); | ||
process.exit(1); | ||
} | ||
|
||
const newSuppressions = tryLoadSuppressions(suppressionsJsonPath); | ||
if (newSuppressions === existingSuppressions) { | ||
updateFilePaths.delete(referenceSuppressionsJsonPath); | ||
} else { | ||
updateFilePaths.add(referenceSuppressionsJsonPath); | ||
FileSystem.writeFile(referenceSuppressionsJsonPath, newSuppressions); | ||
} | ||
|
||
FileSystem.deleteFile(suppressionsJsonPath); | ||
} | ||
} | ||
|
||
if (updateFilePaths.size > 0) { | ||
for (const updateFilePath of updateFilePaths) { | ||
console.log(`The suppressions file "${updateFilePath}" was updated and must be committed to git.`); | ||
} | ||
|
||
process.exit(1); | ||
} |
File renamed without changes.
File renamed without changes.
139 changes: 139 additions & 0 deletions
139
build-tests/eslint-bulk-suppressions-test-legacy/client/.eslint-bulk-suppressions-8.6.0.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
32
build-tests/eslint-bulk-suppressions-test-legacy/client/.eslintrc.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: [ | ||
'@rushstack/eslint-config/profile/node-trusted-tool', | ||
'@rushstack/eslint-config/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 } | ||
} | ||
] | ||
}; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.