GithubHelp home page GithubHelp logo

2zh / prettier-stylelint Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hugomrdias/prettier-stylelint

1.0 2.0 0.0 241 KB

code > prettier > stylelint > formatted code

License: MIT License

JavaScript 79.11% CSS 20.89%

prettier-stylelint's Introduction

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-stylelint')
const sourceCode = 'a[id="foo"] { content: "x"; }'
const options = {
  text: sourceCode
}
const formatted = format.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}

Related

License

MIT © Hugo Dias

prettier-stylelint's People

Contributors

2zh avatar hugomrdias avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.