UNPKG

@antebudimir/eslint-plugin-vanilla-extract

Version:

ESLint plugin for enforcing best practices in vanilla-extract CSS styles, including CSS property ordering and additional linting rules.

86 lines (85 loc) 2.75 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; constructor(); /** * 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 categorizeFunction; } /** * Creates a visitor that tracks vanilla-extract imports and bindings */ export declare function createReferenceTrackingVisitor(tracker: ReferenceTracker): Rule.RuleListener;