1 # prettier-stylelint [![NPM Version](https://img.shields.io/npm/v/prettier-stylelint.svg)](https://www.npmjs.com/package/prettier-stylelint) [![NPM Downloads](https://img.shields.io/npm/dt/prettier-stylelint.svg)](https://www.npmjs.com/package/prettier-stylelint) [![NPM License](https://img.shields.io/npm/l/prettier-stylelint.svg)](https://www.npmjs.com/package/prettier-stylelint) [![Build Status](https://travis-ci.org/hugomrdias/prettier-stylelint.svg?branch=master)](https://travis-ci.org/hugomrdias/prettier-stylelint) [![codecov](https://codecov.io/gh/hugomrdias/prettier-stylelint/branch/master/graph/badge.svg)](https://codecov.io/gh/hugomrdias/prettier-stylelint)
2 > Format your styles with ease!
4 code > prettier > stylelint > formatted code
6 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.
11 yarn add prettier-stylelint -D
12 npm install prettier-stylelint --save-dev
16 This package has a stylelint config to disable some rules that conflict with prettier.
22 "stylelint-config-idiomatic-order",
23 "./node_modules/prettier-stylelint/config.js"
27 "string-quotes": "single"
33 After adding the disabling config you can just `prettier-stylelint --write` and its done. Check the CLI options below for more information.
34 Also in a near future we should have support for prettier-stylelint in `prettier-vscode` follow this [PR](https://github.com/prettier/prettier-vscode/pull/218).
39 const format = require('prettier-eslint')
40 const sourceCode = 'a[id="foo"] { content: "x"; }'
44 const formatted = format(options)
55 The cli automatically ignores `.gitignore` and `.prettierignore`.
57 >**NOTE:** It is recommended that you keep your files under source control and committed
58 > before running `prettier-stylelint --write` as it will overwrite your files!
63 $ prettier-stylelint [<file|glob> ...]
66 --ignore Additional paths to ignore [Can be set multiple times]
67 --extension Additional extension to lint [Can be set multiple times]
68 --cwd=<dir> Working directory for files
69 --stdin Validate/fix code from stdin ('prettier-stylelint -' also works)
70 --write Edit files in place (DRAGONS AHEAD !!)
71 --quiet -q Only log stderr
75 $ prettier-stylelint index.js
76 $ prettier-stylelint *.js !foo.js
77 $ echo 'a[id="foo"] { content: "x"; }' | prettier-stylelint --stdin
79 Default pattern when no arguments:
80 **/*.{css,scss,less,sss}
85 - [prettier-vscode](https://github.com/esbenp/prettier-vscode) - prettier vscode extension
86 - [prettier-eslint](https://github.com/prettier/prettier-eslint) - the inspiration for this package
87 - [stylelint](https://github.com/stylelint/stylelint) - the linter ^^
91 MIT © [Hugo Dias](https://hugodias.me)