Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/content/blog/2025-02-18-eslint-css-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,11 @@ export default [
];
```

If you're using [Tailwind](https://tailwindcss.com), you can configure most of the custom syntax using the builtin `tailwindSyntax` object, like this:
If you're using [Tailwind](https://tailwindcss.com), you can configure the custom syntax using [tailwind-csstree](https://www.npmjs.com/package/tailwind-csstree), like this:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
If you're using [Tailwind](https://tailwindcss.com), you can configure the custom syntax using [tailwind-csstree](https://www.npmjs.com/package/tailwind-csstree), like this:
If you're using [Tailwind](https://tailwindcss.com), you can configure the custom syntax using [`tailwind-csstree`](https://www.npmjs.com/package/tailwind-csstree), like this:

Non-blocking suggestion: I think it would be nice if the package name is wrapped in backticks, like in the README.md of @eslint/css :)

Ref: https://github.com/eslint/css?tab=readme-ov-file#configuring-tailwind-syntax

Image


```js
import css from "@eslint/css";
import { tailwindSyntax } from "@eslint/css/syntax";
import { tailwind4 } from "tailwind-csstree";

export default [
{
Expand All @@ -141,7 +141,7 @@ export default [
},
language: "css/css",
languageOptions: {
customSyntax: tailwindSyntax,
customSyntax: tailwind4,
},
rules: {
"css/no-empty-blocks": "error",
Expand All @@ -150,8 +150,6 @@ export default [
];
```

**Note:** The Tailwind syntax doesn't currently provide for the `theme()` function. This is a limitation of CSSTree that we hope will be resolved soon.

## Creating custom rules and using Code Explorer

As with `@eslint/json` and `@eslint/markdown`, `@eslint/css` allows the creation of custom rules. Using the [CSSTree AST format](https://github.com/csstree/csstree/blob/master/docs/ast.md), you can create your own rules in the same way you would for JavaScript. [Code Explorer](https://explorer.eslint.org) now supports CSS parsing and is a great resource to get started creating your own rules.
Expand Down