From 0874d39ca57a501d6544f3159e28b8c258e0139f Mon Sep 17 00:00:00 2001 From: Timothy Deakin Date: Sat, 13 Apr 2024 17:46:56 +0100 Subject: [PATCH 1/2] feat: add eslint rule for top level imports Signed-off-by: Timothy Deakin --- .changeset/weak-files-admire.md | 5 +++++ plugins/example-todo-list/.eslintrc.js | 6 +++++- .../src/components/TodoList/TodoList.tsx | 2 +- .../components/TodoListPage/TodoListPage.tsx | 20 +++++++++---------- 4 files changed, 20 insertions(+), 13 deletions(-) create mode 100644 .changeset/weak-files-admire.md diff --git a/.changeset/weak-files-admire.md b/.changeset/weak-files-admire.md new file mode 100644 index 0000000000..84f0033810 --- /dev/null +++ b/.changeset/weak-files-admire.md @@ -0,0 +1,5 @@ +--- +'@internal/plugin-todo-list': 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/example-todo-list/.eslintrc.js b/plugins/example-todo-list/.eslintrc.js index e2a53a6ad2..e487f765b2 100644 --- a/plugins/example-todo-list/.eslintrc.js +++ b/plugins/example-todo-list/.eslintrc.js @@ -1 +1,5 @@ -module.exports = require('@backstage/cli/config/eslint-factory')(__dirname); +module.exports = require('@backstage/cli/config/eslint-factory')(__dirname, { + rules: { + '@backstage/no-top-level-material-ui-4-imports': 'error', + }, +}); diff --git a/plugins/example-todo-list/src/components/TodoList/TodoList.tsx b/plugins/example-todo-list/src/components/TodoList/TodoList.tsx index a8eb239e70..887dd68a84 100644 --- a/plugins/example-todo-list/src/components/TodoList/TodoList.tsx +++ b/plugins/example-todo-list/src/components/TodoList/TodoList.tsx @@ -22,7 +22,7 @@ import { fetchApiRef, useApi, } from '@backstage/core-plugin-api'; -import { Button } from '@material-ui/core'; +import Button from '@material-ui/core/Button'; export type Todo = { title: string; diff --git a/plugins/example-todo-list/src/components/TodoListPage/TodoListPage.tsx b/plugins/example-todo-list/src/components/TodoListPage/TodoListPage.tsx index 9185c37419..418ec61201 100644 --- a/plugins/example-todo-list/src/components/TodoListPage/TodoListPage.tsx +++ b/plugins/example-todo-list/src/components/TodoListPage/TodoListPage.tsx @@ -14,17 +14,15 @@ * limitations under the License. */ import React, { useReducer, useRef, useState } from 'react'; -import { - Typography, - Grid, - TextField, - Button, - Dialog, - Box, - DialogTitle, - DialogContent, - DialogActions, -} from '@material-ui/core'; +import Typography from '@material-ui/core/Typography'; +import Grid from '@material-ui/core/Grid'; +import TextField from '@material-ui/core/TextField'; +import Button from '@material-ui/core/Button'; +import Dialog from '@material-ui/core/Dialog'; +import Box from '@material-ui/core/Box'; +import DialogTitle from '@material-ui/core/DialogTitle'; +import DialogContent from '@material-ui/core/DialogContent'; +import DialogActions from '@material-ui/core/DialogActions'; import { Header, Page, From 6cfb8268628cfcde08c5c4f9382b080daf513c8e Mon Sep 17 00:00:00 2001 From: Timothy Deakin Date: Sun, 14 Apr 2024 20:08:59 +0100 Subject: [PATCH 2/2] refactor: remove unneded changeset Signed-off-by: Timothy Deakin --- .changeset/weak-files-admire.md | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 .changeset/weak-files-admire.md diff --git a/.changeset/weak-files-admire.md b/.changeset/weak-files-admire.md deleted file mode 100644 index 84f0033810..0000000000 --- a/.changeset/weak-files-admire.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@internal/plugin-todo-list': patch ---- - -Added the `no-top-level-material-ui-4-imports` ESLint rule to aid with the migration to Material UI v5