Skip to content

Commit 828a6eb

Browse files
authored
feat: Switch to @eslint/css-tree (#83)
* feat: Switch to @eslint/css-tree * Fix tests * Remove typings references
1 parent a360046 commit 828a6eb

File tree

12 files changed

+33
-1154
lines changed

12 files changed

+33
-1154
lines changed

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,15 @@ export default [
5656

5757
<!-- Rule Table Start -->
5858

59-
| **Rule Name** | **Description** | **Recommended** |
60-
| :------------------------------------------------------------------------- | :------------------------------------ | :-------------: |
61-
| [`no-duplicate-imports`](./docs/rules/no-duplicate-imports.md) | Disallow duplicate @import rules | yes |
62-
| [`no-empty-blocks`](./docs/rules/no-empty-blocks.md) | Disallow empty blocks | yes |
63-
| [`no-invalid-at-rules`](./docs/rules/no-invalid-at-rules.md) | Disallow invalid at-rules | yes |
64-
| [`no-invalid-properties`](./docs/rules/no-invalid-properties.md) | Disallow invalid properties | yes |
65-
| [`prefer-logical-properties`](./docs//rules//prefer-logical-properties.md) | Enforce the use of logical properties | no |
66-
| [`require-baseline`](./docs/rules/require-baseline.md) | Enforce the use of baseline features | yes |
67-
| [`use-layers`](./docs/rules/use-layers.md) | Require use of layers | no |
59+
| **Rule Name** | **Description** | **Recommended** |
60+
| :----------------------------------------------------------------------- | :------------------------------------ | :-------------: |
61+
| [`no-duplicate-imports`](./docs/rules/no-duplicate-imports.md) | Disallow duplicate @import rules | yes |
62+
| [`no-empty-blocks`](./docs/rules/no-empty-blocks.md) | Disallow empty blocks | yes |
63+
| [`no-invalid-at-rules`](./docs/rules/no-invalid-at-rules.md) | Disallow invalid at-rules | yes |
64+
| [`no-invalid-properties`](./docs/rules/no-invalid-properties.md) | Disallow invalid properties | yes |
65+
| [`prefer-logical-properties`](./docs/rules/prefer-logical-properties.md) | Enforce the use of logical properties | no |
66+
| [`require-baseline`](./docs/rules/require-baseline.md) | Enforce the use of baseline features | yes |
67+
| [`use-layers`](./docs/rules/use-layers.md) | Require use of layers | no |
6868

6969
<!-- Rule Table End -->
7070

jsr.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313
"dist/esm/syntax/index.d.ts",
1414
"README.md",
1515
"jsr.json",
16-
"LICENSE",
17-
"typings/css-tree/index.d.ts",
18-
"typings/css-tree/LICENSE"
16+
"LICENSE"
1917
]
2018
}
2119
}

