Fela plugin to validate style objects
npm install fela-plugin-validatorEnforces object validation for keyframes and rules.
Logs invalid properties to the console.
If enabled, csslint is used to check the CSS.
One might also enable automatic property deletion.
``sh`
yarn add fela-plugin-validator
You may alternatively use npm i --save fela-plugin-validator.
Make sure to read the documentation on how to use plugins.
`javascript
import { createRenderer } from 'fela'
import validator from 'fela-plugin-validator'
const renderer = createRenderer({
plugins: [validator()],
})
`
Make sure that you place the validator plugin _at the end_ of your plugins array - or else you may get some false error / validation messages.
##### Options
| Option | Value | Default | Description |
| ------------- | --------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| logInvalid | _(boolean?)_ | true | logs invalid properties/values |false
| deleteInvalid | _(boolean?)_ | | deletes invalid properties/values |false
| useCSSLint | _(boolean?)_
_(Object?)_ | | use CSSLint for style validation.
If an object is transferred, it will be interpreted as a set of rules for the validation (see here) |
##### Example
`javascript
import { createRenderer } from 'fela'
import validator from 'fela-plugin-validator'
const validatorPlugin = validator({
logInvalid: true,
deleteInvalid: true,
useCSSLint: true,
})
const renderer = createRenderer({
plugins: [validatorPlugin],
})
`
If the deleteInvalid option is enabled.
#### Input
`javascript`
{
'0%': {
color: 'red'
},
'101%': {
color: 'blue'
},
color: 'blue'
}
#### Output
`javascript`
{
'0%': {
color: 'red'
}
}
#### Input
`javascript`
{
color: 'red',
':hover': {
color: 'green',
foo: {
color: 'blue'
}
},
'nested': {
color: 'yellow'
}
}
#### Output
`javascript``
{
color: 'red',
':hover': {
color: 'green',
}
}
Fela is licensed under the MIT License.
Documentation is licensed under Creative Commons License.
Created with ♥ by @robinweser and all the great contributors.