emotion-js/emotion · error · Error
Unexpected null when attempting to fix ${context.getFilename
Error message
Unexpected null when attempting to fix ${context.getFilename()} - please file a github issue at ${REPO_URL} What it means
The jsx-import ESLint rule's autofixer replaces the @jsxImportSource pragma comment; it asserts the comment node it located earlier is non-null when the fix runs. If it's null at fix time (an internal invariant violation), it throws and asks the user to file a GitHub issue.
Source
Thrown at packages/eslint-plugin/src/rules/jsx-import.ts:115
node,
messageId: 'cssProp',
data: { importSource },
fix(fixer) {
return fixer.insertTextBefore(
sourceCode.ast.body[0],
`/** @jsxImportSource ${importSource} */\n`
)
}
})
} else if (!validJsxImportSource && jsxImportSourcePragmaComment) {
context.report({
node,
messageId: 'cssProp',
data: { importSource },
fix(fixer) {
/* istanbul ignore if */
if (jsxImportSourcePragmaComment === null) {
throw new Error(
`Unexpected null when attempting to fix ${context.getFilename()} - please file a github issue at ${REPO_URL}`
)
}
return fixer.replaceText(
jsxImportSourcePragmaComment,
`/** @jsxImportSource ${importSource} */`
)
}
})
}
}
}
}
return {
JSXAttribute(node) {
if (node.name.name !== 'css') {View on GitHub (pinned to b882bcba85)
Solutions
- File a GitHub issue at the emotion repo with the file and ESLint config reproducing it
- Temporarily disable the jsx-import rule (or run without --fix) for that file
- Update @emotion/eslint-plugin to the latest version in case the bug is fixed
Defensive patterns
Strategy: try-catch
Validate before calling
// no pre-call validation possible; this is an internal invariant of the rule's fixer
Prevention
- Keep @emotion/eslint-plugin and eslint versions compatible and current
- If it reproduces, minimize the file and report it to the emotion repo
- Run lint without --fix in CI to surface issues before autofix runs
When it happens
Trigger: Running eslint --fix on JSX code where the rule reported 'cssProp' but the previously captured jsxImportSourcePragmaComment reference became null when the fixer executed.
Common situations: A plugin/rule bug rather than user error — potentially triggered by unusual comment positioning or interactions with other fixing rules between suggestion and fix phases.
Related errors
- @emotion/babel-plugin-jsx-pragmatic: You must specify `modul
- You have specified that '${importSource}' re-exports '${reex
- The 'autoLabel' option must be undefined, or one of the foll
- There is no transformer for the export '${exportName}' in '$
- The `runtime` option has been removed. If you want to config
AI-assisted analysis of emotion-js/emotion@b882bcba85 (2026-09-02).
Data as JSON: /api/errors/a3559546f427e0b0.
Report an issue: GitHub.