New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

postcss-validator

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-validator

PostCSS plugin to check if an input string is valid CSS

latest
Source
npmnpm
Version
0.2.0
Version published
Weekly downloads
101
-15.13%
Maintainers
1
Weekly downloads
 
Created
Source

postcss-validator Build Status

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

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

Keywords

css

FAQs

Package last updated on 15 Mar 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts