# perfectionist

> Beautify CSS files.

Latest version **2.4.0** (published 2017-01-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install perfectionist
pnpm add perfectionist
yarn add perfectionist
bun add perfectionist
```

Provides the command `perfectionist`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.4.0 |
| Published | 2017-01-10 |
| First published | 2015-07-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 10 |
| Known vulnerabilities | 0 (+6 in 1 direct dependencies) |
| Install scripts | no |
| Author | Ben Briggs |
| Maintainers | beneb |
| Keywords | beautify, css, format, postcss, postcss-plugin, pretty |

## Links

- npm: https://www.npmjs.com/package/perfectionist
- Repository: https://github.com/ben-eb/perfectionist
- Issues: https://github.com/ben-eb/perfectionist/issues
- npm.io page: https://npm.io/package/perfectionist

## Dependencies (10)

- [defined](https://npm.io/package/defined.md) ^1.0.0
- [postcss](https://npm.io/package/postcss.md) ^5.0.8
- [vendors](https://npm.io/package/vendors.md) ^1.0.0
- [minimist](https://npm.io/package/minimist.md) ^1.2.0
- [postcss-scss](https://npm.io/package/postcss-scss.md) ^0.3.0
- [comment-regex](https://npm.io/package/comment-regex.md) ^1.0.0
- [read-file-stdin](https://npm.io/package/read-file-stdin.md) ^0.2.0
- [write-file-stdout](https://npm.io/package/write-file-stdout.md) 0.0.2
- [postcss-value-parser](https://npm.io/package/postcss-value-parser.md) ^3.3.0
- [string.prototype.repeat](https://npm.io/package/string.prototype.repeat.md) ^0.2.0

## Alternatives

- [style-dictionary](https://npm.io/package/style-dictionary.md) — 2.0M weekly downloads
- [postcss-merge-idents](https://npm.io/package/postcss-merge-idents.md) — 1.7M weekly downloads
- [@fontsource/noto-sans](https://npm.io/package/@fontsource/noto-sans.md) — 93.0K weekly downloads
- [uglifycss](https://npm.io/package/uglifycss.md) — 71.6K weekly downloads
- [mat4-interpolate](https://npm.io/package/mat4-interpolate.md) — 23.3K weekly downloads

## Recent versions

- 2.4.0 (latest) — 2017-01-10
- 2.3.1 — 2016-09-30
- 2.3.0 — 2016-09-05
- 2.2.0 — 2016-08-22
- 2.1.4 — 2016-07-24
- 2.1.3 — 2016-01-16
- 2.1.2 — 2015-10-07
- 2.1.1 — 2015-09-22
- 2.1.0 — 2015-09-10
- 2.0.0 — 2015-09-06
- 1.4.1 — 2015-08-28
- 1.4.0 — 2015-08-28
- 1.3.1 — 2015-08-12
- 1.3.0 — 2015-08-10
- 1.2.2 — 2015-08-09
- … 6 more at https://npm.io/package/perfectionist/versions

## README

# perfectionist [![Build Status](https://travis-ci.org/ben-eb/perfectionist.svg?branch=master)][ci] [![NPM version](https://badge.fury.io/js/perfectionist.svg)][npm] [![Dependency Status](https://gemnasium.com/ben-eb/perfectionist.svg)][deps]

> Beautify CSS files.

## Install

With [npm](https://npmjs.org/package/perfectionist) do:

```
npm install perfectionist --save
```

## Example

### Input

```css
h1   {
         color   :  red }
```

### Expanded output

```css
h1 {
    color: red;
}
```

### Compact output

```css
h1 { color: red; }
```

### Compressed output

```css
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.

```css
/* true */
h1 {
    -webkit-border-radius: 12px;
            border-radius: 12px;
}

/* false */
h1 {
    -webkit-border-radius: 12px;
    border-radius: 12px;
}
```

##### colorCase

Type: `string`
Default: `lower`

Set either `lower` or `upper` to transform hexadecimal colors to the according case.

```css
/* lower */
p { color: #C8C8C8 }

/* upper */
p { color: #c8c8c8 }
```

##### colorShorthand

Type: `boolean`
Default: `true`

Set this to `true` to shorten hexadecimal colors.

```css
/* true */
p { color: #fff }

/* false */
p { color: #ffffff }
```

##### 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].

##### indentChar

Type: `string`
Default: ` ` (space)

Specify `\t` here instead if you would like to use tabs for indentation.

##### indentSize

Type: `number`
Default: `4`

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

##### trimLeadingZero

Type: `boolean`
Default: `true`

Set this to `true` to trim leading zero for fractional numbers less than 1.

```css
/* true */
p { line-height: .8 }

/* false */
p { line-height: 0.8 }
```

##### trimTrailingZeros

Type: `boolean`
Default: `true`

Set this to `true` to traim trailing zeros in numbers.

```css
/* true */
div { top: 50px }

/* false */
div { top: 50.000px }
```

##### 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](https://github.com/postcss/postcss-scss) plugin.

##### zeroLengthNoUnit

Type: `boolean`
Default: `true`

Set this to `true` to trim units after zero length.

```css
/* true */
div { padding: 0 }

/* false */
div { padding: 0px }
```

### `postcss([ perfectionist(opts) ])`

perfectionist can also be consumed as a PostCSS plugin. See the
[documentation](https://github.com/postcss/postcss#usage) for examples for
your environment.

### CLI

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

```sh
$ perfectionist --help
```

## Usage

See the [PostCSS documentation](https://github.com/postcss/postcss#usage) for
examples for your environment.

## Integrations

- [Sublime Text plugin](https://github.com/yisibl/sublime-perfectionist)
- [Atom plugin](https://github.com/sindresorhus/atom-perfectionist)

## Contributing

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

## License

MIT © [Ben Briggs](http://beneb.info)

[ci]:      https://travis-ci.org/ben-eb/perfectionist
[cssnano]: https://github.com/ben-eb/cssnano
[deps]:    https://gemnasium.com/ben-eb/perfectionist
[npm]:     http://badge.fury.io/js/perfectionist
[postcss]: https://github.com/postcss/postcss

---
_Source: https://npm.io/package/perfectionist · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
