UNPKG

5.56 kBMarkdownView Raw
1# Options
2
3Options 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
11CLI flag: `--config`
12
13Path to a JSON, YAML, or JS file that contains your [configuration object](../configure.md).
14
15Use this option if you don't want stylelint to search for a configuration file.
16
17The path should be either absolute or relative to the directory that your process is running from (`process.cwd()`).
18
19## `configBasedir`
20
21CLI flag: `--config-basedir`
22
23Absolute 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
27CLI flag: `--fix`
28
29Automatically fix, where possible, violations reported by rules.
30
31For CSS with standard syntax, stylelint uses [postcss-safe-parser](https://github.com/postcss/postcss-safe-parser) to fix syntax errors.
32
33If 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
38This limitation in being tracked in [issue #2643](https://github.com/stylelint/stylelint/issues/2643).
39
40## `formatter`
41
42CLI flags: `--formatter, -f` | `--custom-formatter`
43
44Specify the formatter to format your results.
45
46Options are:
47
48- `compact`
49- `json` (default for Node API)
50- `string` (default for CLI)
51- `unix`
52- `verbose`
53
54The `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
58CLI flag: `--cache`
59
60Store 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
62Enabling 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
68CLI flag: `--cache-location`
69
70Path to a file or directory for the cache location.
71
72If 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
78CLI flags: `--max-warnings, --mw`
79
80Set a limit to the number of warnings accepted.
81
82It is useful when setting [`defaultSeverity`](../configure.md#defaultseverity) to `"warning"` and expecting the process to fail on warnings (e.g. CI build).
83
84If 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
91CLI flags: `--syntax, -s`
92
93Specify a syntax. Options:
94
95- `css`
96- `css-in-js`
97- `html`
98- `less`
99- `markdown`
100- `sass`
101- `scss`
102- `sugarss`
103
104If you do not specify a syntax, stylelint automatically infer the syntaxes.
105
106Only use this option if you want to force a specific syntax.
107
108## `customSyntax`
109
110CLI flag: `--custom-syntax`
111
112Module name or path to a JS file exporting a [PostCSS-compatible syntax](https://github.com/postcss/postcss#syntaxes).
113
114Note, 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
118CLI flags: `--disable-default-ignores, --di`
119
120Disable the default ignores. stylelint will not automatically ignore the contents of `node_modules`.
121
122## `ignorePath`
123
124CLI flags: `--ignore-path, -i`
125
126A 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
130CLI flags: `--ignore-disables, --id`
131
132Ignore `styleline-disable` (e.g. `/* stylelint-disable block-no-empty */`) comments.
133
134You can use this option to see what your linting results would be like without those exceptions.
135
136## `reportNeedlessDisables`
137
138CLI flags: `--report-needless-disables, --rd`
139
140Produce a report to clean up your codebase, keeping only the stylelint-disable comments that serve a purpose.
141
142If 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
149CLI flags: `--report-invalid-scope-disables, --risd`
150
151Produce a report of the stylelint-disable comments that used for rules that don't exist within the configuration object.
152
153If 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
160CLI flag: `--stdin-filename`
161
162A filename to assign the input.
163
164If using `code` or `stdin` to pass a source string directly, you can use `codeFilename` to associate that code with a particular filename.