Options shared by the:
You can use some of these options in the configuration object.
Stylelint does not throw an error when glob pattern matches no files.
Path to a JSON, YAML, or JS file that contains your configuration object.
Use this option if you don't want Stylelint to search for a configuration file.
The path should be either absolute or relative to the directory that your process is running from (
Absolute path to the directory that relative paths defining "extends", "plugins", and "customSyntax" are relative to. Only necessary if these values are relative paths.
Automatically fix, where possible, problems reported by rules.
For CSS with standard syntax, Stylelint uses postcss-safe-parser to fix syntax errors.
When using the Node.js API, the autofixed code is available as the value of the
output property in the returned object.
If a source contains a:
- scoped disable comment, e.g.
/* stylelint-disable indentation */, any problems reported by the scoped rules will not be automatically fixed anywhere in the source
- unscoped disable comment, i.e.
/* stylelint-disable */, the entirety of source will not be automatically fixed
This limitation in being tracked in issue #2643.
Specify a custom syntax to use on your code.
There are many styling languages, ranging from CSS language extensions like SCSS to entirely different notations, e.g. CSS-in-JS objects.
These styling languages can be embedded within other languages too. For example:
- markdown fences
This option allows Stylelint to transform these into something that resembles CSS, which is the language that:
- underpins all the other styling languages
- is best understood by rules built into Stylelint
This option should be a string that resolves to a JS module that exports a PostCSS-compatible syntax. The string can be a module name (like
my-module) or a path to a JS file (like
If you want to lint two or more different languages, you can combine
customSyntax with the
overrides configuration property.
Using the Node.js API, the
customSyntax option can also accept a Syntax object. Stylelint treats the
parse property as a required value.
Note that Stylelint can provide no guarantee that core rules work with custom syntaxes.
--formatter, -f |
Specify the formatter to format your results.
compact- generates output similar to ESLint's compact formatter
github- generates messages via workflow commands for GitHub Actions
json(default for Node API) - generates JSON that can be consumed by another tool
string(default for CLI) - generates human-readable strings
tap- generates Test Anything Protocol output
unix- generates messages like a C compiler, so that tools like Emacs' Compilation mode can hyperlink them
stringto include a list of checked files and a tally for each rule
formatter Node.js API option can also accept a function, whereas the
--custom-formatter CLI flag accepts a path (either a filesystem path or a dependency) to a JS file exporting one. The function in both cases must fit the signature described in the Developer Guide.
Store the results of processed files so that Stylelint only operates on the changed ones. By default, the cache is stored in
Enabling this option can dramatically improve Stylelint's speed because only changed files are linted.
If you run Stylelint with
cache and then run Stylelint without
cache, Stylelint deletes the
.stylelintcache because we have to assume that the second command invalidated
Path to a file or directory for the cache location.
If a directory is specified, Stylelint creates a cache file inside the specified folder. The name of the file is based on the hash of
.cache_hashOfCWD) so that Stylelint can reuse a single location for a variety of caches from different projects.
If the directory of
cacheLocation does not exist, make sure you add a trailing
/ on *nix systems or
\ on Windows. Otherwise, Stylelint assumes the path to be a file.
Strategy for the cache to use for detecting changed files. Can be either "metadata" or "content".
The "content" strategy can be useful in cases where the modification time of your files changes even if their contents have not. For example, this can happen during git operations like "git clone" because git does not track file modification time.
Set a limit to the number of warnings accepted.
It is useful when setting
"warning" and expecting the process to fail on warnings (e.g. CI build).
If the number of warnings exceeds this value, the:
- CLI process exits with code
- Node.js API adds a
maxWarningsExceededproperty to the returned data
Disable the default ignores. Stylelint will not automatically ignore the contents of
Options passed to globby. More info.
Path to a file containing patterns that describe files to ignore. The path can be absolute or relative to
process.cwd(). You can repeat the option to provide multiple paths. By default, Stylelint looks for
/* stylelint-disable block-no-empty */) comments.
You can use this option to see what your linting results would be like without those exceptions.
stylelint-disable comments without a description.
The following patterns are reported:
/* stylelint-disable */
/* stylelint-disable-next-line block-no-empty */
But, the following patterns (
stylelint-disable -- <description>) are not reported:
/* stylelint-disable -- This problem is ignorable. */
/* stylelint-disable-next-line block-no-empty -- This problem is ignorable. */
stylelint-disable comments that don't match rules that are specified in the configuration object.
stylelint-disable comments that don't actually match any lints that need to be disabled.
A filename to assign the input.
stdin to pass a source string directly, you can use
codeFilename to associate that code with a particular filename.
Only register problems for rules with an "error"-level severity (ignore "warning"-level).
Ignore deprecation warnings.