Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fela-plugin-validator

Package Overview
Dependencies
Maintainers
2
Versions
111
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fela-plugin-validator

Fela plugin to validate style objects

  • 10.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6K
decreased by-18.68%
Maintainers
2
Weekly downloads
 
Created
Source

fela-plugin-validator

npm version npm downloads Bundlephobia

Enforces 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.

Installation

yarn add fela-plugin-validator

You may alternatively use npm i --save fela-plugin-validator.

Usage

Make sure to read the documentation on how to use plugins.

import { createRenderer } from 'fela'
import validator from 'fela-plugin-validator'

const renderer = createRenderer({
  plugins: [ validator() ]
})

Plugin ordering

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.

Configuration

Options
 OptionValueDefaultDescription
logInvalid(boolean?) truelogs invalid properties/values
deleteInvalid(boolean?) falsedeletes invalid properties/values
useCSSLint(boolean?)
(Object?)
falseuse CSSLint for style validation.
If an object is transferred, it will be interpreted as a set of rules for the validation (see here)
Example
import { createRenderer } from 'fela'
import validator from 'fela-plugin-validator'

const validatorPlugin = validator({
  logInvalid: true,
  deleteInvalid: true,
  useCSSLint: true
})

const renderer = createRenderer({
  plugins: [ validatorPlugin ]
})

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',
  }
}

License

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

Keywords

FAQs

Package last updated on 12 Dec 2018

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc