
CSS Tree Validator
CSS validator built on CSSTree
How to use:
NPM package
> npm install csstree-validator
Manualy validate CSS string or CSSTree's AST:
const { validate } = require('./lib');
console.log(validate('.class { pading: 10px; border: 1px super red }', 'demo/example.css'));
Another option is to use helpers to validate a file or directory and buildin reporters:
const { validateFile } = require('csstree-validator');
const reporter = require('csstree-validator').reporters.checkstyle;
console.log(reporter(validateFile('/path/to/style.css')));
API
Validate methods:
- validateAtrule(node)
- validateAtrulePrelude(atrule, prelude, preludeLoc)
- validateAtruleDescriptor(atrule, descriptor, value, descriptorLoc)
- validateDeclaration(property, value, valueLoc)
- validateRule(node)
- validate(css, filename)
Helpers:
- validateDictionary(dictionary)
- validateString(css, filename)
- validateFile(filename)
- validateFileList(list)
- validatePath(searchPath, filter)
- validatePathList(pathList, filter)
Reporters
CLI (terminal command)
> npm install -g csstree-validator
> csstree-validator /path/to/style.css
> csstree-validator -h
Usage:
csstree-validate [fileOrDir] [options]
Options:
-h, --help Output usage information
-r, --reporter <name> Format of output: console (default), checkstyle, json, gnu
-v, --version Output version
Ready to use
Plugins that are using csstree-validator
:
License
MIT