The recommended shareable Vue config for Stylelint.
npm install stylelint-config-recommended-vue




> The recommended shareable Vue config for [Stylelint].
This config:
- extends the stylelint-config-recommended shared config and configures its rules for Vue
- bundles the postcss-html custom syntax and configures it
> Requirements
>
> - [Stylelint] v14.0.0 and above
> It cannot be used with Stylelint v13 and below.
To see the rules that this config uses, please read the config itself.
``shell`
npm install --save-dev postcss-html stylelint-config-recommended-vue
Set your stylelint config to:
`json`
{
"extends": "stylelint-config-recommended-vue"
}
Note: This config enables rules for only .vue files.
If you don't want the rules to be overridden (If you want to enable only the parser.), please use stylelint-config-html.
`json`
{
"extends": "stylelint-config-html/vue"
}
Since this package configure customSyntax option to allow parsing Vue files, be sure it is the LAST item into the extends array, in case more than one configuration is applied.Unknown word (CssSyntaxError)
Not complying to this rule may result in broken Vue files parsing, generating confusing errors like .
Install postcss-scss and stylelint-config-recommended-scss:
`shell`
npm install --save-dev postcss-scss stylelint-config-recommended-scss
Set your stylelint config to:
`json`
{
"extends": "stylelint-config-recommended-vue/scss"
}
When used with stylelint-config-standard-scss:
`json`
{
"extends": [
"stylelint-config-standard-scss",
"stylelint-config-recommended-vue/scss"
]
}
However, some stylistic rules may not work well with Vue. We recommend that you install stylelint-config-standard-vue instead.
Simply add a "rules" key to your config, then add your overrides and additions there.
For example, to add the unit-allowed-list rule:
`json`
{
"extends": "stylelint-config-recommended-vue",
"overrides": [
{
"files": [".vue", "/.vue"],
"rules": {
"unit-allowed-list": ["em", "rem", "s"]
}
}
]
}
Use the stylelint.vscode-stylelint extension that [Stylelint] provides officially.
You have to configure the stylelint.validate option of the extension to check .vue files, because the extension does not check the *.vue file by default.
Example .vscode/settings.json:
`jsonc``
{
"stylelint.validate": [
...,
// ↓ Add "vue" language.
"vue"
]
See the LICENSE file for license rights and limitations (MIT).
[Stylelint]: https://stylelint.io/