diff --git a/.changeset/forty-spiders-warn.md b/.changeset/forty-spiders-warn.md new file mode 100644 index 0000000..753a575 --- /dev/null +++ b/.changeset/forty-spiders-warn.md @@ -0,0 +1,5 @@ +--- +'@pandacss/eslint-plugin': patch +--- + +Warn when sourceCode is not detected diff --git a/plugin/src/utils/helpers.ts b/plugin/src/utils/helpers.ts index dd726ba..2f4104a 100644 --- a/plugin/src/utils/helpers.ts +++ b/plugin/src/utils/helpers.ts @@ -101,7 +101,14 @@ export const isPandaIsh = (name: string, context: RuleContext) => { const findDeclaration = (name: string, context: RuleContext) => { try { - const scope = analyze(context.sourceCode.ast, { + const src = context.sourceCode + + if (!src) { + console.warn("⚠️ ESLint's sourceCode is not available. Ensure that the rule is invoked with valid code.") + return undefined + } + + const scope = analyze(src.ast, { sourceType: 'module', }) const decl = scope.variables