stylelint-config-selleo
v0.1.1
Published
Stylelint Config Selleo CLI
Readme
stylelint-config-selleo
Linter for styles, configurable with 3 variants:
- CSS & SCSS syntax
- BEM methodology
- SASS syntax
Installation
Target repo
Minimum Node.js version: 16
npm i --save-dev stylelintnpm i --save-dev stylelint-config-selleoin the
package.jsonadd:"scripts": { "stylelint-config-selleo": "stylelint-config-selleo" }run
npm run stylelint-config-selleo initselect appropriate extensions
in your project root directory
.stylelintrc.jsonfile will appear with previously selected extensions
If you use prettier:
Create or update existing .prettierignore following rule - ignore prettier for css, sccs and sass files - use stylelint by default
**/*.css
**/*.scss
**/*.sassIDE setup
VSCode
- Install Stylelint plugin.
- Go to
Preferences > Settings. - Search for
stylelint. - Inside
Stylelint: SnippetandStylelint: Validateaddscssorsass.
Autofix on file save
- Open VSCode settings in the
jsonformat - Paste following rule at the end of file
"editor.codeActionsOnSave": {
"source.fixAll.stylelint": true
},JetBrains (RubyMine, WebStorm)
- Go to
Preferences > Languages & Frameworks > Style Sheets > Stylelint. - Click Enable.
- Inside Run for files enter
{**/*,*}.{css,scss,sass}- without spaces between file extensions!
Autofix on file save
- Open WebStorm
Preferences > Tools > File Watchers - Click
+/Add > <custom> - Provide watcher name ie
stylelint-auto-fix - Change
File typetoAny - Set
Programto$ProjectFileDir$/node_modules/stylelint/bin/stylelint.js - Set
Argumentsto$FilePath$ --fix - Set
Working directoryto$ProjectFileDir$ - Open
Advanced Optionsand let onlyTrigger the watcher on external changeschecked - Save and Apply changes
Add External Tools
This is a workaround for this issue. It will
not work on file save, but you can instead run it by Right Click > External Tools - stylelint-auto-fix.
- Open WebStorm
Preferences > Tools > External Tools - Click
+/Add - Provide name ie
stylelint-auto-fix - Set
Programto$ProjectFileDir$/node_modules/stylelint/bin/stylelint.js - Set
Argumentsto$FilePath$ --fix - Set
Working directoryto$ProjectFileDir$ - Save and Apply changes
CLI / CI
Run npm run stylelint-config-selleo to see all available commands:
fix-all Run auto fix for all changed files
fix-current Run auto fix for currently changed files
help Display help for stylelint-config-selleo.
init Initialize the Stylelint Selleo Config by selecting extensions
list-all List all styles issues
list-current List styles issues for currently changed files
plugins List installed plugins.