rushstack
rushstack copied to clipboard
[eslint-patch] Improve performance of eslint-bulk-suppressions
Summary
Fixes #5054 Fixes #5006
~~Fixes an issue with incorrect computation of scope ids that were resulting in overly broad suppressions.~~
Details
~~- Simplifies the patching logic to load ESLint's linter.js into memory and only override Linter.prototype.verify, without generating any temporary files.~~
~~- Uses AST traversal to find the relevant node instead of extracting it from the reporter, due to limitations of data visibility. However, the new version only processes reported problems that aren't already suppressed via inline comments.~~
- Adds a new environment variable
ESLINT_BULK_ESLINTRC_FOLDER_PATHthat, if specified, short-circuits the patch searching for.eslintrc.jsfrom every single file. - Updates
@rushstack/heft-eslint-pluginto setESLINT_BULK_ESLINTRC_FOLDER_PATHto the parent of its detected ESLint config. - Adds a tag
eslint-teststo the ESLint test projects to make them easier to run - Updates the ESLint bulk suppressions test project to run the suppression tester as well
- Ensures that issues suppressed by bulk suppressions show up in the
getSuppressedMessages()output of the linter, for use by auditing.
Edited:
- Updates the logic for identifying bulk suppressions to only attach the AST node on the initial walk and defer identification of bulk suppressions until all problems have been collated and inline suppressions have been performed
- Adds a new flag
"disableLintConfigSearch"to the options forheft-lint-pluginthat, if configured, prevents the linter from searching for config files based on the location of linted files and tells it to just use the config in the project root.
How it was tested
Ran in the ESLint test projects. Linked this version of the patch into a repository that has tons of bulk suppressions and ran it there. Profiled this version vs. the old to ensure no regression.
Impacted documentation
Behavior should be the same, other than ensuring that the suppressions from this feature show up in the output of getSuppressedMessages().