Skip to content

Commit af371c2

Browse files
authored
Enforce Path Imports for MUI Icons (#1393)
* enforce-path-imports * enforce-path-imports-for-mui-icons * fix-import * disable-correct-eslint-rule * move eslint config to package.json * use @stylistic/quotes in elint rules
1 parent 55204b7 commit af371c2

File tree

7 files changed

+303
-192
lines changed

7 files changed

+303
-192
lines changed

package.json

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@
102102
"@babel/preset-env": "^7.0.0",
103103
"@jupyterlab/builder": "^4.0.0",
104104
"@jupyterlab/testutils": "^4.0.0",
105+
"@stylistic/eslint-plugin": "^3.0.1",
105106
"@testing-library/jest-dom": "^6.1.4",
106107
"@testing-library/react": "^14.0.0",
107108
"@testing-library/user-event": "^14.5.1",
@@ -114,11 +115,11 @@
114115
"@types/react-virtualized-auto-sizer": "^1.0.0",
115116
"@types/react-window": "^1.8.2",
116117
"@types/resize-observer-browser": "^0.1.7",
117-
"@typescript-eslint/eslint-plugin": "^6.1.0",
118-
"@typescript-eslint/parser": "^6.1.0",
118+
"@typescript-eslint/eslint-plugin": "^8.0.0",
119+
"@typescript-eslint/parser": "^8.0.0",
119120
"all-contributors-cli": "^6.14.0",
120121
"css-loader": "^6.7.1",
121-
"eslint": "^8.36.0",
122+
"eslint": "^8.56.0",
122123
"eslint-config-prettier": "^8.8.0",
123124
"eslint-plugin-prettier": "^5.0.0",
124125
"eslint-plugin-react": "^7.33.0",
@@ -210,6 +211,7 @@
210211
"sourceType": "module"
211212
},
212213
"plugins": [
214+
"@stylistic",
213215
"@typescript-eslint"
214216
],
215217
"rules": {
@@ -235,7 +237,7 @@
235237
"@typescript-eslint/no-explicit-any": "off",
236238
"@typescript-eslint/no-namespace": "off",
237239
"@typescript-eslint/no-use-before-define": "off",
238-
"@typescript-eslint/quotes": [
240+
"@stylistic/quotes": [
239241
"error",
240242
"single",
241243
{
@@ -248,6 +250,24 @@
248250
"all"
249251
],
250252
"eqeqeq": "error",
253+
"no-restricted-imports": [
254+
"error",
255+
{
256+
"paths": [
257+
{
258+
"name": "@mui/icons-material",
259+
"message":
260+
"Please import icons using path imports, e.g. import AddIcon from '@mui/icons-material/Add'"
261+
}
262+
],
263+
"patterns": [
264+
{
265+
"group": ["@mui/*/*/*"],
266+
"message": "3rd level imports in mui are considered private"
267+
}
268+
]
269+
}
270+
],
251271
"prefer-arrow-callback": "error"
252272
}
253273
},

src/components/GitPanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { TranslationBundle } from '@jupyterlab/translation';
66
import { CommandRegistry } from '@lumino/commands';
77
import { JSONObject } from '@lumino/coreutils';
88
import { Signal } from '@lumino/signaling';
9-
import { WarningRounded as WarningRoundedIcon } from '@mui/icons-material';
9+
import WarningRoundedIcon from '@mui/icons-material/WarningRounded';
1010
import Tab from '@mui/material/Tab';
1111
import Tabs from '@mui/material/Tabs';
1212
import * as React from 'react';

src/components/StatusWidget.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { ReactWidget, UseSignal } from '@jupyterlab/apputils';
22
import { ISettingRegistry } from '@jupyterlab/settingregistry';
33
import { IStatusBar } from '@jupyterlab/statusbar';
44
import { TranslationBundle } from '@jupyterlab/translation';
5-
import { Badge } from '@mui/material';
5+
import Badge from '@mui/material/Badge';
66
import React from 'react';
77
import { classes } from 'typestyle';
88
import { Operation, showGitOperationDialog } from '../commandsAndMenu';

src/components/SubmoduleMenu.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export interface ISubmoduleMenuProps {
3939
/**
4040
* Interface describing component state.
4141
*/
42+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
4243
export interface ISubmoduleMenuState {}
4344

4445
/**

src/components/Toolbar.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ import {
77
refreshIcon
88
} from '@jupyterlab/ui-components';
99
import { CommandRegistry } from '@lumino/commands';
10-
import { Badge, Tab, Tabs } from '@mui/material';
10+
import Badge from '@mui/material/Badge';
11+
import Tab from '@mui/material/Tab';
12+
import Tabs from '@mui/material/Tabs';
1113
import * as React from 'react';
1214
import { classes } from 'typestyle';
1315
import { showError } from '../notifications';

src/components/WarningBox.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CardContent } from '@mui/material';
1+
import CardContent from '@mui/material/CardContent';
22
import Card from '@mui/material/Card';
33
import CardHeader from '@mui/material/CardHeader';
44
import * as React from 'react';

0 commit comments

Comments
 (0)