diff --git a/packages/eslint-plugin/src/rules/import-from-emotion.ts b/packages/eslint-plugin/src/rules/import-from-emotion.ts index c390ff1d7..e710f39b7 100644 --- a/packages/eslint-plugin/src/rules/import-from-emotion.ts +++ b/packages/eslint-plugin/src/rules/import-from-emotion.ts @@ -42,14 +42,20 @@ export default createRule({ 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 diff --git a/packages/eslint-plugin/src/rules/jsx-import.ts b/packages/eslint-plugin/src/rules/jsx-import.ts index 68bb68520..54a623dc5 100644 --- a/packages/eslint-plugin/src/rules/jsx-import.ts +++ b/packages/eslint-plugin/src/rules/jsx-import.ts @@ -160,6 +160,7 @@ export default createRule({ 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) { @@ -253,6 +254,7 @@ export default createRule({ let cssSpecifier = specifiers.find( x => x.type === AST_NODE_TYPES.ImportSpecifier && + x.imported.type === AST_NODE_TYPES.Identifier && x.imported.name === 'css' )