Stylelint plugin for Stylus
npm install stylelint-stylusThis plugin is still in an experimental state
[Stylelint] plugin for [Stylus].
This plugin allows us to check the [Stylus] with [Stylelint].
- Finds the many wrong use of selector, declaration, at-rule and more using the rules of [Stylelint].
- Finds the violations in coding style for [Stylus].
- Use the [fix option] to automatically fixes the many stylistic violations.
[fix option]: https://stylelint.io/user-guide/usage/options#fix
Stylelint editor integrations are useful to check your code in real-time.
You can check on the Online DEMO.
Via [npm]:
``bash`
npm install --save-dev stylelint stylelint-stylus
stylelint-stylus is a plugin for [Stylelint], so it is for use with [Stylelint].
If you are not using [Stylelint], start by using [Stylelint].
Use .stylelintrc.* or stylelint.config.js file to configure rules. See also: https://stylelint.io/user-guide/configure.
Example stylelint.config.js:
`js`
module.exports = {
extends: [
// add more generic rulesets here, such as:
// "stylelint-config-standard",
"stylelint-stylus/standard",
],
rules: {
// override/add rules settings here, such as:
// "stylus/declaration-colon": "never"
},
};
If you want to set all the rules yourself, set as follows.
`js`
module.exports = {
plugins: [
// add this plugin here:
"stylelint-stylus",
],
// makes the stylus files parseable.
overrides: [
{
files: [".stylus", ".styl", "/.stylus", "/.styl"],
customSyntax: "postcss-styl",
},
],
rules: {
// add rules settings here, such as:
"stylus/declaration-colon": "never",
"stylus/pythonic": "always",
"stylus/selector-list-comma": "never",
"stylus/semicolon": "never",
"stylus/single-line-comment": "always",
},
};
Use the stylelint.vscode-stylelint extension that [Stylelint] provides officially.
You have to configure the stylelint.validate option of the extension to check .stylus files, because the extension does not check the *.stylus file by default.
Example .vscode/settings.json:
`jsonc`
{
"stylelint.validate": [
...,
// ↓ Add "stylus" language.
"stylus"
]
}
If you are using stylelint v13, you need to do the following:
Set custom syntax for parsing [Stylus]. With the following setting, .styl and