# postcss-validator

> PostCSS plugin to check if an input string is valid CSS

Latest version **0.2.0** (published 2017-03-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install postcss-validator
pnpm add postcss-validator
yarn add postcss-validator
bun add postcss-validator
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2017-03-15 |
| First published | 2017-03-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 (+6 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Masaaki Morishita |
| Maintainers | morishitter |
| Keywords | css, postcss, postcss-plugin, validator |

## Links

- npm: https://www.npmjs.com/package/postcss-validator
- Repository: https://github.com/morishitter/postcss-validator/git
- npm.io page: https://npm.io/package/postcss-validator

## Dependencies (3)

- [chalk](https://npm.io/package/chalk.md) ^1.1.3
- [postcss](https://npm.io/package/postcss.md) ^5.2.16
- [known-css-properties](https://npm.io/package/known-css-properties.md) 0.0.7

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

- 0.2.0 (latest) — 2017-03-15
- 0.1.0 — 2017-03-15

## README

# postcss-validator [![Build Status](https://travis-ci.org/morishitter/postcss-validator.svg)](https://travis-ci.org/morishitter/postcss-validator)

PostCSS is very flexible CSS parser, so we can extend CSS syntax easily.
But, The output of PostCSS plugins may not be valid CSS string.
[postcss-validator](https://github.com/morishitter/postcss-validator) can check if an input string is valid CSS.

## Features

postcss-validator can check to using the followings:

- Nested selector (like Sass)
- Unknown properties

## Example

### Using nested selectors

Input:

```
.class {
  color: tomato;

  .nested {
    color: lime;
  }
}
```

Yield:

```
CssSyntaxError: postcss-validator: <css input>:2:3: Nested rules [.nested]
```

### Using unknown property

Input:

```
.class {
  margintop: 10px;
}
```

Yield:

```
CssSyntaxError: postcss-validator: <css input>:2:3: Unknown property [margintop] is used
```

## Installation

```shell
$ npm install postcss-validator
```

## Usage

Set postcss-validator at the bottom of loaded PostCSS plugins.

### in Node.js

```js
// dependencies
var fs = require("fs")
var postcss = require("postcss")
var customProperties = require("postcss-custom-properties")
var nesting = require("postcss-nesting")
var validator = require("postcss-validator")

// css to be processed
var css = fs.readFileSync("input.css", "utf8")

// process css
var output = postcss()
  .use(customProperties())
  .use(nesting())
  .use(validator())
  .process(css)
  .css
```

## License

The MIT License (MIT)

Copyright (c) 2017 Masaaki Morishita

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