Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

prettier-stylelint

hugomrdias138kMIT0.4.2

code > prettier > stylelint > formatted code

stylelint, prettier, style, lint, linter, validate, code style, strict, check

readme

prettier-stylelint NPM Version NPM Downloads NPM License Build Status codecov

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

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.

"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.

API

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 [<file|glob> ...]

Options
  --ignore          Additional paths to ignore  [Can be set multiple times]
  --extension       Additional extension to lint [Can be set multiple times]
  --cwd=<dir>       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 stderr

Examples
  $ 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}

License

MIT © Hugo Dias

changelog

0.4.2 (2017-09-25)

Bug Fixes

0.4.1 (2017-09-25)

0.4.0 (2017-09-25)

Features

  • lookup prettier config and relative package import, plus more tests (bbc651a)

0.3.2 (2017-09-21)

Bug Fixes

  • dont re use the same linter instance because we can't invalidate the config cache (b6e1f7b)

0.3.1 (2017-09-21)

Bug Fixes

  • fix tests and update deps (fa9ee6e)
  • vscode extension PR url (6da9874)

0.3.0 (2017-09-19)

Features

  • no more temp file to fix with stylelint (d78b40c)

0.2.3 (2017-09-19)

Bug Fixes

0.2.1 (2017-09-19)

Bug Fixes

  • add version to build changelog with np (b925156)

Features

0.2.0 (2017-09-14)

Bug Fixes

  • no need to check for arrays anymore (cc27ee9)

Features

  • support extends and add compatibility stylelint config (5698124)

0.1.1 (2017-09-13)

0.1.0 (2017-09-13)

Features

0.0.1 (2017-09-12)

Bug Fixes

  • cleanup cli (abf97a2)
  • make this test pass needs further investigation (208de52)
  • make this test pass needs further investigation (f83496b)
  • remove @std/esm cause it breaks in vscode extension (fa198eb)

Features

  • add initial implementation for the formatter and cli (6dbf2f7)
  • add more tests and test custom syntax support (a1c813b)