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

eslint-plugin-css

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-css

An ESLint plugin that provides rules to verify CSS definition objects.

  • 0.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
15K
increased by0.21%
Maintainers
1
Weekly downloads
 
Created
Source

Introduction

eslint-plugin-css is an ESLint plugin that provides rules to verify CSS definition objects.

NPM license NPM version NPM downloads NPM downloads NPM downloads NPM downloads NPM downloads Build Status Coverage Status

::: WORKING IN PROGRESS :::

:name_badge: Features

This ESLint plugin provides linting rules to verify CSS definition objects.

  • Find the wrong usage of CSS definition objects, and their hints.
  • The plugin support for Vue and JSX (React).
  • The plugin partial support for styled-components style objects.

You can check on the Online DEMO.

:question: Why is it ESLint plugin?

Stylelint partially supports CSS in JS, but some issues haven't been resolved for a long time.
Also, CSS definitions using template literals are similar to CSS syntax, but CSS definitions using JavaScript objects are not. ESLint may work better for linting JavaScript objects.

:book: Documentation

See documents.

:cd: Installation

npm install --save-dev eslint eslint-plugin-css

Requirements

  • ESLint v7.0.0 and above
  • Node.js v12.22.x, v14.17.x, v16.x and above

:book: Usage

Add css to the plugins section of your .eslintrc configuration file (you can omit the eslint-plugin- prefix) and either use one of the two configurations available (recommended or all) or configure the rules you want:

The plugin:css/recommended config enables a subset of the rules that should be most useful to most users. See lib/configs/recommended.ts for more details.

// .eslintrc.js
module.exports = {
    "plugins": [
        "css"
    ],
    "extends": [
         // add more generic rulesets here, such as:
         // 'eslint:recommended',
        "plugin:css/recommended"
    ]
}

Advanced Configuration

Override/add specific rules configurations. See also: http://eslint.org/docs/user-guide/configuring.

// .eslintrc.js
module.exports = {
    "plugins": [
        "css"
    ],
    "rules": {
        // Override/add rules settings here, such as:
        "css/rule-name": "error"
    }
}

Using "plugin:css/all"

The plugin:css/all config enables all rules. It's meant for testing, not for production use because it changes with every minor and major version of the plugin. Use it at your own risk. See lib/configs/all.ts for more details.

:white_check_mark: Rules

The --fix option on the command line automatically fixes problems reported by rules which have a wrench :wrench: below. The rules with the following star :star: are included in the plugin:css/recommended config.

Possible Errors

Rule IDDescription
css/no-dupe-propertiesdisallow duplicate properties:star:
css/no-invalid-color-hexdisallow invalid hex colors:star:
css/no-unknown-propertydisallow unknown properties:star:
css/no-unknown-unitdisallow unknown units:star:

Best Practices

Rule IDDescription
css/no-length-zero-unitdisallow units for zero lengths:wrench:

Stylistic Issues

Rule IDDescription
css/property-casingenforce specific casing for CSS properties:wrench:

:gear: Settings

See Settings.

:beers: Contributing

Welcome contributing!

Please use GitHub's Issues/PRs.

See CONTRIBUTING.md.

Development Tools

  • npm test runs tests and measures coverage.
  • npm run update runs in order to update readme and recommended configuration.
  • npm run new [new rule name] runs to create the files needed for the new rule.
  • npm run docs:watch starts the website locally.

:lock: License

See the LICENSE file for license rights and limitations (MIT).

Keywords

FAQs

Package last updated on 10 Nov 2021

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