Skip to content

Commit 8d0b9d2

Browse files
ryo-manbaybiquitousMouvediajeddy3
authored
Add support for bulk suppressions (#8564)
Co-authored-by: Masafumi Koba <473530+ybiquitous@users.noreply.github.com> Co-authored-by: Gary Gozlan <Mouvedia@users.noreply.github.com> Co-authored-by: jeddy3 <jeddy3@users.noreply.github.com>
1 parent 6342d1e commit 8d0b9d2

29 files changed

+1537
-22
lines changed

.changeset/moody-parrots-report.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"stylelint": minor
3+
---
4+
5+
Added: support for bulk suppressions

docs/user-guide/cli.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,14 @@ A filename to assign the input. [More info](options.md#codefilename).
132132

133133
Accept stdin input even if it is empty.
134134

135+
### `--suppress`
136+
137+
Suppress problems that have the severity of `error` and record them in a file. [More info](suppressions.md#--suppress-rule).
138+
139+
### `--suppress-location`
140+
141+
Path to a file or directory for the suppressions location. [More info](suppressions.md#--suppress-location-path).
142+
135143
### `--validate, --no-validate`
136144

137145
Force enable/disable the validation of the rules' options. [More info](options.md#validate).

docs/user-guide/suppressions.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Bulk suppressions
2+
3+
> [!WARNING]
4+
> This feature is **experimental**, and might change significantly.
5+
6+
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.
7+
8+
## `--suppress [<rule>]`
9+
10+
Suppress problems that have the severity of `error` and record them in a file.
11+
12+
If no rule is specified, all problems are suppressed. Otherwise, only problems with the given rules are suppressed, e.g., `--suppress rule1 --suppress rule2`.
13+
14+
Subsequent runs without the `--suppress` flag will not report these problems, unless there are more problems for the same rule in the same file.
15+
16+
> [!TIP]
17+
> We recommend committing the suppressions file to your repository and using the `--fix` option alongside the `--suppress`.
18+
19+
> [!NOTE]
20+
> `--suppress` can't be combined with stdin input (e.g., piping code via `echo "..." | stylelint`).
21+
22+
## `--suppress-location <path>`
23+
24+
Path to a suppressions file or directory. Defaults to `stylelint-suppressions.json`.
25+
26+
If you specify a directory path, Stylelint will create a file named `stylelint-suppressions.json` in that directory.
27+
28+
> [!IMPORTANT]
29+
> You must use `--suppress-location` on all subsequent runs, even when not using the `--suppress` flag.

lib/__tests__/__snapshots__/cli.test.mjs.snap

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,18 @@ exports[`CLI --help 1`] = `
174174
175175
When a glob pattern matches no files, the process will exit without throwing an error.
176176
177+
--suppress [<rule>]
178+
Suppress problems and record them in a file. If no rule is specified,
179+
all problems are suppressed. Otherwise, only problems with the given
180+
rules are suppressed, e.g., "--suppress rule1 --suppress rule2".
181+
See also "--suppress-location".
182+
183+
--suppress-location <path>
184+
185+
A path to a file or directory to be used for the suppressions file location. If a
186+
directory is specified, a suppressions file will be created inside the specified
187+
folder, with the name "stylelint-suppressions.json".
188+
177189
--globby-options, --go <json>
178190
179191
Options in JSON format passed to globby.

0 commit comments

Comments
 (0)