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 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
$ npm install postcss-validator
Usage
Set postcss-validator at the bottom of loaded PostCSS plugins.
in Node.js
// dependenciesvar fs = var postcss = var customProperties = var nesting = var validator = // css to be processedvar css = fs // process cssvar output = css
License
The MIT License (MIT)
Copyright (c) 2017 Masaaki Morishita