Giter Club home page Giter Club logo

perfectionist's Introduction

perfectionist Build Status NPM version Dependency Status

Beautify CSS files.

Install

With npm do:

npm install perfectionist --save

Example

Input

h1   {
         color   :  red }

Expanded output

h1 {
    color: red;
}

Compact output

h1 { color: red; }

Compressed output

h1{color:red}

API

perfectionist.process(css, [options])

css

Type: string Required option.

Pass a CSS string to beautify it.

options

cascade

Type: boolean Default: true

Set this to false to disable visual cascading of vendor prefixed properties. Note that this transform only applies to the expanded format.

true
h1 {
    -webkit-border-radius: 12px;
            border-radius: 12px;
}
false
h1 {
    -webkit-border-radius: 12px;
    border-radius: 12px;
}
format

Type: string Default: expanded

Pass either expanded, compact or compressed. Note that the compressed format only facilitates simple whitespace compression around selectors & declarations. For more powerful compression, see cssnano.

indentSize

Type: number Default: 4

This number will be used as a basis for all indent levels, using the expanded format.

maxAtRuleLength

Type: boolean|number Default: 80

If set to a positive integer, set a maximum width for at-rule parameters; if they exceed this, they will be split up over multiple lines. If false, this behaviour will not be performed. Note that this transform only applies to the expanded format.

maxSelectorLength

Type: boolean|number Default: 80

If set to a positive integer, set a maximum width for a selector string; if it exceeds this, it will be split up over multiple lines. If false, this behaviour will not be performed. Note that this transform is excluded from the compressed format.

maxValueLength

Type: boolean|number Default: 80

If set to a positive integer, set a maximum width for a property value; if it exceeds this, it will be split up over multiple lines. If false, this behaviour will not be performed. Note that this transform only applies to the expanded format.

sourcemap

Type: boolean Default: false

Generate a sourcemap with the transformed CSS.

syntax

Type: string

Specify scss if you would like to also format SCSS-style single line comments. This loads the postcss-scss plugin.

postcss([ perfectionist(opts) ])

perfectionist can also be consumed as a PostCSS plugin. See the documentation for examples for your environment.

CLI

perfectionist also ships with a CLI app. To see the available options, just run:

$ perfectionist --help

Usage

See the PostCSS documentation for examples for your environment.

Integrations

Contributing

Pull requests are welcome. If you add functionality, then please add unit tests to cover it.

License

MIT © Ben Briggs

perfectionist's People

Contributors

ben-eb avatar sindresorhus avatar yisibl avatar

Watchers

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