Skip to content

Conversation

@ryo-manba
Copy link
Member

@ryo-manba ryo-manba commented May 5, 2025

Which issue, if any, is this issue related to?

Closes #8173

Is there anything in the PR that needs further explanation?

Adds bulk suppressions to Stylelint, based on ESLint’s feature.

  • New CLI flags:--suppress, --suppress=<rule>, --suppress-location
  • CLI integration and tests
  • Docs updates: brief “Suppressing Violations” section in cli.md and full guide in user-guide/suppressions.md

Reference:

@changeset-bot
Copy link

changeset-bot bot commented May 5, 2025

🦋 Changeset detected

Latest commit: e78bf6b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
stylelint Minor

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

@github-actions
Copy link
Contributor

github-actions bot commented May 5, 2025

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

@ryo-manba ryo-manba marked this pull request as ready for review May 6, 2025 17:16
Copy link

Copilot AI left a 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.

@Mouvedia
Copy link
Member

@ryo-manba thanks for the PR.

I did a first pass on some files; Ill do the rest eventually.
Nothing major or blocking, it's looking good.

@ryo-manba ryo-manba requested a review from Mouvedia May 16, 2025 12:37
ybiquitous

This comment was marked as resolved.

ybiquitous

This comment was marked as resolved.

@Mouvedia

This comment was marked as resolved.

@ryo-manba

This comment was marked as resolved.

@ybiquitous

This comment was marked as resolved.

ryo-manba and others added 6 commits September 9, 2025 00:44
Co-authored-by: Masafumi Koba <473530+ybiquitous@users.noreply.github.com>
Co-authored-by: Masafumi Koba <473530+ybiquitous@users.noreply.github.com>
Copy link
Member

@ybiquitous ybiquitous left a 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!

ryo-manba and others added 3 commits September 9, 2025 22:49
Co-authored-by: Masafumi Koba <473530+ybiquitous@users.noreply.github.com>
Copy link
Member

@jeddy3 jeddy3 left a 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 severity secondary 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
Copy link
Member

@jeddy3 jeddy3 Sep 15, 2025

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?

Copy link
Member Author

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.

Comment on lines 137 to 143
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`).
Copy link
Member

@jeddy3 jeddy3 Sep 15, 2025

Choose a reason for hiding this comment

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

Suggested change
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.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed via ed50f2b.

@ryo-manba
Copy link
Member Author

ryo-manba commented Sep 23, 2025

@jeddy3
Thanks for the thoughtful suggestions!

For this PR, I’d like to keep the scope to the CLI-only.
The Node.js API integration (needed for IDE integrations like VS Code) has a lot of design considerations.
ESLint is actively discussing this in an RFC (See: eslint/rfcs#133).

I’d prefer we evaluate Node.js API support separately. (issue created: #8775)

ryo-manba and others added 4 commits September 23, 2025 14:55
Copy link
Member

@jeddy3 jeddy3 left a 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.

@ryo-manba
Copy link
Member Author

Many thanks to @jeddy3, @Mouvedia , and @ybiquitous for the patient and thorough reviews.
I really appreciate all your feedback.

Merging now.

@ryo-manba ryo-manba merged commit 8d0b9d2 into main Sep 23, 2025
19 of 20 checks passed
@ryo-manba ryo-manba deleted the issue-8173 branch September 23, 2025 12:18
renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request Oct 3, 2025
| 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)).
renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request Oct 3, 2025
| 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)).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Add support for bulk suppressions

5 participants