1 | # Options
|
2 |
|
3 | Options shared by the:
|
4 |
|
5 | - [CLI](cli.md)
|
6 | - [Node.js API](node-api.md)
|
7 | - [PostCSS plugin](postcss-plugin.md)
|
8 |
|
9 | ## `configFile`
|
10 |
|
11 | CLI flag: `--config`
|
12 |
|
13 | Path to a JSON, YAML, or JS file that contains your [configuration object](../configure.md).
|
14 |
|
15 | Use this option if you don't want stylelint to search for a configuration file.
|
16 |
|
17 | The path should be either absolute or relative to the directory that your process is running from (`process.cwd()`).
|
18 |
|
19 | ## `configBasedir`
|
20 |
|
21 | CLI flag: `--config-basedir`
|
22 |
|
23 | Absolute path to the directory that relative paths defining "extends" and "plugins" are _relative to_. Only necessary if these values are relative paths.
|
24 |
|
25 | ## `fix`
|
26 |
|
27 | CLI flag: `--fix`
|
28 |
|
29 | Automatically fix, where possible, violations reported by rules.
|
30 |
|
31 | For CSS with standard syntax, stylelint uses [postcss-safe-parser](https://github.com/postcss/postcss-safe-parser) to fix syntax errors.
|
32 |
|
33 | If a source contains a:
|
34 |
|
35 | - scoped disable comment, e.g. `/* stylelint-disable indentation */`, any violations reported by the scoped rules will not be automatically fixed anywhere in the source
|
36 | - unscoped disable comment, i.e. `/* stylelint-disable */`, the entirety of source will not be automatically fixed
|
37 |
|
38 | This limitation in being tracked in [issue #2643](https://github.com/stylelint/stylelint/issues/2643).
|
39 |
|
40 | ## `formatter`
|
41 |
|
42 | CLI flags: `--formatter, -f` | `--custom-formatter`
|
43 |
|
44 | Specify the formatter to format your results.
|
45 |
|
46 | Options are:
|
47 |
|
48 | - `compact`
|
49 | - `json` (default for Node API)
|
50 | - `string` (default for CLI)
|
51 | - `unix`
|
52 | - `verbose`
|
53 |
|
54 | The `formatter` Node.js API option can also accept a function, whereas the `--custom-formatter` CLI flag accepts a path to a JS file exporting one. The function in both cases must fit the signature described in the [Developer Guide](../../developer-guide/formatters.md).
|
55 |
|
56 | ## `cache`
|
57 |
|
58 | CLI flag: `--cache`
|
59 |
|
60 | Store the results of processed files so that stylelint only operates on the changed ones. By default, the cache is stored in `./.stylelintcache` in `process.cwd()`.
|
61 |
|
62 | Enabling this option can dramatically improve stylelint's speed because only changed files are linted.
|
63 |
|
64 | _If you run stylelint with `cache` and then run stylelint without `cache`, stylelint deletes the `.stylelintcache` because we have to assume that that second command invalidated `.stylelintcache`._
|
65 |
|
66 | ## `cacheLocation`
|
67 |
|
68 | CLI flag: `--cache-location`
|
69 |
|
70 | Path to a file or directory for the cache location.
|
71 |
|
72 | 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 `process.cwd()` (e.g. `.cache_hashOfCWD`) so that stylelint can reuse a single location for a variety of caches from different projects.
|
73 |
|
74 | _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._
|
75 |
|
76 | ## `maxWarnings`
|
77 |
|
78 | CLI flags: `--max-warnings, --mw`
|
79 |
|
80 | Set a limit to the number of warnings accepted.
|
81 |
|
82 | It is useful when setting [`defaultSeverity`](../configure.md#defaultseverity) to `"warning"` and expecting the process to fail on warnings (e.g. CI build).
|
83 |
|
84 | If the number of warnings exceeds this value, the:
|
85 |
|
86 | - CLI process exits with code `2`
|
87 | - Node.js API adds a [`maxWarningsExceeded`](node-api.md#maxwarningsexceeded) property to the returned data
|
88 |
|
89 | ## `syntax`
|
90 |
|
91 | CLI flags: `--syntax, -s`
|
92 |
|
93 | Specify a syntax. Options:
|
94 |
|
95 | - `css`
|
96 | - `css-in-js`
|
97 | - `html`
|
98 | - `less`
|
99 | - `markdown`
|
100 | - `sass`
|
101 | - `scss`
|
102 | - `sugarss`
|
103 |
|
104 | If you do not specify a syntax, stylelint automatically infer the syntaxes.
|
105 |
|
106 | Only use this option if you want to force a specific syntax.
|
107 |
|
108 | ## `customSyntax`
|
109 |
|
110 | CLI flag: `--custom-syntax`
|
111 |
|
112 | Module name or path to a JS file exporting a [PostCSS-compatible syntax](https://github.com/postcss/postcss#syntaxes).
|
113 |
|
114 | Note, however, that stylelint can provide no guarantee that core rules work with syntaxes other than the defaults listed for the `syntax` option above.
|
115 |
|
116 | ## `disableDefaultIgnores`
|
117 |
|
118 | CLI flags: `--disable-default-ignores, --di`
|
119 |
|
120 | Disable the default ignores. stylelint will not automatically ignore the contents of `node_modules`.
|
121 |
|
122 | ## `ignorePath`
|
123 |
|
124 | CLI flags: `--ignore-path, -i`
|
125 |
|
126 | A path to a file containing patterns describing files to ignore. The path can be absolute or relative to `process.cwd()`. By default, stylelint looks for `.stylelintignore` in `process.cwd()`.
|
127 |
|
128 | ## `ignoreDisables`
|
129 |
|
130 | CLI flags: `--ignore-disables, --id`
|
131 |
|
132 | Ignore `styleline-disable` (e.g. `/* stylelint-disable block-no-empty */`) comments.
|
133 |
|
134 | You can use this option to see what your linting results would be like without those exceptions.
|
135 |
|
136 | ## `reportNeedlessDisables`
|
137 |
|
138 | CLI flags: `--report-needless-disables, --rd`
|
139 |
|
140 | Produce a report to clean up your codebase, keeping only the stylelint-disable comments that serve a purpose.
|
141 |
|
142 | If needless disables are found, the:
|
143 |
|
144 | - CLI process exits with code `2`
|
145 | - Node.js API adds a [`needlessDisables`](node-api.md#needlessdisables) property to the returned data
|
146 |
|
147 | ## `reportInvalidScopeDisables`
|
148 |
|
149 | CLI flags: `--report-invalid-scope-disables, --risd`
|
150 |
|
151 | Produce a report of the stylelint-disable comments that used for rules that don't exist within the configuration object.
|
152 |
|
153 | If invalid scope disables are found, the:
|
154 |
|
155 | - CLI process exits with code `2`
|
156 | - Node.js API adds a [`invalidScopeDisables`](node-api.md#invalidscopedisables) property to the returned data
|
157 |
|
158 | ## `codeFilename`
|
159 |
|
160 | CLI flag: `--stdin-filename`
|
161 |
|
162 | A filename to assign the input.
|
163 |
|
164 | If using `code` or `stdin` to pass a source string directly, you can use `codeFilename` to associate that code with a particular filename.
|