From f2d3ea0bdc9f865e60d1d4977f1d29396e0afbaf Mon Sep 17 00:00:00 2001 From: Aditya Kumar Date: Fri, 15 Mar 2024 10:07:38 +0530 Subject: [PATCH] Add ESLint Rule to Codescene Plugin Signed-off-by: Aditya Kumar --- .changeset/nine-dryers-drive.md | 5 +++++ plugins/codescene/.eslintrc.js | 6 +++++- .../CodeHealthKpisCard/CodeHealthKpisCard.tsx | 5 ++++- .../CodeSceneEntityFileSummary.tsx | 2 +- .../CodeSceneEntityKPICard.tsx | 3 ++- .../CodeScenePageComponent.tsx | 2 +- .../CodeSceneProjectDetailsPage.tsx | 3 ++- .../ProjectsComponent/ProjectsComponent.tsx | 18 ++++++++---------- 8 files changed, 28 insertions(+), 16 deletions(-) create mode 100644 .changeset/nine-dryers-drive.md diff --git a/.changeset/nine-dryers-drive.md b/.changeset/nine-dryers-drive.md new file mode 100644 index 0000000000..d2c7c6b7e6 --- /dev/null +++ b/.changeset/nine-dryers-drive.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-codescene': patch +--- + +Added ESLint rule `no-top-level-material-ui-4-imports` in the Codescene plugin to migrate the Material UI imports. diff --git a/plugins/codescene/.eslintrc.js b/plugins/codescene/.eslintrc.js index e2a53a6ad2..6f6668b53d 100644 --- a/plugins/codescene/.eslintrc.js +++ b/plugins/codescene/.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/codescene/src/components/CodeHealthKpisCard/CodeHealthKpisCard.tsx b/plugins/codescene/src/components/CodeHealthKpisCard/CodeHealthKpisCard.tsx index f7dda5c56c..59781f6304 100644 --- a/plugins/codescene/src/components/CodeHealthKpisCard/CodeHealthKpisCard.tsx +++ b/plugins/codescene/src/components/CodeHealthKpisCard/CodeHealthKpisCard.tsx @@ -14,7 +14,10 @@ * limitations under the License. */ import { EmptyState, InfoCard } from '@backstage/core-components'; -import { Button, Grid, makeStyles, Typography } from '@material-ui/core'; +import Button from '@material-ui/core/Button'; +import Grid from '@material-ui/core/Grid'; +import Typography from '@material-ui/core/Typography'; +import { makeStyles } from '@material-ui/core/styles'; import React, { PropsWithChildren } from 'react'; import { Analysis } from '../../api/types'; import { Gauge } from '../Gauge/Gauge'; diff --git a/plugins/codescene/src/components/CodeSceneEntityFileSummary/CodeSceneEntityFileSummary.tsx b/plugins/codescene/src/components/CodeSceneEntityFileSummary/CodeSceneEntityFileSummary.tsx index db5cef8c44..5714bb15c4 100644 --- a/plugins/codescene/src/components/CodeSceneEntityFileSummary/CodeSceneEntityFileSummary.tsx +++ b/plugins/codescene/src/components/CodeSceneEntityFileSummary/CodeSceneEntityFileSummary.tsx @@ -14,7 +14,7 @@ * limitations under the License. */ import { Content, EmptyState, InfoCard } from '@backstage/core-components'; -import { Grid } from '@material-ui/core'; +import Grid from '@material-ui/core/Grid'; import Alert from '@material-ui/lab/Alert'; import React from 'react'; import { diff --git a/plugins/codescene/src/components/CodeSceneEntityKPICard/CodeSceneEntityKPICard.tsx b/plugins/codescene/src/components/CodeSceneEntityKPICard/CodeSceneEntityKPICard.tsx index 1757ad19cf..826d726d1f 100644 --- a/plugins/codescene/src/components/CodeSceneEntityKPICard/CodeSceneEntityKPICard.tsx +++ b/plugins/codescene/src/components/CodeSceneEntityKPICard/CodeSceneEntityKPICard.tsx @@ -29,7 +29,8 @@ import { } from '../../utils/commonUtil'; import { DateTime } from 'luxon'; import { MissingAnnotationEmptyState } from '@backstage/plugin-catalog-react'; -import { Grid, Typography } from '@material-ui/core'; +import Grid from '@material-ui/core/Grid'; +import Typography from '@material-ui/core/Typography'; export const CodeSceneEntityKPICard = () => { const { entity } = useEntity(); diff --git a/plugins/codescene/src/components/CodeScenePageComponent/CodeScenePageComponent.tsx b/plugins/codescene/src/components/CodeScenePageComponent/CodeScenePageComponent.tsx index 118a68f39e..d3afcc0e06 100644 --- a/plugins/codescene/src/components/CodeScenePageComponent/CodeScenePageComponent.tsx +++ b/plugins/codescene/src/components/CodeScenePageComponent/CodeScenePageComponent.tsx @@ -14,7 +14,7 @@ * limitations under the License. */ import React from 'react'; -import { Grid } from '@material-ui/core'; +import Grid from '@material-ui/core/Grid'; import { Header, Page, diff --git a/plugins/codescene/src/components/CodeSceneProjectDetailsPage/CodeSceneProjectDetailsPage.tsx b/plugins/codescene/src/components/CodeSceneProjectDetailsPage/CodeSceneProjectDetailsPage.tsx index dbacd919b4..6d3298383b 100644 --- a/plugins/codescene/src/components/CodeSceneProjectDetailsPage/CodeSceneProjectDetailsPage.tsx +++ b/plugins/codescene/src/components/CodeSceneProjectDetailsPage/CodeSceneProjectDetailsPage.tsx @@ -25,7 +25,8 @@ import { TableColumn, } from '@backstage/core-components'; import { configApiRef, useApi, useApp } from '@backstage/core-plugin-api'; -import { Grid, Typography } from '@material-ui/core'; +import Grid from '@material-ui/core/Grid'; +import Typography from '@material-ui/core/Typography'; import Alert from '@material-ui/lab/Alert'; import React from 'react'; import { useParams } from 'react-router-dom'; diff --git a/plugins/codescene/src/components/ProjectsComponent/ProjectsComponent.tsx b/plugins/codescene/src/components/ProjectsComponent/ProjectsComponent.tsx index 212ab6e746..b291002ae4 100644 --- a/plugins/codescene/src/components/ProjectsComponent/ProjectsComponent.tsx +++ b/plugins/codescene/src/components/ProjectsComponent/ProjectsComponent.tsx @@ -27,16 +27,14 @@ import { Link as RouterLink } from 'react-router-dom'; import { rootRouteRef } from '../../routes'; import { codesceneApiRef } from '../../api/api'; import { Project, Analysis } from '../../api/types'; -import { - Grid, - Card, - CardActionArea, - Input, - makeStyles, - CardContent, - Chip, - CardActions, -} from '@material-ui/core'; +import Grid from '@material-ui/core/Grid'; +import Card from '@material-ui/core/Card'; +import CardActionArea from '@material-ui/core/CardActionArea'; +import Input from '@material-ui/core/Input'; +import CardContent from '@material-ui/core/CardContent'; +import Chip from '@material-ui/core/Chip'; +import CardActions from '@material-ui/core/CardActions'; +import { makeStyles } from '@material-ui/core/styles'; const useStyles = makeStyles(() => ({ overflowXScroll: {