5

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.

Yangshun Tay
  • 49,270
  • 33
  • 114
  • 141

2 Answers2

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
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"]
}
Community
  • 1
  • 1
sanriot
  • 804
  • 4
  • 13