1.0.0 • Published 2 years ago

@sika7/postcss-whitelist-sanitize v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

postcss-whitelist-sanitize

PostCSS plugin this postcss plugin whitelist filter. sanitize leaving the allowed properties and values..

.foo {
  a: #eee; // <= remove unknown property.
  background-color: hoge; // <= remove unknown value.
  position: fixed; // <= remove not allowed property.
  color: #eee;
}
.foo {
  color: #eee;
}

Usage

Step 1: Install plugin:

npm install --save postcss postcss-whitelist-sanitize

Step 2: allow property config.

const opts = {
  allowPropertys: ["background-color", "color"], // required
  validationCheck: true,
  allowPropertyCheck: true,
}
postcss([postcssWhitelistSanitize(opts)]).process()

config

default config.

{
  allowPropertys: [], // all not allow propertys.
  validationCheck: true, // default true.
  allowPropertyCheck: true, // default true.
}
settingdescriptiondefaultexample
allowPropertyssetting a allow propertys.[]"color","text-align"
validationChecktrue is remove validation error property and value. General w3c style Guideline applies. Using ben-eb/css-values module.true
allowPropertyChecktrue is remove not allow property. Using allowPropertys.true