From 7a3789a41a3e5759ae49d93865b696291f50b8d7 Mon Sep 17 00:00:00 2001 From: Timothy Deakin Date: Sat, 13 Apr 2024 17:58:25 +0100 Subject: [PATCH] feat: add eslint rule for top level imports Signed-off-by: Timothy Deakin --- .changeset/silver-pugs-bow.md | 5 +++++ plugins/ilert/.eslintrc.js | 1 + plugins/ilert/src/components/Alert/AlertActionsMenu.tsx | 5 ++++- plugins/ilert/src/components/Alert/AlertAssignModal.tsx | 2 +- plugins/ilert/src/components/Alert/AlertNewModal.tsx | 2 +- plugins/ilert/src/components/AlertsPage/StatusChip.tsx | 3 ++- .../components/Errors/MissingAuthorizationHeaderError.tsx | 2 +- plugins/ilert/src/components/Service/ServiceActionsMenu.tsx | 5 ++++- plugins/ilert/src/components/ServicesPage/StatusChip.tsx | 3 ++- plugins/ilert/src/components/Shift/ShiftOverrideModal.tsx | 5 +++-- .../src/components/StatusPage/StatusPageActionsMenu.tsx | 5 ++++- plugins/ilert/src/components/StatusPagePage/StatusChip.tsx | 3 ++- .../ilert/src/components/StatusPagePage/VisibilityChip.tsx | 3 ++- 13 files changed, 32 insertions(+), 12 deletions(-) create mode 100644 .changeset/silver-pugs-bow.md diff --git a/.changeset/silver-pugs-bow.md b/.changeset/silver-pugs-bow.md new file mode 100644 index 0000000000..6833d9c841 --- /dev/null +++ b/.changeset/silver-pugs-bow.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-ilert': patch +--- + +Added the `no-top-level-material-ui-4-imports` ESLint rule to aid with the migration to Material UI v5 diff --git a/plugins/ilert/.eslintrc.js b/plugins/ilert/.eslintrc.js index b4ec729b09..3fc43012b9 100644 --- a/plugins/ilert/.eslintrc.js +++ b/plugins/ilert/.eslintrc.js @@ -1,5 +1,6 @@ module.exports = require('@backstage/cli/config/eslint-factory')(__dirname, { rules: { quotes: ['error', 'single'], + '@backstage/no-top-level-material-ui-4-imports': 'error', }, }); diff --git a/plugins/ilert/src/components/Alert/AlertActionsMenu.tsx b/plugins/ilert/src/components/Alert/AlertActionsMenu.tsx index ff20e39b24..6903a68b89 100644 --- a/plugins/ilert/src/components/Alert/AlertActionsMenu.tsx +++ b/plugins/ilert/src/components/Alert/AlertActionsMenu.tsx @@ -13,7 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { IconButton, Menu, MenuItem, Typography } from '@material-ui/core'; +import IconButton from '@material-ui/core/IconButton'; +import Menu from '@material-ui/core/Menu'; +import MenuItem from '@material-ui/core/MenuItem'; +import Typography from '@material-ui/core/Typography'; import MoreVertIcon from '@material-ui/icons/MoreVert'; import React from 'react'; import { ilertApiRef } from '../../api'; diff --git a/plugins/ilert/src/components/Alert/AlertAssignModal.tsx b/plugins/ilert/src/components/Alert/AlertAssignModal.tsx index d1ecefafa1..1674b787d2 100644 --- a/plugins/ilert/src/components/Alert/AlertAssignModal.tsx +++ b/plugins/ilert/src/components/Alert/AlertAssignModal.tsx @@ -14,7 +14,7 @@ * limitations under the License. */ import { alertApiRef, useApi } from '@backstage/core-plugin-api'; -import { Typography } from '@material-ui/core'; +import Typography from '@material-ui/core/Typography'; import Button from '@material-ui/core/Button'; import Dialog from '@material-ui/core/Dialog'; import DialogActions from '@material-ui/core/DialogActions'; diff --git a/plugins/ilert/src/components/Alert/AlertNewModal.tsx b/plugins/ilert/src/components/Alert/AlertNewModal.tsx index 66928e07e3..6e61750c3a 100644 --- a/plugins/ilert/src/components/Alert/AlertNewModal.tsx +++ b/plugins/ilert/src/components/Alert/AlertNewModal.tsx @@ -19,7 +19,7 @@ import { identityApiRef, useApi, } from '@backstage/core-plugin-api'; -import { Typography } from '@material-ui/core'; +import Typography from '@material-ui/core/Typography'; import Button from '@material-ui/core/Button'; import Dialog from '@material-ui/core/Dialog'; import DialogActions from '@material-ui/core/DialogActions'; diff --git a/plugins/ilert/src/components/AlertsPage/StatusChip.tsx b/plugins/ilert/src/components/AlertsPage/StatusChip.tsx index ac7147b3b2..56748c8712 100644 --- a/plugins/ilert/src/components/AlertsPage/StatusChip.tsx +++ b/plugins/ilert/src/components/AlertsPage/StatusChip.tsx @@ -13,7 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { Chip, withStyles } from '@material-ui/core'; +import Chip from '@material-ui/core/Chip'; +import { withStyles } from '@material-ui/core/styles'; import React from 'react'; import { ACCEPTED, Alert, PENDING, RESOLVED } from '../../types'; diff --git a/plugins/ilert/src/components/Errors/MissingAuthorizationHeaderError.tsx b/plugins/ilert/src/components/Errors/MissingAuthorizationHeaderError.tsx index d698b9c2d1..03a017ec1b 100644 --- a/plugins/ilert/src/components/Errors/MissingAuthorizationHeaderError.tsx +++ b/plugins/ilert/src/components/Errors/MissingAuthorizationHeaderError.tsx @@ -14,7 +14,7 @@ * limitations under the License. */ import React from 'react'; -import { Button } from '@material-ui/core'; +import Button from '@material-ui/core/Button'; import { EmptyState } from '@backstage/core-components'; export const MissingAuthorizationHeaderError = () => ( diff --git a/plugins/ilert/src/components/Service/ServiceActionsMenu.tsx b/plugins/ilert/src/components/Service/ServiceActionsMenu.tsx index 096cc391ee..f554bfda80 100644 --- a/plugins/ilert/src/components/Service/ServiceActionsMenu.tsx +++ b/plugins/ilert/src/components/Service/ServiceActionsMenu.tsx @@ -13,7 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { IconButton, Menu, MenuItem, Typography } from '@material-ui/core'; +import IconButton from '@material-ui/core/IconButton'; +import Menu from '@material-ui/core/Menu'; +import MenuItem from '@material-ui/core/MenuItem'; +import Typography from '@material-ui/core/Typography'; import MoreVertIcon from '@material-ui/icons/MoreVert'; import React from 'react'; import { ilertApiRef } from '../../api'; diff --git a/plugins/ilert/src/components/ServicesPage/StatusChip.tsx b/plugins/ilert/src/components/ServicesPage/StatusChip.tsx index 1d2c89ec6c..0f56c0b1f8 100644 --- a/plugins/ilert/src/components/ServicesPage/StatusChip.tsx +++ b/plugins/ilert/src/components/ServicesPage/StatusChip.tsx @@ -13,7 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { Chip, withStyles } from '@material-ui/core'; +import Chip from '@material-ui/core/Chip'; +import { withStyles } from '@material-ui/core/styles'; import React from 'react'; import { DEGRADED, diff --git a/plugins/ilert/src/components/Shift/ShiftOverrideModal.tsx b/plugins/ilert/src/components/Shift/ShiftOverrideModal.tsx index 63af27c725..3f754aa0db 100644 --- a/plugins/ilert/src/components/Shift/ShiftOverrideModal.tsx +++ b/plugins/ilert/src/components/Shift/ShiftOverrideModal.tsx @@ -23,11 +23,12 @@ import DialogActions from '@material-ui/core/DialogActions'; import DialogContent from '@material-ui/core/DialogContent'; import DialogTitle from '@material-ui/core/DialogTitle'; import Autocomplete from '@material-ui/lab/Autocomplete'; -import { Typography } from '@material-ui/core'; +import Typography from '@material-ui/core/Typography'; import { ilertApiRef } from '../../api'; import { useShiftOverride } from '../../hooks/useShiftOverride'; import { Shift } from '../../types'; -import { DateTimePicker, MuiPickersUtilsProvider } from '@material-ui/pickers'; +import DateTimePicker from '@material-ui/pickers/DateTimePicker'; +import MuiPickersUtilsProvider from '@material-ui/pickers/MuiPickersUtilsProvider'; import LuxonUtils from '@date-io/luxon'; import { alertApiRef, useApi } from '@backstage/core-plugin-api'; diff --git a/plugins/ilert/src/components/StatusPage/StatusPageActionsMenu.tsx b/plugins/ilert/src/components/StatusPage/StatusPageActionsMenu.tsx index 8fe94eb2e1..aa84c779f3 100644 --- a/plugins/ilert/src/components/StatusPage/StatusPageActionsMenu.tsx +++ b/plugins/ilert/src/components/StatusPage/StatusPageActionsMenu.tsx @@ -13,7 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { IconButton, Menu, MenuItem, Typography } from '@material-ui/core'; +import IconButton from '@material-ui/core/IconButton'; +import Menu from '@material-ui/core/Menu'; +import MenuItem from '@material-ui/core/MenuItem'; +import Typography from '@material-ui/core/Typography'; import MoreVertIcon from '@material-ui/icons/MoreVert'; import React from 'react'; import { ilertApiRef } from '../../api'; diff --git a/plugins/ilert/src/components/StatusPagePage/StatusChip.tsx b/plugins/ilert/src/components/StatusPagePage/StatusChip.tsx index 1eaffafd25..090f618f7a 100644 --- a/plugins/ilert/src/components/StatusPagePage/StatusChip.tsx +++ b/plugins/ilert/src/components/StatusPagePage/StatusChip.tsx @@ -13,7 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { Chip, withStyles } from '@material-ui/core'; +import Chip from '@material-ui/core/Chip'; +import { withStyles } from '@material-ui/core/styles'; import React from 'react'; import { DEGRADED, diff --git a/plugins/ilert/src/components/StatusPagePage/VisibilityChip.tsx b/plugins/ilert/src/components/StatusPagePage/VisibilityChip.tsx index 90967e5483..2dac7b38c2 100644 --- a/plugins/ilert/src/components/StatusPagePage/VisibilityChip.tsx +++ b/plugins/ilert/src/components/StatusPagePage/VisibilityChip.tsx @@ -13,7 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { Chip, withStyles } from '@material-ui/core'; +import Chip from '@material-ui/core/Chip'; +import { withStyles } from '@material-ui/core/styles'; import React from 'react'; import { PRIVATE, PUBLIC, StatusPage } from '../../types';