@eslint/css-tree 4.1.1 → 4.1.3

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
@@ -95,7 +95,7 @@ module.exports = {
95
95
  "absolute-size": "xx-small|x-small|small|medium|large|x-large|xx-large|xxx-large",
96
96
  "acos()": "acos( <calc-sum> )",
97
97
  "alpha-value": "<number>|<percentage>",
98
- "an+b": "odd|even|<integer>|<n-dimension>|'+'? † n|-n|<ndashdigit-dimension>|'+'? † <ndashdigit-ident>|<dashndashdigit-ident>|<n-dimension> <signed-integer>|'+'? † n <signed-integer>|-n <signed-integer>|<ndash-dimension> <signless-integer>|'+'? † n- <signless-integer>|-n- <signless-integer>|<n-dimension> ['+'|'-'] <signless-integer>|'+'? † n ['+'|'-'] <signless-integer>|-n ['+'|'-'] <signless-integer>",
98
+ "an+b": "odd|even|<integer>|<n-dimension>|'+'? n|-n|<ndashdigit-dimension>|'+'? <ndashdigit-ident>|<dashndashdigit-ident>|<n-dimension> <signed-integer>|'+'? n <signed-integer>|-n <signed-integer>|<ndash-dimension> <signless-integer>|'+'? n- <signless-integer>|-n- <signless-integer>|<n-dimension> ['+'|'-'] <signless-integer>|'+'? n ['+'|'-'] <signless-integer>|-n ['+'|'-'] <signless-integer>",
99
99
  "anchor()": "anchor( <anchor-name>?&&<anchor-side> , <length-percentage>? )",
100
100
  "anchor-name": "<dashed-ident>",
101
101
  "anchor-side": "inside|outside|top|left|right|bottom|start|end|self-start|self-end|<percentage>|center",
@@ -420,7 +420,7 @@ module.exports = {
420
420
  "step-position": "jump-start|jump-end|jump-none|jump-both|start|end",
421
421
  "step-easing-function": "step-start|step-end|<steps()>",
422
422
  "steps()": "steps( <integer> , <step-position>? )",
423
- "style-feature": "<declaration>",
423
+ "style-feature": "<declaration>|<custom-property-name>",
424
424
  "style-in-parens": "( <style-condition> )|( <style-feature> )|<general-enclosed>",
425
425
  "style-query": "<style-condition>|<style-feature>",
426
426
  "subclass-selector": "<id-selector>|<class-selector>|<attribute-selector>|<pseudo-class-selector>",
@@ -1104,6 +1104,7 @@ module.exports = {
1104
1104
  "rx": "<length-percentage>|auto",
1105
1105
  "ry": "<length-percentage>|auto",
1106
1106
  "scale": "none|[<number>|<percentage>]{1,3}",
1107
+ "scroll-axis-lock": "auto|none",
1107
1108
  "scroll-behavior": "auto|smooth",
1108
1109
  "scroll-initial-target": "none|nearest",
1109
1110
  "scroll-margin": "<length>{1,4}",
@@ -1239,6 +1240,7 @@ module.exports = {
1239
1240
  "widows": "<integer>",
1240
1241
  "width": "auto|<length-percentage [0,∞]>|min-content|max-content|fit-content|fit-content( <length-percentage [0,∞]> )|<calc-size()>|<anchor-size()>|stretch|<-non-standard-size>",
1241
1242
  "will-change": "auto|<animateable-feature>#",
1243
+ "window-drag": "none|move",
1242
1244
  "word-break": "normal|break-all|keep-all|break-word|auto-phrase",
1243
1245
  "word-spacing": "normal|<length>",
1244
1246
  "word-wrap": "normal|break-word",
@@ -1386,6 +1388,7 @@ module.exports = {
1386
1388
  "descriptors": {
1387
1389
  "bleed": "auto|<length>",
1388
1390
  "marks": "none|[crop||cross]",
1391
+ "page-margin-safety": "none|clamp|add",
1389
1392
  "page-orientation": "upright|rotate-left|rotate-right",
1390
1393
  "size": "<length [0,∞]>{1,2}|auto|[<page-size>||[portrait|landscape]]",
1391
1394
  "margin-top": "<'margin-top'>",
package/dist/data.js CHANGED
@@ -95,7 +95,7 @@ export default {
95
95
  "absolute-size": "xx-small|x-small|small|medium|large|x-large|xx-large|xxx-large",
96
96
  "acos()": "acos( <calc-sum> )",
97
97
  "alpha-value": "<number>|<percentage>",
98
- "an+b": "odd|even|<integer>|<n-dimension>|'+'? † n|-n|<ndashdigit-dimension>|'+'? † <ndashdigit-ident>|<dashndashdigit-ident>|<n-dimension> <signed-integer>|'+'? † n <signed-integer>|-n <signed-integer>|<ndash-dimension> <signless-integer>|'+'? † n- <signless-integer>|-n- <signless-integer>|<n-dimension> ['+'|'-'] <signless-integer>|'+'? † n ['+'|'-'] <signless-integer>|-n ['+'|'-'] <signless-integer>",
98
+ "an+b": "odd|even|<integer>|<n-dimension>|'+'? n|-n|<ndashdigit-dimension>|'+'? <ndashdigit-ident>|<dashndashdigit-ident>|<n-dimension> <signed-integer>|'+'? n <signed-integer>|-n <signed-integer>|<ndash-dimension> <signless-integer>|'+'? n- <signless-integer>|-n- <signless-integer>|<n-dimension> ['+'|'-'] <signless-integer>|'+'? n ['+'|'-'] <signless-integer>|-n ['+'|'-'] <signless-integer>",
99
99
  "anchor()": "anchor( <anchor-name>?&&<anchor-side> , <length-percentage>? )",
100
100
  "anchor-name": "<dashed-ident>",
101
101
  "anchor-side": "inside|outside|top|left|right|bottom|start|end|self-start|self-end|<percentage>|center",
@@ -420,7 +420,7 @@ export default {
420
420
  "step-position": "jump-start|jump-end|jump-none|jump-both|start|end",
421
421
  "step-easing-function": "step-start|step-end|<steps()>",
422
422
  "steps()": "steps( <integer> , <step-position>? )",
423
- "style-feature": "<declaration>",
423
+ "style-feature": "<declaration>|<custom-property-name>",
424
424
  "style-in-parens": "( <style-condition> )|( <style-feature> )|<general-enclosed>",
425
425
  "style-query": "<style-condition>|<style-feature>",
426
426
  "subclass-selector": "<id-selector>|<class-selector>|<attribute-selector>|<pseudo-class-selector>",
@@ -1104,6 +1104,7 @@ export default {
1104
1104
  "rx": "<length-percentage>|auto",
1105
1105
  "ry": "<length-percentage>|auto",
1106
1106
  "scale": "none|[<number>|<percentage>]{1,3}",
1107
+ "scroll-axis-lock": "auto|none",
1107
1108
  "scroll-behavior": "auto|smooth",
1108
1109
  "scroll-initial-target": "none|nearest",
1109
1110
  "scroll-margin": "<length>{1,4}",
@@ -1239,6 +1240,7 @@ export default {
1239
1240
  "widows": "<integer>",
1240
1241
  "width": "auto|<length-percentage [0,∞]>|min-content|max-content|fit-content|fit-content( <length-percentage [0,∞]> )|<calc-size()>|<anchor-size()>|stretch|<-non-standard-size>",
1241
1242
  "will-change": "auto|<animateable-feature>#",
1243
+ "window-drag": "none|move",
1242
1244
  "word-break": "normal|break-all|keep-all|break-word|auto-phrase",
1243
1245
  "word-spacing": "normal|<length>",
1244
1246
  "word-wrap": "normal|break-word",
@@ -1386,6 +1388,7 @@ export default {
1386
1388
  "descriptors": {
1387
1389
  "bleed": "auto|<length>",
1388
1390
  "marks": "none|[crop||cross]",
1391
+ "page-margin-safety": "none|clamp|add",
1389
1392
  "page-orientation": "upright|rotate-left|rotate-right",
1390
1393
  "size": "<length [0,∞]>{1,2}|auto|[<page-size>||[portrait|landscape]]",
1391
1394
  "margin-top": "<'margin-top'>",
package/dist/version.cjs CHANGED
@@ -1 +1 @@
1
- module.exports = "4.1.1";
1
+ module.exports = "4.1.3";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = "4.1.1";
1
+ export const version = "4.1.3";
@@ -5,6 +5,7 @@ import * as node from '../node/index-parse.js';
5
5
  import {
6
6
  Ident,
7
7
  String as StringToken,
8
+ Colon,
8
9
  tokenize
9
10
  } from '../../tokenizer/index.js';
10
11
 
@@ -63,6 +64,10 @@ export default {
63
64
  },
64
65
  container: {
65
66
  style() {
67
+ if (this.tokenType === Ident && this.lookupTypeNonSC(1) !== Colon) {
68
+ return this.Identifier();
69
+ }
70
+
66
71
  return this.Declaration();
67
72
  }
68
73
  }
@@ -6,12 +6,12 @@ import {
6
6
  Hash,
7
7
  Colon,
8
8
  Ident,
9
- Function,
10
9
  AtKeyword,
11
10
  LeftSquareBracket,
12
11
  LeftCurlyBracket,
13
12
  RightCurlyBracket
14
13
  } from '../../tokenizer/index.js';
14
+ import { isCustomProperty } from '../../utils/names.js';
15
15
 
16
16
  const AMPERSAND = 0x0026; // U+0026 AMPERSAND (&)
17
17
  const DOT = 0x002E; // U+002E FULL STOP (.)
@@ -64,43 +64,32 @@ function isElementSelectorStart() {
64
64
  return true;
65
65
  }
66
66
 
67
- // If next token is colon, we need to look further ahead to distinguish
68
- // between property declarations (p: value) and pseudo-class selectors (p:hover)
69
- if (nextTokenType === Colon) {
70
- // Look for the token after the colon (skipping whitespace)
71
- const tokenAfterColon = this.lookupTypeNonSC(2);
72
-
73
- // If it's an identifier (like 'hover', 'first-of-type') or function (like 'nth-child()', 'not()'),
74
- // this could be a pseudo-class
75
- if (tokenAfterColon === Ident || tokenAfterColon === Function) {
76
- // Look further ahead to see if there's a left curly bracket
77
- // which would indicate this is a selector with a block
78
- let offset = 3;
79
- let tokenType;
80
-
81
- // Skip whitespace and look for either a left curly bracket or other tokens
82
- while (offset <= 15) { // Increased limit to handle function pseudo-classes
83
- tokenType = this.lookupType(offset);
84
-
85
- if (tokenType === LeftCurlyBracket) {
86
- // Found opening brace, this is definitely a selector
87
- return true;
88
- } else if (tokenType === Semicolon || tokenType === RightCurlyBracket) {
89
- // Found semicolon or closing brace before opening brace, likely a property
90
- return false;
91
- } else if (tokenType === WhiteSpace || tokenType === Comment) {
92
- // Skip whitespace and comments
93
- offset++;
94
- continue;
95
- } else {
96
- // Other tokens might indicate more complex selectors, continue looking
97
- offset++;
98
- }
99
- }
67
+ // Custom property values may contain top-level curly blocks.
68
+ if (isCustomProperty(this.source, this.tokenStart)) {
69
+ return false;
70
+ }
71
+
72
+ // Only top-level delimiters distinguish declarations from nested rules.
73
+ for (let offset = 1; this.tokenIndex + offset < this.tokenCount; offset++) {
74
+ const tokenType = this.lookupType(offset);
75
+
76
+ if (tokenType === LeftCurlyBracket) {
77
+ return true;
100
78
  }
101
79
 
102
- // If we can't determine conclusively, default to property behavior
103
- return false;
80
+ if (tokenType === Semicolon || tokenType === RightCurlyBracket) {
81
+ return false;
82
+ }
83
+
84
+ if (this.isBlockOpenerTokenType(tokenType)) {
85
+ const pairIndex = this.getBlockTokenPairIndex(this.tokenIndex + offset);
86
+
87
+ if (pairIndex === -1) {
88
+ return false;
89
+ }
90
+
91
+ offset = pairIndex - this.tokenIndex;
92
+ }
104
93
  }
105
94
 
106
95
  return false;
@@ -6,6 +6,7 @@ import {
6
6
  RightParenthesis,
7
7
  Function as FunctionToken,
8
8
  Colon,
9
+ Delim,
9
10
  EOF
10
11
  } from '../../tokenizer/index.js';
11
12
 
@@ -24,8 +25,29 @@ export const structure = {
24
25
  };
25
26
 
26
27
  function featureOrRange(kind) {
27
- if (this.lookupTypeNonSC(1) === Ident &&
28
- likelyFeatureToken.has(this.lookupTypeNonSC(2))) {
28
+ const firstToken = this.lookupTypeNonSC(1);
29
+ let secondToken = this.lookupTypeNonSC(2);
30
+
31
+ if (firstToken === FunctionToken) {
32
+ let index = this.getBlockTokenPairIndex(this.tokenIndex + this.lookupOffsetNonSC(1));
33
+
34
+ if (index !== -1) {
35
+ do {
36
+ secondToken = this.getTokenType(++index);
37
+ } while (secondToken === WhiteSpace || secondToken === Comment);
38
+
39
+ if (secondToken !== Delim) {
40
+ return null;
41
+ }
42
+ }
43
+ }
44
+
45
+ if (firstToken === LeftParenthesis ||
46
+ (firstToken === Ident && (secondToken === LeftParenthesis || secondToken === FunctionToken))) {
47
+ return null;
48
+ }
49
+
50
+ if (firstToken === Ident && likelyFeatureToken.has(secondToken)) {
29
51
  return this.Feature(kind);
30
52
  }
31
53
 
@@ -125,4 +147,3 @@ export function generate(node) {
125
147
  }
126
148
  });
127
149
  }
128
-
@@ -1,3 +1,4 @@
1
+ import { Ident } from '../../tokenizer/index.js';
1
2
  import { parseLanguageRangeList } from './lang.js';
2
3
 
3
4
  const selectorList = {
@@ -24,6 +25,19 @@ const identList = {
24
25
  }
25
26
  };
26
27
 
28
+ const identSequence = {
29
+ parse() {
30
+ const children = this.createList();
31
+
32
+ do {
33
+ children.push(this.Identifier());
34
+ this.skipSC();
35
+ } while (this.tokenType === Ident);
36
+
37
+ return children;
38
+ }
39
+ };
40
+
27
41
  const langList = {
28
42
  parse: parseLanguageRangeList
29
43
  };
@@ -52,5 +66,6 @@ export default {
52
66
  'nth-of-type': nth,
53
67
  'slotted': selector,
54
68
  'host': selector,
55
- 'host-context': selector
69
+ 'host-context': selector,
70
+ 'part': identSequence
56
71
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint/css-tree",
3
- "version": "4.1.1",
3
+ "version": "4.1.3",
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",
@@ -106,8 +106,12 @@
106
106
  "prepublishOnly": "npm run lint-and-test && npm run build-and-test",
107
107
  "test:types": "tsc -p tests/types/tsconfig.json"
108
108
  },
109
+ "allowScripts": {
110
+ "esbuild": false,
111
+ "fsevents": false
112
+ },
109
113
  "dependencies": {
110
- "mdn-data": "2.35.0",
114
+ "mdn-data": "2.37.2",
111
115
  "source-map-js": "^1.2.1"
112
116
  },
113
117
  "devDependencies": {