From f21ef8c283593cf111e6e88a26d27faf8693fdb6 Mon Sep 17 00:00:00 2001 From: Aditya Kumar Date: Thu, 21 Mar 2024 11:11:42 +0530 Subject: [PATCH] Add ESLint Rule to Opencost Plugin Signed-off-by: Aditya Kumar --- .changeset/modern-cats-fly.md | 5 +++++ plugins/opencost/.eslintrc.js | 6 +++++- .../src/components/AllocationChart/RangeChart.jsx | 2 +- plugins/opencost/src/components/AllocationReport.jsx | 2 +- plugins/opencost/src/components/Controls/Edit.jsx | 2 +- .../opencost/src/components/OpenCostPage/OpenCostPage.tsx | 2 +- .../src/components/OpenCostReport/OpenCostReport.tsx | 2 +- plugins/opencost/src/components/Page.jsx | 2 +- plugins/opencost/src/components/SelectWindow.jsx | 8 +++----- plugins/opencost/src/components/Subtitle.jsx | 2 +- plugins/opencost/src/components/Warnings.jsx | 2 +- 11 files changed, 21 insertions(+), 14 deletions(-) create mode 100644 .changeset/modern-cats-fly.md diff --git a/.changeset/modern-cats-fly.md b/.changeset/modern-cats-fly.md new file mode 100644 index 0000000000..f5d2ba8d18 --- /dev/null +++ b/.changeset/modern-cats-fly.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-opencost': patch +--- + +Added ESLint rule `no-top-level-material-ui-4-imports` in the `opencost` plugin to migrate the Material UI imports. diff --git a/plugins/opencost/.eslintrc.js b/plugins/opencost/.eslintrc.js index e2a53a6ad2..a2d8179106 100644 --- a/plugins/opencost/.eslintrc.js +++ b/plugins/opencost/.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/opencost/src/components/AllocationChart/RangeChart.jsx b/plugins/opencost/src/components/AllocationChart/RangeChart.jsx index b1ce5a34ee..28b59e9c7f 100644 --- a/plugins/opencost/src/components/AllocationChart/RangeChart.jsx +++ b/plugins/opencost/src/components/AllocationChart/RangeChart.jsx @@ -23,7 +23,7 @@ import { Tooltip, ResponsiveContainer, } from 'recharts'; -import { makeStyles } from '@material-ui/styles'; +import { makeStyles } from '@material-ui/core/styles'; import { reverse } from 'lodash'; import { primary, greyscale, browns } from '../../constants/colors'; import { toCurrency } from '../../util'; diff --git a/plugins/opencost/src/components/AllocationReport.jsx b/plugins/opencost/src/components/AllocationReport.jsx index 52686a741c..44263001d6 100644 --- a/plugins/opencost/src/components/AllocationReport.jsx +++ b/plugins/opencost/src/components/AllocationReport.jsx @@ -20,7 +20,7 @@ import React, { useEffect, useState } from 'react'; import { get, round } from 'lodash'; -import { makeStyles } from '@material-ui/styles'; +import { makeStyles } from '@material-ui/core/styles'; import Table from '@material-ui/core/Table'; import TableBody from '@material-ui/core/TableBody'; import TableCell from '@material-ui/core/TableCell'; diff --git a/plugins/opencost/src/components/Controls/Edit.jsx b/plugins/opencost/src/components/Controls/Edit.jsx index f02f8cc111..dba81afb05 100644 --- a/plugins/opencost/src/components/Controls/Edit.jsx +++ b/plugins/opencost/src/components/Controls/Edit.jsx @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { makeStyles } from '@material-ui/styles'; +import { makeStyles } from '@material-ui/core/styles'; import FormControl from '@material-ui/core/FormControl'; import InputLabel from '@material-ui/core/InputLabel'; import MenuItem from '@material-ui/core/MenuItem'; diff --git a/plugins/opencost/src/components/OpenCostPage/OpenCostPage.tsx b/plugins/opencost/src/components/OpenCostPage/OpenCostPage.tsx index 4062eca155..65bf4fae21 100644 --- a/plugins/opencost/src/components/OpenCostPage/OpenCostPage.tsx +++ b/plugins/opencost/src/components/OpenCostPage/OpenCostPage.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, Content } from '@backstage/core-components'; import { OpenCostReport } from '../OpenCostReport'; import logo from '../../images/pig.png'; diff --git a/plugins/opencost/src/components/OpenCostReport/OpenCostReport.tsx b/plugins/opencost/src/components/OpenCostReport/OpenCostReport.tsx index 12f64f3606..f6aca9a360 100644 --- a/plugins/opencost/src/components/OpenCostReport/OpenCostReport.tsx +++ b/plugins/opencost/src/components/OpenCostReport/OpenCostReport.tsx @@ -23,7 +23,7 @@ import RefreshIcon from '@material-ui/icons/Refresh'; import Typography from '@material-ui/core/Typography'; import { useLocation, useNavigate } from 'react-router-dom'; import { find, get, sortBy, toArray } from 'lodash'; -import { makeStyles } from '@material-ui/styles'; +import { makeStyles } from '@material-ui/core/styles'; import AllocationReport from '../AllocationReport'; import AllocationService from '../../services/allocation'; import Controls from '../Controls'; diff --git a/plugins/opencost/src/components/Page.jsx b/plugins/opencost/src/components/Page.jsx index 6346b6287b..fd731f540b 100644 --- a/plugins/opencost/src/components/Page.jsx +++ b/plugins/opencost/src/components/Page.jsx @@ -14,7 +14,7 @@ * limitations under the License. */ -import { makeStyles } from '@material-ui/styles'; +import { makeStyles } from '@material-ui/core/styles'; import React from 'react'; const useStyles = makeStyles({ diff --git a/plugins/opencost/src/components/SelectWindow.jsx b/plugins/opencost/src/components/SelectWindow.jsx index 470770f35c..8a81ff139d 100644 --- a/plugins/opencost/src/components/SelectWindow.jsx +++ b/plugins/opencost/src/components/SelectWindow.jsx @@ -15,11 +15,9 @@ */ import React, { useEffect, useState } from 'react'; -import { makeStyles } from '@material-ui/styles'; -import { - MuiPickersUtilsProvider, - KeyboardDatePicker, -} from '@material-ui/pickers'; +import { makeStyles } from '@material-ui/core/styles'; +import MuiPickersUtilsProvider from '@material-ui/pickers/MuiPickersUtilsProvider'; +import KeyboardDatePicker from '@material-ui/pickers/KeyboardDatePicker'; import Button from '@material-ui/core/Button'; import LuxonUtils from '@date-io/luxon'; import FormControl from '@material-ui/core/FormControl'; diff --git a/plugins/opencost/src/components/Subtitle.jsx b/plugins/opencost/src/components/Subtitle.jsx index 63b3df61ff..5c99cc9fb7 100644 --- a/plugins/opencost/src/components/Subtitle.jsx +++ b/plugins/opencost/src/components/Subtitle.jsx @@ -15,7 +15,7 @@ */ import React from 'react'; -import { makeStyles } from '@material-ui/styles'; +import { makeStyles } from '@material-ui/core/styles'; import { upperFirst } from 'lodash'; import Breadcrumbs from '@material-ui/core/Breadcrumbs'; import NavigateNextIcon from '@material-ui/icons/NavigateNext'; diff --git a/plugins/opencost/src/components/Warnings.jsx b/plugins/opencost/src/components/Warnings.jsx index ae1047ebc2..f0422c5b75 100644 --- a/plugins/opencost/src/components/Warnings.jsx +++ b/plugins/opencost/src/components/Warnings.jsx @@ -15,7 +15,7 @@ */ import React from 'react'; -import { makeStyles } from '@material-ui/styles'; +import { makeStyles } from '@material-ui/core/styles'; import List from '@material-ui/core/List'; import ListItem from '@material-ui/core/ListItem'; import ListItemIcon from '@material-ui/core/ListItemIcon';