@eslint/css-tree 4.0.4 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/data.cjs CHANGED
@@ -5,7 +5,8 @@ module.exports = {
5
5
  "inherit",
6
6
  "unset",
7
7
  "revert",
8
- "revert-layer"
8
+ "revert-layer",
9
+ "revert-rule"
9
10
  ],
10
11
  "units": {
11
12
  "angle": [
@@ -119,7 +120,7 @@ module.exports = {
119
120
  "auto-track-list": "[<line-names>? [<fixed-size>|<fixed-repeat>]]* <line-names>? <auto-repeat> [<line-names>? [<fixed-size>|<fixed-repeat>]]* <line-names>?",
120
121
  "axis": "block|inline|x|y",
121
122
  "baseline-position": "[first|last]? baseline",
122
- "basic-shape": "<inset()>|<xywh()>|<rect()>|<circle()>|<ellipse()>|<polygon()>|<path()>",
123
+ "basic-shape": "<inset()>|<xywh()>|<rect()>|<circle()>|<ellipse()>|<polygon()>|<path()>|shape( )",
123
124
  "basic-shape-rect": "<inset()>|<rect()>|<xywh()>",
124
125
  "bg-clip": "<visual-box>|border-area|text",
125
126
  "bg-image": "<image>|none",
@@ -504,6 +505,7 @@ module.exports = {
504
505
  "device-cmyk()": "<legacy-device-cmyk-syntax>|<modern-device-cmyk-syntax>",
505
506
  "legacy-device-cmyk-syntax": "device-cmyk( <number>#{4} )",
506
507
  "modern-device-cmyk-syntax": "device-cmyk( <cmyk-component>{4} [/ [<alpha-value>|none]]? )",
508
+ "param()": "param( <dashed-ident> , <declaration-value>? )",
507
509
  "cmyk-component": "<number>|<percentage>|none",
508
510
  "color-space": "<rectangular-color-space>|<polar-color-space>|<custom-color-space>",
509
511
  "right": "<length>|auto",
@@ -771,6 +773,7 @@ module.exports = {
771
773
  "border-right-color": "<color>",
772
774
  "border-right-style": "<line-style>",
773
775
  "border-right-width": "<line-width>",
776
+ "border-shape": "none|[<basic-shape> <geometry-box>?]{1,2}",
774
777
  "border-spacing": "<length>{1,2}",
775
778
  "border-start-end-radius": "<'border-top-left-radius'>",
776
779
  "border-start-start-radius": "<'border-top-left-radius'>",
@@ -871,8 +874,9 @@ module.exports = {
871
874
  "flex-direction": "row|row-reverse|column|column-reverse",
872
875
  "flex-flow": "<'flex-direction'>||<'flex-wrap'>",
873
876
  "flex-grow": "<number>",
877
+ "flex-line-count": "<integer [1,∞]>",
874
878
  "flex-shrink": "<number>",
875
- "flex-wrap": "nowrap|wrap|wrap-reverse",
879
+ "flex-wrap": "nowrap|[wrap|wrap-reverse]||balance",
876
880
  "float": "left|right|none|inline-start|inline-end",
877
881
  "flood-color": "<color>",
878
882
  "flood-opacity": "<'opacity'>",
@@ -905,6 +909,7 @@ module.exports = {
905
909
  "font-weight": "<font-weight-absolute>|bolder|lighter",
906
910
  "font-width": "normal|<percentage [0,∞]>|ultra-condensed|extra-condensed|condensed|semi-condensed|semi-expanded|expanded|extra-expanded|ultra-expanded",
907
911
  "forced-color-adjust": "auto|none|preserve-parent-color",
912
+ "frame-sizing": "auto|content-width|content-height|content-block-size|content-inline-size",
908
913
  "gap": "<'row-gap'> <'column-gap'>?",
909
914
  "grid": "<'grid-template'>|<'grid-template-rows'> / [auto-flow&&dense?] <'grid-auto-columns'>?|[auto-flow&&dense?] <'grid-auto-rows'>? / <'grid-template-columns'>",
910
915
  "grid-area": "<grid-line> [/ <grid-line>]{0,3}",
@@ -960,6 +965,7 @@ module.exports = {
960
965
  "line-clamp": "none|<integer>",
961
966
  "line-height": "normal|<number>|<length>|<percentage>",
962
967
  "line-height-step": "<length>",
968
+ "link-parameters": "none|<param()>#",
963
969
  "list-style": "<'list-style-type'>||<'list-style-position'>||<'list-style-image'>",
964
970
  "list-style-image": "<image>|none",
965
971
  "list-style-position": "inside|outside",
@@ -1059,6 +1065,7 @@ module.exports = {
1059
1065
  "page-break-before": "auto|always|avoid|left|right|recto|verso",
1060
1066
  "page-break-inside": "auto|avoid",
1061
1067
  "paint-order": "normal|[fill||stroke||markers]",
1068
+ "path-length": "none|<length> [0 , ∞]",
1062
1069
  "perspective": "none|<length>",
1063
1070
  "perspective-origin": "<position>",
1064
1071
  "place-content": "<'align-content'> <'justify-content'>?",
@@ -1157,7 +1164,7 @@ module.exports = {
1157
1164
  "text-combine-upright": "none|all|[digits <integer>?]",
1158
1165
  "text-decoration": "<'text-decoration-line'>||<'text-decoration-style'>||<'text-decoration-color'>||<'text-decoration-thickness'>",
1159
1166
  "text-decoration-color": "<color>",
1160
- "text-decoration-inset": "<length>{1,2}|auto",
1167
+ "text-decoration-inset": "<length-percentage>{1,2}|auto",
1161
1168
  "text-decoration-line": "none|[underline||overline||line-through||blink]|spelling-error|grammar-error",
1162
1169
  "text-decoration-skip": "none|[objects||[spaces|[leading-spaces||trailing-spaces]]||edges||box-decoration]",
1163
1170
  "text-decoration-skip-ink": "auto|all|none",
@@ -1167,6 +1174,7 @@ module.exports = {
1167
1174
  "text-emphasis-color": "<color>",
1168
1175
  "text-emphasis-position": "auto|[over|under]&&[right|left]?",
1169
1176
  "text-emphasis-style": "none|[[filled|open]||[dot|circle|double-circle|triangle|sesame]]|<string>",
1177
+ "text-fit": "[none|grow|shrink] [consistent|per-line|per-line-all]? <percentage>?",
1170
1178
  "text-indent": "<length-percentage>&&hanging?&&each-line?",
1171
1179
  "text-justify": "auto|inter-character|inter-word|none",
1172
1180
  "text-orientation": "mixed|upright|sideways",
@@ -1215,6 +1223,7 @@ module.exports = {
1215
1223
  "view-timeline-name": "[none|<dashed-ident>]#",
1216
1224
  "view-transition-class": "none|<custom-ident>+",
1217
1225
  "view-transition-name": "none|<custom-ident>|match-element",
1226
+ "view-transition-scope": "none|all",
1218
1227
  "visibility": "visible|hidden|collapse",
1219
1228
  "white-space": "normal|pre|pre-wrap|pre-line|<'white-space-collapse'>||<'text-wrap-mode'>",
1220
1229
  "white-space-collapse": "collapse|preserve|preserve-breaks|preserve-spaces|break-spaces",
@@ -1331,7 +1340,9 @@ module.exports = {
1331
1340
  },
1332
1341
  "font-feature-values": {
1333
1342
  "prelude": "<family-name>#",
1334
- "descriptors": null
1343
+ "descriptors": {
1344
+ "font-display": "auto|block|swap|fallback|optional"
1345
+ }
1335
1346
  },
1336
1347
  "font-palette-values": {
1337
1348
  "prelude": "<dashed-ident>",
@@ -1367,7 +1378,12 @@ module.exports = {
1367
1378
  "bleed": "auto|<length>",
1368
1379
  "marks": "none|[crop||cross]",
1369
1380
  "page-orientation": "upright|rotate-left|rotate-right",
1370
- "size": "<length [0,∞]>{1,2}|auto|[<page-size>||[portrait|landscape]]"
1381
+ "size": "<length [0,∞]>{1,2}|auto|[<page-size>||[portrait|landscape]]",
1382
+ "margin-top": "<'margin-top'>",
1383
+ "margin-right": "<'margin-right'>",
1384
+ "margin-bottom": "<'margin-bottom'>",
1385
+ "margin-left": "<'margin-left'>",
1386
+ "margin": "<'margin'>"
1371
1387
  }
1372
1388
  },
1373
1389
  "position-try": {
@@ -1437,12 +1453,6 @@ module.exports = {
1437
1453
  "navigation": "auto|none",
1438
1454
  "types": "none|<custom-ident>+"
1439
1455
  }
1440
- },
1441
- "font-features-values": {
1442
- "prelude": "[<string>|<custom-ident>]+",
1443
- "descriptors": {
1444
- "font-display": "auto|block|swap|fallback|optional"
1445
- }
1446
1456
  }
1447
1457
  }
1448
1458
  };
package/dist/data.js CHANGED
@@ -5,7 +5,8 @@ export default {
5
5
  "inherit",
6
6
  "unset",
7
7
  "revert",
8
- "revert-layer"
8
+ "revert-layer",
9
+ "revert-rule"
9
10
  ],
10
11
  "units": {
11
12
  "angle": [
@@ -119,7 +120,7 @@ export default {
119
120
  "auto-track-list": "[<line-names>? [<fixed-size>|<fixed-repeat>]]* <line-names>? <auto-repeat> [<line-names>? [<fixed-size>|<fixed-repeat>]]* <line-names>?",
120
121
  "axis": "block|inline|x|y",
121
122
  "baseline-position": "[first|last]? baseline",
122
- "basic-shape": "<inset()>|<xywh()>|<rect()>|<circle()>|<ellipse()>|<polygon()>|<path()>",
123
+ "basic-shape": "<inset()>|<xywh()>|<rect()>|<circle()>|<ellipse()>|<polygon()>|<path()>|shape( )",
123
124
  "basic-shape-rect": "<inset()>|<rect()>|<xywh()>",
124
125
  "bg-clip": "<visual-box>|border-area|text",
125
126
  "bg-image": "<image>|none",
@@ -504,6 +505,7 @@ export default {
504
505
  "device-cmyk()": "<legacy-device-cmyk-syntax>|<modern-device-cmyk-syntax>",
505
506
  "legacy-device-cmyk-syntax": "device-cmyk( <number>#{4} )",
506
507
  "modern-device-cmyk-syntax": "device-cmyk( <cmyk-component>{4} [/ [<alpha-value>|none]]? )",
508
+ "param()": "param( <dashed-ident> , <declaration-value>? )",
507
509
  "cmyk-component": "<number>|<percentage>|none",
508
510
  "color-space": "<rectangular-color-space>|<polar-color-space>|<custom-color-space>",
509
511
  "right": "<length>|auto",
@@ -771,6 +773,7 @@ export default {
771
773
  "border-right-color": "<color>",
772
774
  "border-right-style": "<line-style>",
773
775
  "border-right-width": "<line-width>",
776
+ "border-shape": "none|[<basic-shape> <geometry-box>?]{1,2}",
774
777
  "border-spacing": "<length>{1,2}",
775
778
  "border-start-end-radius": "<'border-top-left-radius'>",
776
779
  "border-start-start-radius": "<'border-top-left-radius'>",
@@ -871,8 +874,9 @@ export default {
871
874
  "flex-direction": "row|row-reverse|column|column-reverse",
872
875
  "flex-flow": "<'flex-direction'>||<'flex-wrap'>",
873
876
  "flex-grow": "<number>",
877
+ "flex-line-count": "<integer [1,∞]>",
874
878
  "flex-shrink": "<number>",
875
- "flex-wrap": "nowrap|wrap|wrap-reverse",
879
+ "flex-wrap": "nowrap|[wrap|wrap-reverse]||balance",
876
880
  "float": "left|right|none|inline-start|inline-end",
877
881
  "flood-color": "<color>",
878
882
  "flood-opacity": "<'opacity'>",
@@ -905,6 +909,7 @@ export default {
905
909
  "font-weight": "<font-weight-absolute>|bolder|lighter",
906
910
  "font-width": "normal|<percentage [0,∞]>|ultra-condensed|extra-condensed|condensed|semi-condensed|semi-expanded|expanded|extra-expanded|ultra-expanded",
907
911
  "forced-color-adjust": "auto|none|preserve-parent-color",
912
+ "frame-sizing": "auto|content-width|content-height|content-block-size|content-inline-size",
908
913
  "gap": "<'row-gap'> <'column-gap'>?",
909
914
  "grid": "<'grid-template'>|<'grid-template-rows'> / [auto-flow&&dense?] <'grid-auto-columns'>?|[auto-flow&&dense?] <'grid-auto-rows'>? / <'grid-template-columns'>",
910
915
  "grid-area": "<grid-line> [/ <grid-line>]{0,3}",
@@ -960,6 +965,7 @@ export default {
960
965
  "line-clamp": "none|<integer>",
961
966
  "line-height": "normal|<number>|<length>|<percentage>",
962
967
  "line-height-step": "<length>",
968
+ "link-parameters": "none|<param()>#",
963
969
  "list-style": "<'list-style-type'>||<'list-style-position'>||<'list-style-image'>",
964
970
  "list-style-image": "<image>|none",
965
971
  "list-style-position": "inside|outside",
@@ -1059,6 +1065,7 @@ export default {
1059
1065
  "page-break-before": "auto|always|avoid|left|right|recto|verso",
1060
1066
  "page-break-inside": "auto|avoid",
1061
1067
  "paint-order": "normal|[fill||stroke||markers]",
1068
+ "path-length": "none|<length> [0 , ∞]",
1062
1069
  "perspective": "none|<length>",
1063
1070
  "perspective-origin": "<position>",
1064
1071
  "place-content": "<'align-content'> <'justify-content'>?",
@@ -1157,7 +1164,7 @@ export default {
1157
1164
  "text-combine-upright": "none|all|[digits <integer>?]",
1158
1165
  "text-decoration": "<'text-decoration-line'>||<'text-decoration-style'>||<'text-decoration-color'>||<'text-decoration-thickness'>",
1159
1166
  "text-decoration-color": "<color>",
1160
- "text-decoration-inset": "<length>{1,2}|auto",
1167
+ "text-decoration-inset": "<length-percentage>{1,2}|auto",
1161
1168
  "text-decoration-line": "none|[underline||overline||line-through||blink]|spelling-error|grammar-error",
1162
1169
  "text-decoration-skip": "none|[objects||[spaces|[leading-spaces||trailing-spaces]]||edges||box-decoration]",
1163
1170
  "text-decoration-skip-ink": "auto|all|none",
@@ -1167,6 +1174,7 @@ export default {
1167
1174
  "text-emphasis-color": "<color>",
1168
1175
  "text-emphasis-position": "auto|[over|under]&&[right|left]?",
1169
1176
  "text-emphasis-style": "none|[[filled|open]||[dot|circle|double-circle|triangle|sesame]]|<string>",
1177
+ "text-fit": "[none|grow|shrink] [consistent|per-line|per-line-all]? <percentage>?",
1170
1178
  "text-indent": "<length-percentage>&&hanging?&&each-line?",
1171
1179
  "text-justify": "auto|inter-character|inter-word|none",
1172
1180
  "text-orientation": "mixed|upright|sideways",
@@ -1215,6 +1223,7 @@ export default {
1215
1223
  "view-timeline-name": "[none|<dashed-ident>]#",
1216
1224
  "view-transition-class": "none|<custom-ident>+",
1217
1225
  "view-transition-name": "none|<custom-ident>|match-element",
1226
+ "view-transition-scope": "none|all",
1218
1227
  "visibility": "visible|hidden|collapse",
1219
1228
  "white-space": "normal|pre|pre-wrap|pre-line|<'white-space-collapse'>||<'text-wrap-mode'>",
1220
1229
  "white-space-collapse": "collapse|preserve|preserve-breaks|preserve-spaces|break-spaces",
@@ -1331,7 +1340,9 @@ export default {
1331
1340
  },
1332
1341
  "font-feature-values": {
1333
1342
  "prelude": "<family-name>#",
1334
- "descriptors": null
1343
+ "descriptors": {
1344
+ "font-display": "auto|block|swap|fallback|optional"
1345
+ }
1335
1346
  },
1336
1347
  "font-palette-values": {
1337
1348
  "prelude": "<dashed-ident>",
@@ -1367,7 +1378,12 @@ export default {
1367
1378
  "bleed": "auto|<length>",
1368
1379
  "marks": "none|[crop||cross]",
1369
1380
  "page-orientation": "upright|rotate-left|rotate-right",
1370
- "size": "<length [0,∞]>{1,2}|auto|[<page-size>||[portrait|landscape]]"
1381
+ "size": "<length [0,∞]>{1,2}|auto|[<page-size>||[portrait|landscape]]",
1382
+ "margin-top": "<'margin-top'>",
1383
+ "margin-right": "<'margin-right'>",
1384
+ "margin-bottom": "<'margin-bottom'>",
1385
+ "margin-left": "<'margin-left'>",
1386
+ "margin": "<'margin'>"
1371
1387
  }
1372
1388
  },
1373
1389
  "position-try": {
@@ -1437,12 +1453,6 @@ export default {
1437
1453
  "navigation": "auto|none",
1438
1454
  "types": "none|<custom-ident>+"
1439
1455
  }
1440
- },
1441
- "font-features-values": {
1442
- "prelude": "[<string>|<custom-ident>]+",
1443
- "descriptors": {
1444
- "font-display": "auto|block|swap|fallback|optional"
1445
- }
1446
1456
  }
1447
1457
  }
1448
1458
  };
package/dist/version.cjs CHANGED
@@ -1 +1 @@
1
- module.exports = "4.0.4";
1
+ module.exports = "4.1.0";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = "4.0.4";
1
+ export const version = "4.1.0";
package/lib/index.d.ts CHANGED
@@ -2381,6 +2381,20 @@ export class SyntaxReferenceError extends SyntaxError {
2381
2381
  reference: string;
2382
2382
  }
2383
2383
 
2384
+ /**
2385
+ * Represents an error that occurs when a value cannot be matched because it
2386
+ * contains a function whose result is unknown at match time, such as `var()`
2387
+ * or `env()`. Extends the standard `SyntaxError`.
2388
+ */
2389
+ export class UnsupportedMatchingTree extends SyntaxError {
2390
+ name: "UnsupportedMatchingTree";
2391
+
2392
+ /**
2393
+ * A stable code identifying which unsupported function prevented matching.
2394
+ */
2395
+ code: "ERR_LEXER_VAR_MATCH_UNSUPPORTED" | "ERR_LEXER_ENV_MATCH_UNSUPPORTED";
2396
+ }
2397
+
2384
2398
  /**
2385
2399
  * Represents the result of a lexer match operation.
2386
2400
  */
@@ -2398,7 +2412,7 @@ export interface LexerMatchResult {
2398
2412
  /**
2399
2413
  * An error object if a matching error occurred, or `null` if no error.
2400
2414
  */
2401
- error: Error | SyntaxMatchError | SyntaxReferenceError | null;
2415
+ error: Error | SyntaxMatchError | SyntaxReferenceError | UnsupportedMatchingTree | null;
2402
2416
 
2403
2417
  /**
2404
2418
  * Retrieves the trace of matching operations for a specific node.
@@ -1,4 +1,4 @@
1
- import { SyntaxReferenceError, SyntaxMatchError } from './error.js';
1
+ import { SyntaxReferenceError, SyntaxMatchError, UnsupportedMatchingTree } from './error.js';
2
2
  import * as names from '../utils/names.js';
3
3
  import { cssWideKeywords } from './generic-const.js';
4
4
  import { createGenericTypes } from './generic.js';
@@ -87,11 +87,11 @@ function matchSyntax(lexer, syntax, value, useCssWideKeywords) {
87
87
  let result;
88
88
 
89
89
  if (valueHasVar(tokens)) {
90
- return buildMatchResult(null, new Error('Matching for a tree with var() is not supported'));
90
+ return buildMatchResult(null, new UnsupportedMatchingTree('var'));
91
91
  }
92
92
 
93
93
  if (valueHasEnv(tokens)) {
94
- return buildMatchResult(null, new Error('Matching for a tree with env() is not supported'));
94
+ return buildMatchResult(null, new UnsupportedMatchingTree('env'));
95
95
  }
96
96
 
97
97
  if (useCssWideKeywords) {
@@ -92,6 +92,17 @@ export const SyntaxReferenceError = function(type, referenceName) {
92
92
  return error;
93
93
  };
94
94
 
95
+ export const UnsupportedMatchingTree = function(fnName) {
96
+ const error = createCustomError(
97
+ 'UnsupportedMatchingTree',
98
+ `Matching for a tree with ${fnName}() is not supported`
99
+ );
100
+
101
+ error.code = `ERR_LEXER_${fnName.toUpperCase()}_MATCH_UNSUPPORTED`;
102
+
103
+ return error;
104
+ };
105
+
95
106
  export const SyntaxMatchError = function(message, syntax, node, matchResult) {
96
107
  const error = createCustomError('SyntaxMatchError', message);
97
108
  const {
@@ -4,5 +4,6 @@ export const cssWideKeywords = [
4
4
  'inherit',
5
5
  'unset',
6
6
  'revert',
7
- 'revert-layer'
7
+ 'revert-layer',
8
+ 'revert-rule'
8
9
  ];
@@ -157,9 +157,10 @@ function getImportant() {
157
157
  this.eat(Delim);
158
158
  this.skipSC();
159
159
 
160
+ const isImportant = this.cmpStr(this.tokenStart, this.tokenEnd, 'important');
160
161
  const important = this.consume(Ident);
161
162
 
162
- // store original value in case it differ from `important`
163
- // for better original source restoring and hacks like `!ie` support
164
- return important === 'important' ? true : important;
163
+ // Store non-standard values for better original source restoring and hacks
164
+ // like `!ie` support.
165
+ return isImportant ? true : important;
165
166
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint/css-tree",
3
- "version": "4.0.4",
3
+ "version": "4.1.0",
4
4
  "description": "A tool set for CSS: fast detailed parser (CSS → AST), walker (AST traversal), generator (AST → CSS) and lexer (validation and matching) based on specs and browser implementations",
5
5
  "author": "Roman Dvornov <rdvornov@gmail.com> (https://github.com/lahmatiy)",
6
6
  "license": "MIT",
@@ -107,7 +107,7 @@
107
107
  "test:types": "tsc -p tests/types/tsconfig.json"
108
108
  },
109
109
  "dependencies": {
110
- "mdn-data": "2.28.1",
110
+ "mdn-data": "2.34.0",
111
111
  "source-map-js": "^1.2.1"
112
112
  },
113
113
  "devDependencies": {
@@ -116,7 +116,7 @@
116
116
  "esbuild": "^0.27.3",
117
117
  "eslint": "^8.50.0",
118
118
  "json-to-ast": "^2.1.0",
119
- "mocha": "^9.2.2",
119
+ "mocha": "^11.7.6",
120
120
  "rollup": "^2.80.0",
121
121
  "typescript": "^5.7.3"
122
122
  },