{"name":"@eslint/css","version":"0.14.0","keywords":["eslint","eslint-plugin","eslintplugin","css","linting"],"author":{"name":"Nicholas C. Zakas"},"license":"Apache-2.0","_id":"@eslint/css@0.14.0","maintainers":[{"name":"openjsfoundation","email":"npm@openjsf.org"},{"name":"eslintbot","email":"contact@eslint.org"}],"homepage":"https://github.com/eslint/css#readme","bugs":{"url":"https://github.com/eslint/css/issues"},"dist":{"shasum":"61afa84238714d85d60d38e3d9a31d030676948c","tarball":"http://registry-npm.ywwl.com/@eslint/css/download/@eslint/css-0.14.0.tgz","fileCount":10,"integrity":"sha512-2UDkW1Oolf27KCWI9nceLFrpcDqSlJH1JMiXu8v4S9bYEEPr1KT5cvEjQkITjACR8EkQQYNrMYggvg8bVHp9fA==","signatures":[{"sig":"MEQCIBEPAtBmZljp2mGWCuHnyx5M2TXNoBKoOeKLusGbA2GfAiAgVM6xPnauwBFl8YOw+Ay/a6kyLnHFprYKbHTVjtvKpA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@eslint%2fcss@0.14.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":426435,"size":82984,"noattachment":false,"key":"/@eslint/css/-/@eslint/css-0.14.0.tgz"},"main":"dist/esm/index.js","type":"module","types":"dist/esm/index.d.ts","engines":{"node":"^18.18.0 || ^20.9.0 || >=21.1.0"},"exports":{".":{"import":{"types":"./dist/esm/index.d.ts","default":"./dist/esm/index.js"},"require":{"types":"./dist/cjs/index.d.cts","default":"./dist/cjs/index.cjs"}},"./types":{"import":{"types":"./dist/esm/types.d.ts"},"require":{"types":"./dist/cjs/types.cts"}}},"gitHead":"14db7f5e5dec9455d400bcfb2b8688c6e1502b35","scripts":{"fmt":"prettier --write .","lint":"eslint","test":"mocha \"tests/**/*.test.js\"","build":"npm run build:rules && rollup -c && npm run build:dedupe-types && tsc -p tsconfig.esm.json && npm run build:cts","prepare":"npm run build","pretest":"npm run build","lint:fix":"eslint --fix","test:jsr":"npx jsr@latest publish --dry-run","build:cts":"node -e \"fs.copyFileSync('dist/esm/index.d.ts', 'dist/cjs/index.d.cts')\" && node tools/update-cts.js dist/cjs/types.cts dist/cjs/index.d.cts","fmt:check":"prettier --check .","test:types":"npm run build && tsc -p tests/types/tsconfig.json","build:rules":"node tools/build-rules.js","test:coverage":"c8 npm test","build:baseline":"node tools/generate-baseline.js","build:dedupe-types":"node tools/dedupe-types.js dist/cjs/index.cjs dist/esm/index.js","build:update-rules-docs":"node tools/update-rules-docs.js"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:608606d9-f024-475b-bb79-2fba8a0c34a9"}},"gitHooks":{"pre-commit":"lint-staged"},"repository":{"url":"git+https://github.com/eslint/css.git","type":"git"},"_npmVersion":"11.6.2","description":"CSS linting plugin for ESLint","directories":{},"lint-staged":{"*.js":["eslint --fix","prettier --write"],"!(*.js)":"prettier --write --ignore-unknown","README.md":["npm run build:update-rules-docs"],"{src/rules/*.js,tools/update-rules-docs.js}":["npm run build:update-rules-docs","git add README.md"]},"_nodeVersion":"24.11.0","dependencies":{"@eslint/core":"^0.16.0","@eslint/css-tree":"^3.6.6","@eslint/plugin-kit":"^0.4.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"c8":"^10.1.3","mocha":"^11.0.0","dedent":"^1.5.3","eslint":"^9.36.0","rollup":"^4.52.3","yorkie":"^2.0.0","mdn-data":"^2.24.0","prettier":"^3.6.0","typescript":"^5.9.2","lint-staged":"^15.2.7","@eslint/json":"^0.13.2","web-features":"^3.6.0","tailwind-csstree":"^0.1.0","rollup-plugin-copy":"^3.5.0","eslint-config-eslint":"^13.0.0","rollup-plugin-delete":"^3.0.1","mdast-util-from-markdown":"^2.0.2","eslint-plugin-eslint-plugin":"^6.3.2"},"_npmOperationalInternal":{"tmp":"tmp/css_0.14.0_1761748337279_0.034216800874507625","host":"s3://npm-registry-packages-npm-production"},"readme":"# ESLint CSS Language Plugin\n\n## Overview\n\nThis package contains a plugin that allows you to natively lint CSS files using ESLint.\n\n**Important:** This plugin requires ESLint v9.15.0 or higher and you must be using the [new configuration system](https://eslint.org/docs/latest/use/configure/configuration-files).\n\n## Prerequisites\n\nIn order to use the ESLint CSS plugin, you must have the following installed:\n\n1. [Node.js](https://nodejs.org)\n1. [ESLint](https://eslint.org/docs/latest/use/getting-started)\n\n## Installation\n\nYou can install ESLint using npm or other package managers:\n\n```shell\nnpm install eslint -D\n# or\nyarn add eslint -D\n# or\npnpm install eslint -D\n# or\nbun add eslint -D\n```\n\nThen, for Node.js and compatible runtimes:\n\n```shell\nnpm install @eslint/css -D\n# or\nyarn add @eslint/css -D\n# or\npnpm install @eslint/css -D\n# or\nbun add @eslint/css -D\n```\n\nFor Deno (experimental):\n\n```shell\ndeno add jsr:@eslint/css\n```\n\n### Configurations\n\n| **Configuration Name** | **Description**                |\n| ---------------------- | ------------------------------ |\n| `recommended`          | Enables all recommended rules. |\n\nIn your `eslint.config.js` file, import `@eslint/css` and include the recommended config:\n\n```js\n// eslint.config.js\nimport { defineConfig } from \"eslint/config\";\nimport css from \"@eslint/css\";\n\nexport default defineConfig([\n\t// lint CSS files\n\t{\n\t\tfiles: [\"**/*.css\"],\n\t\tlanguage: \"css/css\",\n\t\tplugins: { css },\n\t\textends: [\"css/recommended\"],\n\t},\n\n\t// your other configs here\n]);\n```\n\n### Rules\n\n<!-- NOTE: The following table is autogenerated. Do not manually edit. -->\n\n<!-- Rule Table Start -->\n\n| **Rule Name**                                                                        | **Description**                                       | **Recommended** |\n| :----------------------------------------------------------------------------------- | :---------------------------------------------------- | :-------------: |\n| [`font-family-fallbacks`](./docs/rules/font-family-fallbacks.md)                     | Enforce use of fallback fonts and a generic font last |       yes       |\n| [`no-duplicate-imports`](./docs/rules/no-duplicate-imports.md)                       | Disallow duplicate @import rules                      |       yes       |\n| [`no-duplicate-keyframe-selectors`](./docs/rules/no-duplicate-keyframe-selectors.md) | Disallow duplicate selectors within keyframe blocks   |       yes       |\n| [`no-empty-blocks`](./docs/rules/no-empty-blocks.md)                                 | Disallow empty blocks                                 |       yes       |\n| [`no-important`](./docs/rules/no-important.md)                                       | Disallow !important flags                             |       yes       |\n| [`no-invalid-at-rule-placement`](./docs/rules/no-invalid-at-rule-placement.md)       | Disallow invalid placement of at-rules                |       yes       |\n| [`no-invalid-at-rules`](./docs/rules/no-invalid-at-rules.md)                         | Disallow invalid at-rules                             |       yes       |\n| [`no-invalid-named-grid-areas`](./docs/rules/no-invalid-named-grid-areas.md)         | Disallow invalid named grid areas                     |       yes       |\n| [`no-invalid-properties`](./docs/rules/no-invalid-properties.md)                     | Disallow invalid properties                           |       yes       |\n| [`no-unmatchable-selectors`](./docs/rules/no-unmatchable-selectors.md)               | Disallow unmatchable selectors                        |       yes       |\n| [`prefer-logical-properties`](./docs/rules/prefer-logical-properties.md)             | Enforce the use of logical properties                 |       no        |\n| [`relative-font-units`](./docs/rules/relative-font-units.md)                         | Enforce the use of relative font units                |       no        |\n| [`selector-complexity`](./docs/rules/selector-complexity.md)                         | Disallow and limit CSS selectors                      |       no        |\n| [`use-baseline`](./docs/rules/use-baseline.md)                                       | Enforce the use of baseline features                  |       yes       |\n| [`use-layers`](./docs/rules/use-layers.md)                                           | Require use of layers                                 |       no        |\n\n<!-- Rule Table End -->\n\n**Note:** This plugin does not provide formatting rules. We recommend using a source code formatter such as [Prettier](https://prettier.io) for that purpose.\n\nIn order to individually configure a rule in your `eslint.config.js` file, import `@eslint/css` and configure each rule with a prefix:\n\n```js\n// eslint.config.js\nimport { defineConfig } from \"eslint/config\";\nimport css from \"@eslint/css\";\n\nexport default defineConfig([\n\t{\n\t\tfiles: [\"**/*.css\"],\n\t\tplugins: {\n\t\t\tcss,\n\t\t},\n\t\tlanguage: \"css/css\",\n\t\trules: {\n\t\t\t\"css/no-empty-blocks\": \"error\",\n\t\t},\n\t},\n]);\n```\n\nYou can individually configure, disable, and enable rules in CSS using comments, such as:\n\n<!-- prettier-ignore -->\n```css\n/* eslint css/no-empty-blocks: error */\n\n/* eslint-disable css/no-empty-blocks -- this one is ok */\na {\n}\n/* eslint-enable css/no-empty-blocks */\n\nb { /* eslint-disable-line css/no-empty-blocks */\n}\n\n/* eslint-disable-next-line css/no-empty-blocks */\nem {\n}\n```\n\n### Languages\n\n| **Language Name** | **Description**        |\n| ----------------- | ---------------------- |\n| `css`             | Parse CSS stylesheets. |\n\nIn order to individually configure a language in your `eslint.config.js` file, import `@eslint/css` and configure a `language`:\n\n```js\n// eslint.config.js\nimport { defineConfig } from \"eslint/config\";\nimport css from \"@eslint/css\";\n\nexport default defineConfig([\n\t{\n\t\tfiles: [\"**/*.css\"],\n\t\tplugins: {\n\t\t\tcss,\n\t\t},\n\t\tlanguage: \"css/css\",\n\t\trules: {\n\t\t\t\"css/no-empty-blocks\": \"error\",\n\t\t},\n\t},\n]);\n```\n\n#### Tolerant Mode\n\nBy default, the CSS parser runs in strict mode, which reports all parsing errors. If you'd like to allow recoverable parsing errors (those that the browser automatically fixes on its own), you can set the `tolerant` option to `true`:\n\n```js\n// eslint.config.js\nimport { defineConfig } from \"eslint/config\";\nimport css from \"@eslint/css\";\n\nexport default defineConfig([\n\t{\n\t\tfiles: [\"**/*.css\"],\n\t\tplugins: {\n\t\t\tcss,\n\t\t},\n\t\tlanguage: \"css/css\",\n\t\tlanguageOptions: {\n\t\t\ttolerant: true,\n\t\t},\n\t\trules: {\n\t\t\t\"css/no-empty-blocks\": \"error\",\n\t\t},\n\t},\n]);\n```\n\nSetting `tolerant` to `true` is necessary if you are using custom syntax, such as [PostCSS](https://postcss.org/) plugins, that aren't part of the standard CSS syntax.\n\n#### Configuring Custom Syntax\n\nThe CSS lexer comes prebuilt with a set of known syntax for CSS that is used in rules like `no-invalid-properties` to validate CSS code. While this works for most cases, there may be cases when you want to define your own extensions to CSS, and this can be done using the `customSyntax` language option.\n\nThe `customSyntax` option accepts either an object or a function:\n\n**Object-based syntax**: An object that uses the [CSSTree format](https://github.com/csstree/csstree/blob/master/data/patch.json) for defining custom syntax, which allows you to specify at-rules, properties, and some types. For example, suppose you'd like to define a custom at-rule that looks like this:\n\n```css\n@my-at-rule \"hello world!\";\n```\n\nYou can configure that syntax as follows:\n\n```js\n// eslint.config.js\nimport { defineConfig } from \"eslint/config\";\nimport css from \"@eslint/css\";\n\nexport default defineConfig([\n\t{\n\t\tfiles: [\"**/*.css\"],\n\t\tplugins: {\n\t\t\tcss,\n\t\t},\n\t\tlanguage: \"css/css\",\n\t\tlanguageOptions: {\n\t\t\tcustomSyntax: {\n\t\t\t\tatrules: {\n\t\t\t\t\t\"my-at-rule\": {\n\t\t\t\t\t\tprelude: \"<string>\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\trules: {\n\t\t\t\"css/no-empty-blocks\": \"error\",\n\t\t},\n\t},\n]);\n```\n\n**Function-based syntax**: A function that receives the default CSS syntax data and returns a custom syntax configuration. This is useful when you want to extend the base syntax rather than replace it. For example:\n\n```js\n// eslint.config.js\nimport { defineConfig } from \"eslint/config\";\nimport css from \"@eslint/css\";\n\nexport default defineConfig([\n\t{\n\t\tfiles: [\"**/*.css\"],\n\t\tplugins: {\n\t\t\tcss,\n\t\t},\n\t\tlanguage: \"css/css\",\n\t\tlanguageOptions: {\n\t\t\tcustomSyntax: defaultSyntax => ({\n\t\t\t\t...defaultSyntax,\n\t\t\t\tproperties: {\n\t\t\t\t\t...defaultSyntax.properties,\n\t\t\t\t\t\"-webkit-custom\": \"<length>\",\n\t\t\t\t\t\"-moz-custom\": \"<color>\",\n\t\t\t\t},\n\t\t\t}),\n\t\t},\n\t\trules: {\n\t\t\t\"css/no-empty-blocks\": \"error\",\n\t\t},\n\t},\n]);\n```\n\n#### Configuring Tailwind Syntax\n\n[Tailwind](https://tailwindcss.com) specifies some extensions to CSS that will otherwise be flagged as invalid by the rules in this plugin. To properly parse Tailwind-specific syntax, install the [`tailwind-csstree`](https://npmjs.com/package/tailwind-csstree) package:\n\n```shell\nnpm i tailwind-csstree --save-dev\n```\n\nThen include it in your configuration using `languageOptions.customSyntax`:\n\n```js\n// eslint.config.js\nimport { defineConfig } from \"eslint/config\";\nimport css from \"@eslint/css\";\nimport { tailwind4 } from \"tailwind-csstree\";\n\nexport default defineConfig([\n\t{\n\t\tfiles: [\"**/*.css\"],\n\t\tplugins: {\n\t\t\tcss,\n\t\t},\n\t\tlanguage: \"css/css\",\n\t\tlanguageOptions: {\n\t\t\tcustomSyntax: tailwind4,\n\t\t},\n\t\trules: {\n\t\t\t\"css/no-empty-blocks\": \"error\",\n\t\t},\n\t},\n]);\n```\n\n## Editor and IDE Setup\n\n### Visual Studio Code\n\nFirst, ensure you have the [ESLint plugin](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) installed.\n\nThen, edit `eslint.validate` in your `settings.json` file to include `css`:\n\n```json\n{\n\t\"eslint.validate\": [\"css\"]\n}\n```\n\n### JetBrains WebStorm\n\nFor any [JetBrains WebStorm](https://www.jetbrains.com/webstorm/), configure the [ESLint scope](https://www.jetbrains.com/help/webstorm/eslint.html#ws_eslint_configure_scope) to include `css`, such as:\n\n```text\n**/*.{js,ts,jsx,tsx,cjs,cts,mjs,mts,html,vue,css}\n```\n\n## License\n\nApache 2.0\n\n<!-- NOTE: This section is autogenerated. Do not manually edit.-->\n<!--sponsorsstart-->\n\n## Sponsors\n\nThe following companies, organizations, and individuals support ESLint's ongoing maintenance and development. [Become a Sponsor](https://eslint.org/donate)\nto get your logo on our READMEs and [website](https://eslint.org/sponsors).\n\n<h3>Platinum Sponsors</h3>\n<p><a href=\"https://automattic.com\"><img src=\"https://images.opencollective.com/automattic/d0ef3e1/logo.png\" alt=\"Automattic\" height=\"128\"></a></p><h3>Gold Sponsors</h3>\n<p><a href=\"https://qlty.sh/\"><img src=\"https://images.opencollective.com/qltysh/33d157d/logo.png\" alt=\"Qlty Software\" height=\"96\"></a> <a href=\"https://shopify.engineering/\"><img src=\"https://avatars.githubusercontent.com/u/8085\" alt=\"Shopify\" height=\"96\"></a> <a href=\"https://www.coderabbit.ai/?utm_source=cr_org&utm_medium=github\"><img src=\"https://avatars.githubusercontent.com/u/132028505\" alt=\"CodeRabbit\" height=\"96\"></a></p><h3>Silver Sponsors</h3>\n<p><a href=\"https://vite.dev/\"><img src=\"https://images.opencollective.com/vite/d472863/logo.png\" alt=\"Vite\" height=\"64\"></a> <a href=\"https://liftoff.io/\"><img src=\"https://images.opencollective.com/liftoff/2d6c3b6/logo.png\" alt=\"Liftoff\" height=\"64\"></a> <a href=\"https://stackblitz.com\"><img src=\"https://avatars.githubusercontent.com/u/28635252\" alt=\"StackBlitz\" height=\"64\"></a></p><h3>Bronze Sponsors</h3>\n<p><a href=\"https://cybozu.co.jp/\"><img src=\"https://images.opencollective.com/cybozu/933e46d/logo.png\" alt=\"Cybozu\" height=\"32\"></a> <a href=\"https://opensource.sap.com\"><img src=\"https://avatars.githubusercontent.com/u/2531208\" alt=\"SAP\" height=\"32\"></a> <a href=\"https://icons8.com/\"><img src=\"https://images.opencollective.com/icons8/7fa1641/logo.png\" alt=\"Icons8\" height=\"32\"></a> <a href=\"https://discord.com\"><img src=\"https://images.opencollective.com/discordapp/f9645d9/logo.png\" alt=\"Discord\" height=\"32\"></a> <a href=\"https://www.gitbook.com\"><img src=\"https://avatars.githubusercontent.com/u/7111340\" alt=\"GitBook\" height=\"32\"></a> <a href=\"https://citadel-ai.com\"><img src=\"https://avatars.githubusercontent.com/u/75781367\" alt=\"Citadel AI\" height=\"32\"></a> <a href=\"https://www.testmuai.com\"><img src=\"https://avatars.githubusercontent.com/u/171592363\" alt=\"TestMu AI Open Source Office (Formerly LambdaTest)\" height=\"32\"></a></p>\n<h3>Technology Sponsors</h3>\nTechnology sponsors allow us to use their products and services for free as part of a contribution to the open source ecosystem and our work.\n<p><a href=\"https://netlify.com\"><img src=\"https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/netlify-icon.svg\" alt=\"Netlify\" height=\"32\"></a> <a href=\"https://algolia.com\"><img src=\"https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/algolia-icon.svg\" alt=\"Algolia\" height=\"32\"></a> <a href=\"https://1password.com\"><img src=\"https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/1password-icon.svg\" alt=\"1Password\" height=\"32\"></a></p>\n<!--sponsorsend-->\n","publish_time":1761748337461,"_cnpm_publish_time":1761748337461,"dist-tags":{"latest":"2.0.1"}}