.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / stylelint / docs / user-guide / css-processors.md
1 # CSS processors
2
3 The linter supports current and future CSS syntax. This includes all standard CSS but also special features that use standard CSS syntactic structures, e.g. special at-rules, special properties, and special functions. Some CSS-*like* language extensions --   features that use non-standard syntactic structures --   are, as such, supported; however, since there are infinite processing possibilities, the linter cannot support everything.
4
5 You can run the linter before or after your css processors. Depending on which processors you use, each approach has caveats:
6
7 1.  *Before*: Some plugins/processors might enable a syntax that isn't compatible with the linter.
8 2.  *After*: Some plugins/processors might generate CSS that is invalid against your linter config, causing violations that do not correspond to your original stylesheets.
9
10 *In both cases you can either turn off the incompatible linter rule, or stop using the incompatible plugin/processor.* You could also approach plugin/processor authors and request alternate formatting options that will make their plugin/processor compatible with stylelint.
11
12 ## Parsing non-standard syntax
13
14 By default, the linter can *parse* any the following non-standard syntaxes by using special PostCSS parsers:
15
16 -   SCSS (using [`postcss-scss`](https://github.com/postcss/postcss-scss))
17 -   Less (using [`postcss-less`](https://github.com/shellscape/postcss-less))
18 -   SugarSS (using [`sugarss`](https://github.com/postcss/sugarss))
19 -   HTML,
20 [Markdown](https://daringfireball.net/projects/markdown/syntax),
21 [Vue component](https://vue-loader.vuejs.org/)
22 (using [`postcss-html`](https://github.com/gucong3000/postcss-html))
23
24 *Non-standard syntaxes can automatically be inferred from the following file extensions, values for the `lang` or `type` attribute on `<style>` tags, and markers for Markdown code fences: `css`, `less`, `scss`, and `sss`.* If you would need to specify your non-standard syntax, though, both the [CLI](cli.md) and the [Node API](node-api.md) expose a `syntax` option.
25
26 -   If you're using the CLI, use the `syntax` flag like so:  `stylelint ... --syntax scss`.
27 -   If you're using the Node API, pass in the `syntax` option like so: `stylelint.lint({ syntax: "sugarss", ... })`.
28
29 Additionally, stylelint can accept a custom [PostCSS-compatible syntax](https://github.com/postcss/postcss#syntaxes) when using the CLI or Node API. For custom syntaxes, please use the `custom-syntax` and `customSyntax` options, respectively.
30
31 -   If you're using the CLI, use the `custom-syntax` flag like so:  `stylelint ... --custom-syntax custom-syntax-module` or `stylelint ... --custom-syntax ./path/to/custom-syntax-module`.
32 -   If you're using the Node API, pass in the `customSyntax` option like so: `stylelint.lint({ customSyntax: path.join(process.cwd(), './path/to/custom-syntax-module') , ... })`.
33
34 If you're using the linter as a [PostCSS Plugin](postcss-plugin.md), you'll need to use the special parser directly with PostCSS's `syntax` option like so:
35
36 ```js
37 var postcss = require("postcss")
38 var scss = require("postcss-scss")
39 // or use "postcss-less", "sugarss", "postcss-sass", or "postcss-html"
40
41 postcss([
42   require("stylelint"),
43   require("reporter")
44 ])
45   .process(css, {
46     from: "lib/app.css",
47     syntax: scss
48   })
49 })
50 ```