diff --git a/packages/eslint-plugin/rules/no-top-level-material-ui-4-imports.js b/packages/eslint-plugin/rules/no-top-level-material-ui-4-imports.js index 76a928a5e5..dc2a555e24 100644 --- a/packages/eslint-plugin/rules/no-top-level-material-ui-4-imports.js +++ b/packages/eslint-plugin/rules/no-top-level-material-ui-4-imports.js @@ -32,8 +32,6 @@ module.exports = { fixable: 'code', messages: { topLevelImport: 'Top level imports for Material UI are not allowed', - thirdLevelImport: - 'Third level or deeper imports for Material UI are not allowed', }, docs: { description: 'Forbid top level import from Material UI v4 packages.', @@ -65,15 +63,11 @@ module.exports = { ) return; - // Report third level or deeper imports + // Return if third level or deeper imports if ( - node.specifiers.length === 1 && + node.specifiers.length >= 1 && node.source.value.split('/').length > 3 ) { - context.report({ - node, - messageId: 'thirdLevelImport', - }); return; } diff --git a/packages/eslint-plugin/src/no-top-level-material-ui-4-imports.test.ts b/packages/eslint-plugin/src/no-top-level-material-ui-4-imports.test.ts index ac0b3770e0..568bdb8cc8 100644 --- a/packages/eslint-plugin/src/no-top-level-material-ui-4-imports.test.ts +++ b/packages/eslint-plugin/src/no-top-level-material-ui-4-imports.test.ts @@ -38,6 +38,12 @@ ruleTester.run('path-imports-rule', rule, { { code: `import SvgIcon, { SvgIconProps } from '@material-ui/core/SvgIcon';`, }, + { + code: `import { StyleRules } from '@material-ui/core/styles/withStyles';`, + }, + { + code: `import { CreateCSSProperties, StyledComponentProps } from '@material-ui/core/styles/withStyles';`, + }, ], invalid: [ { @@ -68,10 +74,6 @@ import DialogTitle from '@material-ui/core/DialogTitle'; import Grid from '@material-ui/core/Grid'; import { makeStyles } from '@material-ui/core/styles';`, }, - { - code: `import { TabIndicator } from '@material-ui/core/Tabs/TabIndicator';`, - errors: [{ messageId: 'thirdLevelImport' }], - }, { code: `import { Box, Button, makeStyles } from '@material-ui/core';`, errors: [{ messageId: 'topLevelImport' }],