Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hugomrdias/prettier-stylelint
code > prettier > stylelint > formatted code
https://github.com/hugomrdias/prettier-stylelint
cli prettier stylelint
Last synced: 27 days ago
JSON representation
code > prettier > stylelint > formatted code
- Host: GitHub
- URL: https://github.com/hugomrdias/prettier-stylelint
- Owner: hugomrdias
- License: mit
- Archived: true
- Created: 2017-09-11T18:05:18.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-06-23T21:19:49.000Z (over 2 years ago)
- Last Synced: 2024-09-20T06:48:53.029Z (5 months ago)
- Topics: cli, prettier, stylelint
- Language: JavaScript
- Homepage:
- Size: 881 KB
- Stars: 175
- Watchers: 6
- Forks: 29
- Open Issues: 48
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# prettier-stylelint [](https://www.npmjs.com/package/prettier-stylelint) [](https://www.npmjs.com/package/prettier-stylelint) [](https://www.npmjs.com/package/prettier-stylelint) [](https://travis-ci.org/hugomrdias/prettier-stylelint) [](https://codecov.io/gh/hugomrdias/prettier-stylelint)
> Format your styles with ease!code > 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.
## Install
```bash
yarn add prettier-stylelint -D
npm install prettier-stylelint --save-dev
```## Usage
This package has a stylelint config to disable some rules that conflict with prettier.```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.
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).### API
```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';
}
```### CLI Options
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 --stdinDefault pattern when no arguments:
**/*.{css,scss,less,sss}
```## Related
- [prettier-vscode](https://github.com/esbenp/prettier-vscode) - prettier vscode extension
- [prettier-eslint](https://github.com/prettier/prettier-eslint) - the inspiration for this package
- [stylelint](https://github.com/stylelint/stylelint) - the linter ^^## License
MIT © [Hugo Dias](https://hugodias.me)