JSPM

  • Created
  • Published
  • Downloads 13299
  • Score
    100M100P100Q141499F
  • License MIT

Fela plugin to validate style objects

Package Exports

  • fela-plugin-validator

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (fela-plugin-validator) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

fela-plugin-validator

npm downloads gzipped size

Enforces object validation for keyframes and rules. Logs invalid properties to the console. One might also enable automatic property deletion.

Installation

npm i --save fela-plugin-validator

Assuming you are using npm as your package mananger you can just npm install.
Otherwise we also provide a UMD. You can easily use it via npmcdn. It registers a FelaPluginValidator global.

<!-- Fela (Development): Unminified version including all warnings -->
<script src="https://npmcdn.com/fela-plugin-validator@1.1.0/dist/fela-plugin-validator.js"></script>
<!-- Fela (Production): Minified version -->
<script src="https://npmcdn.com/fela-plugin-validator@1.1.0/dist/fela-plugin-validator.min.js"></script>

Example

If the deleteInvalid option is enabled.

Keyframe

Input

{
  '0%': {
    color: 'red'
  },
  '101%': {
    color: 'blue'
  },
  color: 'blue'
}

Output

{
  '0%': {
    color: 'red'
  }
}

Rule

Input

{
  color: 'red',
  ':hover': {
    color: 'green',
    foo: {
      color: 'blue'
    }
  },
  'nested': {
    color: 'yellow'
  }
}

Output

{
  color: 'red',
  ':hover': {
    color: 'green',
  }
}

Configuration

The validator plugin uses two different option flags to enable/disable features.

import validator from 'fela-plugin-validator'

const plugin = validator({
  // Will log invalid properties as well as
  // the value assigned to, default: true
  logInvalid: true,
  // Will automatically delete invalid
  // properties, default: false
  deleteInvalid: true
})

License

Fela is licensed under the MIT License.
Documentation is licensed under Creative Common License.
Created with ♥ by @rofrischmann and all the great contributors.