#
Integrate with VS Code
Stylelint VS Code extension greatly improves the development experience by automatically linting the code as you type and automatically formatting the code according to your Stylelint configuration whenever you save.
#
Install Stylelint extension
Open VS Code and install the stylelint.vscode-stylelint extension.
#
Configure VS Code
Then, add the following settings to your solution VS Code settings file:
./vscode/settings.json
{
"editor.codeActionsOnSave": {
"source.fixAll": true, // Makes sure Stylelint is run on save
},
"editor.formatOnSave": true,
"css.validate": false, // Disables the default formatter to use Stylelint instead
"scss.validate": false // Disables the default formatter to use Stylelint instead
}
#
Install EditorConfig extension
Finally, install the EditorConfig.EditorConfig extension.
#
Try it 🚀
Restart VS Code, open a CSS file, type invalid code in a CSS selector (e.g. color: #fff
), then save. The code should have been formatted automatically (e.g. color: #ffffff
).