ESLint: Introduce bulk suppressions workflow#77392
Conversation
|
Flaky tests detected in 8a2bccc. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/24663295540
|
|
Size Change: 0 B Total Size: 7.75 MB ℹ️ View Unchanged
|
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Yes. Especially in the lint-staged flow, I found it quite unclear which command I'm supposed to re-run with the flag. I feel like we should try to be as clear as possible here, given the feature is new to everybody. What do you think? By the way I also considered pruning automatically for the absolute minimum friction, but that also seemed confusing since the feature is still unfamiliar. |
There was a problem hiding this comment.
Something worth noting that I noticed in testing: --prune-suppressions writes a new eslint-suppressions.json with two spaces, not tabs. This feels really prone to thrashing back and forth depending if someone applies Prettier to the file (as I expect you have done in this initial commit). I wonder if we could either coerce ESLint to write with a particular indentation, or enforce Prettier on this file (and update the instructions messaging to reflect the expectation).
I'm still a little hesitant on the wrapper script. One future maintenance headache could be if ESLint changes the messaging in a future version that our pattern matching won't match anymore.
| const stdout = stripStaleSuppressionsMessage( result.stdout ); | ||
| const stderr = stripStaleSuppressionsMessage( result.stderr ); |
There was a problem hiding this comment.
I feel like what we're doing here with manipulating and redirecting the output is a perfect use-case for Node.js streams.
aduth
left a comment
There was a problem hiding this comment.
I'll preemptively approve because the behavior works well in my testing, though I think we should get ahead of finding a solution for the indentation concern I flagged in my previous comment.
|
In #77215, we are consolidating ESLint config into |
|
@manzoorwanijk Thanks for flagging. Agreed that I would prefer merging this one ASAP because it's ready to go, and we can cut down on later migration work the earlier we can start enforcing these ratcheted lints. From looking at your PR, it looks like the move itself is small (file move, one constant in |
* ESLint: Add stale suppressions guidance * ESLint: Fix lint wrapper types * ESLint: Ratchet use-recommended-components * ESLint: Hide stale suppressions output * Move to suppressions file * Stream and simplify * Always enable proper colors * Always format the json file * Update suppressions file * Update suppressions file fully * Fix prune exit code handling Co-authored-by: mirka <0mirka00@git.wordpress.org> Co-authored-by: aduth <aduth@git.wordpress.org> Co-authored-by: manzoorwanijk <manzoorwanijk@git.wordpress.org>


What?
Introduces the bulk suppressions workflow we can use repo-wide to ratchet ESLint rules without waiting to fix every existing violation first.
As the first use case, this PR ratchets
@wordpress/use-recommended-componentsby:@wordpress/componentsimportseslint-suppressions.jsonbaseline for the rule's current violationslint:js:prune-suppressionsscriptlint-stagedpath so touched-file stale suppressions show the same guidance locallyWhy?
We want to start enforcing new violations immediately, without having to first fix or inline-disable the full backlog for a rule.
ESLint bulk suppressions give us a path to do that incrementally:
@wordpress/use-recommended-componentsis the first rule we are applying this workflow to.How?
lint:js:prune-suppressionsscriptbin/lint-js.jsto wrapwp-scripts lint-jslint-stagedwitheslint.config.strict.mjsuse-recommended-componentsto cover more@wordpress/componentsimportseslint-suppressions.jsonbaseline for that ruleTesting Instructions
npm run build.eslint-suppressions.jsonfor@wordpress/use-recommended-components, for examplepackages/admin-ui/src/breadcrumbs/index.tsx.@wordpress/use-recommended-componentsviolation from that file.eslint-suppressions.json.npm run lint:js:prune-suppressions.npm run lint:js:prune-suppressions.eslint-suppressions.jsonand retry the commit.Use of AI Tools
Used Cursor to help implement and review the lint wrapper, suppressions workflow, and baseline generation.
Thanks @manzoorwanijk for #76654, which unblocked this new Eslint feature 🙏