From 0df5c608e12d4245e2cb942451aa38ca4865d5ad Mon Sep 17 00:00:00 2001 From: Aditya Kumar Date: Thu, 21 Mar 2024 11:06:07 +0530 Subject: [PATCH] Add ESLint Rule to Org Plugin Signed-off-by: Aditya Kumar --- .changeset/proud-cups-rush.md | 5 +++++ plugins/org/.eslintrc.js | 6 +++++- .../GroupProfile/GroupProfileCard.stories.tsx | 2 +- .../Group/GroupProfile/GroupProfileCard.tsx | 18 ++++++++---------- .../MembersList/MembersListCard.stories.tsx | 2 +- .../Group/MembersList/MembersListCard.tsx | 14 +++++--------- .../src/components/Cards/Meta/LinksGroup.tsx | 10 ++++------ .../Cards/OwnershipCard/ComponentsGrid.tsx | 11 ++++------- .../OwnershipCard/OwnershipCard.stories.tsx | 2 +- .../Cards/OwnershipCard/OwnershipCard.tsx | 16 +++++++--------- .../UserProfileCard.stories.tsx | 2 +- .../User/UserProfileCard/UserProfileCard.tsx | 18 ++++++++---------- 12 files changed, 50 insertions(+), 56 deletions(-) create mode 100644 .changeset/proud-cups-rush.md diff --git a/.changeset/proud-cups-rush.md b/.changeset/proud-cups-rush.md new file mode 100644 index 0000000000..e45a0c1592 --- /dev/null +++ b/.changeset/proud-cups-rush.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-org': patch +--- + +Added ESLint rule `no-top-level-material-ui-4-imports` in the `org` plugin to migrate the Material UI imports. diff --git a/plugins/org/.eslintrc.js b/plugins/org/.eslintrc.js index e2a53a6ad2..a2d8179106 100644 --- a/plugins/org/.eslintrc.js +++ b/plugins/org/.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/org/src/components/Cards/Group/GroupProfile/GroupProfileCard.stories.tsx b/plugins/org/src/components/Cards/Group/GroupProfile/GroupProfileCard.stories.tsx index 17f285c039..5e6e5b72b4 100644 --- a/plugins/org/src/components/Cards/Group/GroupProfile/GroupProfileCard.stories.tsx +++ b/plugins/org/src/components/Cards/Group/GroupProfile/GroupProfileCard.stories.tsx @@ -24,7 +24,7 @@ import { import { permissionApiRef } from '@backstage/plugin-permission-react'; import { AuthorizeResult } from '@backstage/plugin-permission-common'; import { TestApiProvider, wrapInTestApp } from '@backstage/test-utils'; -import { Grid } from '@material-ui/core'; +import Grid from '@material-ui/core/Grid'; import React, { ComponentType, PropsWithChildren } from 'react'; import { GroupProfileCard } from './GroupProfileCard'; diff --git a/plugins/org/src/components/Cards/Group/GroupProfile/GroupProfileCard.tsx b/plugins/org/src/components/Cards/Group/GroupProfile/GroupProfileCard.tsx index 33c6ee137a..b863bef482 100644 --- a/plugins/org/src/components/Cards/Group/GroupProfile/GroupProfileCard.tsx +++ b/plugins/org/src/components/Cards/Group/GroupProfile/GroupProfileCard.tsx @@ -28,16 +28,14 @@ import { InfoCardVariants, Link, } from '@backstage/core-components'; -import { - Box, - Grid, - IconButton, - List, - ListItem, - ListItemIcon, - ListItemText, - Tooltip, -} from '@material-ui/core'; +import Box from '@material-ui/core/Box'; +import Grid from '@material-ui/core/Grid'; +import IconButton from '@material-ui/core/IconButton'; +import List from '@material-ui/core/List'; +import ListItem from '@material-ui/core/ListItem'; +import ListItemIcon from '@material-ui/core/ListItemIcon'; +import ListItemText from '@material-ui/core/ListItemText'; +import Tooltip from '@material-ui/core/Tooltip'; import { EntityRefLinks, catalogApiRef, diff --git a/plugins/org/src/components/Cards/Group/MembersList/MembersListCard.stories.tsx b/plugins/org/src/components/Cards/Group/MembersList/MembersListCard.stories.tsx index 0e2b6a39f7..db54be9e02 100644 --- a/plugins/org/src/components/Cards/Group/MembersList/MembersListCard.stories.tsx +++ b/plugins/org/src/components/Cards/Group/MembersList/MembersListCard.stories.tsx @@ -17,7 +17,7 @@ import { Entity, GroupEntity } from '@backstage/catalog-model'; import { catalogApiRef, EntityProvider } from '@backstage/plugin-catalog-react'; import { TestApiProvider } from '@backstage/test-utils'; -import { Grid } from '@material-ui/core'; +import Grid from '@material-ui/core/Grid'; import React from 'react'; import { MemoryRouter } from 'react-router-dom'; import { diff --git a/plugins/org/src/components/Cards/Group/MembersList/MembersListCard.tsx b/plugins/org/src/components/Cards/Group/MembersList/MembersListCard.tsx index 981ec309b4..418a83f5b2 100644 --- a/plugins/org/src/components/Cards/Group/MembersList/MembersListCard.tsx +++ b/plugins/org/src/components/Cards/Group/MembersList/MembersListCard.tsx @@ -21,15 +21,11 @@ import { stringifyEntityRef, } from '@backstage/catalog-model'; import { catalogApiRef, useEntity } from '@backstage/plugin-catalog-react'; -import { - Box, - createStyles, - Grid, - makeStyles, - Switch, - Theme, - Typography, -} from '@material-ui/core'; +import Box from '@material-ui/core/Box'; +import Grid from '@material-ui/core/Grid'; +import Switch from '@material-ui/core/Switch'; +import Typography from '@material-ui/core/Typography'; +import { createStyles, makeStyles, Theme } from '@material-ui/core/styles'; import Pagination from '@material-ui/lab/Pagination'; import React, { useState } from 'react'; import useAsync from 'react-use/esm/useAsync'; diff --git a/plugins/org/src/components/Cards/Meta/LinksGroup.tsx b/plugins/org/src/components/Cards/Meta/LinksGroup.tsx index dfc654c14b..895bf33205 100644 --- a/plugins/org/src/components/Cards/Meta/LinksGroup.tsx +++ b/plugins/org/src/components/Cards/Meta/LinksGroup.tsx @@ -16,12 +16,10 @@ import { EntityLink } from '@backstage/catalog-model'; import { IconComponent, useApp } from '@backstage/core-plugin-api'; import LanguageIcon from '@material-ui/icons/Language'; -import { - ListItem, - ListItemIcon, - ListItemText, - Divider, -} from '@material-ui/core'; +import ListItem from '@material-ui/core/ListItem'; +import ListItemIcon from '@material-ui/core/ListItemIcon'; +import ListItemText from '@material-ui/core/ListItemText'; +import Divider from '@material-ui/core/Divider'; import React from 'react'; import { Link } from '@backstage/core-components'; diff --git a/plugins/org/src/components/Cards/OwnershipCard/ComponentsGrid.tsx b/plugins/org/src/components/Cards/OwnershipCard/ComponentsGrid.tsx index 928f242e0d..ff16a4ab2d 100644 --- a/plugins/org/src/components/Cards/OwnershipCard/ComponentsGrid.tsx +++ b/plugins/org/src/components/Cards/OwnershipCard/ComponentsGrid.tsx @@ -22,13 +22,10 @@ import { ResponseErrorPanel, } from '@backstage/core-components'; import { useRouteRef } from '@backstage/core-plugin-api'; -import { - Box, - createStyles, - Grid, - makeStyles, - Typography, -} from '@material-ui/core'; +import Box from '@material-ui/core/Box'; +import Grid from '@material-ui/core/Grid'; +import Typography from '@material-ui/core/Typography'; +import { createStyles, makeStyles } from '@material-ui/core/styles'; import React from 'react'; import pluralize from 'pluralize'; import { catalogIndexRouteRef } from '../../../routes'; diff --git a/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.stories.tsx b/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.stories.tsx index d0b9ea1197..493b2e3215 100644 --- a/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.stories.tsx +++ b/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.stories.tsx @@ -22,7 +22,7 @@ import { EntityProvider, } from '@backstage/plugin-catalog-react'; import { TestApiRegistry, wrapInTestApp } from '@backstage/test-utils'; -import { Grid } from '@material-ui/core'; +import Grid from '@material-ui/core/Grid'; import React from 'react'; import { catalogIndexRouteRef } from '../../../routes'; import { OwnershipCard } from './OwnershipCard'; diff --git a/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.tsx b/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.tsx index 0747f710ef..a5b0b7bb19 100644 --- a/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.tsx +++ b/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.tsx @@ -16,15 +16,13 @@ import { InfoCard, InfoCardVariants } from '@backstage/core-components'; import { useEntity } from '@backstage/plugin-catalog-react'; -import { - List, - ListItem, - ListItemSecondaryAction, - ListItemText, - makeStyles, - Switch, - Tooltip, -} from '@material-ui/core'; +import List from '@material-ui/core/List'; +import ListItem from '@material-ui/core/ListItem'; +import ListItemSecondaryAction from '@material-ui/core/ListItemSecondaryAction'; +import ListItemText from '@material-ui/core/ListItemText'; +import Switch from '@material-ui/core/Switch'; +import Tooltip from '@material-ui/core/Tooltip'; +import { makeStyles } from '@material-ui/core/styles'; import React, { useEffect, useState } from 'react'; import { ComponentsGrid } from './ComponentsGrid'; import { EntityRelationAggregation } from '../types'; diff --git a/plugins/org/src/components/Cards/User/UserProfileCard/UserProfileCard.stories.tsx b/plugins/org/src/components/Cards/User/UserProfileCard/UserProfileCard.stories.tsx index 6326a043bc..e5d6ab4d19 100644 --- a/plugins/org/src/components/Cards/User/UserProfileCard/UserProfileCard.stories.tsx +++ b/plugins/org/src/components/Cards/User/UserProfileCard/UserProfileCard.stories.tsx @@ -20,7 +20,7 @@ import { entityRouteRef, } from '@backstage/plugin-catalog-react'; import { wrapInTestApp } from '@backstage/test-utils'; -import { Grid } from '@material-ui/core'; +import Grid from '@material-ui/core/Grid'; import React, { ComponentType, PropsWithChildren } from 'react'; import { UserProfileCard } from './UserProfileCard'; diff --git a/plugins/org/src/components/Cards/User/UserProfileCard/UserProfileCard.tsx b/plugins/org/src/components/Cards/User/UserProfileCard/UserProfileCard.tsx index a45658b3a6..3c60599a39 100644 --- a/plugins/org/src/components/Cards/User/UserProfileCard/UserProfileCard.tsx +++ b/plugins/org/src/components/Cards/User/UserProfileCard/UserProfileCard.tsx @@ -25,16 +25,14 @@ import { InfoCardVariants, Link, } from '@backstage/core-components'; -import { - Box, - Grid, - IconButton, - List, - ListItem, - ListItemIcon, - ListItemText, - Tooltip, -} from '@material-ui/core'; +import Box from '@material-ui/core/Box'; +import Grid from '@material-ui/core/Grid'; +import IconButton from '@material-ui/core/IconButton'; +import List from '@material-ui/core/List'; +import ListItem from '@material-ui/core/ListItem'; +import ListItemIcon from '@material-ui/core/ListItemIcon'; +import ListItemText from '@material-ui/core/ListItemText'; +import Tooltip from '@material-ui/core/Tooltip'; import { EntityRefLinks, getEntityRelations,