@eslint/css-tree 4.0.5 → 4.1.1

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/README.md CHANGED
@@ -204,7 +204,7 @@ to get your logo on our READMEs and [website](https://eslint.org/sponsors).
204
204
  <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>
205
205
  <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>
206
206
  <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>
207
- <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://syntax.fm"><img src="https://github.com/syntaxfm.png" alt="Syntax" 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></p>
207
+ <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://syntax.fm"><img src="https://github.com/syntaxfm.png" alt="Syntax" 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>
208
208
  <h3>Technology Sponsors</h3>
209
209
  Technology sponsors allow us to use their products and services for free as part of a contribution to the open source ecosystem and our work.
210
210
  <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>
@@ -91,11 +91,11 @@ function matchSyntax(lexer, syntax, value, useCssWideKeywords) {
91
91
  let result;
92
92
 
93
93
  if (valueHasVar(tokens)) {
94
- return buildMatchResult(null, new Error('Matching for a tree with var() is not supported'));
94
+ return buildMatchResult(null, new error.UnsupportedMatchingTree('var'));
95
95
  }
96
96
 
97
97
  if (valueHasEnv(tokens)) {
98
- return buildMatchResult(null, new Error('Matching for a tree with env() is not supported'));
98
+ return buildMatchResult(null, new error.UnsupportedMatchingTree('env'));
99
99
  }
100
100
 
101
101
  if (useCssWideKeywords) {
@@ -94,6 +94,17 @@ const SyntaxReferenceError = function(type, referenceName) {
94
94
  return error;
95
95
  };
96
96
 
97
+ const UnsupportedMatchingTree = function(fnName) {
98
+ const error = createCustomError.createCustomError(
99
+ 'UnsupportedMatchingTree',
100
+ `Matching for a tree with ${fnName}() is not supported`
101
+ );
102
+
103
+ error.code = `ERR_LEXER_${fnName.toUpperCase()}_MATCH_UNSUPPORTED`;
104
+
105
+ return error;
106
+ };
107
+
97
108
  const SyntaxMatchError = function(message, syntax, node, matchResult) {
98
109
  const error = createCustomError.createCustomError('SyntaxMatchError', message);
99
110
  const {
@@ -126,3 +137,4 @@ const SyntaxMatchError = function(message, syntax, node, matchResult) {
126
137
 
127
138
  exports.SyntaxMatchError = SyntaxMatchError;
128
139
  exports.SyntaxReferenceError = SyntaxReferenceError;
140
+ exports.UnsupportedMatchingTree = UnsupportedMatchingTree;
@@ -6,7 +6,8 @@ const cssWideKeywords = [
6
6
  'inherit',
7
7
  'unset',
8
8
  'revert',
9
- 'revert-layer'
9
+ 'revert-layer',
10
+ 'revert-rule'
10
11
  ];
11
12
 
12
13
  exports.cssWideKeywords = cssWideKeywords;
@@ -37,8 +37,9 @@ const parseFunctions = {
37
37
  const children = this.createList();
38
38
  const node = parseWithFallback.call(
39
39
  this,
40
- this.Declaration,
41
- () => parseWithFallback.call(this, () => this.Condition('supports'))
40
+ this.tokenType === types.Ident && this.lookupTypeNonSC(1) === types.Colon
41
+ ? this.Declaration
42
+ : () => this.Condition('supports')
42
43
  );
43
44
 
44
45
  if (node.type !== 'Raw' || node.value !== '') {
@@ -5,6 +5,24 @@ const index$1 = require('../atrule/index.cjs');
5
5
  const index$2 = require('../pseudo/index.cjs');
6
6
  const indexParse = require('../node/index-parse.cjs');
7
7
  const index$3 = require('../../tokenizer/index.cjs');
8
+ const types = require('../../tokenizer/types.cjs');
9
+
10
+ function identifier() {
11
+ return this.Identifier();
12
+ }
13
+
14
+ function fontFormat() {
15
+ switch (this.tokenType) {
16
+ case types.Ident:
17
+ return this.Identifier();
18
+
19
+ case types.String:
20
+ return this.String();
21
+
22
+ default:
23
+ this.error('Identifier or string is expected');
24
+ }
25
+ }
8
26
 
9
27
  const config = {
10
28
  parseContext: {
@@ -33,7 +51,14 @@ const config = {
33
51
  supports: {
34
52
  selector() {
35
53
  return this.Selector();
36
- }
54
+ },
55
+ 'font-tech': identifier,
56
+ 'font-format': fontFormat,
57
+ 'at-rule'() {
58
+ return this.AtKeyword();
59
+ },
60
+ 'named-feature': identifier,
61
+ env: identifier
37
62
  },
38
63
  container: {
39
64
  style() {
@@ -0,0 +1,29 @@
1
+ 'use strict';
2
+
3
+ const types = require('../../tokenizer/types.cjs');
4
+
5
+ const name = 'AtKeyword';
6
+ const structure = {
7
+ name: String
8
+ };
9
+
10
+ function parse() {
11
+ const start = this.tokenStart;
12
+
13
+ this.eat(types.AtKeyword);
14
+
15
+ return {
16
+ type: 'AtKeyword',
17
+ loc: this.getLocation(start, this.tokenStart),
18
+ name: this.substrToCursor(start + 1)
19
+ };
20
+ }
21
+
22
+ function generate(node) {
23
+ this.token(types.AtKeyword, '@' + node.name);
24
+ }
25
+
26
+ exports.generate = generate;
27
+ exports.name = name;
28
+ exports.parse = parse;
29
+ exports.structure = structure;
@@ -29,7 +29,12 @@ const parentheses = {
29
29
  media: featureOrRange,
30
30
  container: featureOrRange,
31
31
  supports() {
32
- return this.SupportsDeclaration();
32
+ if (this.lookupTypeNonSC(1) === types.Ident &&
33
+ this.lookupTypeNonSC(2) === types.Colon) {
34
+ return this.SupportsDeclaration();
35
+ }
36
+
37
+ return null;
33
38
  }
34
39
  };
35
40
 
@@ -152,11 +152,12 @@ function getImportant() {
152
152
  this.eat(types.Delim);
153
153
  this.skipSC();
154
154
 
155
+ const isImportant = this.cmpStr(this.tokenStart, this.tokenEnd, 'important');
155
156
  const important = this.consume(types.Ident);
156
157
 
157
- // store original value in case it differ from `important`
158
- // for better original source restoring and hacks like `!ie` support
159
- return important === 'important' ? true : important;
158
+ // Store non-standard values for better original source restoring and hacks
159
+ // like `!ie` support.
160
+ return isImportant ? true : important;
160
161
  }
161
162
 
162
163
  exports.generate = generate;
@@ -6,7 +6,7 @@ const name = 'FeatureFunction';
6
6
  const structure = {
7
7
  kind: String,
8
8
  feature: String,
9
- value: ['Declaration', 'Selector']
9
+ value: ['Declaration', 'Selector', 'Identifier', 'String', 'AtKeyword', 'Raw']
10
10
  };
11
11
 
12
12
  function getFeatureParser(kind, name) {
@@ -32,6 +32,8 @@ function parse(kind = 'unknown') {
32
32
  const startValueToken = this.tokenIndex;
33
33
  const value = valueParser.call(this);
34
34
 
35
+ this.skipSC();
36
+
35
37
  if (this.eof === false &&
36
38
  this.isBalanceEdge(startValueToken) === false) {
37
39
  this.error();
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const AnPlusB = require('./AnPlusB.cjs');
4
+ const AtKeyword = require('./AtKeyword.cjs');
4
5
  const Atrule = require('./Atrule.cjs');
5
6
  const AtrulePrelude = require('./AtrulePrelude.cjs');
6
7
  const AttributeSelector = require('./AttributeSelector.cjs');
@@ -53,6 +54,7 @@ const WhiteSpace = require('./WhiteSpace.cjs');
53
54
 
54
55
 
55
56
  exports.AnPlusB = AnPlusB.generate;
57
+ exports.AtKeyword = AtKeyword.generate;
56
58
  exports.Atrule = Atrule.generate;
57
59
  exports.AtrulePrelude = AtrulePrelude.generate;
58
60
  exports.AttributeSelector = AttributeSelector.generate;
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const AnPlusB = require('./AnPlusB.cjs');
4
+ const AtKeyword = require('./AtKeyword.cjs');
4
5
  const Atrule = require('./Atrule.cjs');
5
6
  const AtrulePrelude = require('./AtrulePrelude.cjs');
6
7
  const AttributeSelector = require('./AttributeSelector.cjs');
@@ -53,6 +54,7 @@ const WhiteSpace = require('./WhiteSpace.cjs');
53
54
 
54
55
 
55
56
  exports.AnPlusB = AnPlusB.parse;
57
+ exports.AtKeyword = AtKeyword.parse;
56
58
  exports.Atrule = Atrule.parse;
57
59
  exports.AtrulePrelude = AtrulePrelude.parse;
58
60
  exports.AttributeSelector = AttributeSelector.parse;
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const AnPlusB = require('./AnPlusB.cjs');
4
+ const AtKeyword = require('./AtKeyword.cjs');
4
5
  const Atrule = require('./Atrule.cjs');
5
6
  const AtrulePrelude = require('./AtrulePrelude.cjs');
6
7
  const AttributeSelector = require('./AttributeSelector.cjs');
@@ -53,6 +54,7 @@ const WhiteSpace = require('./WhiteSpace.cjs');
53
54
 
54
55
 
55
56
  exports.AnPlusB = AnPlusB;
57
+ exports.AtKeyword = AtKeyword;
56
58
  exports.Atrule = Atrule;
57
59
  exports.AtrulePrelude = AtrulePrelude;
58
60
  exports.AttributeSelector = AttributeSelector;
package/data/patch.json CHANGED
@@ -14,13 +14,21 @@
14
14
  }
15
15
  }
16
16
  },
17
- "font-features-values": {
18
- "comment": "The features values syntax is defined in https://www.w3.org/TR/css-fonts-4/#at-ruledef-font-feature-values",
19
- "prelude": "[<string> | <custom-ident>]+",
17
+ "font-feature-values": {
18
+ "comment": "The font-display descriptor: https://www.w3.org/TR/css-fonts-4/#descdef-font-feature-values-font-display",
20
19
  "descriptors": {
21
20
  "font-display": "auto | block | swap | fallback | optional"
22
21
  }
23
22
  },
23
+ "page": {
24
+ "descriptors": {
25
+ "margin-top": "<'margin-top'>",
26
+ "margin-right": "<'margin-right'>",
27
+ "margin-bottom": "<'margin-bottom'>",
28
+ "margin-left": "<'margin-left'>",
29
+ "margin": "<'margin'>"
30
+ }
31
+ },
24
32
  "scope": {
25
33
  "prelude": "[ ( <scope-start> ) ]? [ to ( <scope-end> ) ]?"
26
34
  },
@@ -626,6 +634,18 @@
626
634
  "comment": "new definition on font-4, https://drafts.csswg.org/css-fonts-4/#typedef-generic-family",
627
635
  "syntax": "<generic-script-specific>| <generic-complete> | <generic-incomplete> | <-non-standard-generic-family>"
628
636
  },
637
+ "font-features-tech": {
638
+ "syntax": "features-opentype | features-aat | features-graphite"
639
+ },
640
+ "font-format": {
641
+ "syntax": "<string> | collection | embedded-opentype | opentype | svg | truetype | woff | woff2"
642
+ },
643
+ "font-tech": {
644
+ "syntax": "<font-features-tech> | <color-font-tech> | variations | palettes | incremental"
645
+ },
646
+ "color-font-tech": {
647
+ "syntax": "color-COLRv0 | color-COLRv1 | color-SVG | color-sbix | color-CBDT"
648
+ },
629
649
  "generic-script-specific": {
630
650
  "syntax": "generic(kai) | generic(fangsong) | generic(nastaliq)"
631
651
  },
@@ -661,6 +681,9 @@
661
681
  "modern-device-cmyk-syntax": {
662
682
  "syntax": "device-cmyk( <cmyk-component>{4} [ / [ <alpha-value> | none ] ]? )"
663
683
  },
684
+ "param()": {
685
+ "syntax": "param( <dashed-ident> , <declaration-value>? )"
686
+ },
664
687
  "cmyk-component": {
665
688
  "syntax": "<number> | <percentage> | none"
666
689
  },
@@ -916,6 +939,24 @@
916
939
  "comment": "missed, https://drafts.csswg.org/css-contain-3/#container-rule",
917
940
  "syntax": "( <style-condition> ) | ( <style-feature> ) | <general-enclosed>"
918
941
  },
942
+ "supports-feature": {
943
+ "syntax": "<supports-selector-fn> | <supports-font-tech-fn> | <supports-font-format-fn> | <supports-at-rule-fn> | <supports-named-feature-fn> | <supports-env-fn> | <supports-decl>"
944
+ },
945
+ "supports-font-tech-fn": {
946
+ "syntax": "font-tech( <font-tech> )"
947
+ },
948
+ "supports-font-format-fn": {
949
+ "syntax": "font-format( <font-format> )"
950
+ },
951
+ "supports-at-rule-fn": {
952
+ "syntax": "at-rule( <at-keyword-token> )"
953
+ },
954
+ "supports-named-feature-fn": {
955
+ "syntax": "named-feature( <ident> )"
956
+ },
957
+ "supports-env-fn": {
958
+ "syntax": "env( <ident> )"
959
+ },
919
960
  "-non-standard-display": {
920
961
  "syntax": "-ms-inline-flexbox | -ms-grid | -ms-inline-grid | -webkit-flex | -webkit-inline-flex | -webkit-box | -webkit-inline-box | -moz-inline-stack | -moz-box | -moz-inline-box"
921
962
  },