Skip to content

Commit

Permalink
Fix new errors from ESTree spec changes
Browse files Browse the repository at this point in the history
  • Loading branch information
soren121 committed Dec 15, 2024
1 parent 25233a7 commit e70b975
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/eslint-plugin/src/rules/import-from-emotion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,20 @@ export default createRule<never[], keyof typeof messages>({
node.specifiers[0].type ===
AST_NODE_TYPES.ImportDefaultSpecifier
) {
type ImportSpecifierWithIdentifier =
TSESTree.ImportSpecifier & {
imported: TSESTree.Identifier
}

return fixer.replaceText(
node,
`import ${
node.specifiers[0].local.name
} from '@emotion/styled';\nimport { ${node.specifiers
.filter(
(x): x is TSESTree.ImportSpecifier =>
x.type === AST_NODE_TYPES.ImportSpecifier
(x): x is ImportSpecifierWithIdentifier =>
x.type === AST_NODE_TYPES.ImportSpecifier &&
x.imported.type === AST_NODE_TYPES.Identifier
)
.map(x =>
x.local.name === x.imported.name
Expand Down
2 changes: 2 additions & 0 deletions packages/eslint-plugin/src/rules/jsx-import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ export default createRule<RuleOptions, keyof typeof messages>({
let jsxSpecifier = x.specifiers.find(
x =>
x.type === AST_NODE_TYPES.ImportSpecifier &&
x.imported.type === AST_NODE_TYPES.Identifier &&
x.imported.name === 'jsx'
)
if (jsxSpecifier) {
Expand Down Expand Up @@ -253,6 +254,7 @@ export default createRule<RuleOptions, keyof typeof messages>({
let cssSpecifier = specifiers.find(
x =>
x.type === AST_NODE_TYPES.ImportSpecifier &&
x.imported.type === AST_NODE_TYPES.Identifier &&
x.imported.name === 'css'
)

Expand Down

0 comments on commit e70b975

Please sign in to comment.