-
-
Notifications
You must be signed in to change notification settings - Fork 986
Add support for bulk suppressions #8564
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
Conversation
🦋 Changeset detectedLatest commit: e78bf6b The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
This PR is packaged and the instant preview is available (e78bf6b). View the demo website. Install it locally: npm i -D https://pkg.pr.new/stylelint@e78bf6b |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for bulk suppressions to Stylelint by introducing new CLI flags (such as --suppress-all, --suppress-rule, --suppressions-location, and --prune-suppressions), integrating them into the core CLI, and updating related documentation and tests.
- Implements the suppressions service in both ESM and CJS formats.
- Updates the CLI to handle suppression flags along with proper error reporting for conflicting or missing options.
- Enhances the documentation and tests to reflect the new bulk suppressions feature.
Reviewed Changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/utils/suppressionsService.{mjs,cjs} | Introduces suppression service logic; counts violations and updates suppression file. |
| lib/standalone.{mjs,cjs} | Integrates suppressions handling into the standalone linting command. |
| lib/cli.mjs | Updates CLI flags to support bulk suppressions and defines error conditions. |
| docs/user-guide/suppressions.md | Adds new documentation covering bulk suppressions usage and options. |
| docs/user-guide/cli.md | Updates CLI documentation with new suppression flags. |
| Other test fixture and utility files | Include required test cases and utility updates supporting the new feature. |
|
@ryo-manba thanks for the PR. I did a first pass on some files; Ill do the rest eventually. |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Co-authored-by: Masafumi Koba <473530+ybiquitous@users.noreply.github.com>
Co-authored-by: Masafumi Koba <473530+ybiquitous@users.noreply.github.com>
ybiquitous
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've left a few nitpicks, but LGTM. 👍🏼
Let's wait for one more approval to merge it!
Co-authored-by: Masafumi Koba <473530+ybiquitous@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again for all the hard work creating and reviewing this PR.
I set aside time to revise the documentation for this feature and read up on ESLint's original RFC for this feature. We do a few things differently to ESLint, and I've made some suggestions and changes that reflect them, including how we:
- standardised on "problem" rather than "violation" (for example)
- have a
severitysecondary option, whereas ESLint use"warn"and"error"for their primary option
I've pushed a commit to update the code to use "problem".
To help us maintain the docs and to keep things consistent for our users, we typically put the documentation for each option or configuration property in a single place (e.g. options.md or configure.md) and then duplicate the key part in cli.md and the CLI help, rather than spreading the docs out or wording things differently. In my suggestion, I've pulled and combined the wording from cli.md and the CLI help and then consolidated them in suppression.md.
I've also tried to make the language consistent, e.g., standardising on "suppress", rather than using "mute" interchangeably.
How much effort is needed to add this feature to the Node.js API, and do we think the feature should be available to the Node.js API and live under "Options"?
In preparation for this possibility, I've condensed the docs in my suggestion so that they more closely match the conciseness and style of the other options.
| @@ -0,0 +1,80 @@ | |||
| # Bulk suppressions | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Bulk suppressions
> [!WARNING]
> This feature is **experimental**, and might change significantly.
Turning on a rule with the severity of `error` can be difficult when an established codebase already contains many problems that can't be auto-fixed. You can suppress those legacy problems so the rule is enforced only for new code, and then clear the backlog at your own pace.
## `--suppress [<rule>]`
Suppress problems that have the severity of `error` and record them in a file.
If no rule is specified, all problems are suppressed. Otherwise, only problems with the given rules are suppressed, e.g., `--suppress rule1 --suppress rule2`.
Subsequent runs without the `--suppress` flag will not report these problems, unless there are more problems for the same rule in the same file.
> [!TIP]
> We recommend committing the suppressions file to your repository and using the `--fix` option alongside the `--suppress`.
> [!NOTE]
> `--suppress` can't be combined with stdin input (e.g., piping code via `echo "..." | stylelint`).
## `--suppress-location <path>`
Path to a suppressions file or directory. Defaults to `stylelint-suppressions.json`.
If you specify a directory path, Stylelint will create a file named `stylelint-suppressions.json` in that directory.
> [!IMPORTANT]
> You must use `--suppress-location` on all subsequent runs, even when not using the `--suppress` flag.
A suggestion for an alternative version. It's concise like the docs for our options. Do we think it retains the key points from the existing version, or does anything need to be expanded upon?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, Looks good.
Fixed via e8ab682.
docs/user-guide/cli.md
Outdated
| Suppress all current problems and record them in a suppressions file. [More info](suppressions.md). | ||
|
|
||
| If a rule is specified as an argument (e.g., `--suppress=block-no-empty`), it suppresses violations for only the specified rule. You can repeat the flag to target multiple rules. | ||
|
|
||
| > [!NOTE] | ||
| > | ||
| > - `--suppress` cannot be combined with stdin input (e.g., piping code via `echo "..." | stylelint`). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Suppress all current problems and record them in a suppressions file. [More info](suppressions.md). | |
| If a rule is specified as an argument (e.g., `--suppress=block-no-empty`), it suppresses violations for only the specified rule. You can repeat the flag to target multiple rules. | |
| > [!NOTE] | |
| > | |
| > - `--suppress` cannot be combined with stdin input (e.g., piping code via `echo "..." | stylelint`). | |
| Suppress problems that have the severity of `error` and record them in a file. [More info](suppressions.md#suppress). |
To be consistent with other flags in the doc cli.md, i.e. we duplicate just the key part of the linked doc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed via ed50f2b.
|
@jeddy3 For this PR, I’d like to keep the scope to the CLI-only. I’d prefer we evaluate Node.js API support separately. (issue created: #8775) |
Co-authored-by: Richard Hallows <jeddy3@users.noreply.github.com>
jeddy3
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you.
Let's add this as an experimental CLI-only option, and then see how its used and where the ESLint discussion goes.
|
Many thanks to @jeddy3, @Mouvedia , and @ybiquitous for the patient and thorough reviews. Merging now. |
| datasource | package | from | to | | ---------- | --------- | ------- | ------- | | npm | stylelint | 16.24.0 | 16.25.0 | ## [v16.25.0](https://github.com/stylelint/stylelint/blob/HEAD/CHANGELOG.md#16250---2025-10-03) It adds 3 new features, including experimental support for bulk suppressions. It's also our first [immutable release](https://github.blog/changelog/2025-08-26-releases-now-support-immutability-in-public-preview/), with the package published to npm using [trusted publishing](https://github.blog/changelog/2025-07-31-npm-trusted-publishing-with-oidc-is-generally-available/) and our dependencies updated on a [cool down](https://github.blog/changelog/2025-07-01-dependabot-supports-configuration-of-a-minimum-package-age/) for improved supply chain security. - Added: support for bulk suppressions ([#8564](stylelint/stylelint#8564)) ([@ryo-manba](https://github.com/ryo-manba)). - Added: `ignoreAtRules: []` to `no-invalid-position-declaration` ([#8781](stylelint/stylelint#8781)) ([@jrmlt](https://github.com/jrmlt)). - Added: rule name to custom messages ([#8774](stylelint/stylelint#8774)) ([@jhae-de](https://github.com/jhae-de)).
| datasource | package | from | to | | ---------- | --------- | ------- | ------- | | npm | stylelint | 16.24.0 | 16.25.0 | ## [v16.25.0](https://github.com/stylelint/stylelint/blob/HEAD/CHANGELOG.md#16250---2025-10-03) It adds 3 new features, including experimental support for bulk suppressions. It's also our first [immutable release](https://github.blog/changelog/2025-08-26-releases-now-support-immutability-in-public-preview/), with the package published to npm using [trusted publishing](https://github.blog/changelog/2025-07-31-npm-trusted-publishing-with-oidc-is-generally-available/) and our dependencies updated on a [cool down](https://github.blog/changelog/2025-07-01-dependabot-supports-configuration-of-a-minimum-package-age/) for improved supply chain security. - Added: support for bulk suppressions ([#8564](stylelint/stylelint#8564)) ([@ryo-manba](https://github.com/ryo-manba)). - Added: `ignoreAtRules: []` to `no-invalid-position-declaration` ([#8781](stylelint/stylelint#8781)) ([@jrmlt](https://github.com/jrmlt)). - Added: rule name to custom messages ([#8774](stylelint/stylelint#8774)) ([@jhae-de](https://github.com/jhae-de)).
Closes #8173
Adds bulk suppressions to Stylelint, based on ESLint’s feature.
--suppress,--suppress=<rule>,--suppress-locationcli.mdand full guide inuser-guide/suppressions.mdReference: