@eslint/css-tree 3.3.1 → 3.3.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
@@ -469,6 +469,7 @@ module.exports = {
469
469
  "bottom": "<length>|auto",
470
470
  "container-name": "<custom-ident>",
471
471
  "container-condition": "not <query-in-parens>|<query-in-parens> [[and <query-in-parens>]*|[or <query-in-parens>]*]",
472
+ "cubic-bezier-easing-function": "ease|ease-in|ease-out|ease-in-out|cubic-bezier( <number [0,1]> , <number> , <number [0,1]> , <number> )",
472
473
  "generic-voice": "[<age>? <gender> <integer>?]",
473
474
  "gender": "male|female|neutral",
474
475
  "generic-script-specific": "generic( kai )|generic( fangsong )|generic( nastaliq )",
@@ -1029,7 +1030,7 @@ module.exports = {
1029
1030
  "scroll-snap-type": "none|[x|y|block|inline|both] [mandatory|proximity]?",
1030
1031
  "scroll-snap-type-x": "none|mandatory|proximity",
1031
1032
  "scroll-snap-type-y": "none|mandatory|proximity",
1032
- "scroll-timeline": "[<'scroll-timeline-name'>||<'scroll-timeline-axis'>]#",
1033
+ "scroll-timeline": "[<'scroll-timeline-name'> <'scroll-timeline-axis'>?]#",
1033
1034
  "scroll-timeline-axis": "[block|inline|x|y]#",
1034
1035
  "scroll-timeline-name": "[none|<dashed-ident>]#",
1035
1036
  "scrollbar-color": "auto|<color>{2}",
@@ -1165,9 +1166,7 @@ module.exports = {
1165
1166
  "rest": "<'rest-before'> <'rest-after'>?",
1166
1167
  "rest-after": "<time>|none|x-weak|weak|medium|strong|x-strong",
1167
1168
  "rest-before": "<time>|none|x-weak|weak|medium|strong|x-strong",
1168
- "src": "[<url> [format( <string># )]?|local( <family-name> )]#",
1169
1169
  "speak": "auto|never|always",
1170
- "unicode-range": "<urange>#",
1171
1170
  "voice-balance": "<number>|left|center|right|leftwards|rightwards",
1172
1171
  "voice-duration": "auto|<time>",
1173
1172
  "voice-family": "[[<family-name>|<generic-voice>] ,]* [<family-name>|<generic-voice>]|preserve",
@@ -1217,7 +1216,7 @@ module.exports = {
1217
1216
  "line-gap-override": "normal|<percentage>",
1218
1217
  "size-adjust": "<percentage>",
1219
1218
  "src": "[<url> [format( <string># )]?|local( <family-name> )]#",
1220
- "unicode-range": "<urange>#"
1219
+ "unicode-range": "<unicode-range-token>#"
1221
1220
  }
1222
1221
  },
1223
1222
  "font-feature-values": {
package/dist/data.js CHANGED
@@ -469,6 +469,7 @@ export default {
469
469
  "bottom": "<length>|auto",
470
470
  "container-name": "<custom-ident>",
471
471
  "container-condition": "not <query-in-parens>|<query-in-parens> [[and <query-in-parens>]*|[or <query-in-parens>]*]",
472
+ "cubic-bezier-easing-function": "ease|ease-in|ease-out|ease-in-out|cubic-bezier( <number [0,1]> , <number> , <number [0,1]> , <number> )",
472
473
  "generic-voice": "[<age>? <gender> <integer>?]",
473
474
  "gender": "male|female|neutral",
474
475
  "generic-script-specific": "generic( kai )|generic( fangsong )|generic( nastaliq )",
@@ -1029,7 +1030,7 @@ export default {
1029
1030
  "scroll-snap-type": "none|[x|y|block|inline|both] [mandatory|proximity]?",
1030
1031
  "scroll-snap-type-x": "none|mandatory|proximity",
1031
1032
  "scroll-snap-type-y": "none|mandatory|proximity",
1032
- "scroll-timeline": "[<'scroll-timeline-name'>||<'scroll-timeline-axis'>]#",
1033
+ "scroll-timeline": "[<'scroll-timeline-name'> <'scroll-timeline-axis'>?]#",
1033
1034
  "scroll-timeline-axis": "[block|inline|x|y]#",
1034
1035
  "scroll-timeline-name": "[none|<dashed-ident>]#",
1035
1036
  "scrollbar-color": "auto|<color>{2}",
@@ -1165,9 +1166,7 @@ export default {
1165
1166
  "rest": "<'rest-before'> <'rest-after'>?",
1166
1167
  "rest-after": "<time>|none|x-weak|weak|medium|strong|x-strong",
1167
1168
  "rest-before": "<time>|none|x-weak|weak|medium|strong|x-strong",
1168
- "src": "[<url> [format( <string># )]?|local( <family-name> )]#",
1169
1169
  "speak": "auto|never|always",
1170
- "unicode-range": "<urange>#",
1171
1170
  "voice-balance": "<number>|left|center|right|leftwards|rightwards",
1172
1171
  "voice-duration": "auto|<time>",
1173
1172
  "voice-family": "[[<family-name>|<generic-voice>] ,]* [<family-name>|<generic-voice>]|preserve",
@@ -1217,7 +1216,7 @@ export default {
1217
1216
  "line-gap-override": "normal|<percentage>",
1218
1217
  "size-adjust": "<percentage>",
1219
1218
  "src": "[<url> [format( <string># )]?|local( <family-name> )]#",
1220
- "unicode-range": "<urange>#"
1219
+ "unicode-range": "<unicode-range-token>#"
1221
1220
  }
1222
1221
  },
1223
1222
  "font-feature-values": {
package/dist/version.cjs CHANGED
@@ -1 +1 @@
1
- module.exports = "3.3.1";
1
+ module.exports = "3.3.3";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = "3.3.1";
1
+ export const version = "3.3.3";
package/lib/index.d.ts CHANGED
@@ -606,6 +606,18 @@ export interface Comment extends CssNodeCommon {
606
606
  value: string;
607
607
  }
608
608
 
609
+ export interface Condition extends CssNodeCommon {
610
+ type: "Condition";
611
+ kind: string;
612
+ children: List<CssNode>;
613
+ }
614
+
615
+ export interface ConditionPlain extends CssNodeCommon {
616
+ type: "Condition";
617
+ kind: string;
618
+ children: CssNodePlain[];
619
+ }
620
+
609
621
  export interface Declaration extends CssNodeCommon {
610
622
  type: "Declaration";
611
623
  important: boolean | string;
@@ -636,6 +648,37 @@ export interface Dimension extends CssNodeCommon {
636
648
  unit: string;
637
649
  }
638
650
 
651
+ export interface Feature extends CssNodeCommon {
652
+ type: "Feature";
653
+ name: string;
654
+ kind: string;
655
+ value: Identifier | NumberNode | Dimension | Ratio | FunctionNode | null;
656
+ }
657
+
658
+ export interface FeatureFunction extends CssNodeCommon {
659
+ type: "FeatureFunction";
660
+ feature: string;
661
+ kind: string;
662
+ value: Declaration | Selector;
663
+ }
664
+
665
+ export interface FeatureFunctionPlain extends CssNodeCommon {
666
+ type: "FeatureFunction";
667
+ feature: string;
668
+ kind: string;
669
+ value: DeclarationPlain | SelectorPlain;
670
+ }
671
+
672
+ export interface FeatureRange extends CssNodeCommon {
673
+ type: "FeatureRange";
674
+ kind: string;
675
+ left: Identifier | NumberNode | Dimension | Ratio | FunctionNode;
676
+ leftComparison: string;
677
+ middle: Identifier | NumberNode | Dimension | Ratio | FunctionNode;
678
+ rightComparison: string | null;
679
+ right: Identifier | NumberNode | Dimension | Ratio | FunctionNode | null;
680
+ }
681
+
639
682
  export interface FunctionNode extends CssNodeCommon {
640
683
  type: "Function";
641
684
  name: string;
@@ -663,6 +706,21 @@ export interface Identifier extends CssNodeCommon {
663
706
  name: string;
664
707
  }
665
708
 
709
+ export interface Layer extends CssNodeCommon {
710
+ type: "Layer";
711
+ name: string;
712
+ }
713
+
714
+ export interface LayerList extends CssNodeCommon {
715
+ type: "LayerList";
716
+ children: List<Layer>;
717
+ }
718
+
719
+ export interface LayerListPlain extends CssNodeCommon {
720
+ type: "LayerList";
721
+ children: Layer[];
722
+ }
723
+
666
724
  export interface MediaFeature extends CssNodeCommon {
667
725
  type: "MediaFeature";
668
726
  name: string;
@@ -807,6 +865,11 @@ export interface StyleSheet extends CssNodeCommon {
807
865
  children: List<CssNode>;
808
866
  }
809
867
 
868
+ export interface SupportsDeclaration extends CssNodeCommon {
869
+ type: "SupportsDeclaration";
870
+ declaration: Declaration | Raw;
871
+ }
872
+
810
873
  export interface StyleSheetPlain extends CssNodeCommon {
811
874
  type: "StyleSheet";
812
875
  children: CssNodePlain[];
@@ -842,6 +905,7 @@ export interface WhiteSpace extends CssNodeCommon {
842
905
  value: string;
843
906
  }
844
907
 
908
+ /* IMPORTANT! If you update this, also update `CssNodePlain` */
845
909
  export type CssNode =
846
910
  | AnPlusB
847
911
  | Atrule
@@ -854,13 +918,19 @@ export type CssNode =
854
918
  | ClassSelector
855
919
  | Combinator
856
920
  | Comment
921
+ | Condition
857
922
  | Declaration
858
923
  | DeclarationList
859
924
  | Dimension
925
+ | Feature
926
+ | FeatureFunction
927
+ | FeatureRange
860
928
  | FunctionNode
861
929
  | Hash
862
930
  | IdSelector
863
931
  | Identifier
932
+ | Layer
933
+ | LayerList
864
934
  | MediaFeature
865
935
  | MediaQuery
866
936
  | MediaQueryList
@@ -879,12 +949,14 @@ export type CssNode =
879
949
  | SelectorList
880
950
  | StringNode
881
951
  | StyleSheet
952
+ | SupportsDeclaration
882
953
  | TypeSelector
883
954
  | UnicodeRange
884
955
  | Url
885
956
  | Value
886
957
  | WhiteSpace;
887
958
 
959
+ /* IMPORTANT! If you update this, also update `CssNode` */
888
960
  export type CssNodePlain =
889
961
  | AnPlusB
890
962
  | AtrulePlain
@@ -897,16 +969,23 @@ export type CssNodePlain =
897
969
  | ClassSelector
898
970
  | Combinator
899
971
  | Comment
972
+ | ConditionPlain
900
973
  | DeclarationPlain
901
974
  | DeclarationListPlain
902
975
  | Dimension
976
+ | Feature
977
+ | FeatureFunctionPlain
978
+ | FeatureRange
903
979
  | FunctionNodePlain
904
980
  | Hash
905
981
  | IdSelector
906
982
  | Identifier
983
+ | Layer
984
+ | LayerListPlain
907
985
  | MediaFeature
908
986
  | MediaQueryPlain
909
987
  | MediaQueryListPlain
988
+ | NestingSelector
910
989
  | NthPlain
911
990
  | NumberNode
912
991
  | Operator
@@ -921,54 +1000,16 @@ export type CssNodePlain =
921
1000
  | SelectorListPlain
922
1001
  | StringNode
923
1002
  | StyleSheetPlain
1003
+ | SupportsDeclaration
924
1004
  | TypeSelector
925
1005
  | UnicodeRange
926
1006
  | Url
927
1007
  | ValuePlain
928
1008
  | WhiteSpace;
929
1009
 
930
- type CssNodeNames =
931
- | "AnPlusB"
932
- | "Atrule"
933
- | "AtrulePrelude"
934
- | "AttributeSelector"
935
- | "Block"
936
- | "Brackets"
937
- | "CDC"
938
- | "CDO"
939
- | "ClassSelector"
940
- | "Combinator"
941
- | "Comment"
942
- | "Declaration"
943
- | "DeclarationList"
944
- | "Dimension"
945
- | "Function"
946
- | "Hash"
947
- | "IdSelector"
948
- | "Identifier"
949
- | "MediaFeature"
950
- | "MediaQuery"
951
- | "MediaQueryList"
952
- | "NestingSelector"
953
- | "Nth"
954
- | "Number"
955
- | "Operator"
956
- | "Parentheses"
957
- | "Percentage"
958
- | "PseudoClassSelector"
959
- | "PseudoElementSelector"
960
- | "Ratio"
961
- | "Raw"
962
- | "Rule"
963
- | "Selector"
964
- | "SelectorList"
965
- | "String"
966
- | "StyleSheet"
967
- | "TypeSelector"
968
- | "UnicodeRange"
969
- | "Url"
970
- | "Value"
971
- | "WhiteSpace";
1010
+ type CssNodeNames = CssNode["type"];
1011
+
1012
+ type AnyCssNode = CssNode | CssNodePlain;
972
1013
 
973
1014
  // ----------------------------------------------------------
974
1015
  // Tokenizer
@@ -1644,7 +1685,7 @@ export interface GenerateOptions {
1644
1685
  * @param options - Optional configuration for the generator.
1645
1686
  * @returns The generated CSS string.
1646
1687
  */
1647
- export type GenerateFunction = (ast: CssNode, options?: GenerateOptions) => string;
1688
+ export type GenerateFunction = (ast: AnyCssNode, options?: GenerateOptions) => string;
1648
1689
 
1649
1690
  /**
1650
1691
  * Generates a CSS string from an abstract syntax tree (AST).
@@ -1676,7 +1717,7 @@ export interface WalkContext {
1676
1717
  /**
1677
1718
  * The root node of the tree being traversed.
1678
1719
  */
1679
- root: CssNode;
1720
+ root: AnyCssNode;
1680
1721
 
1681
1722
  /**
1682
1723
  * The current stylesheet node being visited, or `null` if not applicable.
@@ -1784,48 +1825,7 @@ export interface WalkOptionsVisit<NodeType extends CssNode = CssNode> {
1784
1825
  /**
1785
1826
  * Combined options for tree-walking, supporting specific node types or general traversal options.
1786
1827
  */
1787
- export type WalkOptions =
1788
- | WalkOptionsVisit<AnPlusB>
1789
- | WalkOptionsVisit<Atrule>
1790
- | WalkOptionsVisit<AtrulePrelude>
1791
- | WalkOptionsVisit<AttributeSelector>
1792
- | WalkOptionsVisit<Block>
1793
- | WalkOptionsVisit<Brackets>
1794
- | WalkOptionsVisit<CDC>
1795
- | WalkOptionsVisit<CDO>
1796
- | WalkOptionsVisit<ClassSelector>
1797
- | WalkOptionsVisit<Combinator>
1798
- | WalkOptionsVisit<Comment>
1799
- | WalkOptionsVisit<Declaration>
1800
- | WalkOptionsVisit<DeclarationList>
1801
- | WalkOptionsVisit<Dimension>
1802
- | WalkOptionsVisit<FunctionNode>
1803
- | WalkOptionsVisit<Hash>
1804
- | WalkOptionsVisit<IdSelector>
1805
- | WalkOptionsVisit<Identifier>
1806
- | WalkOptionsVisit<MediaFeature>
1807
- | WalkOptionsVisit<MediaQuery>
1808
- | WalkOptionsVisit<MediaQueryList>
1809
- | WalkOptionsVisit<Nth>
1810
- | WalkOptionsVisit<NumberNode>
1811
- | WalkOptionsVisit<Operator>
1812
- | WalkOptionsVisit<Parentheses>
1813
- | WalkOptionsVisit<Percentage>
1814
- | WalkOptionsVisit<PseudoClassSelector>
1815
- | WalkOptionsVisit<PseudoElementSelector>
1816
- | WalkOptionsVisit<Ratio>
1817
- | WalkOptionsVisit<Raw>
1818
- | WalkOptionsVisit<Rule>
1819
- | WalkOptionsVisit<Selector>
1820
- | WalkOptionsVisit<SelectorList>
1821
- | WalkOptionsVisit<StringNode>
1822
- | WalkOptionsVisit<StyleSheet>
1823
- | WalkOptionsVisit<TypeSelector>
1824
- | WalkOptionsVisit<UnicodeRange>
1825
- | WalkOptionsVisit<Url>
1826
- | WalkOptionsVisit<Value>
1827
- | WalkOptionsVisit<WhiteSpace>
1828
- | WalkOptionsNoVisit;
1828
+ export type WalkOptions = WalkOptionsVisit<CssNode> | WalkOptionsNoVisit;
1829
1829
 
1830
1830
  /**
1831
1831
  * Walks through a CSS abstract syntax tree (AST) and invokes callback functions on nodes.
@@ -1837,7 +1837,7 @@ export const walk: {
1837
1837
  * @param ast - The CSS abstract syntax tree to traverse.
1838
1838
  * @param options - The options controlling the traversal process.
1839
1839
  */
1840
- (ast: CssNode, options: EnterOrLeaveFn | WalkOptions): void;
1840
+ (ast: AnyCssNode, options: EnterOrLeaveFn | WalkOptions): void;
1841
1841
 
1842
1842
  /**
1843
1843
  * Stops traversal. No visitor function will be invoked once this value is returned by a visitor.
@@ -1859,7 +1859,7 @@ export const walk: {
1859
1859
  * @param list - The list containing the current node.
1860
1860
  * @returns `true` if the node matches the condition; `false` otherwise.
1861
1861
  */
1862
- export type FindFn = (this: WalkContext, node: CssNode, item: ListItem<CssNode>, list: List<CssNode>) => boolean;
1862
+ export type FindFn = (this: WalkContext, node: AnyCssNode, item: ListItem<CssNode>, list: List<CssNode>) => boolean;
1863
1863
 
1864
1864
  /**
1865
1865
  * Finds the first node in the tree that matches the specified predicate function.
@@ -1868,7 +1868,7 @@ export type FindFn = (this: WalkContext, node: CssNode, item: ListItem<CssNode>,
1868
1868
  * @param fn - The predicate function to match nodes.
1869
1869
  * @returns The first matching node, or `null` if no match is found.
1870
1870
  */
1871
- export function find(ast: CssNode, fn: FindFn): CssNode | null;
1871
+ export function find(ast: AnyCssNode, fn: FindFn): AnyCssNode | null;
1872
1872
 
1873
1873
  /**
1874
1874
  * Finds the last node in the tree that matches the specified predicate function.
@@ -1877,7 +1877,7 @@ export function find(ast: CssNode, fn: FindFn): CssNode | null;
1877
1877
  * @param fn - The predicate function to match nodes.
1878
1878
  * @returns The last matching node, or `null` if no match is found.
1879
1879
  */
1880
- export function findLast(ast: CssNode, fn: FindFn): CssNode | null;
1880
+ export function findLast(ast: AnyCssNode, fn: FindFn): AnyCssNode | null;
1881
1881
 
1882
1882
  /**
1883
1883
  * Finds all nodes in the tree that match the specified predicate function.
@@ -1886,7 +1886,7 @@ export function findLast(ast: CssNode, fn: FindFn): CssNode | null;
1886
1886
  * @param fn - The predicate function to match nodes.
1887
1887
  * @returns An array of all matching nodes.
1888
1888
  */
1889
- export function findAll(ast: CssNode, fn: FindFn): CssNode[];
1889
+ export function findAll(ast: AnyCssNode, fn: FindFn): AnyCssNode[];
1890
1890
 
1891
1891
  // ----------------------------------------------------------
1892
1892
  // Name utils
@@ -3033,7 +3033,7 @@ export class Lexer {
3033
3033
  * @param prelude - The prelude content.
3034
3034
  * @returns The match result as a `LexerMatchResult`.
3035
3035
  */
3036
- matchAtrulePrelude(atruleName: string, prelude: CssNode | string): LexerMatchResult;
3036
+ matchAtrulePrelude(atruleName: string, prelude: AnyCssNode | string): LexerMatchResult;
3037
3037
 
3038
3038
  /**
3039
3039
  * Matches an at-rule descriptor value against its syntax definition.
@@ -3043,7 +3043,7 @@ export class Lexer {
3043
3043
  * @param value - The value to match.
3044
3044
  * @returns The match result as a `LexerMatchResult`.
3045
3045
  */
3046
- matchAtruleDescriptor(atruleName: string, descriptorName: string, value: CssNode | string): LexerMatchResult;
3046
+ matchAtruleDescriptor(atruleName: string, descriptorName: string, value: AnyCssNode | string): LexerMatchResult;
3047
3047
 
3048
3048
  /**
3049
3049
  * Matches a declaration node against its syntax definition.
@@ -3051,7 +3051,7 @@ export class Lexer {
3051
3051
  * @param node - The declaration node to match.
3052
3052
  * @returns The match result as a `LexerMatchResult`.
3053
3053
  */
3054
- matchDeclaration(node: CssNode): LexerMatchResult;
3054
+ matchDeclaration(node: AnyCssNode): LexerMatchResult;
3055
3055
 
3056
3056
  /**
3057
3057
  * Matches a property value against its syntax definition.
@@ -3060,7 +3060,7 @@ export class Lexer {
3060
3060
  * @param value - The value to match.
3061
3061
  * @returns The match result as a `LexerMatchResult`.
3062
3062
  */
3063
- matchProperty(propertyName: string, value: CssNode | string): LexerMatchResult;
3063
+ matchProperty(propertyName: string, value: AnyCssNode | string): LexerMatchResult;
3064
3064
 
3065
3065
  /**
3066
3066
  * Matches a type value against its syntax definition.
@@ -3069,7 +3069,7 @@ export class Lexer {
3069
3069
  * @param value - The value to match.
3070
3070
  * @returns The match result as a `LexerMatchResult`.
3071
3071
  */
3072
- matchType(typeName: string, value: CssNode | string): LexerMatchResult;
3072
+ matchType(typeName: string, value: AnyCssNode | string): LexerMatchResult;
3073
3073
 
3074
3074
  /**
3075
3075
  * Matches a generic syntax descriptor against a value.
@@ -3078,7 +3078,7 @@ export class Lexer {
3078
3078
  * @param value - The value to match.
3079
3079
  * @returns The match result as a `LexerMatchResult`.
3080
3080
  */
3081
- match(syntax: SyntaxDescriptor | string, value: CssNode | string): LexerMatchResult;
3081
+ match(syntax: SyntaxDescriptor | string, value: AnyCssNode | string): LexerMatchResult;
3082
3082
 
3083
3083
  /**
3084
3084
  * Finds fragments of a value that match a specific syntax type and name.
@@ -3089,7 +3089,7 @@ export class Lexer {
3089
3089
  * @param name - The name to match.
3090
3090
  * @returns An array of matching fragments.
3091
3091
  */
3092
- findValueFragments(propertyName: string, value: CssNode, type: string, name: string): FragmentMatch<Value>[];
3092
+ findValueFragments(propertyName: string, value: AnyCssNode, type: string, name: string): FragmentMatch<Value>[];
3093
3093
 
3094
3094
  /**
3095
3095
  * Finds fragments of a declaration value that match a specific syntax type and name.
@@ -3109,7 +3109,7 @@ export class Lexer {
3109
3109
  * @param name - The name to match.
3110
3110
  * @returns An array of matching fragments.
3111
3111
  */
3112
- findAllFragments(ast: CssNode, type: string, name: string): FragmentMatch[];
3112
+ findAllFragments(ast: AnyCssNode, type: string, name: string): FragmentMatch[];
3113
3113
 
3114
3114
  /**
3115
3115
  * Retrieves the syntax descriptor for an at-rule.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint/css-tree",
3
- "version": "3.3.1",
3
+ "version": "3.3.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",