Removed third level or deeper reporting

Signed-off-by: Andre Wanlin <awanlin@spotify.com>
This commit is contained in:
Andre Wanlin
2023-12-22 12:56:47 -06:00
parent 834d2f530e
commit 7965c57e86
2 changed files with 8 additions and 12 deletions
@@ -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;
}
@@ -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' }],