UNPKG

@antebudimir/eslint-plugin-vanilla-extract

Version:

Comprehensive ESLint plugin for vanilla-extract with CSS property ordering, style validation, and best practices enforcement. Supports alphabetical, concentric and custom CSS ordering, auto-fixing, and zero-runtime safety.

92 lines (91 loc) 2.89 kB
import type { Rule } from 'eslint'; import { TSESTree } from '@typescript-eslint/utils'; export interface ImportReference { source: string; importedName: string; localName: string; } export interface WrapperFunctionInfo { originalFunction: string; parameterMapping: number; } export interface TrackedFunctions { styleFunctions: Set<string>; recipeFunctions: Set<string>; fontFaceFunctions: Set<string>; globalFunctions: Set<string>; keyframeFunctions: Set<string>; } /** * Tracks vanilla-extract function imports and their local bindings */ export declare class ReferenceTracker { private imports; private trackedFunctions; private wrapperFunctions; private style; private recipe; constructor(options?: { style?: string[]; recipe?: string[]; }); /** * Processes import declarations to track vanilla-extract functions */ processImportDeclaration(node: TSESTree.ImportDeclaration): void; /** * Processes variable declarations to track re-assignments and destructuring */ processVariableDeclarator(node: TSESTree.VariableDeclarator): void; /** * Processes function declarations to detect wrapper functions */ processFunctionDeclaration(node: TSESTree.FunctionDeclaration): void; /** * Analyzes a function to see if it wraps a vanilla-extract function */ private analyzeWrapperFunction; /** * Analyzes a wrapper function expression to detect vanilla-extract calls and parameter mapping */ private analyzeWrapperExpression; /** * Checks if a node is a vanilla-extract function call */ private checkForVanillaExtractCall; /** * Traverses a block statement to find vanilla-extract calls */ private traverseBlockForVanillaExtractCalls; /** * Checks if a function name corresponds to a tracked vanilla-extract function */ isTrackedFunction(functionName: string): boolean; /** * Gets the category of a tracked function */ getFunctionCategory(functionName: string): keyof TrackedFunctions | null; /** * Gets the original imported name for a local function name */ getOriginalName(localName: string): string | null; /** * Gets wrapper function information */ getWrapperInfo(functionName: string): WrapperFunctionInfo | null; /** * Gets all tracked functions by category */ getTrackedFunctions(): TrackedFunctions; /** * Resets the tracker state (useful for processing multiple files) */ reset(): void; private isVanillaExtractSource; private getCustomWrapper; private categorizeFunction; } /** * Creates a visitor that tracks vanilla-extract imports and bindings */ export declare function createReferenceTrackingVisitor(tracker: ReferenceTracker): Rule.RuleListener;