diff --git a/.changeset/light-cooks-deny.md b/.changeset/light-cooks-deny.md new file mode 100644 index 0000000..08886e2 --- /dev/null +++ b/.changeset/light-cooks-deny.md @@ -0,0 +1,5 @@ +--- +"@pandacss/eslint-plugin": patch +--- + +Improve nested styling detection in `no-invalid-nesting` rule diff --git a/plugin/src/rules/no-invalid-nesting.ts b/plugin/src/rules/no-invalid-nesting.ts index 55b5421..9a342b6 100644 --- a/plugin/src/rules/no-invalid-nesting.ts +++ b/plugin/src/rules/no-invalid-nesting.ts @@ -1,6 +1,6 @@ import { isIdentifier, isLiteral, isObjectExpression, isTemplateLiteral } from '../utils/nodes' import { type Rule, createRule } from '../utils' -import { isInJSXProp, isInPandaFunction } from '../utils/helpers' +import { isPandaAttribute } from '../utils/helpers' export const RULE_NAME = 'no-invalid-nesting' @@ -21,7 +21,7 @@ const rule: Rule = createRule({ return { Property(node) { if (!isObjectExpression(node.value) || isIdentifier(node.key)) return - if (!isInPandaFunction(node, context) && !isInJSXProp(node, context)) return + if (isPandaAttribute(node, context)) return const invalidLiteral = isLiteral(node.key) && typeof node.key.value === 'string' && !node.key.value.includes('&') diff --git a/plugin/src/utils/helpers.ts b/plugin/src/utils/helpers.ts index dcc7227..822bcc4 100644 --- a/plugin/src/utils/helpers.ts +++ b/plugin/src/utils/helpers.ts @@ -163,7 +163,7 @@ export const isPandaProp = (node: TSESTree.JSXAttribute, context: RuleContext, calleeName: string) => { +export const isStyledProperty = (node: TSESTree.Property, context: RuleContext, calleeName?: string) => { if (!isIdentifier(node.key) && !isLiteral(node.key) && !isTemplateLiteral(node.key)) return if (isIdentifier(node.key) && !isValidProperty(node.key.name, context, calleeName)) return @@ -221,7 +221,7 @@ export const isPandaAttribute = (node: TSESTree.Property, context: RuleContext) => {