code > prettier > stylelint > formatted code
npm install prettier-stylelintcode > prettier > stylelint > formatted code
prettier-stylelint attempts to create a prettier config based on the stylelint config, then format with prettier followed by stylelint --fix. So after that you should end up with formatted code with no linting errors.
``bash`
yarn add prettier-stylelint -D
npm install prettier-stylelint --save-dev
`json
"stylelint": {
"extends": [
"stylelint-config-idiomatic-order",
"./node_modules/prettier-stylelint/config.js"
],
"rules": {
"indentation": 4,
"string-quotes": "single"
}
}
`
After adding the disabling config you can just prettier-stylelint --write and its done. Check the CLI options below for more information. prettier-vscode
Also in a near future we should have support for prettier-stylelint in follow this PR.
js
const format = require('prettier-eslint')
const sourceCode = 'a[id="foo"] { content: "x"; }'
const options = {
text: sourceCode
}
const formatted = format(options)
// formatted
a[id='foo'] {
content: 'x';
}
` $3
The cli automatically ignores
.gitignore and .prettierignore.>NOTE: It is recommended that you keep your files under source control and committed
> before running
prettier-stylelint --write as it will overwrite your files!
`
Usage
$ prettier-stylelint [ ...]Options
--ignore Additional paths to ignore [Can be set multiple times]
--extension Additional extension to lint [Can be set multiple times]
--cwd=
Working directory for files
--stdin Validate/fix code from stdin ('prettier-stylelint -' also works)
--write Edit files in place (DRAGONS AHEAD !!)
--quiet -q Only log stderrExamples
$ prettier-stylelint
$ prettier-stylelint index.js
$ prettier-stylelint *.js !foo.js
$ echo 'a[id="foo"] { content: "x"; }' | prettier-stylelint --stdin
Default pattern when no arguments:
*/.{css,scss,less,sss}
``- prettier-vscode - prettier vscode extension
- prettier-eslint - the inspiration for this package
- stylelint - the linter ^^
MIT © Hugo Dias