Merge pull request #26919 from backstage/freben/mui-grid

exclude the data-grid package from the imports rule
This commit is contained in:
Fredrik Adelöw
2024-10-07 11:16:53 +02:00
committed by GitHub
3 changed files with 10 additions and 0 deletions
@@ -135,6 +135,8 @@ module.exports = {
if (!node.source.value.startsWith('@material-ui/')) return;
// Return if import is from '@material-ui/core/styles', as it's valid already
if (node.source.value === '@material-ui/core/styles') return;
// Ignore the @material-ui/data-grid library which shares this namespace
if (node.source.value === '@material-ui/data-grid') return;
// Return if proper import eg. `import Box from '@material-ui/core/Box'`
// Or if third level or deeper imports
if (node.source.value?.split('/').length >= 3) return;
@@ -47,6 +47,9 @@ ruleTester.run('path-imports-rule', rule, {
{
code: `import { CreateCSSProperties, StyledComponentProps } from '@material-ui/core/styles/withStyles';`,
},
{
code: `import { DataGrid, GridColDef, GridValueGetterParams } from '@material-ui/data-grid';`,
},
],
invalid: [
{