From 7965c57e86b1afeaffbcd33dfed3f0efa61d98c9 Mon Sep 17 00:00:00 2001 From: Andre Wanlin Date: Fri, 22 Dec 2023 12:56:47 -0600 Subject: [PATCH] Removed third level or deeper reporting Signed-off-by: Andre Wanlin --- .../rules/no-top-level-material-ui-4-imports.js | 10 ++-------- .../src/no-top-level-material-ui-4-imports.test.ts | 10 ++++++---- 2 files changed, 8 insertions(+), 12 deletions(-) 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' }],