@tenphi/eslint-plugin-tasty 1.10.0 → 1.11.0
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 +9 -0
- package/dist/config.js +6 -3
- package/dist/config.js.map +1 -1
- package/dist/configs.js +1 -0
- package/dist/configs.js.map +1 -1
- package/dist/constants.js +35 -1
- package/dist/constants.js.map +1 -1
- package/dist/context.js +6 -7
- package/dist/context.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/module-components.js +77 -1
- package/dist/module-components.js.map +1 -1
- package/dist/protected-components.js +160 -0
- package/dist/protected-components.js.map +1 -0
- package/dist/rules/no-protected-restyle.js +120 -0
- package/dist/rules/no-protected-restyle.js.map +1 -0
- package/dist/rules/tasty-component-props.js +27 -19
- package/dist/rules/tasty-component-props.js.map +1 -1
- package/dist/types.d.ts +23 -1
- package/dist/utils.js +6 -1
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
package/dist/context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","names":[],"sources":["../src/context.ts"],"sourcesContent":["import type { TSESTree } from '@typescript-eslint/utils';\nimport type { RuleContext } from '@typescript-eslint/utils/ts-eslint';\nimport type { ResolvedConfig, StyleFunctionConfig } from './types.js';\nimport { loadConfig } from './config.js';\nimport {\n DEFAULT_IMPORT_SOURCES,\n KNOWN_CSS_PROPERTIES,\n KNOWN_TASTY_PROPERTIES,\n SPECIAL_STYLE_KEYS,\n} from './constants.js';\nimport {\n collectLocalStateAliases,\n getKeyName,\n unwrapExpression,\n} from './utils.js';\nimport { finishJSXAnalysis, jsxPropKind } from './type-aware-jsx.js';\nimport { isModuleTastyComponent } from './module-components.js';\n\n/**\n * Every object is considered, then TastyContext gates it by its actual context.\n * Narrow ancestry selectors miss nested shared styles and wrapped JSX values.\n */\nexport const STYLE_OBJECT_SELECTORS = ['ObjectExpression'] as const;\n\n/** One listener per object; context recognition remains the caller's gate. */\nexport function styleObjectListeners(\n handler: (node: TSESTree.ObjectExpression) => void,\n): Record<string, (node: TSESTree.ObjectExpression) => void> {\n return { ObjectExpression: handler };\n}\n\nexport interface StyleContext {\n type: 'tasty' | 'tastyStatic' | 'useStyles' | 'useGlobalStyles';\n isStaticCall: boolean;\n isSelectorMode: boolean;\n isExtending: boolean;\n /**\n * Local name of the component this layer extends, when there is one and it is\n * an identifier. `null` covers every other case — a base definition, a\n * selector, or a layer whose base cannot be read off the AST — so a rule that\n * cares must treat `null` as \"unknown\", not as \"not extending\".\n */\n baseComponent: string | null;\n}\n\nexport interface TastyImport {\n localName: string;\n importedName: string;\n source: string;\n}\n\n/**\n * Whether a type annotation names tasty's `Styles` anywhere inside it.\n *\n * Walks the annotation rather than matching only the outermost reference, so a\n * wrapped tasty type (`Styles | undefined`, `Array<Styles>`) is recognised while\n * `CSSProperties` in the same positions is not. Maps of styles are told apart\n * first by `stylesAnnotationShape`. Deliberately name-based: the plugin has no type checker, and requiring one\n * would make every rule type-aware.\n */\nfunction referencesStylesType(node: TSESTree.TypeNode): boolean {\n const stack: TSESTree.Node[] = [node];\n\n while (stack.length) {\n const current = stack.pop()!;\n\n if (\n current.type === 'TSTypeReference' &&\n current.typeName.type === 'Identifier' &&\n /^Styles$/i.test(current.typeName.name)\n ) {\n return true;\n }\n\n for (const value of Object.values(\n current as unknown as Record<string, unknown>,\n )) {\n if (Array.isArray(value)) {\n for (const item of value) {\n if (item && typeof item === 'object' && 'type' in item) {\n stack.push(item as TSESTree.Node);\n }\n }\n } else if (value && typeof value === 'object' && 'type' in value) {\n // Skip `parent` — it points back up the tree and would loop forever.\n if (value !== (current as TSESTree.Node).parent) {\n stack.push(value as TSESTree.Node);\n }\n }\n }\n }\n\n return false;\n}\n\n/** Utility types whose result has the same shape as their argument. */\nconst SHAPE_PRESERVING_TYPES = new Set([\n 'Readonly',\n 'Partial',\n 'Required',\n 'NonNullable',\n]);\n\n/**\n * What a `Styles`-bearing annotation declares: `'styles'` for a style object,\n * `'map'` for an object whose *values* are style objects (`Record<K, Styles>`,\n * `{ [k: string]: Styles }`, `{ root: Styles }`), `null` when `Styles` does not\n * appear at all.\n *\n * The distinction matters for a map: its keys are variant or block names, so\n * checking the map itself as a style object reports every one of them as an\n * unknown property, while the style objects it holds go unchecked.\n */\nfunction stylesAnnotationShape(\n node: TSESTree.TypeNode,\n): 'styles' | 'map' | null {\n if (node.type === 'TSUnionType' || node.type === 'TSIntersectionType') {\n const shapes = node.types.map(stylesAnnotationShape);\n if (shapes.includes('styles')) return 'styles';\n return shapes.includes('map') ? 'map' : null;\n }\n\n if (node.type === 'TSTypeReference' && node.typeName.type === 'Identifier') {\n const name = node.typeName.name;\n const args = node.typeArguments?.params ?? [];\n\n if (/^Styles$/i.test(name)) return 'styles';\n if (name === 'Record' && args.length === 2) {\n if (stylesAnnotationShape(args[1]) === 'styles') return 'map';\n }\n if (SHAPE_PRESERVING_TYPES.has(name) && args.length === 1) {\n return stylesAnnotationShape(args[0]);\n }\n }\n\n if (node.type === 'TSTypeLiteral') {\n const holdsStyles = node.members.some(\n (member) =>\n (member.type === 'TSIndexSignature' ||\n member.type === 'TSPropertySignature') &&\n member.typeAnnotation !== undefined &&\n stylesAnnotationShape(member.typeAnnotation.typeAnnotation) ===\n 'styles',\n );\n if (holdsStyles) return 'map';\n }\n\n return referencesStylesType(node) ? 'styles' : null;\n}\n\n/**\n * Whether a key could plausibly be a tasty style key.\n *\n * Covers every top-level shape tasty accepts: a style property, a sub-element\n * (capitalised), an at-rule or state/custom-property/colour key (`@`, `&`, `$`,\n * `#`), and the default-state key.\n */\nfunction isPlausibleStyleKey(key: string): boolean {\n if (key === '' || key === '_') return true;\n if (/^[A-Z]/.test(key)) return true;\n if (/^[@&$#]/.test(key)) return true;\n if (SPECIAL_STYLE_KEYS.has(key)) return true;\n\n return KNOWN_TASTY_PROPERTIES.has(key) || KNOWN_CSS_PROPERTIES.has(key);\n}\n\n/**\n * Whether an object is a map of named CSS blocks rather than a tasty styles object.\n *\n * The shape is unmistakable — `{ table: {…}, th: {…}, td: {…} }`, `{ root: {…},\n * toolbar: {…} }` — and it is what a React inline-style map looks like when it\n * carries no type annotation to opt it out. Every key is a block name that is not a\n * style key, and every value is an object.\n *\n * Requiring *every* value to be an object literal is what keeps this from swallowing\n * the case it would hurt most: `const styles = { colour: 'red' }` has a string value,\n * so it is not treated as a block map and `known-property` still reports the typo.\n * Otherwise the rule that catches a misspelled property would be silenced by the\n * misspelling.\n */\nfunction isNamedCssBlockMap(node: TSESTree.ObjectExpression): boolean {\n if (node.properties.length === 0) return false;\n\n for (const prop of node.properties) {\n if (prop.type !== 'Property' || prop.computed) return false;\n\n const key = getKeyName(prop.key);\n\n if (key === null || isPlausibleStyleKey(key)) return false;\n if (prop.value.type !== 'ObjectExpression') return false;\n }\n\n return true;\n}\n\n/**\n * The outermost expression an object is the result of through conditional and\n * logical operators (and type wrappers): `cond ? { … } : null`, `cond && { … }`,\n * `styles ?? { … }`. Whatever position that expression takes, the object may\n * land in. The test of a conditional and the left of `&&` never become the\n * value, so they are not followed.\n */\nfunction conditionalFlowRoot(node: TSESTree.Node): TSESTree.Node {\n let current = node;\n // Matching unwraps type wrappers itself, so the root is the outermost\n // operator, not a wrapper around it.\n let root = node;\n while (current.parent) {\n const parent: TSESTree.Node = current.parent;\n if (\n (parent.type === 'TSAsExpression' ||\n parent.type === 'TSSatisfiesExpression' ||\n parent.type === 'TSNonNullExpression' ||\n parent.type === 'TSTypeAssertion') &&\n parent.expression === current\n ) {\n current = parent;\n } else if (\n (parent.type === 'ConditionalExpression' && parent.test !== current) ||\n (parent.type === 'LogicalExpression' &&\n (parent.right === current || parent.operator !== '&&'))\n ) {\n current = root = parent;\n } else {\n break;\n }\n }\n return root;\n}\n\n/**\n * The component a `styles` JSX prop overrides — `<Card styles={…} />` -> `Card`.\n * A namespaced tag (`<UI.Card />`) resolves to its root object, since that is the\n * name an import can be matched against.\n */\nfunction jsxStylesPropTarget(node: TSESTree.Node): string | null {\n let wrapped: TSESTree.Node = node;\n while (wrapped.parent && unwrapExpression(wrapped.parent) === node) {\n wrapped = wrapped.parent;\n }\n const container = wrapped.parent;\n if (container?.type !== 'JSXExpressionContainer') return null;\n\n const attribute = container.parent;\n if (attribute?.type !== 'JSXAttribute') return null;\n\n const element = attribute.parent;\n if (element?.type !== 'JSXOpeningElement') return null;\n\n let name: TSESTree.JSXTagNameExpression = element.name;\n while (name.type === 'JSXMemberExpression') name = name.object;\n\n return name.type === 'JSXIdentifier' ? name.name : null;\n}\n\n/**\n * The identifier a base-component argument resolves to — `tasty(UI.Card, {…})`\n * -> `UI`, which is what the import map is keyed by.\n *\n * Type assertions are stripped on the way down. Reading `Button as any` as an\n * unknown base would quietly promote an imported component to \"owned\", which is\n * the reading that produces a warning the author cannot act on.\n */\nfunction baseComponentName(node: TSESTree.Node): string | null {\n let current = unwrapExpression(node);\n\n while (current.type === 'MemberExpression') {\n current = unwrapExpression(current.object);\n }\n\n return current.type === 'Identifier' ? current.name : null;\n}\n\n/**\n * Whether `source` is inside this project. Relative and absolute specifiers are,\n * as are the conventional in-repo aliases (`~/`, `#internal`, `@/`) — `@` alone\n * is not, since `@scope/pkg` is a published package.\n */\nfunction isInRepoSource(source: string): boolean {\n return (\n source.startsWith('.') ||\n source.startsWith('/') ||\n source.startsWith('~') ||\n source.startsWith('#') ||\n source.startsWith('@/')\n );\n}\n\n/** Matches a source against an `ownedSources` pattern, where `*` is any run of characters. */\nfunction matchesSourcePattern(pattern: string, source: string): boolean {\n const escaped = pattern.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n\n return new RegExp(`^${escaped.replace(/\\\\\\*/g, '.*')}$`).test(source);\n}\n\n/** `settings.tasty.mergeFunctions`: project helpers with `mergeStyles` semantics. */\nfunction readMergeFunctions(\n context: RuleContext<string, unknown[]>,\n): ReadonlySet<string> {\n const settings = context.settings?.tasty as\n | { mergeFunctions?: unknown }\n | undefined;\n const option = settings?.mergeFunctions;\n if (option === undefined) return new Set();\n if (\n !Array.isArray(option) ||\n option.some((name) => typeof name !== 'string')\n ) {\n throw new Error(\n 'tasty: mergeFunctions must be an array of function names.',\n );\n }\n return new Set(option);\n}\n\nconst TASTY_FUNCTION_NAMES = new Set([\n 'tasty',\n 'tastyStatic',\n 'useStyles',\n 'useGlobalStyles',\n 'mergeStyles',\n 'configure',\n]);\n\n/**\n * Context tracker for a single file's lint pass.\n * Tracks which imports come from tasty and provides\n * helpers to determine if a node is in a tasty style context.\n */\nexport class TastyContext {\n readonly config: ResolvedConfig;\n private imports = new Map<string, TastyImport>();\n private moduleSources = new Map<string, string>();\n private importSources: Set<string>;\n private mergeFunctions: ReadonlySet<string>;\n private relativeComponents = new Map<string, boolean>();\n private resolving = new Set<TSESTree.Node>();\n\n constructor(\n private context: RuleContext<string, unknown[]>,\n config?: ResolvedConfig,\n ) {\n this.config = config ?? loadConfig(context.filename);\n this.importSources = new Set([\n ...DEFAULT_IMPORT_SOURCES,\n ...this.config.importSources,\n ]);\n this.mergeFunctions = readMergeFunctions(context);\n }\n\n trackImport(node: TSESTree.ImportDeclaration): void {\n const source = node.source.value;\n\n // Every import is recorded, tasty or not. Where a *base component* comes\n // from is what tells a rule whether the file it would send the author to\n // edit is even theirs — see `isOwnedComponent`.\n for (const specifier of node.specifiers) {\n this.moduleSources.set(specifier.local.name, source);\n }\n\n if (!this.importSources.has(source) || node.importKind === 'type') return;\n\n for (const specifier of node.specifiers) {\n if (\n specifier.type === 'ImportSpecifier' &&\n specifier.importKind !== 'type'\n ) {\n const importedName =\n specifier.imported.type === 'Identifier'\n ? specifier.imported.name\n : specifier.imported.value;\n if (\n TASTY_FUNCTION_NAMES.has(importedName) ||\n Object.hasOwn(this.config.styleFunctions ?? {}, importedName)\n ) {\n this.imports.set(specifier.local.name, {\n localName: specifier.local.name,\n importedName,\n source,\n });\n }\n }\n }\n }\n\n isComponentJSXProp(node: TSESTree.JSXAttribute): boolean {\n return jsxPropKind(this.context, node) === 'component';\n }\n\n finishJSXAnalysis(): void {\n finishJSXAnalysis(this.context);\n }\n\n getImport(localName: string): TastyImport | undefined {\n return this.imports.get(localName);\n }\n\n /**\n * Whether the base component an extension layer sits on top of lives in a file\n * this project can edit — so a rule can decide whether pointing the author at\n * the base's own definition is advice they can act on.\n *\n * A name that was never imported is declared in this very file, and an unknown\n * base (`null`) counts as owned as well: staying quiet is for a base that is\n * demonstrably someone else's, never for one the plugin merely failed to read.\n */\n isOwnedComponent(localName: string | null): boolean {\n if (localName === null) return true;\n\n const source = this.moduleSources.get(localName);\n if (source === undefined) return true;\n if (isInRepoSource(source)) return true;\n\n // `ownedSources` is optional on the public `ResolvedConfig`, so a config\n // built by a consumer rather than by `loadConfig` may not carry it.\n return (this.config.ownedSources ?? []).some((pattern) =>\n matchesSourcePattern(pattern, source),\n );\n }\n\n isTastyCall(node: TSESTree.CallExpression): TastyImport | undefined {\n const callee = unwrapExpression(node.callee);\n if (callee.type !== 'Identifier') return undefined;\n const imp = this.imports.get(callee.name);\n if (!imp) return undefined;\n\n // A parameter or local declaration can shadow the imported helper. Only\n // the import binding carries evidence that the call accepts Tasty styles.\n let scope = this.context.sourceCode.getScope(callee);\n while (scope) {\n const variable = scope.set.get(callee.name);\n if (variable) {\n return variable.defs.some((def) => def.type === 'ImportBinding')\n ? imp\n : undefined;\n }\n if (!scope.upper) break;\n scope = scope.upper;\n }\n return undefined;\n }\n\n /**\n * `mergeStyles(...)`, or a call to a project helper named in\n * `settings.tasty.mergeFunctions`. A helper matches by its imported name, so\n * an aliased import still counts, or by the name it is declared under in this\n * file; a parameter of the same name shadows it.\n */\n isMergeStylesCall(node: TSESTree.CallExpression): boolean {\n if (this.isTastyCall(node)?.importedName === 'mergeStyles') return true;\n if (this.mergeFunctions.size === 0) return false;\n\n const callee = unwrapExpression(node.callee);\n if (callee.type !== 'Identifier') return false;\n\n let scope = this.context.sourceCode.getScope(callee);\n while (scope) {\n const variable = scope.set.get(callee.name);\n if (variable) {\n return variable.defs.some((def) => {\n if (def.type === 'FunctionName' || def.type === 'Variable') {\n return this.mergeFunctions.has(callee.name);\n }\n if (\n def.type !== 'ImportBinding' ||\n def.parent.type !== 'ImportDeclaration' ||\n def.parent.importKind === 'type'\n ) {\n return false;\n }\n if (def.node.type === 'ImportDefaultSpecifier') {\n return this.mergeFunctions.has(callee.name);\n }\n if (def.node.type !== 'ImportSpecifier') return false;\n if (def.node.importKind === 'type') return false;\n const imported = def.node.imported;\n return this.mergeFunctions.has(\n imported.type === 'Identifier' ? imported.name : imported.value,\n );\n });\n }\n if (!scope.upper) break;\n scope = scope.upper;\n }\n // An undeclared global, such as an auto-imported helper.\n return this.mergeFunctions.has(callee.name);\n }\n\n /** Local factory results, const aliases, and configured component imports. */\n isTastyJSXComponent(node: TSESTree.Node, name: string): boolean {\n const visited = new Set<TSESTree.VariableDeclarator>();\n const resolve = (reference: TSESTree.Node, localName: string): boolean => {\n let scope = this.context.sourceCode.getScope(reference);\n while (scope) {\n const variable = scope.set.get(localName);\n if (variable) {\n return variable.defs.some((def) => {\n if (def.type === 'ImportBinding') {\n if (\n def.parent.type !== 'ImportDeclaration' ||\n def.parent.importKind === 'type' ||\n (def.node.type === 'ImportSpecifier' &&\n def.node.importKind === 'type')\n ) {\n return false;\n }\n const source = def.parent.source.value;\n if (this.importSources.has(source)) return true;\n return this.isRelativeTastyImport(source, def.node);\n }\n if (def.type !== 'Variable') return false;\n const declaration = def.node;\n if (\n declaration.id.type !== 'Identifier' ||\n declaration.parent.kind !== 'const' ||\n !declaration.init ||\n visited.has(declaration)\n )\n return false;\n visited.add(declaration);\n const init = unwrapExpression(declaration.init);\n if (init.type === 'Identifier') return resolve(init, init.name);\n if (init.type === 'MemberExpression' && !init.computed) {\n let member: TSESTree.Node = init;\n while (member.type === 'MemberExpression') {\n if (member.computed) return false;\n member = unwrapExpression(member.object);\n }\n const root = baseComponentName(init);\n return root !== null && resolve(init, root);\n }\n if (init.type !== 'CallExpression') return false;\n const imp = this.isTastyCall(init);\n return (\n imp?.importedName === 'tasty' ||\n (imp !== undefined &&\n this.config.styleFunctions?.[imp.importedName]?.kind ===\n 'options')\n );\n });\n }\n if (!scope.upper) break;\n scope = scope.upper;\n }\n return false;\n };\n return resolve(node, name);\n }\n\n /**\n * Whether a binding imported from a relative module names a Tasty component\n * declared there — `import { Panel } from './styled'`. A namespace import has\n * no single export to follow.\n */\n private isRelativeTastyImport(\n source: string,\n specifier: TSESTree.Node,\n ): boolean {\n if (\n specifier.type !== 'ImportSpecifier' &&\n specifier.type !== 'ImportDefaultSpecifier'\n ) {\n return false;\n }\n const exportName =\n specifier.type === 'ImportDefaultSpecifier'\n ? 'default'\n : specifier.imported.type === 'Identifier'\n ? specifier.imported.name\n : specifier.imported.value;\n const key = `${source}\\0${exportName}`;\n let result = this.relativeComponents.get(key);\n if (result === undefined) {\n result = isModuleTastyComponent(\n this.context.filename,\n source,\n exportName,\n {\n importSources: this.importSources,\n isComponentFactory: (name) =>\n name === 'tasty' ||\n this.config.styleFunctions?.[name]?.kind === 'options',\n },\n );\n this.relativeComponents.set(key, result);\n }\n return result;\n }\n\n /**\n * Determines whether an object expression is a tasty style object\n * by walking up the AST to find a recognized call expression.\n */\n isStyleObject(node: TSESTree.ObjectExpression): boolean {\n return this.getStyleContext(node) !== null;\n }\n\n private getSubElementParent(\n node: TSESTree.Node,\n ): TSESTree.ObjectExpression | null {\n let wrapped: TSESTree.Node = node;\n while (wrapped.parent && unwrapExpression(wrapped.parent) === node) {\n wrapped = wrapped.parent;\n }\n const parent = wrapped.parent;\n if (parent?.type !== 'Property' || parent.computed) return null;\n const key = getKeyName(parent.key);\n return key &&\n /^[A-Z]/.test(key) &&\n parent.parent.type === 'ObjectExpression'\n ? parent.parent\n : null;\n }\n\n /** Follow only sub-elements of recognized styles, never a variants container. */\n getRootStyleObject(\n node: TSESTree.ObjectExpression,\n ): TSESTree.ObjectExpression {\n let current = node;\n while (true) {\n const parent = this.getSubElementParent(current);\n if (!parent || !this.isStyleObject(parent)) return current;\n current = parent;\n }\n }\n\n /**\n * The `mergeStyles(...)` call, or configured merge helper call, this object\n * is a direct argument of, if any.\n */\n private getMergeStylesCall(\n node: TSESTree.ObjectExpression,\n ): TSESTree.CallExpression | null {\n let wrapped: TSESTree.Node = node;\n while (wrapped.parent && unwrapExpression(wrapped.parent) === node) {\n wrapped = wrapped.parent;\n }\n const call = wrapped.parent;\n return call?.type === 'CallExpression' &&\n call.arguments.includes(wrapped as TSESTree.CallExpressionArgument) &&\n this.isMergeStylesCall(call)\n ? call\n : null;\n }\n\n /**\n * Local `@name` state aliases visible to a style object, the way Tasty\n * resolves them: the object's own, then those of each enclosing sub-element\n * up to the root. A `mergeStyles(...)` argument stands for the merged object,\n * so every object argument of the call contributes, and a call that is a\n * sub-element value sees the aliases of the styles it sits in.\n */\n getLocalStateAliases(node: TSESTree.ObjectExpression): string[] {\n const aliases = new Set<string>();\n let current: TSESTree.ObjectExpression | null = node;\n\n while (current) {\n const call = this.getMergeStylesCall(current);\n const scope = call\n ? call.arguments\n .map((arg) => unwrapExpression(arg))\n .filter(\n (arg): arg is TSESTree.ObjectExpression =>\n arg.type === 'ObjectExpression',\n )\n : [current];\n for (const object of scope) {\n for (const alias of collectLocalStateAliases(object))\n aliases.add(alias);\n }\n\n const parent = this.getSubElementParent(call ?? current);\n current = parent && this.isStyleObject(parent) ? parent : null;\n }\n\n return [...aliases];\n }\n\n /**\n * Whether the style object this node belongs to is declared on its own — a\n * `const CELL_STYLES: Styles` or a value of a `Record<K, Styles>` — rather\n * than handed to a call or prop. Such styles can be spread anywhere,\n * including into a sub-element, so their root is not necessarily the\n * component's root.\n */\n isSharedStyleObject(node: TSESTree.ObjectExpression): boolean {\n const outermost = (inner: TSESTree.Node): TSESTree.Node => {\n let wrapped = inner;\n while (wrapped.parent && unwrapExpression(wrapped.parent) === inner) {\n wrapped = wrapped.parent;\n }\n return wrapped;\n };\n\n let parent = outermost(this.getRootStyleObject(node)).parent;\n if (\n parent?.type === 'Property' &&\n parent.parent.type === 'ObjectExpression'\n ) {\n parent = outermost(parent.parent).parent;\n }\n return parent?.type === 'VariableDeclarator';\n }\n\n /** Include helper calls nested inside a real sub-element, but not variant names. */\n isInsideSubElement(node: TSESTree.Node): boolean {\n let current = node.parent;\n while (current) {\n if (current.type === 'Property' && !current.computed) {\n const key = getKeyName(current.key);\n if (\n key &&\n /^[A-Z]/.test(key) &&\n current.parent.type === 'ObjectExpression' &&\n this.isStyleObject(current.parent)\n ) {\n return true;\n }\n }\n current = current.parent;\n }\n return false;\n }\n\n /**\n * The style context of an object, or of any expression standing where a\n * style object goes. Besides objects written in place, this covers an object\n * that reaches a style position only through a conditional or logical\n * operator (`mergeStyles(cond ? { … } : null, styles)`), and one held in a\n * render-scope variable that is then passed on (`const local = { … }`,\n * `styles = { ...styles, … }`, then `styles={local}`): Tasty receives each of\n * them as styles all the same.\n */\n getStyleContext(node: TSESTree.Node): StyleContext | null {\n // A binding can lead back into the object being resolved (`a = { X: a }`).\n if (this.resolving.has(node)) return null;\n this.resolving.add(node);\n try {\n if (node.type === 'ObjectExpression') {\n const flow = conditionalFlowRoot(node);\n if (flow !== node) return this.getStyleContext(flow);\n }\n return (\n this.getDirectStyleContext(node) ?? this.getBindingStyleContext(node)\n );\n } finally {\n this.resolving.delete(node);\n }\n }\n\n /**\n * The context of a value held in a render-scope variable, taken from the\n * first place the variable is read as styles. Module-scope bindings are\n * shared values and are left to the declaration heuristics.\n */\n private getBindingStyleContext(node: TSESTree.Node): StyleContext | null {\n let wrapped: TSESTree.Node = node;\n while (wrapped.parent && unwrapExpression(wrapped.parent) === node) {\n wrapped = wrapped.parent;\n }\n const holder = wrapped.parent;\n let target: TSESTree.Identifier | null = null;\n if (\n holder?.type === 'VariableDeclarator' &&\n holder.init === wrapped &&\n holder.id.type === 'Identifier'\n ) {\n target = holder.id;\n } else if (\n holder?.type === 'AssignmentExpression' &&\n holder.operator === '=' &&\n holder.right === wrapped &&\n holder.left.type === 'Identifier'\n ) {\n target = holder.left;\n }\n if (!target) return null;\n\n let scope = this.context.sourceCode.getScope(target);\n while (!scope.set.has(target.name) && scope.upper) scope = scope.upper;\n const variable = scope.set.get(target.name);\n if (!variable || scope.type === 'module' || scope.type === 'global') {\n return null;\n }\n\n for (const reference of variable.references ?? []) {\n if (!reference.isRead() || reference.identifier === target) continue;\n const context = this.getStyleContext(reference.identifier);\n if (context) return context;\n }\n return null;\n }\n\n private getDirectStyleContext(node: TSESTree.Node): StyleContext | null {\n // Sub-element objects inherit their parent style object's context\n const parent = this.getSubElementParent(node);\n if (parent) {\n const inherited = this.getStyleContext(parent);\n if (inherited) return inherited;\n }\n\n // An object assigned to a `styles` key (or a `styles` JSX prop) is a style\n // object on its own terms — no enclosing tasty call or `styles`-ish variable\n // name required. Checked before the walk, which would otherwise climb past it\n // to an unrelated call or declaration and reject the whole thing.\n if (this.isStylesPropertyValue(node)) {\n // A `styles` prop is an override layer by construction: the component it\n // is handed to already carries its own styles and this object lands on\n // top of them. A Storybook `args.styles` is the same prop by another name,\n // but the component behind `args` is not on the AST path, so its base\n // stays unknown.\n return {\n type: 'tasty',\n isStaticCall: false,\n isSelectorMode: false,\n isExtending: true,\n baseComponent: jsxStylesPropTarget(node),\n };\n }\n\n let current: TSESTree.Node | undefined = node;\n\n while (current) {\n if (current.type === 'CallExpression') {\n if (this.isMergeStylesCall(current)) {\n return this.getMergeStylesContext(current, node);\n }\n\n const imp = this.isTastyCall(current);\n if (!imp) return null;\n\n const name = imp.importedName;\n const isStaticCall = name === 'tastyStatic';\n\n if (name === 'tasty') {\n return this.getTastyCallContext(current, node);\n }\n\n if (name === 'tastyStatic') {\n return this.getTastyStaticCallContext(current, node);\n }\n\n if (name === 'useStyles') {\n if (current.arguments[0] === node) {\n return {\n type: 'useStyles',\n isStaticCall: false,\n isSelectorMode: false,\n isExtending: false,\n baseComponent: null,\n };\n }\n }\n\n if (name === 'useGlobalStyles') {\n if (current.arguments[1] === node) {\n return {\n type: 'useGlobalStyles',\n isStaticCall,\n isSelectorMode: true,\n isExtending: false,\n baseComponent: null,\n };\n }\n }\n\n // Built-in signatures always take precedence over configured ones.\n const custom = this.config.styleFunctions?.[name];\n if (!TASTY_FUNCTION_NAMES.has(name) && custom) {\n return this.getCustomCallContext(current, node, custom);\n }\n\n return null;\n }\n\n if (this.isStyleVariableDeclaration(current, node)) {\n return {\n type: 'tasty',\n isStaticCall: false,\n isSelectorMode: false,\n isExtending: false,\n baseComponent: null,\n };\n }\n\n current = current.parent;\n }\n\n return null;\n }\n\n private isStyleVariableDeclaration(\n current: TSESTree.Node,\n targetNode: TSESTree.Node,\n ): boolean {\n if (\n current.type !== 'VariableDeclarator' ||\n current.id.type !== 'Identifier'\n ) {\n return false;\n }\n\n let init: TSESTree.Node | null | undefined = current.init;\n while (\n init?.type === 'TSAsExpression' ||\n init?.type === 'TSSatisfiesExpression' ||\n init?.type === 'TSTypeAssertion' ||\n init?.type === 'TSNonNullExpression'\n ) {\n init = (init as TSESTree.TSAsExpression).expression;\n }\n\n // An explicit type annotation is authoritative, in both directions, and is\n // read before anything about the name. The name heuristics below are a\n // guess; a declared type is the author stating what the object is, so it\n // wins — `const CARD_STYLES: Styles` is as much a style object as\n // `const cardStyles: Styles`.\n //\n // This matters because the rewrites these rules offer are only valid *inside*\n // tasty: `#purple.05` and `$font-sans` are correct tasty declarations and\n // meaningless as raw CSS. A `const styles: Record<string, CSSProperties>`\n // handed to React's `style={…}` was matched on name alone, so its plain CSS\n // longhands were reported as tasty violations — and `--fix` rewrote real\n // `var(--shadow-sm-color)` to `#shadow-sm`, which nothing resolves there, so\n // the browser dropped the declaration.\n const annotated = this.stylesTypeAnnotation(current);\n\n // A map of style objects: its values are checked, never the map itself.\n if (annotated === 'map') {\n return (\n init?.type === 'ObjectExpression' &&\n init.properties.some(\n (prop) =>\n prop.type === 'Property' &&\n unwrapExpression(prop.value) === targetNode,\n )\n );\n }\n\n if (init !== targetNode) return false;\n if (annotated !== null) return annotated === 'styles';\n\n const name = current.id.name;\n\n // Unannotated constants are shared values, not style objects by name alone.\n if (/^[A-Z][A-Z0-9_]*$/.test(name)) return false;\n\n // Only `styles` and `*Styles` count. The singular `style` is conventionally\n // a DOM inline-style object (`el.style`, `CSSProperties`, `setStyle(el, …)`)\n // holding raw CSS longhands, not tasty syntax — matching it reported those\n // longhands as tasty violations.\n if (name === 'styles' || name.endsWith('Styles')) {\n // The name is the weakest evidence there is, so let an unmistakable shape\n // overrule it. Without an annotation to go on, a map of named CSS blocks was\n // reported as tasty — `known-property` on every HTML tag name, each block read\n // as a state map — and `--fix` offered rewrites that are only valid inside\n // tasty.\n return !(\n targetNode.type === 'ObjectExpression' && isNamedCssBlockMap(targetNode)\n );\n }\n\n return false;\n }\n\n private getCustomCallContext(\n call: TSESTree.CallExpression,\n targetNode: TSESTree.Node,\n config: StyleFunctionConfig,\n ): StyleContext | null {\n const { argument, kind } = config;\n if (argument !== 'all' && (!Number.isInteger(argument) || argument < 0)) {\n return null;\n }\n // A preceding spread makes the runtime argument index unknown. Never apply\n // style rewrites to an object that might occupy a different parameter.\n if (\n argument !== 'all' &&\n call.arguments\n .slice(0, argument)\n .some((arg) => arg.type === 'SpreadElement')\n ) {\n return null;\n }\n\n const args =\n argument === 'all' ? call.arguments : [call.arguments[argument]];\n for (const arg of args) {\n if (!arg) continue;\n const value = unwrapExpression(arg);\n if (value.type !== 'ObjectExpression') continue;\n\n const isVariant =\n kind === 'options' && this.isInsideVariantsProperty(value, targetNode);\n const matches =\n kind === 'styles'\n ? value === targetNode\n : kind === 'options' &&\n (this.isInsideStylesProperty(value, targetNode) || isVariant);\n\n if (matches) {\n return {\n type: 'tasty',\n isStaticCall: false,\n isSelectorMode: false,\n isExtending: !isVariant && (config.partial ?? false),\n baseComponent: null,\n };\n }\n }\n\n return null;\n }\n\n /**\n * Verdict from the declared type: `'styles'` the object is tasty, `'map'` its\n * values are, `false` explicitly neither, `null` when there is no annotation to\n * go on and the caller should fall back to the name.\n *\n * A `Styles` reference anywhere in the annotation counts, so wrappers like\n * `Styles | undefined` and `Record<string, Styles>` opt in — while\n * `CSSProperties`, `Record<string, CSSProperties>` and an inline literal of\n * them opt out.\n */\n private stylesTypeAnnotation(\n node: TSESTree.VariableDeclarator,\n ): 'styles' | 'map' | false | null {\n const annotation = node.id.typeAnnotation?.typeAnnotation;\n\n if (!annotation) return null;\n\n return stylesAnnotationShape(annotation) ?? false;\n }\n\n private getTastyCallContext(\n call: TSESTree.CallExpression,\n targetNode: TSESTree.Node,\n ) {\n const args = call.arguments;\n\n // tasty({ styles: { ... } }) or tasty(Component, { styles: { ... } })\n const isExtending =\n args.length >= 2 && unwrapExpression(args[0]).type !== 'ObjectExpression';\n const optionsArg = isExtending ? args[1] : args[0];\n\n if (\n optionsArg?.type === 'ObjectExpression' &&\n this.isInsideStylesProperty(optionsArg, targetNode)\n ) {\n return {\n type: 'tasty' as const,\n isStaticCall: false,\n isSelectorMode: false,\n isExtending,\n baseComponent: isExtending ? baseComponentName(args[0]) : null,\n };\n }\n\n // Check if inside variants\n if (\n optionsArg?.type === 'ObjectExpression' &&\n this.isInsideVariantsProperty(optionsArg, targetNode)\n ) {\n return {\n type: 'tasty' as const,\n isStaticCall: false,\n isSelectorMode: false,\n isExtending: false,\n baseComponent: null,\n };\n }\n\n return null;\n }\n\n /**\n * Every object argument of `mergeStyles(base, ...overrides)` is a style\n * object. The first is the base; each later one is layered on top, where a\n * state map without `''` extends the one below it rather than replacing it.\n */\n private getMergeStylesContext(\n call: TSESTree.CallExpression,\n targetNode: TSESTree.Node,\n ): StyleContext | null {\n const index = call.arguments.findIndex(\n (arg) => unwrapExpression(arg) === targetNode,\n );\n if (index === -1) return null;\n\n return {\n type: 'tasty',\n isStaticCall: false,\n isSelectorMode: false,\n isExtending: index > 0,\n baseComponent: null,\n };\n }\n\n private getTastyStaticCallContext(\n call: TSESTree.CallExpression,\n targetNode: TSESTree.Node,\n ) {\n const args = call.arguments;\n\n // tastyStatic({ ... })\n if (args.length === 1 && args[0] === targetNode) {\n return {\n type: 'tastyStatic' as const,\n isStaticCall: true,\n isSelectorMode: false,\n isExtending: false,\n baseComponent: null,\n };\n }\n\n // tastyStatic(base, { ... }) or tastyStatic('selector', { ... })\n if (args.length === 2 && args[1] === targetNode) {\n const isSelectorMode = unwrapExpression(args[0]).type === 'Literal';\n return {\n type: 'tastyStatic' as const,\n isStaticCall: true,\n isSelectorMode,\n isExtending: !isSelectorMode,\n baseComponent: isSelectorMode ? null : baseComponentName(args[0]),\n };\n }\n\n return null;\n }\n\n private isInsideStylesProperty(\n optionsObj: TSESTree.ObjectExpression,\n targetNode: TSESTree.Node,\n ): boolean {\n for (const prop of optionsObj.properties) {\n if (\n prop.type === 'Property' &&\n !prop.computed &&\n getKeyName(prop.key) === 'styles' &&\n unwrapExpression(prop.value) === targetNode\n ) {\n return true;\n }\n }\n return false;\n }\n\n private isInsideVariantsProperty(\n optionsObj: TSESTree.ObjectExpression,\n targetNode: TSESTree.Node,\n ): boolean {\n for (const prop of optionsObj.properties) {\n if (\n prop.type === 'Property' &&\n !prop.computed &&\n getKeyName(prop.key) === 'variants'\n ) {\n const variants = unwrapExpression(prop.value);\n if (variants.type !== 'ObjectExpression') continue;\n for (const variantProp of variants.properties) {\n if (\n variantProp.type === 'Property' &&\n unwrapExpression(variantProp.value) === targetNode\n ) {\n return true;\n }\n }\n }\n }\n return false;\n }\n\n /**\n * Whether this object is a `styles` JSX prop value or a Storybook `args.styles`.\n *\n * Both are unambiguous enough to stand on their own without an import-tracked\n * call or a `styles`-ish variable name. A bare `styles` key elsewhere is not —\n * see the selector list for why.\n */\n isStylesPropertyValue(node: TSESTree.Node): boolean {\n let wrapped: TSESTree.Node = node;\n while (wrapped.parent && unwrapExpression(wrapped.parent) === node) {\n wrapped = wrapped.parent;\n }\n const parent = wrapped.parent;\n\n if (parent?.type === 'Property' && !parent.computed) {\n if (getKeyName(parent.key) !== 'styles') return false;\n\n // Only inside `args: { … }`.\n const argsObject = parent.parent;\n const argsProperty =\n argsObject?.type === 'ObjectExpression' ? argsObject.parent : undefined;\n\n return (\n argsProperty?.type === 'Property' &&\n !argsProperty.computed &&\n getKeyName(argsProperty.key) === 'args'\n );\n }\n\n if (parent?.type === 'JSXExpressionContainer') {\n const attribute = parent.parent;\n\n return (\n attribute?.type === 'JSXAttribute' &&\n attribute.name.type === 'JSXIdentifier' &&\n (attribute.name.name === 'styles' ||\n attribute.name.name.endsWith('Styles'))\n );\n }\n\n return false;\n }\n\n /**\n * Checks if a property value node is a state mapping object\n * (i.e., an object where keys are state expressions and values are style values).\n */\n isStateMap(\n node: TSESTree.ObjectExpression,\n parentProperty: TSESTree.Property,\n ): boolean {\n const keyName = getKeyName(parentProperty.key);\n if (keyName === null) return false;\n\n // If the key starts with uppercase, it's a sub-element, not a state map\n if (/^[A-Z]/.test(keyName)) return false;\n\n // Special keys are not state maps\n // At-rule blocks are not state maps — their object values are descriptor maps.\n if (SPECIAL_STYLE_KEYS.has(keyName)) return false;\n\n // If the object has keys that look like state expressions, it's a state map.\n // A lone `_` (the fallback floor) or `''` (the default) is enough — both are\n // already covered by the string-literal / identifier branches below.\n return node.properties.some((prop) => {\n if (prop.type !== 'Property') return false;\n if (prop.key.type === 'Literal' && prop.key.value === '') return true;\n if (prop.key.type === 'Identifier') return true;\n if (prop.key.type === 'Literal' && typeof prop.key.value === 'string') {\n return true;\n }\n return false;\n });\n }\n\n /**\n * Checks if a key represents a sub-element (starts with uppercase).\n */\n isSubElementKey(key: string): boolean {\n return /^[A-Z]/.test(key);\n }\n\n /**\n * Checks if a key represents a nested selector (starts with &).\n */\n isNestedSelectorKey(key: string): boolean {\n return key.startsWith('&');\n }\n\n /**\n * Checks if a key is a custom CSS property definition ($name or $$name).\n */\n isCustomPropertyKey(key: string): boolean {\n return key.startsWith('$');\n }\n\n /**\n * Checks if a key is a color token definition (#name or ##name).\n */\n isColorTokenKey(key: string): boolean {\n return key.startsWith('#');\n }\n\n /**\n * Checks if a key is a special @ property (@keyframes, @property, ...).\n */\n isSpecialKey(key: string): boolean {\n return key.startsWith('@');\n }\n}\n"],"mappings":";;;;;;;;AAyBA,SAAgB,qBACd,SAC2D;AAC3D,QAAO,EAAE,kBAAkB,SAAS;;;;;;;;;;;AAgCtC,SAAS,qBAAqB,MAAkC;CAC9D,MAAM,QAAyB,CAAC,KAAK;AAErC,QAAO,MAAM,QAAQ;EACnB,MAAM,UAAU,MAAM,KAAK;AAE3B,MACE,QAAQ,SAAS,qBACjB,QAAQ,SAAS,SAAS,gBAC1B,YAAY,KAAK,QAAQ,SAAS,KAAK,CAEvC,QAAO;AAGT,OAAK,MAAM,SAAS,OAAO,OACzB,QACD,CACC,KAAI,MAAM,QAAQ,MAAM,EACtB;QAAK,MAAM,QAAQ,MACjB,KAAI,QAAQ,OAAO,SAAS,YAAY,UAAU,KAChD,OAAM,KAAK,KAAsB;aAG5B,SAAS,OAAO,UAAU,YAAY,UAAU,OAEzD;OAAI,UAAW,QAA0B,OACvC,OAAM,KAAK,MAAuB;;;AAM1C,QAAO;;;AAIT,MAAM,yBAAyB,IAAI,IAAI;CACrC;CACA;CACA;CACA;CACD,CAAC;;;;;;;;;;;AAYF,SAAS,sBACP,MACyB;AACzB,KAAI,KAAK,SAAS,iBAAiB,KAAK,SAAS,sBAAsB;EACrE,MAAM,SAAS,KAAK,MAAM,IAAI,sBAAsB;AACpD,MAAI,OAAO,SAAS,SAAS,CAAE,QAAO;AACtC,SAAO,OAAO,SAAS,MAAM,GAAG,QAAQ;;AAG1C,KAAI,KAAK,SAAS,qBAAqB,KAAK,SAAS,SAAS,cAAc;EAC1E,MAAM,OAAO,KAAK,SAAS;EAC3B,MAAM,OAAO,KAAK,eAAe,UAAU,EAAE;AAE7C,MAAI,YAAY,KAAK,KAAK,CAAE,QAAO;AACnC,MAAI,SAAS,YAAY,KAAK,WAAW,GACvC;OAAI,sBAAsB,KAAK,GAAG,KAAK,SAAU,QAAO;;AAE1D,MAAI,uBAAuB,IAA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AQ,SAAS,0BAA0B;GAC7C,MAAM,YAAY,OAAO;AAEzB,UACE,WAAW,SAAS,kBACpB,UAAU,KAAK,SAAS,oBACvB,UAAU,KAAK,SAAS,YACvB,UAAU,KAAK,KAAK,SAAS,SAAS;;AAI5C,SAAO;;;;;;CAOT,WACE,MACA,gBACS;EACT,MAAM,UAAU,WAAW,eAAe,IAAI;AAC9C,MAAI,YAAY,KAAM,QAAO;AAG7B,MAAI,SAAS,KAAK,QAAQ,CAAE,QAAO;AAInC,MAAI,mBAAmB,IAAI,QAAQ,CAAE,QAAO;AAK5C,SAAO,KAAK,WAAW,MAAM,SAAS;AACpC,OAAI,KAAK,SAAS,WAAY,QAAO;AACrC,OAAI,KAAK,IAAI,SAAS,aAAa,KAAK,IAAI,UAAU,GAAI,QAAO;AACjE,OAAI,KAAK,IAAI,SAAS,aAAc,QAAO;AAC3C,OAAI,KAAK,IAAI,SAAS,aAAa,OAAO,KAAK,IAAI,UAAU,SAC3D,QAAO;AAET,UAAO;IACP;;;;;CAMJ,gBAAgB,KAAsB;AACpC,SAAO,SAAS,KAAK,IAAI;;;;;CAM3B,oBAAoB,KAAsB;AACxC,SAAO,IAAI,WAAW,IAAI;;;;;CAM5B,oBAAoB,KAAsB;AACxC,SAAO,IAAI,WAAW,IAAI;;;;;CAM5B,gBAAgB,KAAsB;AACpC,SAAO,IAAI,WAAW,IAAI;;;;;CAM5B,aAAa,KAAsB;AACjC,SAAO,IAAI,WAAW,IAAI"}
|
|
1
|
+
{"version":3,"file":"context.js","names":[],"sources":["../src/context.ts"],"sourcesContent":["import type { TSESTree } from '@typescript-eslint/utils';\nimport type { RuleContext } from '@typescript-eslint/utils/ts-eslint';\nimport type { ResolvedConfig, StyleFunctionConfig } from './types.js';\nimport { loadConfig } from './config.js';\nimport {\n DEFAULT_IMPORT_SOURCES,\n KNOWN_CSS_PROPERTIES,\n KNOWN_TASTY_PROPERTIES,\n SPECIAL_STYLE_KEYS,\n} from './constants.js';\nimport {\n collectLocalStateAliases,\n getKeyName,\n unwrapExpression,\n wildcardPattern,\n} from './utils.js';\nimport { finishJSXAnalysis, jsxPropKind } from './type-aware-jsx.js';\nimport { isModuleTastyComponent } from './module-components.js';\n\n/**\n * Every object is considered, then TastyContext gates it by its actual context.\n * Narrow ancestry selectors miss nested shared styles and wrapped JSX values.\n */\nexport const STYLE_OBJECT_SELECTORS = ['ObjectExpression'] as const;\n\n/** One listener per object; context recognition remains the caller's gate. */\nexport function styleObjectListeners(\n handler: (node: TSESTree.ObjectExpression) => void,\n): Record<string, (node: TSESTree.ObjectExpression) => void> {\n return { ObjectExpression: handler };\n}\n\nexport interface StyleContext {\n type: 'tasty' | 'tastyStatic' | 'useStyles' | 'useGlobalStyles';\n isStaticCall: boolean;\n isSelectorMode: boolean;\n isExtending: boolean;\n /**\n * Local name of the component this layer extends, when there is one and it is\n * an identifier. `null` covers every other case — a base definition, a\n * selector, or a layer whose base cannot be read off the AST — so a rule that\n * cares must treat `null` as \"unknown\", not as \"not extending\".\n */\n baseComponent: string | null;\n}\n\nexport interface TastyImport {\n localName: string;\n importedName: string;\n source: string;\n}\n\n/**\n * Whether a type annotation names tasty's `Styles` anywhere inside it.\n *\n * Walks the annotation rather than matching only the outermost reference, so a\n * wrapped tasty type (`Styles | undefined`, `Array<Styles>`) is recognised while\n * `CSSProperties` in the same positions is not. Maps of styles are told apart\n * first by `stylesAnnotationShape`. Deliberately name-based: the plugin has no type checker, and requiring one\n * would make every rule type-aware.\n */\nfunction referencesStylesType(node: TSESTree.TypeNode): boolean {\n const stack: TSESTree.Node[] = [node];\n\n while (stack.length) {\n const current = stack.pop()!;\n\n if (\n current.type === 'TSTypeReference' &&\n current.typeName.type === 'Identifier' &&\n /^Styles$/i.test(current.typeName.name)\n ) {\n return true;\n }\n\n for (const value of Object.values(\n current as unknown as Record<string, unknown>,\n )) {\n if (Array.isArray(value)) {\n for (const item of value) {\n if (item && typeof item === 'object' && 'type' in item) {\n stack.push(item as TSESTree.Node);\n }\n }\n } else if (value && typeof value === 'object' && 'type' in value) {\n // Skip `parent` — it points back up the tree and would loop forever.\n if (value !== (current as TSESTree.Node).parent) {\n stack.push(value as TSESTree.Node);\n }\n }\n }\n }\n\n return false;\n}\n\n/** Utility types whose result has the same shape as their argument. */\nconst SHAPE_PRESERVING_TYPES = new Set([\n 'Readonly',\n 'Partial',\n 'Required',\n 'NonNullable',\n]);\n\n/**\n * What a `Styles`-bearing annotation declares: `'styles'` for a style object,\n * `'map'` for an object whose *values* are style objects (`Record<K, Styles>`,\n * `{ [k: string]: Styles }`, `{ root: Styles }`), `null` when `Styles` does not\n * appear at all.\n *\n * The distinction matters for a map: its keys are variant or block names, so\n * checking the map itself as a style object reports every one of them as an\n * unknown property, while the style objects it holds go unchecked.\n */\nfunction stylesAnnotationShape(\n node: TSESTree.TypeNode,\n): 'styles' | 'map' | null {\n if (node.type === 'TSUnionType' || node.type === 'TSIntersectionType') {\n const shapes = node.types.map(stylesAnnotationShape);\n if (shapes.includes('styles')) return 'styles';\n return shapes.includes('map') ? 'map' : null;\n }\n\n if (node.type === 'TSTypeReference' && node.typeName.type === 'Identifier') {\n const name = node.typeName.name;\n const args = node.typeArguments?.params ?? [];\n\n if (/^Styles$/i.test(name)) return 'styles';\n if (name === 'Record' && args.length === 2) {\n if (stylesAnnotationShape(args[1]) === 'styles') return 'map';\n }\n if (SHAPE_PRESERVING_TYPES.has(name) && args.length === 1) {\n return stylesAnnotationShape(args[0]);\n }\n }\n\n if (node.type === 'TSTypeLiteral') {\n const holdsStyles = node.members.some(\n (member) =>\n (member.type === 'TSIndexSignature' ||\n member.type === 'TSPropertySignature') &&\n member.typeAnnotation !== undefined &&\n stylesAnnotationShape(member.typeAnnotation.typeAnnotation) ===\n 'styles',\n );\n if (holdsStyles) return 'map';\n }\n\n return referencesStylesType(node) ? 'styles' : null;\n}\n\n/**\n * Whether a key could plausibly be a tasty style key.\n *\n * Covers every top-level shape tasty accepts: a style property, a sub-element\n * (capitalised), an at-rule or state/custom-property/colour key (`@`, `&`, `$`,\n * `#`), and the default-state key.\n */\nfunction isPlausibleStyleKey(key: string): boolean {\n if (key === '' || key === '_') return true;\n if (/^[A-Z]/.test(key)) return true;\n if (/^[@&$#]/.test(key)) return true;\n if (SPECIAL_STYLE_KEYS.has(key)) return true;\n\n return KNOWN_TASTY_PROPERTIES.has(key) || KNOWN_CSS_PROPERTIES.has(key);\n}\n\n/**\n * Whether an object is a map of named CSS blocks rather than a tasty styles object.\n *\n * The shape is unmistakable — `{ table: {…}, th: {…}, td: {…} }`, `{ root: {…},\n * toolbar: {…} }` — and it is what a React inline-style map looks like when it\n * carries no type annotation to opt it out. Every key is a block name that is not a\n * style key, and every value is an object.\n *\n * Requiring *every* value to be an object literal is what keeps this from swallowing\n * the case it would hurt most: `const styles = { colour: 'red' }` has a string value,\n * so it is not treated as a block map and `known-property` still reports the typo.\n * Otherwise the rule that catches a misspelled property would be silenced by the\n * misspelling.\n */\nfunction isNamedCssBlockMap(node: TSESTree.ObjectExpression): boolean {\n if (node.properties.length === 0) return false;\n\n for (const prop of node.properties) {\n if (prop.type !== 'Property' || prop.computed) return false;\n\n const key = getKeyName(prop.key);\n\n if (key === null || isPlausibleStyleKey(key)) return false;\n if (prop.value.type !== 'ObjectExpression') return false;\n }\n\n return true;\n}\n\n/**\n * The outermost expression an object is the result of through conditional and\n * logical operators (and type wrappers): `cond ? { … } : null`, `cond && { … }`,\n * `styles ?? { … }`. Whatever position that expression takes, the object may\n * land in. The test of a conditional and the left of `&&` never become the\n * value, so they are not followed.\n */\nfunction conditionalFlowRoot(node: TSESTree.Node): TSESTree.Node {\n let current = node;\n // Matching unwraps type wrappers itself, so the root is the outermost\n // operator, not a wrapper around it.\n let root = node;\n while (current.parent) {\n const parent: TSESTree.Node = current.parent;\n if (\n (parent.type === 'TSAsExpression' ||\n parent.type === 'TSSatisfiesExpression' ||\n parent.type === 'TSNonNullExpression' ||\n parent.type === 'TSTypeAssertion') &&\n parent.expression === current\n ) {\n current = parent;\n } else if (\n (parent.type === 'ConditionalExpression' && parent.test !== current) ||\n (parent.type === 'LogicalExpression' &&\n (parent.right === current || parent.operator !== '&&'))\n ) {\n current = root = parent;\n } else {\n break;\n }\n }\n return root;\n}\n\n/**\n * The component a `styles` JSX prop overrides — `<Card styles={…} />` -> `Card`.\n * A namespaced tag (`<UI.Card />`) resolves to its root object, since that is the\n * name an import can be matched against.\n */\nfunction jsxStylesPropTarget(node: TSESTree.Node): string | null {\n let wrapped: TSESTree.Node = node;\n while (wrapped.parent && unwrapExpression(wrapped.parent) === node) {\n wrapped = wrapped.parent;\n }\n const container = wrapped.parent;\n if (container?.type !== 'JSXExpressionContainer') return null;\n\n const attribute = container.parent;\n if (attribute?.type !== 'JSXAttribute') return null;\n\n const element = attribute.parent;\n if (element?.type !== 'JSXOpeningElement') return null;\n\n let name: TSESTree.JSXTagNameExpression = element.name;\n while (name.type === 'JSXMemberExpression') name = name.object;\n\n return name.type === 'JSXIdentifier' ? name.name : null;\n}\n\n/**\n * The identifier a base-component argument resolves to — `tasty(UI.Card, {…})`\n * -> `UI`, which is what the import map is keyed by.\n *\n * Type assertions are stripped on the way down. Reading `Button as any` as an\n * unknown base would quietly promote an imported component to \"owned\", which is\n * the reading that produces a warning the author cannot act on.\n */\nfunction baseComponentName(node: TSESTree.Node): string | null {\n let current = unwrapExpression(node);\n\n while (current.type === 'MemberExpression') {\n current = unwrapExpression(current.object);\n }\n\n return current.type === 'Identifier' ? current.name : null;\n}\n\n/**\n * Whether `source` is inside this project. Relative and absolute specifiers are,\n * as are the conventional in-repo aliases (`~/`, `#internal`, `@/`) — `@` alone\n * is not, since `@scope/pkg` is a published package.\n */\nfunction isInRepoSource(source: string): boolean {\n return (\n source.startsWith('.') ||\n source.startsWith('/') ||\n source.startsWith('~') ||\n source.startsWith('#') ||\n source.startsWith('@/')\n );\n}\n\n/** `settings.tasty.mergeFunctions`: project helpers with `mergeStyles` semantics. */\nfunction readMergeFunctions(\n context: RuleContext<string, unknown[]>,\n): ReadonlySet<string> {\n const settings = context.settings?.tasty as\n | { mergeFunctions?: unknown }\n | undefined;\n const option = settings?.mergeFunctions;\n if (option === undefined) return new Set();\n if (\n !Array.isArray(option) ||\n option.some((name) => typeof name !== 'string')\n ) {\n throw new Error(\n 'tasty: mergeFunctions must be an array of function names.',\n );\n }\n return new Set(option);\n}\n\nconst TASTY_FUNCTION_NAMES = new Set([\n 'tasty',\n 'tastyStatic',\n 'useStyles',\n 'useGlobalStyles',\n 'mergeStyles',\n 'configure',\n]);\n\n/**\n * Context tracker for a single file's lint pass.\n * Tracks which imports come from tasty and provides\n * helpers to determine if a node is in a tasty style context.\n */\nexport class TastyContext {\n readonly config: ResolvedConfig;\n private imports = new Map<string, TastyImport>();\n private moduleSources = new Map<string, string>();\n private importSources: Set<string>;\n private mergeFunctions: ReadonlySet<string>;\n private relativeComponents = new Map<string, boolean>();\n private resolving = new Set<TSESTree.Node>();\n\n constructor(\n private context: RuleContext<string, unknown[]>,\n config?: ResolvedConfig,\n ) {\n this.config = config ?? loadConfig(context.filename);\n this.importSources = new Set([\n ...DEFAULT_IMPORT_SOURCES,\n ...this.config.importSources,\n ]);\n this.mergeFunctions = readMergeFunctions(context);\n }\n\n trackImport(node: TSESTree.ImportDeclaration): void {\n const source = node.source.value;\n\n // Every import is recorded, tasty or not. Where a *base component* comes\n // from is what tells a rule whether the file it would send the author to\n // edit is even theirs — see `isOwnedComponent`.\n for (const specifier of node.specifiers) {\n this.moduleSources.set(specifier.local.name, source);\n }\n\n if (!this.importSources.has(source) || node.importKind === 'type') return;\n\n for (const specifier of node.specifiers) {\n if (\n specifier.type === 'ImportSpecifier' &&\n specifier.importKind !== 'type'\n ) {\n const importedName =\n specifier.imported.type === 'Identifier'\n ? specifier.imported.name\n : specifier.imported.value;\n if (\n TASTY_FUNCTION_NAMES.has(importedName) ||\n Object.hasOwn(this.config.styleFunctions ?? {}, importedName)\n ) {\n this.imports.set(specifier.local.name, {\n localName: specifier.local.name,\n importedName,\n source,\n });\n }\n }\n }\n }\n\n isComponentJSXProp(node: TSESTree.JSXAttribute): boolean {\n return jsxPropKind(this.context, node) === 'component';\n }\n\n finishJSXAnalysis(): void {\n finishJSXAnalysis(this.context);\n }\n\n getImport(localName: string): TastyImport | undefined {\n return this.imports.get(localName);\n }\n\n /** The built-in and configured `importSources`. */\n get trackedSources(): ReadonlySet<string> {\n return this.importSources;\n }\n\n /**\n * Whether the base component an extension layer sits on top of lives in a file\n * this project can edit — so a rule can decide whether pointing the author at\n * the base's own definition is advice they can act on.\n *\n * A name that was never imported is declared in this very file, and an unknown\n * base (`null`) counts as owned as well: staying quiet is for a base that is\n * demonstrably someone else's, never for one the plugin merely failed to read.\n */\n isOwnedComponent(localName: string | null): boolean {\n if (localName === null) return true;\n\n const source = this.moduleSources.get(localName);\n if (source === undefined) return true;\n if (isInRepoSource(source)) return true;\n\n // `ownedSources` is optional on the public `ResolvedConfig`, so a config\n // built by a consumer rather than by `loadConfig` may not carry it.\n return (this.config.ownedSources ?? []).some((pattern) =>\n wildcardPattern(pattern).test(source),\n );\n }\n\n isTastyCall(node: TSESTree.CallExpression): TastyImport | undefined {\n const callee = unwrapExpression(node.callee);\n if (callee.type !== 'Identifier') return undefined;\n const imp = this.imports.get(callee.name);\n if (!imp) return undefined;\n\n // A parameter or local declaration can shadow the imported helper. Only\n // the import binding carries evidence that the call accepts Tasty styles.\n let scope = this.context.sourceCode.getScope(callee);\n while (scope) {\n const variable = scope.set.get(callee.name);\n if (variable) {\n return variable.defs.some((def) => def.type === 'ImportBinding')\n ? imp\n : undefined;\n }\n if (!scope.upper) break;\n scope = scope.upper;\n }\n return undefined;\n }\n\n /**\n * `mergeStyles(...)`, or a call to a project helper named in\n * `settings.tasty.mergeFunctions`. A helper matches by its imported name, so\n * an aliased import still counts, or by the name it is declared under in this\n * file; a parameter of the same name shadows it.\n */\n isMergeStylesCall(node: TSESTree.CallExpression): boolean {\n if (this.isTastyCall(node)?.importedName === 'mergeStyles') return true;\n if (this.mergeFunctions.size === 0) return false;\n\n const callee = unwrapExpression(node.callee);\n if (callee.type !== 'Identifier') return false;\n\n let scope = this.context.sourceCode.getScope(callee);\n while (scope) {\n const variable = scope.set.get(callee.name);\n if (variable) {\n return variable.defs.some((def) => {\n if (def.type === 'FunctionName' || def.type === 'Variable') {\n return this.mergeFunctions.has(callee.name);\n }\n if (\n def.type !== 'ImportBinding' ||\n def.parent.type !== 'ImportDeclaration' ||\n def.parent.importKind === 'type'\n ) {\n return false;\n }\n if (def.node.type === 'ImportDefaultSpecifier') {\n return this.mergeFunctions.has(callee.name);\n }\n if (def.node.type !== 'ImportSpecifier') return false;\n if (def.node.importKind === 'type') return false;\n const imported = def.node.imported;\n return this.mergeFunctions.has(\n imported.type === 'Identifier' ? imported.name : imported.value,\n );\n });\n }\n if (!scope.upper) break;\n scope = scope.upper;\n }\n // An undeclared global, such as an auto-imported helper.\n return this.mergeFunctions.has(callee.name);\n }\n\n /** Local factory results, const aliases, and configured component imports. */\n isTastyJSXComponent(node: TSESTree.Node, name: string): boolean {\n const visited = new Set<TSESTree.VariableDeclarator>();\n const resolve = (reference: TSESTree.Node, localName: string): boolean => {\n let scope = this.context.sourceCode.getScope(reference);\n while (scope) {\n const variable = scope.set.get(localName);\n if (variable) {\n return variable.defs.some((def) => {\n if (def.type === 'ImportBinding') {\n if (\n def.parent.type !== 'ImportDeclaration' ||\n def.parent.importKind === 'type' ||\n (def.node.type === 'ImportSpecifier' &&\n def.node.importKind === 'type')\n ) {\n return false;\n }\n const source = def.parent.source.value;\n if (this.importSources.has(source)) return true;\n return this.isRelativeTastyImport(source, def.node);\n }\n if (def.type !== 'Variable') return false;\n const declaration = def.node;\n if (\n declaration.id.type !== 'Identifier' ||\n declaration.parent.kind !== 'const' ||\n !declaration.init ||\n visited.has(declaration)\n )\n return false;\n visited.add(declaration);\n const init = unwrapExpression(declaration.init);\n if (init.type === 'Identifier') return resolve(init, init.name);\n if (init.type === 'MemberExpression' && !init.computed) {\n let member: TSESTree.Node = init;\n while (member.type === 'MemberExpression') {\n if (member.computed) return false;\n member = unwrapExpression(member.object);\n }\n const root = baseComponentName(init);\n return root !== null && resolve(init, root);\n }\n if (init.type !== 'CallExpression') return false;\n const imp = this.isTastyCall(init);\n return (\n imp?.importedName === 'tasty' ||\n (imp !== undefined &&\n this.config.styleFunctions?.[imp.importedName]?.kind ===\n 'options')\n );\n });\n }\n if (!scope.upper) break;\n scope = scope.upper;\n }\n return false;\n };\n return resolve(node, name);\n }\n\n /**\n * Whether a binding imported from a relative module names a Tasty component\n * declared there — `import { Panel } from './styled'`. A namespace import has\n * no single export to follow.\n */\n private isRelativeTastyImport(\n source: string,\n specifier: TSESTree.Node,\n ): boolean {\n if (\n specifier.type !== 'ImportSpecifier' &&\n specifier.type !== 'ImportDefaultSpecifier'\n ) {\n return false;\n }\n const exportName =\n specifier.type === 'ImportDefaultSpecifier'\n ? 'default'\n : specifier.imported.type === 'Identifier'\n ? specifier.imported.name\n : specifier.imported.value;\n const key = `${source}\\0${exportName}`;\n let result = this.relativeComponents.get(key);\n if (result === undefined) {\n result = isModuleTastyComponent(\n this.context.filename,\n source,\n exportName,\n {\n importSources: this.importSources,\n isComponentFactory: (name) =>\n name === 'tasty' ||\n this.config.styleFunctions?.[name]?.kind === 'options',\n },\n );\n this.relativeComponents.set(key, result);\n }\n return result;\n }\n\n /**\n * Determines whether an object expression is a tasty style object\n * by walking up the AST to find a recognized call expression.\n */\n isStyleObject(node: TSESTree.ObjectExpression): boolean {\n return this.getStyleContext(node) !== null;\n }\n\n private getSubElementParent(\n node: TSESTree.Node,\n ): TSESTree.ObjectExpression | null {\n let wrapped: TSESTree.Node = node;\n while (wrapped.parent && unwrapExpression(wrapped.parent) === node) {\n wrapped = wrapped.parent;\n }\n const parent = wrapped.parent;\n if (parent?.type !== 'Property' || parent.computed) return null;\n const key = getKeyName(parent.key);\n return key &&\n /^[A-Z]/.test(key) &&\n parent.parent.type === 'ObjectExpression'\n ? parent.parent\n : null;\n }\n\n /** Follow only sub-elements of recognized styles, never a variants container. */\n getRootStyleObject(\n node: TSESTree.ObjectExpression,\n ): TSESTree.ObjectExpression {\n let current = node;\n while (true) {\n const parent = this.getSubElementParent(current);\n if (!parent || !this.isStyleObject(parent)) return current;\n current = parent;\n }\n }\n\n /**\n * The `mergeStyles(...)` call, or configured merge helper call, this object\n * is a direct argument of, if any.\n */\n private getMergeStylesCall(\n node: TSESTree.ObjectExpression,\n ): TSESTree.CallExpression | null {\n let wrapped: TSESTree.Node = node;\n while (wrapped.parent && unwrapExpression(wrapped.parent) === node) {\n wrapped = wrapped.parent;\n }\n const call = wrapped.parent;\n return call?.type === 'CallExpression' &&\n call.arguments.includes(wrapped as TSESTree.CallExpressionArgument) &&\n this.isMergeStylesCall(call)\n ? call\n : null;\n }\n\n /**\n * Local `@name` state aliases visible to a style object, the way Tasty\n * resolves them: the object's own, then those of each enclosing sub-element\n * up to the root. A `mergeStyles(...)` argument stands for the merged object,\n * so every object argument of the call contributes, and a call that is a\n * sub-element value sees the aliases of the styles it sits in.\n */\n getLocalStateAliases(node: TSESTree.ObjectExpression): string[] {\n const aliases = new Set<string>();\n let current: TSESTree.ObjectExpression | null = node;\n\n while (current) {\n const call = this.getMergeStylesCall(current);\n const scope = call\n ? call.arguments\n .map((arg) => unwrapExpression(arg))\n .filter(\n (arg): arg is TSESTree.ObjectExpression =>\n arg.type === 'ObjectExpression',\n )\n : [current];\n for (const object of scope) {\n for (const alias of collectLocalStateAliases(object))\n aliases.add(alias);\n }\n\n const parent = this.getSubElementParent(call ?? current);\n current = parent && this.isStyleObject(parent) ? parent : null;\n }\n\n return [...aliases];\n }\n\n /**\n * Whether the style object this node belongs to is declared on its own — a\n * `const CELL_STYLES: Styles` or a value of a `Record<K, Styles>` — rather\n * than handed to a call or prop. Such styles can be spread anywhere,\n * including into a sub-element, so their root is not necessarily the\n * component's root.\n */\n isSharedStyleObject(node: TSESTree.ObjectExpression): boolean {\n const outermost = (inner: TSESTree.Node): TSESTree.Node => {\n let wrapped = inner;\n while (wrapped.parent && unwrapExpression(wrapped.parent) === inner) {\n wrapped = wrapped.parent;\n }\n return wrapped;\n };\n\n let parent = outermost(this.getRootStyleObject(node)).parent;\n if (\n parent?.type === 'Property' &&\n parent.parent.type === 'ObjectExpression'\n ) {\n parent = outermost(parent.parent).parent;\n }\n return parent?.type === 'VariableDeclarator';\n }\n\n /** Include helper calls nested inside a real sub-element, but not variant names. */\n isInsideSubElement(node: TSESTree.Node): boolean {\n let current = node.parent;\n while (current) {\n if (current.type === 'Property' && !current.computed) {\n const key = getKeyName(current.key);\n if (\n key &&\n /^[A-Z]/.test(key) &&\n current.parent.type === 'ObjectExpression' &&\n this.isStyleObject(current.parent)\n ) {\n return true;\n }\n }\n current = current.parent;\n }\n return false;\n }\n\n /**\n * The style context of an object, or of any expression standing where a\n * style object goes. Besides objects written in place, this covers an object\n * that reaches a style position only through a conditional or logical\n * operator (`mergeStyles(cond ? { … } : null, styles)`), and one held in a\n * render-scope variable that is then passed on (`const local = { … }`,\n * `styles = { ...styles, … }`, then `styles={local}`): Tasty receives each of\n * them as styles all the same.\n */\n getStyleContext(node: TSESTree.Node): StyleContext | null {\n // A binding can lead back into the object being resolved (`a = { X: a }`).\n if (this.resolving.has(node)) return null;\n this.resolving.add(node);\n try {\n if (node.type === 'ObjectExpression') {\n const flow = conditionalFlowRoot(node);\n if (flow !== node) return this.getStyleContext(flow);\n }\n return (\n this.getDirectStyleContext(node) ?? this.getBindingStyleContext(node)\n );\n } finally {\n this.resolving.delete(node);\n }\n }\n\n /**\n * The context of a value held in a render-scope variable, taken from the\n * first place the variable is read as styles. Module-scope bindings are\n * shared values and are left to the declaration heuristics.\n */\n private getBindingStyleContext(node: TSESTree.Node): StyleContext | null {\n let wrapped: TSESTree.Node = node;\n while (wrapped.parent && unwrapExpression(wrapped.parent) === node) {\n wrapped = wrapped.parent;\n }\n const holder = wrapped.parent;\n let target: TSESTree.Identifier | null = null;\n if (\n holder?.type === 'VariableDeclarator' &&\n holder.init === wrapped &&\n holder.id.type === 'Identifier'\n ) {\n target = holder.id;\n } else if (\n holder?.type === 'AssignmentExpression' &&\n holder.operator === '=' &&\n holder.right === wrapped &&\n holder.left.type === 'Identifier'\n ) {\n target = holder.left;\n }\n if (!target) return null;\n\n let scope = this.context.sourceCode.getScope(target);\n while (!scope.set.has(target.name) && scope.upper) scope = scope.upper;\n const variable = scope.set.get(target.name);\n if (!variable || scope.type === 'module' || scope.type === 'global') {\n return null;\n }\n\n for (const reference of variable.references ?? []) {\n if (!reference.isRead() || reference.identifier === target) continue;\n const context = this.getStyleContext(reference.identifier);\n if (context) return context;\n }\n return null;\n }\n\n private getDirectStyleContext(node: TSESTree.Node): StyleContext | null {\n // Sub-element objects inherit their parent style object's context\n const parent = this.getSubElementParent(node);\n if (parent) {\n const inherited = this.getStyleContext(parent);\n if (inherited) return inherited;\n }\n\n // An object assigned to a `styles` key (or a `styles` JSX prop) is a style\n // object on its own terms — no enclosing tasty call or `styles`-ish variable\n // name required. Checked before the walk, which would otherwise climb past it\n // to an unrelated call or declaration and reject the whole thing.\n if (this.isStylesPropertyValue(node)) {\n // A `styles` prop is an override layer by construction: the component it\n // is handed to already carries its own styles and this object lands on\n // top of them. A Storybook `args.styles` is the same prop by another name,\n // but the component behind `args` is not on the AST path, so its base\n // stays unknown.\n return {\n type: 'tasty',\n isStaticCall: false,\n isSelectorMode: false,\n isExtending: true,\n baseComponent: jsxStylesPropTarget(node),\n };\n }\n\n let current: TSESTree.Node | undefined = node;\n\n while (current) {\n if (current.type === 'CallExpression') {\n if (this.isMergeStylesCall(current)) {\n return this.getMergeStylesContext(current, node);\n }\n\n const imp = this.isTastyCall(current);\n if (!imp) return null;\n\n const name = imp.importedName;\n const isStaticCall = name === 'tastyStatic';\n\n if (name === 'tasty') {\n return this.getTastyCallContext(current, node);\n }\n\n if (name === 'tastyStatic') {\n return this.getTastyStaticCallContext(current, node);\n }\n\n if (name === 'useStyles') {\n if (current.arguments[0] === node) {\n return {\n type: 'useStyles',\n isStaticCall: false,\n isSelectorMode: false,\n isExtending: false,\n baseComponent: null,\n };\n }\n }\n\n if (name === 'useGlobalStyles') {\n if (current.arguments[1] === node) {\n return {\n type: 'useGlobalStyles',\n isStaticCall,\n isSelectorMode: true,\n isExtending: false,\n baseComponent: null,\n };\n }\n }\n\n // Built-in signatures always take precedence over configured ones.\n const custom = this.config.styleFunctions?.[name];\n if (!TASTY_FUNCTION_NAMES.has(name) && custom) {\n return this.getCustomCallContext(current, node, custom);\n }\n\n return null;\n }\n\n if (this.isStyleVariableDeclaration(current, node)) {\n return {\n type: 'tasty',\n isStaticCall: false,\n isSelectorMode: false,\n isExtending: false,\n baseComponent: null,\n };\n }\n\n current = current.parent;\n }\n\n return null;\n }\n\n private isStyleVariableDeclaration(\n current: TSESTree.Node,\n targetNode: TSESTree.Node,\n ): boolean {\n if (\n current.type !== 'VariableDeclarator' ||\n current.id.type !== 'Identifier'\n ) {\n return false;\n }\n\n let init: TSESTree.Node | null | undefined = current.init;\n while (\n init?.type === 'TSAsExpression' ||\n init?.type === 'TSSatisfiesExpression' ||\n init?.type === 'TSTypeAssertion' ||\n init?.type === 'TSNonNullExpression'\n ) {\n init = (init as TSESTree.TSAsExpression).expression;\n }\n\n // An explicit type annotation is authoritative, in both directions, and is\n // read before anything about the name. The name heuristics below are a\n // guess; a declared type is the author stating what the object is, so it\n // wins — `const CARD_STYLES: Styles` is as much a style object as\n // `const cardStyles: Styles`.\n //\n // This matters because the rewrites these rules offer are only valid *inside*\n // tasty: `#purple.05` and `$font-sans` are correct tasty declarations and\n // meaningless as raw CSS. A `const styles: Record<string, CSSProperties>`\n // handed to React's `style={…}` was matched on name alone, so its plain CSS\n // longhands were reported as tasty violations — and `--fix` rewrote real\n // `var(--shadow-sm-color)` to `#shadow-sm`, which nothing resolves there, so\n // the browser dropped the declaration.\n const annotated = this.stylesTypeAnnotation(current);\n\n // A map of style objects: its values are checked, never the map itself.\n if (annotated === 'map') {\n return (\n init?.type === 'ObjectExpression' &&\n init.properties.some(\n (prop) =>\n prop.type === 'Property' &&\n unwrapExpression(prop.value) === targetNode,\n )\n );\n }\n\n if (init !== targetNode) return false;\n if (annotated !== null) return annotated === 'styles';\n\n const name = current.id.name;\n\n // Unannotated constants are shared values, not style objects by name alone.\n if (/^[A-Z][A-Z0-9_]*$/.test(name)) return false;\n\n // Only `styles` and `*Styles` count. The singular `style` is conventionally\n // a DOM inline-style object (`el.style`, `CSSProperties`, `setStyle(el, …)`)\n // holding raw CSS longhands, not tasty syntax — matching it reported those\n // longhands as tasty violations.\n if (name === 'styles' || name.endsWith('Styles')) {\n // The name is the weakest evidence there is, so let an unmistakable shape\n // overrule it. Without an annotation to go on, a map of named CSS blocks was\n // reported as tasty — `known-property` on every HTML tag name, each block read\n // as a state map — and `--fix` offered rewrites that are only valid inside\n // tasty.\n return !(\n targetNode.type === 'ObjectExpression' && isNamedCssBlockMap(targetNode)\n );\n }\n\n return false;\n }\n\n private getCustomCallContext(\n call: TSESTree.CallExpression,\n targetNode: TSESTree.Node,\n config: StyleFunctionConfig,\n ): StyleContext | null {\n const { argument, kind } = config;\n if (argument !== 'all' && (!Number.isInteger(argument) || argument < 0)) {\n return null;\n }\n // A preceding spread makes the runtime argument index unknown. Never apply\n // style rewrites to an object that might occupy a different parameter.\n if (\n argument !== 'all' &&\n call.arguments\n .slice(0, argument)\n .some((arg) => arg.type === 'SpreadElement')\n ) {\n return null;\n }\n\n const args =\n argument === 'all' ? call.arguments : [call.arguments[argument]];\n for (const arg of args) {\n if (!arg) continue;\n const value = unwrapExpression(arg);\n if (value.type !== 'ObjectExpression') continue;\n\n const isVariant =\n kind === 'options' && this.isInsideVariantsProperty(value, targetNode);\n const matches =\n kind === 'styles'\n ? value === targetNode\n : kind === 'options' &&\n (this.isInsideStylesProperty(value, targetNode) || isVariant);\n\n if (matches) {\n return {\n type: 'tasty',\n isStaticCall: false,\n isSelectorMode: false,\n isExtending: !isVariant && (config.partial ?? false),\n baseComponent: null,\n };\n }\n }\n\n return null;\n }\n\n /**\n * Verdict from the declared type: `'styles'` the object is tasty, `'map'` its\n * values are, `false` explicitly neither, `null` when there is no annotation to\n * go on and the caller should fall back to the name.\n *\n * A `Styles` reference anywhere in the annotation counts, so wrappers like\n * `Styles | undefined` and `Record<string, Styles>` opt in — while\n * `CSSProperties`, `Record<string, CSSProperties>` and an inline literal of\n * them opt out.\n */\n private stylesTypeAnnotation(\n node: TSESTree.VariableDeclarator,\n ): 'styles' | 'map' | false | null {\n const annotation = node.id.typeAnnotation?.typeAnnotation;\n\n if (!annotation) return null;\n\n return stylesAnnotationShape(annotation) ?? false;\n }\n\n private getTastyCallContext(\n call: TSESTree.CallExpression,\n targetNode: TSESTree.Node,\n ) {\n const args = call.arguments;\n\n // tasty({ styles: { ... } }) or tasty(Component, { styles: { ... } })\n const isExtending =\n args.length >= 2 && unwrapExpression(args[0]).type !== 'ObjectExpression';\n const optionsArg = isExtending ? args[1] : args[0];\n\n if (\n optionsArg?.type === 'ObjectExpression' &&\n this.isInsideStylesProperty(optionsArg, targetNode)\n ) {\n return {\n type: 'tasty' as const,\n isStaticCall: false,\n isSelectorMode: false,\n isExtending,\n baseComponent: isExtending ? baseComponentName(args[0]) : null,\n };\n }\n\n // Check if inside variants\n if (\n optionsArg?.type === 'ObjectExpression' &&\n this.isInsideVariantsProperty(optionsArg, targetNode)\n ) {\n return {\n type: 'tasty' as const,\n isStaticCall: false,\n isSelectorMode: false,\n isExtending: false,\n baseComponent: null,\n };\n }\n\n return null;\n }\n\n /**\n * Every object argument of `mergeStyles(base, ...overrides)` is a style\n * object. The first is the base; each later one is layered on top, where a\n * state map without `''` extends the one below it rather than replacing it.\n */\n private getMergeStylesContext(\n call: TSESTree.CallExpression,\n targetNode: TSESTree.Node,\n ): StyleContext | null {\n const index = call.arguments.findIndex(\n (arg) => unwrapExpression(arg) === targetNode,\n );\n if (index === -1) return null;\n\n return {\n type: 'tasty',\n isStaticCall: false,\n isSelectorMode: false,\n isExtending: index > 0,\n baseComponent: null,\n };\n }\n\n private getTastyStaticCallContext(\n call: TSESTree.CallExpression,\n targetNode: TSESTree.Node,\n ) {\n const args = call.arguments;\n\n // tastyStatic({ ... })\n if (args.length === 1 && args[0] === targetNode) {\n return {\n type: 'tastyStatic' as const,\n isStaticCall: true,\n isSelectorMode: false,\n isExtending: false,\n baseComponent: null,\n };\n }\n\n // tastyStatic(base, { ... }) or tastyStatic('selector', { ... })\n if (args.length === 2 && args[1] === targetNode) {\n const isSelectorMode = unwrapExpression(args[0]).type === 'Literal';\n return {\n type: 'tastyStatic' as const,\n isStaticCall: true,\n isSelectorMode,\n isExtending: !isSelectorMode,\n baseComponent: isSelectorMode ? null : baseComponentName(args[0]),\n };\n }\n\n return null;\n }\n\n private isInsideStylesProperty(\n optionsObj: TSESTree.ObjectExpression,\n targetNode: TSESTree.Node,\n ): boolean {\n for (const prop of optionsObj.properties) {\n if (\n prop.type === 'Property' &&\n !prop.computed &&\n getKeyName(prop.key) === 'styles' &&\n unwrapExpression(prop.value) === targetNode\n ) {\n return true;\n }\n }\n return false;\n }\n\n private isInsideVariantsProperty(\n optionsObj: TSESTree.ObjectExpression,\n targetNode: TSESTree.Node,\n ): boolean {\n for (const prop of optionsObj.properties) {\n if (\n prop.type === 'Property' &&\n !prop.computed &&\n getKeyName(prop.key) === 'variants'\n ) {\n const variants = unwrapExpression(prop.value);\n if (variants.type !== 'ObjectExpression') continue;\n for (const variantProp of variants.properties) {\n if (\n variantProp.type === 'Property' &&\n unwrapExpression(variantProp.value) === targetNode\n ) {\n return true;\n }\n }\n }\n }\n return false;\n }\n\n /**\n * Whether this object is a `styles` JSX prop value or a Storybook `args.styles`.\n *\n * Both are unambiguous enough to stand on their own without an import-tracked\n * call or a `styles`-ish variable name. A bare `styles` key elsewhere is not —\n * see the selector list for why.\n */\n isStylesPropertyValue(node: TSESTree.Node): boolean {\n let wrapped: TSESTree.Node = node;\n while (wrapped.parent && unwrapExpression(wrapped.parent) === node) {\n wrapped = wrapped.parent;\n }\n const parent = wrapped.parent;\n\n if (parent?.type === 'Property' && !parent.computed) {\n if (getKeyName(parent.key) !== 'styles') return false;\n\n // Only inside `args: { … }`.\n const argsObject = parent.parent;\n const argsProperty =\n argsObject?.type === 'ObjectExpression' ? argsObject.parent : undefined;\n\n return (\n argsProperty?.type === 'Property' &&\n !argsProperty.computed &&\n getKeyName(argsProperty.key) === 'args'\n );\n }\n\n if (parent?.type === 'JSXExpressionContainer') {\n const attribute = parent.parent;\n\n return (\n attribute?.type === 'JSXAttribute' &&\n attribute.name.type === 'JSXIdentifier' &&\n (attribute.name.name === 'styles' ||\n attribute.name.name.endsWith('Styles'))\n );\n }\n\n return false;\n }\n\n /**\n * Checks if a property value node is a state mapping object\n * (i.e., an object where keys are state expressions and values are style values).\n */\n isStateMap(\n node: TSESTree.ObjectExpression,\n parentProperty: TSESTree.Property,\n ): boolean {\n const keyName = getKeyName(parentProperty.key);\n if (keyName === null) return false;\n\n // If the key starts with uppercase, it's a sub-element, not a state map\n if (/^[A-Z]/.test(keyName)) return false;\n\n // Special keys are not state maps\n // At-rule blocks are not state maps — their object values are descriptor maps.\n if (SPECIAL_STYLE_KEYS.has(keyName)) return false;\n\n // If the object has keys that look like state expressions, it's a state map.\n // A lone `_` (the fallback floor) or `''` (the default) is enough — both are\n // already covered by the string-literal / identifier branches below.\n return node.properties.some((prop) => {\n if (prop.type !== 'Property') return false;\n if (prop.key.type === 'Literal' && prop.key.value === '') return true;\n if (prop.key.type === 'Identifier') return true;\n if (prop.key.type === 'Literal' && typeof prop.key.value === 'string') {\n return true;\n }\n return false;\n });\n }\n\n /**\n * Checks if a key represents a sub-element (starts with uppercase).\n */\n isSubElementKey(key: string): boolean {\n return /^[A-Z]/.test(key);\n }\n\n /**\n * Checks if a key represents a nested selector (starts with &).\n */\n isNestedSelectorKey(key: string): boolean {\n return key.startsWith('&');\n }\n\n /**\n * Checks if a key is a custom CSS property definition ($name or $$name).\n */\n isCustomPropertyKey(key: string): boolean {\n return key.startsWith('$');\n }\n\n /**\n * Checks if a key is a color token definition (#name or ##name).\n */\n isColorTokenKey(key: string): boolean {\n return key.startsWith('#');\n }\n\n /**\n * Checks if a key is a special @ property (@keyframes, @property, ...).\n */\n isSpecialKey(key: string): boolean {\n return key.startsWith('@');\n }\n}\n"],"mappings":";;;;;;;;AA0BA,SAAgB,qBACd,SAC2D;AAC3D,QAAO,EAAE,kBAAkB,SAAS;;;;;;;;;;;AAgCtC,SAAS,qBAAqB,MAAkC;CAC9D,MAAM,QAAyB,CAAC,KAAK;AAErC,QAAO,MAAM,QAAQ;EACnB,MAAM,UAAU,MAAM,KAAK;AAE3B,MACE,QAAQ,SAAS,qBACjB,QAAQ,SAAS,SAAS,gBAC1B,YAAY,KAAK,QAAQ,SAAS,KAAK,CAEvC,QAAO;AAGT,OAAK,MAAM,SAAS,OAAO,OACzB,QACD,CACC,KAAI,MAAM,QAAQ,MAAM,EACtB;QAAK,MAAM,QAAQ,MACjB,KAAI,QAAQ,OAAO,SAAS,YAAY,UAAU,KAChD,OAAM,KAAK,KAAsB;aAG5B,SAAS,OAAO,UAAU,YAAY,UAAU,OAEzD;OAAI,UAAW,QAA0B,OACvC,OAAM,KAAK,MAAuB;;;AAM1C,QAAO;;;AAIT,MAAM,yBAAyB,IAAI,IAAI;CACrC;CACA;CACA;CACA;CACD,CAAC;;;;;;;;;;;AAYF,SAAS,sBACP,MACyB;AACzB,KAAI,KAAK,SAAS,iBAAiB,KAAK,SAAS,sBAAsB;EACrE,MAAM,SAAS,KAAK,MAAM,IAAI,sBAAsB;AACpD,MAAI,OAAO,SAAS,SAAS,CAAE,QAAO;AACtC,SAAO,OAAO,SAAS,MAAM,GAAG,QAAQ;;AAG1C,KAAI,KAAK,SAAS,qBAAqB,KAAK,SAAS,SAAS,cAAc;EAC1E,MAAM,OAAO,KAAK,SAAS;EAC3B,MAAM,OAAO,KAAK,eAAe,UAAU,EAAE;AAE7C,MAAI,YAAY,KAAK,KAAK,CAAE,Q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Q,SAAS,0BAA0B;GAC7C,MAAM,YAAY,OAAO;AAEzB,UACE,WAAW,SAAS,kBACpB,UAAU,KAAK,SAAS,oBACvB,UAAU,KAAK,SAAS,YACvB,UAAU,KAAK,KAAK,SAAS,SAAS;;AAI5C,SAAO;;;;;;CAOT,WACE,MACA,gBACS;EACT,MAAM,UAAU,WAAW,eAAe,IAAI;AAC9C,MAAI,YAAY,KAAM,QAAO;AAG7B,MAAI,SAAS,KAAK,QAAQ,CAAE,QAAO;AAInC,MAAI,mBAAmB,IAAI,QAAQ,CAAE,QAAO;AAK5C,SAAO,KAAK,WAAW,MAAM,SAAS;AACpC,OAAI,KAAK,SAAS,WAAY,QAAO;AACrC,OAAI,KAAK,IAAI,SAAS,aAAa,KAAK,IAAI,UAAU,GAAI,QAAO;AACjE,OAAI,KAAK,IAAI,SAAS,aAAc,QAAO;AAC3C,OAAI,KAAK,IAAI,SAAS,aAAa,OAAO,KAAK,IAAI,UAAU,SAC3D,QAAO;AAET,UAAO;IACP;;;;;CAMJ,gBAAgB,KAAsB;AACpC,SAAO,SAAS,KAAK,IAAI;;;;;CAM3B,oBAAoB,KAAsB;AACxC,SAAO,IAAI,WAAW,IAAI;;;;;CAM5B,oBAAoB,KAAsB;AACxC,SAAO,IAAI,WAAW,IAAI;;;;;CAM5B,gBAAgB,KAAsB;AACpC,SAAO,IAAI,WAAW,IAAI;;;;;CAM5B,aAAa,KAAsB;AACjC,SAAO,IAAI,WAAW,IAAI"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { recommended, strict } from "./configs.js";
|
|
2
2
|
import { TypeAwareJSXOptions } from "./type-aware-jsx.js";
|
|
3
|
-
import { ResolvedConfig, StyleFunctionConfig, TastyValidationConfig } from "./types.js";
|
|
3
|
+
import { ProtectedComponentConfig, ResolvedConfig, StyleFunctionConfig, TastyValidationConfig } from "./types.js";
|
|
4
4
|
|
|
5
5
|
//#region src/index.d.ts
|
|
6
6
|
declare const plugin: any;
|
|
7
7
|
//#endregion
|
|
8
|
-
export { type ResolvedConfig, type StyleFunctionConfig, type TastyValidationConfig, type TypeAwareJSXOptions, plugin as default, recommended, strict };
|
|
8
|
+
export { type ProtectedComponentConfig, type ResolvedConfig, type StyleFunctionConfig, type TastyValidationConfig, type TypeAwareJSXOptions, plugin as default, recommended, strict };
|
|
9
9
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -28,6 +28,7 @@ import no_raw_motion_duration_default from "./rules/no-raw-motion-duration.js";
|
|
|
28
28
|
import no_styles_prop_default from "./rules/no-styles-prop.js";
|
|
29
29
|
import no_style_prop_default from "./rules/no-style-prop.js";
|
|
30
30
|
import no_classname_prop_default from "./rules/no-classname-prop.js";
|
|
31
|
+
import no_protected_restyle_default from "./rules/no-protected-restyle.js";
|
|
31
32
|
import consistent_token_usage_default from "./rules/consistent-token-usage.js";
|
|
32
33
|
import no_runtime_styles_mutation_default from "./rules/no-runtime-styles-mutation.js";
|
|
33
34
|
import no_style_spread_default from "./rules/no-style-spread.js";
|
|
@@ -76,6 +77,7 @@ const ruleMap = {
|
|
|
76
77
|
"no-styles-prop": no_styles_prop_default,
|
|
77
78
|
"no-style-prop": no_style_prop_default,
|
|
78
79
|
"no-classname-prop": no_classname_prop_default,
|
|
80
|
+
"no-protected-restyle": no_protected_restyle_default,
|
|
79
81
|
"consistent-token-usage": consistent_token_usage_default,
|
|
80
82
|
"no-runtime-styles-mutation": no_runtime_styles_mutation_default,
|
|
81
83
|
"no-style-spread": no_style_spread_default,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["rules.knownProperty","rules.validValue","rules.validColorToken","rules.validCustomUnit","rules.validStateKey","rules.validStylesStructure","rules.noNestedSelector","rules.noStateInSelector","rules.preferElementSelector","rules.validCustomProperty","rules.validPreset","rules.validRecipe","rules.validBooleanProperty","rules.validDirectionalModifier","rules.validRadiusShape","rules.noImportant","rules.validSubElement","rules.noNestedStateMap","rules.staticNoDynamicValues","rules.staticValidSelector","rules.preferShorthandProperty","rules.validTransition","rules.requireDefaultState","rules.noUnknownStateAlias","rules.noRawColorValues","rules.noRawTransitionDuration","rules.noRawMotionDuration","rules.noStylesProp","rules.noStyleProp","rules.noClassNameProp","rules.consistentTokenUsage","rules.noRuntimeStylesMutation","rules.noStyleSpread","rules.validStateDefinition","rules.noOwnAtRoot","rules.noIgnoredPseudoElementState","rules.validDefaultStateOrder","rules.preferAutoCalc","rules.preferStateNegation","rules.preferCustomPropertySyntax","rules.preferHide","rules.preferDirectionalShorthand","rules.preferLonghandProperty"],"sources":["../src/index.ts"],"sourcesContent":["import { createRequire } from 'node:module';\nimport type { TSESLint } from '@typescript-eslint/utils';\nimport * as rules from './rules/index.js';\nimport { recommended, strict } from './configs.js';\n\nconst ruleMap: Record<string, TSESLint.RuleModule<string, unknown[]>> = {\n 'known-property': rules.knownProperty,\n 'valid-value': rules.validValue,\n 'valid-color-token': rules.validColorToken,\n 'valid-custom-unit': rules.validCustomUnit,\n 'valid-state-key': rules.validStateKey,\n 'valid-styles-structure': rules.validStylesStructure,\n 'no-nested-selector': rules.noNestedSelector,\n 'no-state-in-selector': rules.noStateInSelector,\n 'prefer-element-selector': rules.preferElementSelector,\n 'valid-custom-property': rules.validCustomProperty,\n 'valid-preset': rules.validPreset,\n 'valid-recipe': rules.validRecipe,\n 'valid-boolean-property': rules.validBooleanProperty,\n 'valid-directional-modifier': rules.validDirectionalModifier,\n 'valid-radius-shape': rules.validRadiusShape,\n 'no-important': rules.noImportant,\n 'valid-sub-element': rules.validSubElement,\n 'no-nested-state-map': rules.noNestedStateMap,\n 'static-no-dynamic-values': rules.staticNoDynamicValues,\n 'static-valid-selector': rules.staticValidSelector,\n 'prefer-shorthand-property': rules.preferShorthandProperty,\n 'valid-transition': rules.validTransition,\n 'require-default-state': rules.requireDefaultState,\n 'no-unknown-state-alias': rules.noUnknownStateAlias,\n 'no-raw-color-values': rules.noRawColorValues,\n 'no-raw-transition-duration': rules.noRawTransitionDuration,\n 'no-raw-motion-duration': rules.noRawMotionDuration,\n 'no-styles-prop': rules.noStylesProp,\n 'no-style-prop': rules.noStyleProp,\n 'no-classname-prop': rules.noClassNameProp,\n 'consistent-token-usage': rules.consistentTokenUsage,\n 'no-runtime-styles-mutation': rules.noRuntimeStylesMutation,\n 'no-style-spread': rules.noStyleSpread,\n 'valid-state-definition': rules.validStateDefinition,\n 'no-own-at-root': rules.noOwnAtRoot,\n 'no-ignored-pseudo-element-state': rules.noIgnoredPseudoElementState,\n 'valid-default-state-order': rules.validDefaultStateOrder,\n 'prefer-auto-calc': rules.preferAutoCalc,\n 'prefer-state-negation': rules.preferStateNegation,\n 'prefer-custom-property-syntax': rules.preferCustomPropertySyntax,\n 'prefer-hide': rules.preferHide,\n 'prefer-directional-shorthand': rules.preferDirectionalShorthand,\n 'prefer-longhand-property': rules.preferLonghandProperty,\n};\n\n// Read from package.json so `meta.version` cannot drift from the released\n// version, as the previous hardcoded literal had. `../package.json` resolves to\n// the package root from both `src/` and the unbundled `dist/`.\nconst { version } = createRequire(import.meta.url)('../package.json') as {\n version: string;\n};\n\nconst plugin = {\n meta: {\n name: '@tenphi/eslint-plugin-tasty',\n version,\n },\n rules: ruleMap,\n configs: {\n recommended: {\n plugins: {\n get tasty() {\n return plugin;\n },\n },\n rules: recommended,\n },\n strict: {\n plugins: {\n get tasty() {\n return plugin;\n },\n },\n rules: strict,\n },\n },\n} satisfies TSESLint.FlatConfig.Plugin & {\n configs: Record<string, TSESLint.FlatConfig.Config>;\n};\n\nexport default plugin;\n\nexport { recommended, strict } from './configs.js';\nexport type { TypeAwareJSXOptions } from './type-aware-jsx.js';\nexport type {\n TastyValidationConfig,\n ResolvedConfig,\n StyleFunctionConfig,\n} from './types.js';\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":["rules.knownProperty","rules.validValue","rules.validColorToken","rules.validCustomUnit","rules.validStateKey","rules.validStylesStructure","rules.noNestedSelector","rules.noStateInSelector","rules.preferElementSelector","rules.validCustomProperty","rules.validPreset","rules.validRecipe","rules.validBooleanProperty","rules.validDirectionalModifier","rules.validRadiusShape","rules.noImportant","rules.validSubElement","rules.noNestedStateMap","rules.staticNoDynamicValues","rules.staticValidSelector","rules.preferShorthandProperty","rules.validTransition","rules.requireDefaultState","rules.noUnknownStateAlias","rules.noRawColorValues","rules.noRawTransitionDuration","rules.noRawMotionDuration","rules.noStylesProp","rules.noStyleProp","rules.noClassNameProp","rules.noProtectedRestyle","rules.consistentTokenUsage","rules.noRuntimeStylesMutation","rules.noStyleSpread","rules.validStateDefinition","rules.noOwnAtRoot","rules.noIgnoredPseudoElementState","rules.validDefaultStateOrder","rules.preferAutoCalc","rules.preferStateNegation","rules.preferCustomPropertySyntax","rules.preferHide","rules.preferDirectionalShorthand","rules.preferLonghandProperty"],"sources":["../src/index.ts"],"sourcesContent":["import { createRequire } from 'node:module';\nimport type { TSESLint } from '@typescript-eslint/utils';\nimport * as rules from './rules/index.js';\nimport { recommended, strict } from './configs.js';\n\nconst ruleMap: Record<string, TSESLint.RuleModule<string, unknown[]>> = {\n 'known-property': rules.knownProperty,\n 'valid-value': rules.validValue,\n 'valid-color-token': rules.validColorToken,\n 'valid-custom-unit': rules.validCustomUnit,\n 'valid-state-key': rules.validStateKey,\n 'valid-styles-structure': rules.validStylesStructure,\n 'no-nested-selector': rules.noNestedSelector,\n 'no-state-in-selector': rules.noStateInSelector,\n 'prefer-element-selector': rules.preferElementSelector,\n 'valid-custom-property': rules.validCustomProperty,\n 'valid-preset': rules.validPreset,\n 'valid-recipe': rules.validRecipe,\n 'valid-boolean-property': rules.validBooleanProperty,\n 'valid-directional-modifier': rules.validDirectionalModifier,\n 'valid-radius-shape': rules.validRadiusShape,\n 'no-important': rules.noImportant,\n 'valid-sub-element': rules.validSubElement,\n 'no-nested-state-map': rules.noNestedStateMap,\n 'static-no-dynamic-values': rules.staticNoDynamicValues,\n 'static-valid-selector': rules.staticValidSelector,\n 'prefer-shorthand-property': rules.preferShorthandProperty,\n 'valid-transition': rules.validTransition,\n 'require-default-state': rules.requireDefaultState,\n 'no-unknown-state-alias': rules.noUnknownStateAlias,\n 'no-raw-color-values': rules.noRawColorValues,\n 'no-raw-transition-duration': rules.noRawTransitionDuration,\n 'no-raw-motion-duration': rules.noRawMotionDuration,\n 'no-styles-prop': rules.noStylesProp,\n 'no-style-prop': rules.noStyleProp,\n 'no-classname-prop': rules.noClassNameProp,\n 'no-protected-restyle': rules.noProtectedRestyle,\n 'consistent-token-usage': rules.consistentTokenUsage,\n 'no-runtime-styles-mutation': rules.noRuntimeStylesMutation,\n 'no-style-spread': rules.noStyleSpread,\n 'valid-state-definition': rules.validStateDefinition,\n 'no-own-at-root': rules.noOwnAtRoot,\n 'no-ignored-pseudo-element-state': rules.noIgnoredPseudoElementState,\n 'valid-default-state-order': rules.validDefaultStateOrder,\n 'prefer-auto-calc': rules.preferAutoCalc,\n 'prefer-state-negation': rules.preferStateNegation,\n 'prefer-custom-property-syntax': rules.preferCustomPropertySyntax,\n 'prefer-hide': rules.preferHide,\n 'prefer-directional-shorthand': rules.preferDirectionalShorthand,\n 'prefer-longhand-property': rules.preferLonghandProperty,\n};\n\n// Read from package.json so `meta.version` cannot drift from the released\n// version, as the previous hardcoded literal had. `../package.json` resolves to\n// the package root from both `src/` and the unbundled `dist/`.\nconst { version } = createRequire(import.meta.url)('../package.json') as {\n version: string;\n};\n\nconst plugin = {\n meta: {\n name: '@tenphi/eslint-plugin-tasty',\n version,\n },\n rules: ruleMap,\n configs: {\n recommended: {\n plugins: {\n get tasty() {\n return plugin;\n },\n },\n rules: recommended,\n },\n strict: {\n plugins: {\n get tasty() {\n return plugin;\n },\n },\n rules: strict,\n },\n },\n} satisfies TSESLint.FlatConfig.Plugin & {\n configs: Record<string, TSESLint.FlatConfig.Config>;\n};\n\nexport default plugin;\n\nexport { recommended, strict } from './configs.js';\nexport type { TypeAwareJSXOptions } from './type-aware-jsx.js';\nexport type {\n TastyValidationConfig,\n ResolvedConfig,\n StyleFunctionConfig,\n ProtectedComponentConfig,\n} from './types.js';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,MAAM,UAAkE;CACtE,kBAAkBA;CAClB,eAAeC;CACf,qBAAqBC;CACrB,qBAAqBC;CACrB,mBAAmBC;CACnB,0BAA0BC;CAC1B,sBAAsBC;CACtB,wBAAwBC;CACxB,2BAA2BC;CAC3B,yBAAyBC;CACzB,gBAAgBC;CAChB,gBAAgBC;CAChB,0BAA0BC;CAC1B,8BAA8BC;CAC9B,sBAAsBC;CACtB,gBAAgBC;CAChB,qBAAqBC;CACrB,uBAAuBC;CACvB,4BAA4BC;CAC5B,yBAAyBC;CACzB,6BAA6BC;CAC7B,oBAAoBC;CACpB,yBAAyBC;CACzB,0BAA0BC;CAC1B,uBAAuBC;CACvB,8BAA8BC;CAC9B,0BAA0BC;CAC1B,kBAAkBC;CAClB,iBAAiBC;CACjB,qBAAqBC;CACrB,wBAAwBC;CACxB,0BAA0BC;CAC1B,8BAA8BC;CAC9B,mBAAmBC;CACnB,0BAA0BC;CAC1B,kBAAkBC;CAClB,mCAAmCC;CACnC,6BAA6BC;CAC7B,oBAAoBC;CACpB,yBAAyBC;CACzB,iCAAiCC;CACjC,eAAeC;CACf,gCAAgCC;CAChC,4BAA4BC;CAC7B;AAKD,MAAM,EAAE,YAAY,cAAc,OAAO,KAAK,IAAI,CAAC,kBAAkB;AAIrE,MAAM,SAAS;CACb,MAAM;EACJ,MAAM;EACN;EACD;CACD,OAAO;CACP,SAAS;EACP,aAAa;GACX,SAAS,EACP,IAAI,QAAQ;AACV,WAAO;MAEV;GACD,OAAO;GACR;EACD,QAAQ;GACN,SAAS,EACP,IAAI,QAAQ;AACV,WAAO;MAEV;GACD,OAAO;GACR;EACF;CACF"}
|
|
@@ -167,7 +167,83 @@ function isModuleTastyComponent(fromFile, specifier, exportName, options, visite
|
|
|
167
167
|
if (exportName === "default") return false;
|
|
168
168
|
return info.starSources.some((source) => isModuleTastyComponent(filename, source, exportName, options, visited));
|
|
169
169
|
}
|
|
170
|
+
/**
|
|
171
|
+
* Follow `exportName` of the module `specifier` (relative to `fromFile`) to the
|
|
172
|
+
* package import it comes from: through re-exports, `const` aliases, namespace
|
|
173
|
+
* members (`UI.Button` is `Button`, `Text.Strong` is `Text`), and factory
|
|
174
|
+
* wrappers whose first argument is the component they extend.
|
|
175
|
+
*/
|
|
176
|
+
function resolveModuleExportOrigin(fromFile, specifier, exportName, options, visited = /* @__PURE__ */ new Set()) {
|
|
177
|
+
if (!specifier.startsWith(".")) return null;
|
|
178
|
+
const filename = resolveRelativeModule(fromFile, specifier);
|
|
179
|
+
if (filename === null) return null;
|
|
180
|
+
const key = `${filename}\0${exportName}`;
|
|
181
|
+
if (visited.has(key)) return null;
|
|
182
|
+
visited.add(key);
|
|
183
|
+
const info = readModule(filename);
|
|
184
|
+
if (!info) return null;
|
|
185
|
+
const T = getTypeScript();
|
|
186
|
+
const fromImport = (binding, member) => {
|
|
187
|
+
const name = binding.imported === "*" ? member : binding.imported;
|
|
188
|
+
if (name === void 0) return null;
|
|
189
|
+
if (!binding.source.startsWith(".")) return {
|
|
190
|
+
source: binding.source,
|
|
191
|
+
name,
|
|
192
|
+
wrapped: false
|
|
193
|
+
};
|
|
194
|
+
return resolveModuleExportOrigin(filename, binding.source, name, options, visited);
|
|
195
|
+
};
|
|
196
|
+
const seenLocals = /* @__PURE__ */ new Set();
|
|
197
|
+
const fromLocal = (name, member) => {
|
|
198
|
+
const seen = `${name}\0${member ?? ""}`;
|
|
199
|
+
if (seenLocals.has(seen)) return null;
|
|
200
|
+
seenLocals.add(seen);
|
|
201
|
+
const init = info.constants.get(name);
|
|
202
|
+
if (init) return fromExpression(init, member);
|
|
203
|
+
const binding = info.imports.get(name);
|
|
204
|
+
return binding ? fromImport(binding, member) : null;
|
|
205
|
+
};
|
|
206
|
+
const fromExpression = (node, member) => {
|
|
207
|
+
while (T.isParenthesizedExpression(node) || T.isAsExpression(node) || T.isSatisfiesExpression(node) || T.isNonNullExpression(node) || T.isTypeAssertionExpression(node)) node = node.expression;
|
|
208
|
+
if (T.isIdentifier(node)) return fromLocal(node.text, member);
|
|
209
|
+
if (T.isPropertyAccessExpression(node)) {
|
|
210
|
+
let root = node;
|
|
211
|
+
let first = member;
|
|
212
|
+
while (T.isPropertyAccessExpression(root)) {
|
|
213
|
+
first = root.name.text;
|
|
214
|
+
root = root.expression;
|
|
215
|
+
}
|
|
216
|
+
return T.isIdentifier(root) ? fromLocal(root.text, first) : null;
|
|
217
|
+
}
|
|
218
|
+
if (member === void 0 && T.isCallExpression(node) && T.isIdentifier(node.expression)) {
|
|
219
|
+
const binding = info.imports.get(node.expression.text);
|
|
220
|
+
const base = node.arguments[0];
|
|
221
|
+
if (!binding || !options.importSources.has(binding.source) || !options.isComponentFactory(binding.imported) || !base || T.isObjectLiteralExpression(base)) return null;
|
|
222
|
+
const origin = fromExpression(base);
|
|
223
|
+
return origin && {
|
|
224
|
+
...origin,
|
|
225
|
+
wrapped: true
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
return null;
|
|
229
|
+
};
|
|
230
|
+
const local = info.exports.get(exportName);
|
|
231
|
+
if (local !== void 0) return fromLocal(local);
|
|
232
|
+
if (exportName === "default" && info.defaultExpression) return fromExpression(info.defaultExpression);
|
|
233
|
+
const reexport = info.reexports.get(exportName);
|
|
234
|
+
if (reexport) return fromImport(reexport);
|
|
235
|
+
if (exportName === "default") return null;
|
|
236
|
+
for (const source of info.starSources) {
|
|
237
|
+
const origin = source.startsWith(".") ? resolveModuleExportOrigin(filename, source, exportName, options, visited) : options.isOriginSource(source) ? {
|
|
238
|
+
source,
|
|
239
|
+
name: exportName,
|
|
240
|
+
wrapped: false
|
|
241
|
+
} : null;
|
|
242
|
+
if (origin) return origin;
|
|
243
|
+
}
|
|
244
|
+
return null;
|
|
245
|
+
}
|
|
170
246
|
|
|
171
247
|
//#endregion
|
|
172
|
-
export { isModuleTastyComponent };
|
|
248
|
+
export { isModuleTastyComponent, resolveModuleExportOrigin };
|
|
173
249
|
//# sourceMappingURL=module-components.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module-components.js","names":[],"sources":["../src/module-components.ts"],"sourcesContent":["import { readFileSync, statSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport { dirname, extname, join, resolve } from 'node:path';\nimport type ts from 'typescript';\n\n/**\n * Whether an export of a relative module is a Tasty component.\n *\n * Elements of a design-system component usually live next to it in `styled.ts`\n * or `elements.ts`, so a rule that only recognises `tasty()` results declared in\n * the file being linted misses most of them. This reads the imported module the\n * same syntactic way: an export is a component when it is a `tasty()` call (or a\n * configured options-kind factory), a `const` alias of one, an import from a\n * configured source, or a re-export that leads to one of those.\n *\n * Parsing goes through TypeScript, an optional peer dependency. Without it, an\n * imported component is simply not recognised, which is how it was before.\n */\nexport interface ModuleComponentOptions {\n importSources: ReadonlySet<string>;\n /** Imported names whose call result is a Tasty component. */\n isComponentFactory(importedName: string): boolean;\n}\n\ntype TypeScript = typeof ts;\n\ninterface ImportBinding {\n source: string;\n /** `'default'`, `'*'` for a namespace, or the exported name. */\n imported: string;\n}\n\ninterface ModuleInfo {\n imports: Map<string, ImportBinding>;\n constants: Map<string, ts.Expression>;\n /** Exported name -> local name. */\n exports: Map<string, string>;\n reexports: Map<string, ImportBinding>;\n starSources: string[];\n defaultExpression?: ts.Expression;\n}\n\nconst require = createRequire(import.meta.url);\nlet typescript: TypeScript | null | undefined;\nconst modules = new Map<string, { version: string; info: ModuleInfo }>();\n\nconst EXTENSIONS = [\n '.ts',\n '.tsx',\n '.mts',\n '.cts',\n '.js',\n '.jsx',\n '.mjs',\n '.cjs',\n];\n// A TypeScript ESM import names the emitted file: `./styled.js` is `styled.ts`.\nconst SOURCE_EXTENSIONS: Record<string, string[]> = {\n '.js': ['.ts', '.tsx'],\n '.jsx': ['.tsx'],\n '.mjs': ['.mts'],\n '.cjs': ['.cts'],\n};\n\nfunction getTypeScript(): TypeScript | null {\n if (typescript === undefined) {\n try {\n const module = require('typescript') as Partial<TypeScript>;\n // TypeScript 7 (the native port) exports only its version.\n typescript =\n typeof module.createSourceFile === 'function'\n ? (module as TypeScript)\n : null;\n } catch {\n typescript = null;\n }\n }\n return typescript;\n}\n\nfunction version(filename: string): string | null {\n try {\n const stat = statSync(filename);\n return stat.isFile() ? `${stat.mtimeMs}:${stat.size}` : null;\n } catch {\n return null;\n }\n}\n\n/** Resolve a relative specifier the way a bundler would, without `paths`. */\nexport function resolveRelativeModule(\n fromFile: string,\n specifier: string,\n): string | null {\n const base = resolve(dirname(fromFile), specifier);\n const extension = extname(base);\n const candidates = [\n ...(EXTENSIONS.includes(extension) ? [base] : []),\n ...(SOURCE_EXTENSIONS[extension] ?? []).map(\n (replacement) => base.slice(0, -extension.length) + replacement,\n ),\n ...EXTENSIONS.map((ext) => base + ext),\n ...EXTENSIONS.map((ext) => join(base, 'index' + ext)),\n ];\n\n return candidates.find((candidate) => version(candidate) !== null) ?? null;\n}\n\nfunction hasModifier(node: ts.Node, kind: ts.SyntaxKind): boolean {\n const T = getTypeScript()!;\n return (\n T.canHaveModifiers(node) &&\n (T.getModifiers(node)?.some((modifier) => modifier.kind === kind) ?? false)\n );\n}\n\nfunction readModule(filename: string): ModuleInfo | null {\n const T = getTypeScript();\n const current = version(filename);\n if (!T || current === null) return null;\n\n const cached = modules.get(filename);\n if (cached?.version === current) return cached.info;\n\n const source = T.createSourceFile(\n filename,\n readFileSync(filename, 'utf8'),\n T.ScriptTarget.Latest,\n );\n const info: ModuleInfo = {\n imports: new Map(),\n constants: new Map(),\n exports: new Map(),\n reexports: new Map(),\n starSources: [],\n };\n\n for (const statement of source.statements) {\n if (T.isImportDeclaration(statement)) {\n const clause = statement.importClause;\n if (!clause || clause.isTypeOnly) continue;\n if (!T.isStringLiteral(statement.moduleSpecifier)) continue;\n const from = statement.moduleSpecifier.text;\n if (clause.name) {\n info.imports.set(clause.name.text, {\n source: from,\n imported: 'default',\n });\n }\n const bindings = clause.namedBindings;\n if (bindings && T.isNamespaceImport(bindings)) {\n info.imports.set(bindings.name.text, { source: from, imported: '*' });\n } else if (bindings) {\n for (const element of bindings.elements) {\n if (element.isTypeOnly) continue;\n info.imports.set(element.name.text, {\n source: from,\n imported: (element.propertyName ?? element.name).text,\n });\n }\n }\n } else if (T.isVariableStatement(statement)) {\n if (!(statement.declarationList.flags & T.NodeFlags.Const)) continue;\n const exported = hasModifier(statement, T.SyntaxKind.ExportKeyword);\n for (const declaration of statement.declarationList.declarations) {\n if (!T.isIdentifier(declaration.name) || !declaration.initializer) {\n continue;\n }\n const name = declaration.name.text;\n info.constants.set(name, declaration.initializer);\n if (exported) info.exports.set(name, name);\n }\n } else if (T.isExportDeclaration(statement)) {\n if (statement.isTypeOnly) continue;\n const from =\n statement.moduleSpecifier &&\n T.isStringLiteral(statement.moduleSpecifier)\n ? statement.moduleSpecifier.text\n : null;\n const clause = statement.exportClause;\n if (!clause) {\n if (from !== null) info.starSources.push(from);\n } else if (T.isNamedExports(clause)) {\n for (const element of clause.elements) {\n if (element.isTypeOnly) continue;\n const local = (element.propertyName ?? element.name).text;\n if (from === null) info.exports.set(element.name.text, local);\n else\n info.reexports.set(element.name.text, {\n source: from,\n imported: local,\n });\n }\n }\n } else if (T.isExportAssignment(statement) && !statement.isExportEquals) {\n info.defaultExpression = statement.expression;\n }\n }\n\n modules.set(filename, { version: current, info });\n return info;\n}\n\n/** Whether `exportName` of the module `specifier` (relative to `fromFile`) is a Tasty component. */\nexport function isModuleTastyComponent(\n fromFile: string,\n specifier: string,\n exportName: string,\n options: ModuleComponentOptions,\n visited = new Set<string>(),\n): boolean {\n if (!specifier.startsWith('.')) return false;\n const filename = resolveRelativeModule(fromFile, specifier);\n if (filename === null) return false;\n\n const key = `${filename}\\0${exportName}`;\n if (visited.has(key)) return false;\n visited.add(key);\n\n const info = readModule(filename);\n if (!info) return false;\n const T = getTypeScript()!;\n\n const fromImport = (binding: ImportBinding): boolean =>\n options.importSources.has(binding.source) ||\n (binding.imported !== '*' &&\n isModuleTastyComponent(\n filename,\n binding.source,\n binding.imported,\n options,\n visited,\n ));\n\n const seenLocals = new Set<string>();\n const fromLocal = (name: string): boolean => {\n if (seenLocals.has(name)) return false;\n seenLocals.add(name);\n const init = info.constants.get(name);\n if (init) return fromExpression(init);\n const binding = info.imports.get(name);\n return binding !== undefined && fromImport(binding);\n };\n\n const fromExpression = (node: ts.Expression): boolean => {\n while (\n T.isParenthesizedExpression(node) ||\n T.isAsExpression(node) ||\n T.isSatisfiesExpression(node) ||\n T.isNonNullExpression(node) ||\n T.isTypeAssertionExpression(node)\n ) {\n node = node.expression;\n }\n if (T.isIdentifier(node)) return fromLocal(node.text);\n if (T.isPropertyAccessExpression(node)) {\n // `UI.Panel` from `import * as UI from './ui'` is that module's `Panel`.\n if (T.isIdentifier(node.expression)) {\n const binding = info.imports.get(node.expression.text);\n if (\n binding?.imported === '*' &&\n !options.importSources.has(binding.source)\n ) {\n return isModuleTastyComponent(\n filename,\n binding.source,\n node.name.text,\n options,\n visited,\n );\n }\n }\n let root: ts.Expression = node;\n while (T.isPropertyAccessExpression(root)) root = root.expression;\n return T.isIdentifier(root) && fromLocal(root.text);\n }\n if (T.isCallExpression(node) && T.isIdentifier(node.expression)) {\n const binding = info.imports.get(node.expression.text);\n return (\n binding !== undefined &&\n options.importSources.has(binding.source) &&\n options.isComponentFactory(binding.imported)\n );\n }\n return false;\n };\n\n const local = info.exports.get(exportName);\n if (local !== undefined) return fromLocal(local);\n if (exportName === 'default' && info.defaultExpression) {\n return fromExpression(info.defaultExpression);\n }\n const reexport = info.reexports.get(exportName);\n if (reexport) return fromImport(reexport);\n if (exportName === 'default') return false;\n\n return info.starSources.some((source) =>\n isModuleTastyComponent(filename, source, exportName, options, visited),\n );\n}\n"],"mappings":";;;;;AA0CA,MAAM,UAAU,cAAc,OAAO,KAAK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AQ,KAAK,QAAQ,IAAI,WAAW;AAC1C,KAAI,UAAU,OAAW,QAAO,UAAU,MAAM;AAChD,KAAI,eAAe,aAAa,KAAK,kBACnC,QAAO,eAAe,KAAK,kBAAkB;CAE/C,MAAM,WAAW,KAAK,UAAU,IAAI,WAAW;AAC/C,KAAI,SAAU,QAAO,WAAW,SAAS;AACzC,KAAI,eAAe,UAAW,QAAO;AAErC,QAAO,KAAK,YAAY,MAAM,WAC5B,uBAAuB,UAAU,QAAQ,YAAY,SAAS,QAAQ,CACvE"}
|
|
1
|
+
{"version":3,"file":"module-components.js","names":[],"sources":["../src/module-components.ts"],"sourcesContent":["import { readFileSync, statSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport { dirname, extname, join, resolve } from 'node:path';\nimport type ts from 'typescript';\n\n/**\n * Whether an export of a relative module is a Tasty component.\n *\n * Elements of a design-system component usually live next to it in `styled.ts`\n * or `elements.ts`, so a rule that only recognises `tasty()` results declared in\n * the file being linted misses most of them. This reads the imported module the\n * same syntactic way: an export is a component when it is a `tasty()` call (or a\n * configured options-kind factory), a `const` alias of one, an import from a\n * configured source, or a re-export that leads to one of those.\n *\n * Parsing goes through TypeScript, an optional peer dependency. Without it, an\n * imported component is simply not recognised, which is how it was before.\n */\nexport interface ModuleComponentOptions {\n importSources: ReadonlySet<string>;\n /** Imported names whose call result is a Tasty component. */\n isComponentFactory(importedName: string): boolean;\n}\n\ntype TypeScript = typeof ts;\n\ninterface ImportBinding {\n source: string;\n /** `'default'`, `'*'` for a namespace, or the exported name. */\n imported: string;\n}\n\ninterface ModuleInfo {\n imports: Map<string, ImportBinding>;\n constants: Map<string, ts.Expression>;\n /** Exported name -> local name. */\n exports: Map<string, string>;\n reexports: Map<string, ImportBinding>;\n starSources: string[];\n defaultExpression?: ts.Expression;\n}\n\nconst require = createRequire(import.meta.url);\nlet typescript: TypeScript | null | undefined;\nconst modules = new Map<string, { version: string; info: ModuleInfo }>();\n\nconst EXTENSIONS = [\n '.ts',\n '.tsx',\n '.mts',\n '.cts',\n '.js',\n '.jsx',\n '.mjs',\n '.cjs',\n];\n// A TypeScript ESM import names the emitted file: `./styled.js` is `styled.ts`.\nconst SOURCE_EXTENSIONS: Record<string, string[]> = {\n '.js': ['.ts', '.tsx'],\n '.jsx': ['.tsx'],\n '.mjs': ['.mts'],\n '.cjs': ['.cts'],\n};\n\nfunction getTypeScript(): TypeScript | null {\n if (typescript === undefined) {\n try {\n const module = require('typescript') as Partial<TypeScript>;\n // TypeScript 7 (the native port) exports only its version.\n typescript =\n typeof module.createSourceFile === 'function'\n ? (module as TypeScript)\n : null;\n } catch {\n typescript = null;\n }\n }\n return typescript;\n}\n\nfunction version(filename: string): string | null {\n try {\n const stat = statSync(filename);\n return stat.isFile() ? `${stat.mtimeMs}:${stat.size}` : null;\n } catch {\n return null;\n }\n}\n\n/** Resolve a relative specifier the way a bundler would, without `paths`. */\nexport function resolveRelativeModule(\n fromFile: string,\n specifier: string,\n): string | null {\n const base = resolve(dirname(fromFile), specifier);\n const extension = extname(base);\n const candidates = [\n ...(EXTENSIONS.includes(extension) ? [base] : []),\n ...(SOURCE_EXTENSIONS[extension] ?? []).map(\n (replacement) => base.slice(0, -extension.length) + replacement,\n ),\n ...EXTENSIONS.map((ext) => base + ext),\n ...EXTENSIONS.map((ext) => join(base, 'index' + ext)),\n ];\n\n return candidates.find((candidate) => version(candidate) !== null) ?? null;\n}\n\nfunction hasModifier(node: ts.Node, kind: ts.SyntaxKind): boolean {\n const T = getTypeScript()!;\n return (\n T.canHaveModifiers(node) &&\n (T.getModifiers(node)?.some((modifier) => modifier.kind === kind) ?? false)\n );\n}\n\nfunction readModule(filename: string): ModuleInfo | null {\n const T = getTypeScript();\n const current = version(filename);\n if (!T || current === null) return null;\n\n const cached = modules.get(filename);\n if (cached?.version === current) return cached.info;\n\n const source = T.createSourceFile(\n filename,\n readFileSync(filename, 'utf8'),\n T.ScriptTarget.Latest,\n );\n const info: ModuleInfo = {\n imports: new Map(),\n constants: new Map(),\n exports: new Map(),\n reexports: new Map(),\n starSources: [],\n };\n\n for (const statement of source.statements) {\n if (T.isImportDeclaration(statement)) {\n const clause = statement.importClause;\n if (!clause || clause.isTypeOnly) continue;\n if (!T.isStringLiteral(statement.moduleSpecifier)) continue;\n const from = statement.moduleSpecifier.text;\n if (clause.name) {\n info.imports.set(clause.name.text, {\n source: from,\n imported: 'default',\n });\n }\n const bindings = clause.namedBindings;\n if (bindings && T.isNamespaceImport(bindings)) {\n info.imports.set(bindings.name.text, { source: from, imported: '*' });\n } else if (bindings) {\n for (const element of bindings.elements) {\n if (element.isTypeOnly) continue;\n info.imports.set(element.name.text, {\n source: from,\n imported: (element.propertyName ?? element.name).text,\n });\n }\n }\n } else if (T.isVariableStatement(statement)) {\n if (!(statement.declarationList.flags & T.NodeFlags.Const)) continue;\n const exported = hasModifier(statement, T.SyntaxKind.ExportKeyword);\n for (const declaration of statement.declarationList.declarations) {\n if (!T.isIdentifier(declaration.name) || !declaration.initializer) {\n continue;\n }\n const name = declaration.name.text;\n info.constants.set(name, declaration.initializer);\n if (exported) info.exports.set(name, name);\n }\n } else if (T.isExportDeclaration(statement)) {\n if (statement.isTypeOnly) continue;\n const from =\n statement.moduleSpecifier &&\n T.isStringLiteral(statement.moduleSpecifier)\n ? statement.moduleSpecifier.text\n : null;\n const clause = statement.exportClause;\n if (!clause) {\n if (from !== null) info.starSources.push(from);\n } else if (T.isNamedExports(clause)) {\n for (const element of clause.elements) {\n if (element.isTypeOnly) continue;\n const local = (element.propertyName ?? element.name).text;\n if (from === null) info.exports.set(element.name.text, local);\n else\n info.reexports.set(element.name.text, {\n source: from,\n imported: local,\n });\n }\n }\n } else if (T.isExportAssignment(statement) && !statement.isExportEquals) {\n info.defaultExpression = statement.expression;\n }\n }\n\n modules.set(filename, { version: current, info });\n return info;\n}\n\n/** Whether `exportName` of the module `specifier` (relative to `fromFile`) is a Tasty component. */\nexport function isModuleTastyComponent(\n fromFile: string,\n specifier: string,\n exportName: string,\n options: ModuleComponentOptions,\n visited = new Set<string>(),\n): boolean {\n if (!specifier.startsWith('.')) return false;\n const filename = resolveRelativeModule(fromFile, specifier);\n if (filename === null) return false;\n\n const key = `${filename}\\0${exportName}`;\n if (visited.has(key)) return false;\n visited.add(key);\n\n const info = readModule(filename);\n if (!info) return false;\n const T = getTypeScript()!;\n\n const fromImport = (binding: ImportBinding): boolean =>\n options.importSources.has(binding.source) ||\n (binding.imported !== '*' &&\n isModuleTastyComponent(\n filename,\n binding.source,\n binding.imported,\n options,\n visited,\n ));\n\n const seenLocals = new Set<string>();\n const fromLocal = (name: string): boolean => {\n if (seenLocals.has(name)) return false;\n seenLocals.add(name);\n const init = info.constants.get(name);\n if (init) return fromExpression(init);\n const binding = info.imports.get(name);\n return binding !== undefined && fromImport(binding);\n };\n\n const fromExpression = (node: ts.Expression): boolean => {\n while (\n T.isParenthesizedExpression(node) ||\n T.isAsExpression(node) ||\n T.isSatisfiesExpression(node) ||\n T.isNonNullExpression(node) ||\n T.isTypeAssertionExpression(node)\n ) {\n node = node.expression;\n }\n if (T.isIdentifier(node)) return fromLocal(node.text);\n if (T.isPropertyAccessExpression(node)) {\n // `UI.Panel` from `import * as UI from './ui'` is that module's `Panel`.\n if (T.isIdentifier(node.expression)) {\n const binding = info.imports.get(node.expression.text);\n if (\n binding?.imported === '*' &&\n !options.importSources.has(binding.source)\n ) {\n return isModuleTastyComponent(\n filename,\n binding.source,\n node.name.text,\n options,\n visited,\n );\n }\n }\n let root: ts.Expression = node;\n while (T.isPropertyAccessExpression(root)) root = root.expression;\n return T.isIdentifier(root) && fromLocal(root.text);\n }\n if (T.isCallExpression(node) && T.isIdentifier(node.expression)) {\n const binding = info.imports.get(node.expression.text);\n return (\n binding !== undefined &&\n options.importSources.has(binding.source) &&\n options.isComponentFactory(binding.imported)\n );\n }\n return false;\n };\n\n const local = info.exports.get(exportName);\n if (local !== undefined) return fromLocal(local);\n if (exportName === 'default' && info.defaultExpression) {\n return fromExpression(info.defaultExpression);\n }\n const reexport = info.reexports.get(exportName);\n if (reexport) return fromImport(reexport);\n if (exportName === 'default') return false;\n\n return info.starSources.some((source) =>\n isModuleTastyComponent(filename, source, exportName, options, visited),\n );\n}\n\n/** The package import an export of a relative module comes from. */\nexport interface ModuleExportOrigin {\n /** The package specifier, as written in the import. */\n source: string;\n /** The name the package exports it under. */\n name: string;\n /** Whether a component factory call, such as `tasty(Button)`, wraps it. */\n wrapped: boolean;\n}\n\nexport interface ModuleOriginOptions extends ModuleComponentOptions {\n /** Whether `export * from source` may provide the name being followed. */\n isOriginSource(source: string): boolean;\n}\n\n/**\n * Follow `exportName` of the module `specifier` (relative to `fromFile`) to the\n * package import it comes from: through re-exports, `const` aliases, namespace\n * members (`UI.Button` is `Button`, `Text.Strong` is `Text`), and factory\n * wrappers whose first argument is the component they extend.\n */\nexport function resolveModuleExportOrigin(\n fromFile: string,\n specifier: string,\n exportName: string,\n options: ModuleOriginOptions,\n visited = new Set<string>(),\n): ModuleExportOrigin | null {\n if (!specifier.startsWith('.')) return null;\n const filename = resolveRelativeModule(fromFile, specifier);\n if (filename === null) return null;\n\n const key = `${filename}\\0${exportName}`;\n if (visited.has(key)) return null;\n visited.add(key);\n\n const info = readModule(filename);\n if (!info) return null;\n const T = getTypeScript()!;\n\n const fromImport = (\n binding: ImportBinding,\n member?: string,\n ): ModuleExportOrigin | null => {\n const name = binding.imported === '*' ? member : binding.imported;\n if (name === undefined) return null;\n if (!binding.source.startsWith('.')) {\n return { source: binding.source, name, wrapped: false };\n }\n return resolveModuleExportOrigin(\n filename,\n binding.source,\n name,\n options,\n visited,\n );\n };\n\n const seenLocals = new Set<string>();\n const fromLocal = (\n name: string,\n member?: string,\n ): ModuleExportOrigin | null => {\n const seen = `${name}\\0${member ?? ''}`;\n if (seenLocals.has(seen)) return null;\n seenLocals.add(seen);\n const init = info.constants.get(name);\n if (init) return fromExpression(init, member);\n const binding = info.imports.get(name);\n return binding ? fromImport(binding, member) : null;\n };\n\n const fromExpression = (\n node: ts.Expression,\n member?: string,\n ): ModuleExportOrigin | null => {\n while (\n T.isParenthesizedExpression(node) ||\n T.isAsExpression(node) ||\n T.isSatisfiesExpression(node) ||\n T.isNonNullExpression(node) ||\n T.isTypeAssertionExpression(node)\n ) {\n node = node.expression;\n }\n if (T.isIdentifier(node)) return fromLocal(node.text, member);\n if (T.isPropertyAccessExpression(node)) {\n let root: ts.Expression = node;\n let first = member;\n while (T.isPropertyAccessExpression(root)) {\n first = root.name.text;\n root = root.expression;\n }\n return T.isIdentifier(root) ? fromLocal(root.text, first) : null;\n }\n if (\n member === undefined &&\n T.isCallExpression(node) &&\n T.isIdentifier(node.expression)\n ) {\n const binding = info.imports.get(node.expression.text);\n const base = node.arguments[0];\n if (\n !binding ||\n !options.importSources.has(binding.source) ||\n !options.isComponentFactory(binding.imported) ||\n !base ||\n T.isObjectLiteralExpression(base)\n ) {\n return null;\n }\n const origin = fromExpression(base);\n return origin && { ...origin, wrapped: true };\n }\n return null;\n };\n\n const local = info.exports.get(exportName);\n if (local !== undefined) return fromLocal(local);\n if (exportName === 'default' && info.defaultExpression) {\n return fromExpression(info.defaultExpression);\n }\n const reexport = info.reexports.get(exportName);\n if (reexport) return fromImport(reexport);\n if (exportName === 'default') return null;\n\n for (const source of info.starSources) {\n const origin = source.startsWith('.')\n ? resolveModuleExportOrigin(\n filename,\n source,\n exportName,\n options,\n visited,\n )\n : options.isOriginSource(source)\n ? { source, name: exportName, wrapped: false }\n : null;\n if (origin) return origin;\n }\n return null;\n}\n"],"mappings":";;;;;AA0CA,MAAM,UAAU,cAAc,OAAO,KAAK,IAAI;AAC9C,IAAI;AACJ,MAAM,0BAAU,IAAI,KAAoD;AAExE,MAAM,aAAa;CACjB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,MAAM,oBAA8C;CAClD,OAAO,CAAC,OAAO,OAAO;CACtB,QAAQ,CAAC,OAAO;CAChB,QAAQ,CAAC,OAAO;CAChB,QAAQ,CAAC,OAAO;CAC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