package.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@
2929
}
3030
},
3131
"files": [
32-
"dist",
33-
"typings"
32+
"dist"
3433
],
3534
"publishConfig": {
3635
"access": "public"
@@ -87,9 +86,8 @@
8786
"license": "Apache-2.0",
8887
"dependencies": {
8988
"@eslint/core": "^0.10.0",
90-
"@eslint/plugin-kit": "^0.2.5",
91-
"@types/css-tree": "file:./typings/css-tree",
92-
"css-tree": "^3.1.0"
89+
"@eslint/css-tree": "^3.2.0",
90+
"@eslint/plugin-kit": "^0.2.5"
9391
},
9492
"devDependencies": {
9593
"@eslint/json": "^0.5.0",

src/languages/css-language.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,20 @@ import {
1212
lexer as originalLexer,
1313
fork,
1414
toPlainObject,
15-
} from "css-tree";
15+
} from "@eslint/css-tree";
1616
import { CSSSourceCode } from "./css-source-code.js";
1717
import { visitorKeys } from "./css-visitor-keys.js";
1818

1919
//-----------------------------------------------------------------------------
2020
// Types
2121
//-----------------------------------------------------------------------------
2222

23-
/** @typedef {import("css-tree").CssNode} CssNode */
24-
/** @typedef {import("css-tree").CssNodePlain} CssNodePlain */
25-
/** @typedef {import("css-tree").StyleSheet} StyleSheet */
26-
/** @typedef {import("css-tree").Comment} Comment */
27-
/** @typedef {import("css-tree").Lexer} Lexer */
28-
/** @typedef {import("css-tree").SyntaxConfig} SyntaxConfig */
23+
/** @typedef {import("@eslint/css-tree").CssNode} CssNode */
24+
/** @typedef {import("@eslint/css-tree").CssNodePlain} CssNodePlain */
25+
/** @typedef {import("@eslint/css-tree").StyleSheet} StyleSheet */
26+
/** @typedef {import("@eslint/css-tree").Comment} Comment */
27+
/** @typedef {import("@eslint/css-tree").Lexer} Lexer */
28+
/** @typedef {import("@eslint/css-tree").SyntaxConfig} SyntaxConfig */
2929
/** @typedef {import("@eslint/core").Language} Language */
3030
/** @typedef {import("@eslint/core").OkParseResult<CssNodePlain> & { comments: Comment[], lexer: Lexer }} OkParseResult */
3131
/** @typedef {import("@eslint/core").ParseResult<CssNodePlain>} ParseResult */

src/languages/css-source-code.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ import { visitorKeys } from "./css-visitor-keys.js";
1919
// Types
2020
//-----------------------------------------------------------------------------
2121

22-
/** @typedef {import("css-tree").CssNode} CssNode */
23-
/** @typedef {import("css-tree").CssNodePlain} CssNodePlain */
24-
/** @typedef {import("css-tree").BlockPlain} BlockPlain */
25-
/** @typedef {import("css-tree").Comment} Comment */
26-
/** @typedef {import("css-tree").Lexer} Lexer */
22+
/** @typedef {import("@eslint/css-tree").CssNode} CssNode */
23+
/** @typedef {import("@eslint/css-tree").CssNodePlain} CssNodePlain */
24+
/** @typedef {import("@eslint/css-tree").BlockPlain} BlockPlain */
25+
/** @typedef {import("@eslint/css-tree").Comment} Comment */
26+
/** @typedef {import("@eslint/css-tree").Lexer} Lexer */
2727
/** @typedef {import("@eslint/core").SourceRange} SourceRange */
2828
/** @typedef {import("@eslint/core").SourceLocation} SourceLocation */
2929
/** @typedef {import("@eslint/core").SourceLocationWithOffset} SourceLocationWithOffset */

src/rules/require-baseline.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ import { namedColors } from "../data/colors.js";
2323
// Type Definitions
2424
//-----------------------------------------------------------------------------
2525

26-
/** @typedef {import("css-tree").AtrulePlain} AtrulePlain */
27-
/** @typedef {import("css-tree").Identifier} Identifier */
28-
/** @typedef {import("css-tree").FunctionNodePlain} FunctionNodePlain */
26+
/** @typedef {import("@eslint/css-tree").AtrulePlain} AtrulePlain */
27+
/** @typedef {import("@eslint/css-tree").Identifier} Identifier */
28+
/** @typedef {import("@eslint/css-tree").FunctionNodePlain} FunctionNodePlain */
2929

3030
//-----------------------------------------------------------------------------
3131
// Helpers
@@ -432,7 +432,7 @@ export default {
432432

433433
/**
434434
* Checks a property value function to see if it's a baseline feature.
435-
* @param {import("css-tree").FunctionNodePlain} child The node to check.
435+
* @param {import("@eslint/css-tree").FunctionNodePlain} child The node to check.
436436
* @returns {void}
437437
**/
438438
function checkPropertyValueFunction(child) {

src/util.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// Type Definitions
88
//-----------------------------------------------------------------------------
99

10-
/** @typedef {import("css-tree").SyntaxMatchError} SyntaxMatchError */
10+
/** @typedef {import("@eslint/css-tree").SyntaxMatchError} SyntaxMatchError */
1111

1212
//-----------------------------------------------------------------------------
1313
// Helpers

tests/languages/css-source-code.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import { CSSSourceCode } from "../../src/languages/css-source-code.js";
1111
import { CSSLanguage } from "../../src/languages/css-language.js";
12-
import { parse, toPlainObject } from "css-tree";
12+
import { parse, toPlainObject } from "@eslint/css-tree";
1313
import assert from "node:assert";
1414
import dedent from "dedent";
1515

tests/rules/no-invalid-properties.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ ruleTester.run("no-invalid-properties", rule, {
8888
property: "width",
8989
value: "red",
9090
expected:
91-
"auto | <length> | <percentage> | min-content | max-content | fit-content | fit-content( <length-percentage> ) | stretch | <-non-standard-size>",
91+
"auto | <length-percentage [0,∞]> | min-content | max-content | fit-content | fit-content( <length-percentage [0,∞]> ) | <calc-size()> | <anchor-size()> | stretch | <-non-standard-size>",
9292
},
9393
line: 1,
9494
column: 12,
@@ -105,7 +105,7 @@ ruleTester.run("no-invalid-properties", rule, {
105105
data: {
106106
property: "margin",
107107
value: "10px 20px 30px 40px 50px",
108-
expected: "[ <length> | <percentage> | auto ]{1,4}",
108+
expected: "<'margin-top'>{1,4}",
109109
},
110110
line: 1,
111111
column: 33,

typings/css-tree/LICENSE

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)