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

@eslint/css

Package Overview
Dependencies
Maintainers
0
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@eslint/css

CSS linting plugin for ESLint

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
74
increased by5.71%
Maintainers
0
Weekly downloads
 
Created
Source

ESLint CSS Language Plugin

Overview

This package contains a plugin that allows you to natively lint CSS files using ESLint.

Important: This plugin requires ESLint v9.6.0 or higher and you must be using the new configuration system.

Installation

For Node.js and compatible runtimes:

npm install @eslint/css -D
# or
yarn add @eslint/css -D
# or
pnpm install @eslint/css -D
# or
bun install @eslint/css -D

For Deno:

deno add @eslint/css

Configurations

Configuration NameDescription
recommendedEnables all recommended rules.

In your eslint.config.js file, import @eslint/css and include the recommended config:

// eslint.config.js
import css from "@eslint/css";

export default [
	// lint CSS files
	{
		files: ["**/*.css"],
		language: "css/css",
		...css.configs.recommended,
	},

	// your other configs here
];

Rules

Rule NameDescriptionRecommended
no-duplicate-importsDisallow duplicate @import rulesyes
no-empty-blocksDisallow empty blocksyes
no-invalid-at-rulesDisallow invalid at-rulesyes
no-invalid-propertiesDisallow invalid propertiesyes

Note: This plugin does not provide formatting rules. We recommend using a source code formatter such as Prettier for that purpose.

In order to individually configure a rule in your eslint.config.js file, import @eslint/css and configure each rule with a prefix:

// eslint.config.js
import css from "@eslint/css";

export default [
	{
		files: ["**/*.css"],
		plugins: {
			css,
		},
		language: "css/css",
		rules: {
			"css/no-empty-blocks": "error",
		},
	},
];

You can individually config, disable, and enable rules in CSS using comments, such as:

/* eslint css/no-empty-blocks: error */

/* eslint-disable css/no-empty-blocks -- this one is ok */
a {
}
/* eslint-enable css/no-empty-blocks */

b { /* eslint-disable-line css/no-empty-blocks */
}

/* eslint-disable-next-line css/no-empty-blocks */
em {
}

Languages

Language NameDescription
cssParse CSS stylesheets.

In order to individually configure a language in your eslint.config.js file, import @eslint/css and configure a language:

// eslint.config.js
import css from "@eslint/css";

export default [
	{
		files: ["**/*.css"],
		plugins: {
			css,
		},
		language: "css/css",
		rules: {
			"css/no-empty-blocks": "error",
		},
	},
];

License

Apache 2.0

Sponsors

The following companies, organizations, and individuals support ESLint's ongoing maintenance and development. Become a Sponsor to get your logo on our READMEs and website.

Platinum Sponsors

Automattic Airbnb

Gold Sponsors

trunk.io

Silver Sponsors

SERP Triumph JetBrains Liftoff American Express Workleap

Bronze Sponsors

Cybozu Syntax WordHint Anagram Solver Icons8 Discord GitBook Nx HeroCoders

Technology Sponsors

Technology sponsors allow us to use their products and services for free as part of a contribution to the open source ecosystem and our work.

Netlify Algolia 1Password

Keywords

FAQs

Package last updated on 26 Nov 2024

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