@eslint/css-tree 3.5.2 → 3.5.4

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/version.cjs CHANGED
@@ -1 +1 @@
1
- module.exports = "3.5.2";
1
+ module.exports = "3.5.4";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = "3.5.2";
1
+ export const version = "3.5.4";
package/lib/index.d.ts CHANGED
@@ -1284,7 +1284,7 @@ export class TokenStream {
1284
1284
  lookupOffset(offset: number): number;
1285
1285
 
1286
1286
  /**
1287
- * Skips whitespace and comments and returns the starting index (inclusive) of the `idx`-th non-whitespace/comment token in the `TokenStream`.
1287
+ * Returns the starting index (inclusive) of the `idx`-th non-whitespace/comment token in the `TokenStream`. This method skips whitespace and comment tokens until it finds the specified non-whitespace/comment token.
1288
1288
  *
1289
1289
  * @param index - The index of the non-whitespace/comment token to look up (starting from 0).
1290
1290
  * @returns The starting index of the `idx`-th non-whitespace/comment token, or `EOF` if the index is out of bounds or if the end of the stream is reached before the specified token is found.
@@ -1608,6 +1608,14 @@ export interface ParseFunction {
1608
1608
  */
1609
1609
  export const parse: ParseFunction;
1610
1610
 
1611
+ /**
1612
+ * Represents a function that reads a sequence of CSS tokens and returns a list of nodes.
1613
+ *
1614
+ * @param recognizer - A recognizer instance to determine node boundaries.
1615
+ * @returns A list of parsed nodes.
1616
+ */
1617
+ export type ReadSequenceFunction = (this: ParserContext, recognizer: Recognizer) => List<CssNode>;
1618
+
1611
1619
  // ----------------------------------------------------------
1612
1620
  // Generator
1613
1621
  // https://github.com/csstree/csstree/tree/master/lib/generator
@@ -1707,8 +1715,7 @@ export interface WalkContext {
1707
1715
  break: symbol;
1708
1716
 
1709
1717
  /**
1710
- * Prevents the current node from being iterated. No visitor function will
1711
- * be invoked for its properties or children nodes. This value only affects
1718
+ * Prevents the current node from being iterated. No visitor function will be invoked for its properties or children nodes. This value only affects
1712
1719
  * the `enter` visitor; the `leave` visitor is invoked after iterating
1713
1720
  * over all node's properties and children.
1714
1721
  */
@@ -2415,12 +2422,11 @@ export interface LexerMatchResult {
2415
2422
 
2416
2423
  type ConsumerFunction = (this: ParserContext, ...args: unknown[]) => CssNode;
2417
2424
 
2418
- // https://github.com/csstree/csstree/tree/master/lib/syntax/scope
2419
2425
  /**
2420
2426
  * Recognizer is responsible for identifying specific patterns or constructs within the CSS syntax.
2421
2427
  * It provides methods to interpret and handle these constructs during parsing.
2428
+ * @see https://github.com/csstree/csstree/blob/master/lib/syntax/scope
2422
2429
  */
2423
- // FIXME
2424
2430
  interface Recognizer {
2425
2431
  /**
2426
2432
  * Retrieves a node based on the provided parsing context.
@@ -2428,16 +2434,19 @@ interface Recognizer {
2428
2434
  * @param context - The parsing context, which contains relevant state and configuration for the parser.
2429
2435
  * @returns A function that, when executed, produces a `CssNode`.
2430
2436
  */
2431
- getNode(context: ParserContext): (this: ParserContext) => CssNode;
2437
+ getNode(this: ParserContext): CssNode;
2438
+
2439
+ /**
2440
+ * Handles whitespace between CSS selectors during parsing.
2441
+ * Ensures that whitespace is correctly interpreted as a descendant combinator.
2442
+ *
2443
+ * @param next - The next node or token in the parsing sequence.
2444
+ * @param children - The list of parsed nodes, which will be modified to include a `Combinator` node if applicable.
2445
+ */
2446
+ onWhitespace?(this: ParserContext, next: CssNode | null, children: List<CssNode>): void;
2432
2447
 
2433
- // /**
2434
- // * Handles whitespace between CSS selectors during parsing.
2435
- // * Ensures that whitespace is correctly interpreted as a descendant combinator.
2436
- // *
2437
- // * @param next - The next node or token in the parsing sequence.
2438
- // * @param children - The list of parsed nodes, which will be modified to include a `Combinator` node if applicable.
2439
- // */
2440
- // onWhiteSpace?(next: CssNode | null, children: CssNodeList): void;
2448
+ // any number of other properties
2449
+ [key:string]: any;
2441
2450
  }
2442
2451
 
2443
2452
  /**
@@ -2468,11 +2477,8 @@ interface Parser {
2468
2477
 
2469
2478
  /**
2470
2479
  * Reads a sequence of CSS nodes based on the provided recognizer.
2471
- *
2472
- * @param recognizer - A recognizer instance to determine node boundaries.
2473
- * @returns A list of parsed `CssNode` objects.
2474
2480
  */
2475
- readSequence(this: ParserContext, recognizer: Recognizer): List<CssNode>;
2481
+ readSequence: ReadSequenceFunction;
2476
2482
 
2477
2483
  /**
2478
2484
  * Consumes input until the end of a balance context is reached.
@@ -2674,6 +2680,14 @@ interface Parser {
2674
2680
  error: (this: ParserContext, message: string, offset: number) => void;
2675
2681
  }
2676
2682
 
2683
+ // AtruleParseConfig type based on the structure of files in lib/syntax/atrule/
2684
+ interface AtruleParseConfig {
2685
+ parse: {
2686
+ prelude?: ((this: ParserContext) => List<CssNode>) | null;
2687
+ block?: ((this: ParserContext, nested?: boolean) => CssNode) | null;
2688
+ };
2689
+ }
2690
+
2677
2691
  // https://github.com/csstree/csstree/blob/9de5189fadd6fb4e3a149eec0e80d6ed0d0541e5/lib/parser/create.js#L53-L80
2678
2692
  type ParseConfig = {
2679
2693
  context: Record<string, ConsumerFunction | undefined>;
@@ -2732,11 +2746,11 @@ export interface SyntaxConfig<T extends CssNodeCommon = CssNodeCommon> {
2732
2746
  types: Record<string, string>;
2733
2747
  properties: Record<string, string>;
2734
2748
  atrules: Record<string, AtruleSyntax>;
2735
- node: Record<string, NodeSyntaxConfig<T>>;
2736
- atrule: Record<string, { parse: ConsumerFunction; }>;
2749
+ node: Record<string, Partial<NodeSyntaxConfig<T>>>;
2750
+ atrule: Record<string, AtruleParseConfig>;
2737
2751
  pseudo: Record<string, { parse: ConsumerFunction; }>;
2738
- scope: Record<string, Recognizer>;
2739
- features: Record<string, Recognizer>;
2752
+ scope: Record<string, Partial<Recognizer>>;
2753
+ features: Record<string, Partial<Recognizer>>;
2740
2754
  parseContext: ParseContext;
2741
2755
  tokenize: TokenizeFunction;
2742
2756
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint/css-tree",
3
- "version": "3.5.2",
3
+ "version": "3.5.4",
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",