I looked at stylelint's docs and only saw a way to disable stylelint for running on for specific files/directories but what I really want is a way to disable specific rules) for specific files/directories. Is there a way to achieve that? I don't want to use stylelint-disable
within the files.
Asked
Active
Viewed 3,925 times
5

Yangshun Tay
- 49,270
- 33
- 114
- 141
2 Answers
4
In the future, you'll be able to use the overrides
configuration property. In the meantime, you can work around this missing feature by using the extend
configuration property and by running stylelint twice.
Create a second config that extends the more limited main config and turns on additional rules:
.extended-stylelintrc.json
:
{
extends: "./.stylelintrc.json",
rules: {
"unit-whitelist": ["px"]
}
};
Or you can create a second config that extends a full main config and turns off rules:
.limited-stylelintrc.json
:
{
extends: "./.stylelintrc.json",
rules: {
"property-no-unknown": null
}
};
It will require two npm tasks to run it, though:
stylelint "**/*.css"
stylelint "special/**/*.css" --config .extended-stylelintrc.js
Or it can be combined into one:
stylelint "**/*.css" && stylelint "special/**/*.css" --config .extended-stylelintrc.js

jeddy3
- 3,451
- 1
- 12
- 21
-
Seems clunky, but I guess I'll take that – Yangshun Tay Mar 06 '20 at 16:46
2
In that case, you can not use the ignoreFiles
option
or .stylelintignore
?
ignoreFiles
You can provide a glob or array of globs to ignore specific files.
For example, you can ignore all JavaScript files:
{ "ignoreFiles": ["**/*.js"] }
-
2This ignores all rules for those files. I only want to ignore some rules for those files – Yangshun Tay Mar 06 '20 at 16:45