Skip to content

feat: Introduce a way to suppress violations #19159

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 42 commits into from
Mar 26, 2025

Conversation

softius
Copy link
Contributor

@softius softius commented Nov 23, 2024

Prerequisites checklist

What is the purpose of this pull request? (put an "X" next to an item)

[ ] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofix to a rule
[ ] Add a CLI option
[x] Add something to the core
[ ] Other, please explain:

What changes did you make? (Give an overview)

This pull request implements the suppress violations feature as outlined in the approved RFC.

  1. Introduced functionality to generate and manage the suppressions file capturing the current linting violations in a project.
  2. Modified ESLint’s reporting mechanism to suppress violations listed in the file while highlighting new issues.
  3. Added CLI options to create and use the suppressions file.
  4. Updated CLI documentation to guide users on how to use this feature.

Is there anything you'd like reviewers to focus on?

  1. The CLI options: Are they intuitive and consistent with other ESLint commands?
  2. Feedback on the implementation approach: Are there any areas for optimization or improvement?

Copy link

netlify bot commented Nov 23, 2024

Deploy Preview for docs-eslint canceled.

Name Link
🔨 Latest commit b91a3e0
🔍 Latest deploy log https://app.netlify.com/sites/docs-eslint/deploys/67e2843eea385a0008316a1d

@github-actions github-actions bot added cli Relates to ESLint's command-line interface core Relates to ESLint's core APIs and features labels Nov 23, 2024
@eslint-github-bot eslint-github-bot bot added the feature This change adds a new feature to ESLint label Nov 23, 2024
@nzakas
Copy link
Member

nzakas commented Nov 25, 2024

@softius thanks for getting this started. As a note: we don't review draft PRs, so when you're ready for feedback, go ahead and click "Ready for review".

@softius softius force-pushed the rfc-119-suppress-violations branch from 23b4d22 to a2a126b Compare November 27, 2024 16:46
@softius
Copy link
Contributor Author

softius commented Nov 27, 2024

@nzakas is there a way to rerun the failing check for the browser tests? It doesn't seem related to this PR.

@fasttime
Copy link
Member

@softius the browser test is failing most of the times, that's not a problem with your PR. Please, disregard failures in that test until the problem is fixed.

@softius
Copy link
Contributor Author

softius commented Dec 7, 2024

@nzakas @fasttime apart from the changes discussed in the related at the RFC, I did the following changes:

  1. When there are unused suppressions left, the errors are displayed (if any) before displaying the message about pruning.
  2. --fix automatically prunes the suppressions file (if any)
  3. Apart from errorCount the fatalErrorCount, fixableErrorCount, warningCount and fixableWarningCount are also adjusted.

Point 3 is an overkill and error prone, I would prefer to export calculateStatsPerFile and re-use it in SuppressedViolationsManager for consistency, if that makes sense.

Copy link

Hi everyone, it looks like we lost track of this pull request. Please review and see what the next steps are. This pull request will auto-close in 7 days without an update.

@github-actions github-actions bot added the Stale label Dec 17, 2024
@fasttime
Copy link
Member

fasttime commented Dec 18, 2024

Sorry for the late reply.

@nzakas @fasttime apart from the changes discussed in the related at the RFC, I did the following changes:

  1. When there are unused suppressions left, the errors are displayed (if any) before displaying the message about pruning.

I agree it makes sense to display the message about pruning after the formatter output.

  1. --fix automatically prunes the suppressions file (if any)

Not sure if this is necessary. If the fixes and the unused suppressions belong to different rules or different files, it's probably better to handle them separately.

  1. Apart from errorCount the fatalErrorCount, fixableErrorCount, warningCount and fixableWarningCount are also adjusted.

Point 3 is an overkill and error prone, I would prefer to export calculateStatsPerFile and re-use it in SuppressedViolationsManager for consistency, if that makes sense.

All counts need to be all adjusted. It's fine to export calculateStatsPerFile from eslint.js or extract it into a shared module and export it from there, as long as it's not exposed from the public API.

@fasttime fasttime removed the Stale label Dec 18, 2024
Copy link

github-actions bot commented Jan 1, 2025

Hi everyone, it looks like we lost track of this pull request. Please review and see what the next steps are. This pull request will auto-close in 7 days without an update.

@github-actions github-actions bot added the Stale label Jan 1, 2025
@softius softius force-pushed the rfc-119-suppress-violations branch from 6e27104 to 8a707f1 Compare January 2, 2025 05:56
@softius softius marked this pull request as ready for review January 2, 2025 06:22
@softius softius requested a review from a team as a code owner January 2, 2025 06:22
Copy link
Member

@nzakas nzakas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really nice work on all of this. I left a few comments throughout, mostly for a bit of cleanup and aligning with the project standards.

@softius
Copy link
Contributor Author

softius commented Jan 3, 2025

Really nice work on all of this. I left a few comments throughout, mostly for a bit of cleanup and aligning with the project standards.

Thank you @nzakas ! I went through your feedback and adjusted accordingly. Everything should be there now, please advise otherwise.

Copy link
Member

@nzakas nzakas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking good. Just a few bits of cleanup throughout.

Copy link

Hi everyone, it looks like we lost track of this pull request. Please review and see what the next steps are. This pull request will auto-close in 7 days without an update.

@github-actions github-actions bot added the Stale label Jan 17, 2025
@fasttime
Copy link
Member

Not stale. This is pending a review.

@fasttime fasttime removed the Stale label Jan 18, 2025
@nzakas
Copy link
Member

nzakas commented Jan 21, 2025

@eslint/eslint-tsc would appreciate some more reviews on this.

Copy link
Member

@nzakas nzakas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code is looking really good now. I think the thing that's missing is a dedicate docs page that explains how to use this feature.

I'd put this under user/suppressions maybe titled "Bulk Suppressions"? It should walk people through setting up suppressions, purging suppressions, etc. Can you take a look at adding that?

@softius softius force-pushed the rfc-119-suppress-violations branch from 10dc59a to e1fb8d9 Compare March 25, 2025 10:11
@nzakas
Copy link
Member

nzakas commented Mar 25, 2025

@trickpattyFH20 the scope of this PR is closed. If you have suggestions for how to improve things, please open a separate issue.

Regarding VS Code - right now, this is a CLI-only feature, and that's okay. It's a big feature that we need to land and get feedback on before we start thinking through additional use cases. (Again, feel free to open an issue about this. Keep in mind that we don't actually maintain the ESLint VS Code extension, though, so our role would be to ensure access to this feature via some API.)

Copy link
Member

@mdjermanovic mdjermanovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@mdjermanovic mdjermanovic merged commit cd72bcc into eslint:main Mar 26, 2025
29 checks passed
@github-project-automation github-project-automation bot moved this from Implementing to Complete in Triage Mar 26, 2025
@nzakas
Copy link
Member

nzakas commented Mar 26, 2025

Nice work @softius! Would you be interested in writing an introductory blog post for the ESLint blog about this feature? We can publish it along with the next release.

@softius
Copy link
Contributor Author

softius commented Mar 26, 2025

@nzakas absolutely! Please point me to the right direction and I will prepare the blog. Is this for "News and Updates" section?

@nzakas
Copy link
Member

nzakas commented Mar 26, 2025

Yes. Check out the README here:
https://github.com/eslint/eslint.org/tree/main/src/content/drafts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion cli Relates to ESLint's command-line interface contributor pool core Relates to ESLint's core APIs and features feature This change adds a new feature to ESLint
Projects
Status: Complete
Development

Successfully merging this pull request may close these issues.

6 participants