Skip to content

Commit 6d3c196

Browse files
authored
Add import restriction for MUI's Button (#3391)
1 parent 30febe0 commit 6d3c196

File tree

19 files changed

+41
-15
lines changed

19 files changed

+41
-15
lines changed

.changeset/chilly-trams-raise.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@comet/eslint-config": major
3+
---
4+
5+
Add import restriction for MUI's `Button`
6+
7+
Buttons used in Comet DXP applications should match the Comet CI.
8+
Use `Button` from `@comet/admin` instead.

docs/docs/7-migration-guide/migration-from-v7-to-v8.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1595,6 +1595,13 @@ Example:
15951595
15961596
</details>
15971597
1598+
### Import `Button` from `@comet/admin` package
1599+
1600+
```diff
1601+
- import { Button } from "@mui/material";
1602+
+ import { Button } from "@comet/admin";
1603+
```
1604+
15981605
## Site
15991606
16001607
### ✅ Remove `graphQLFetch` from `sitePreviewRoute` calls

packages/admin/admin/src/common/buttons/Button.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
type Breakpoint,
3+
// eslint-disable-next-line no-restricted-imports
34
Button as MuiButton,
45
type ButtonProps as MuiButtonProps,
56
type ComponentsOverrides,

packages/admin/admin/src/common/buttons/split/SplitButton.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { ChevronDown } from "@comet/admin-icons";
22
import {
3+
// eslint-disable-next-line no-restricted-imports
34
Button,
45
ButtonGroup as MuiButtonGroup,
56
type ButtonGroupProps,

packages/admin/admin/src/common/toolbar/actions/ToolbarActionButton.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// eslint-disable-next-line no-restricted-imports
12
import { Button, type ButtonProps, type ComponentsOverrides, IconButton } from "@mui/material";
23
import { css, type Theme, useTheme, useThemeProps } from "@mui/material/styles";
34

packages/admin/admin/src/error/errordialog/ErrorDialog.tsx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
import { Accept, Copy } from "@comet/admin-icons";
2-
import {
3-
// eslint-disable-next-line no-restricted-imports
4-
Dialog,
5-
Divider,
6-
List,
7-
ListItem,
8-
Stack,
9-
Typography,
10-
} from "@mui/material";
2+
// eslint-disable-next-line no-restricted-imports
3+
import { Dialog, Divider, List, ListItem, Stack, Typography } from "@mui/material";
114
import Button from "@mui/material/Button";
125
import DialogActions from "@mui/material/DialogActions";
136
import DialogContent from "@mui/material/DialogContent";

packages/admin/admin/src/table/DeleteButton.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { type PureQueryOptions } from "@apollo/client";
22
import { Delete } from "@comet/admin-icons";
3+
// eslint-disable-next-line no-restricted-imports
34
import { Button, IconButton } from "@mui/material";
45
import { type ButtonProps } from "@mui/material/Button";
56
import CircularProgress from "@mui/material/CircularProgress";

packages/admin/admin/src/table/filterbar/filterBarButton/FilterBarButton.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ChevronDown } from "@comet/admin-icons";
2-
import { buttonClasses, type ButtonProps, type ComponentsOverrides, svgIconClasses } from "@mui/material";
3-
import Button from "@mui/material/Button";
2+
// eslint-disable-next-line no-restricted-imports
3+
import { Button, buttonClasses, type ButtonProps, type ComponentsOverrides, svgIconClasses } from "@mui/material";
44
import { css, type Theme } from "@mui/material/styles";
55
import { useThemeProps } from "@mui/system";
66
import { type ComponentType } from "react";

packages/admin/admin/src/table/filterbar/filterBarPopoverFilter/FilterBarPopoverFilter.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Check, Reset } from "@comet/admin-icons";
2+
// eslint-disable-next-line no-restricted-imports
23
import { Button, type ButtonProps, type ComponentsOverrides, Popover as MuiPopover, type Theme } from "@mui/material";
34
import { css, useThemeProps } from "@mui/material/styles";
45
import { type ComponentType, type MouseEvent, type PropsWithChildren, useState } from "react";

packages/admin/cms-admin/src/blocks/clipboard/CannotPasteBlockDialog.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { messages } from "@comet/admin";
22
import {
3+
// eslint-disable-next-line no-restricted-imports
34
Button,
45
// eslint-disable-next-line no-restricted-imports
56
Dialog,

packages/admin/cms-admin/src/blocks/common/BlockAdminComponentButton.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// eslint-disable-next-line no-restricted-imports
12
import { Button } from "@mui/material";
23
import { type MouseEventHandler, type PropsWithChildren, type ReactNode } from "react";
34

packages/admin/cms-admin/src/blocks/image/EditImageDialog.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { CancelButton, Field, FormSection, messages, SaveButton } from "@comet/a
55
import { OpenNewTab } from "@comet/admin-icons";
66
import {
77
Box,
8+
// eslint-disable-next-line no-restricted-imports
89
Button,
910
// eslint-disable-next-line no-restricted-imports
1011
Dialog,

packages/admin/cms-admin/src/common/signOutButton/SignOutButton.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { useMutation } from "@apollo/client";
22
import { Logout, ThreeDotSaving } from "@comet/admin-icons";
3+
// eslint-disable-next-line no-restricted-imports
34
import { Button, type ButtonProps as MuiButtonProps } from "@mui/material";
45
import { type FunctionComponent, type PropsWithChildren } from "react";
56
import { FormattedMessage } from "react-intl";

packages/admin/cms-admin/src/pages/pageTree/PageDeleteDialog.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { DeleteButton, messages } from "@comet/admin";
22
import { ArrowRight, Clear, Delete } from "@comet/admin-icons";
33
import {
44
Box,
5+
// eslint-disable-next-line no-restricted-imports
56
Button,
67
// eslint-disable-next-line no-restricted-imports
78
Dialog,

packages/admin/cms-admin/src/userPermissions/user/ImpersonationButtons.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// eslint-disable-next-line no-restricted-imports
12
import { Button, type ButtonProps } from "@mui/material";
23
import Cookies from "js-cookie";
34

packages/admin/cms-admin/src/userPermissions/user/permissions/ContentScopeGrid.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
} from "@comet/admin";
1313
import { Select } from "@comet/admin-icons";
1414
import {
15+
// eslint-disable-next-line no-restricted-imports
1516
Button,
1617
Card,
1718
CardContent,

packages/eslint-config/react.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ const config = [
8282
importNames: ["Alert"],
8383
message: "Please use Alert from @comet/admin instead",
8484
},
85+
{
86+
name: "@mui/material",
87+
importNames: ["Button"],
88+
message: "Please use Button from @comet/admin instead",
89+
},
8590
{
8691
name: "@mui/material",
8792
importNames: ["Dialog"],

storybook/src/admin/inlineAlert/InlineAlert.stories.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { InlineAlert } from "@comet/admin";
1+
import { Button, InlineAlert } from "@comet/admin";
22
import { Clear, CometColor, InfoFilled, Reload, RemoveFilled, WarningSolid } from "@comet/admin-icons";
3-
import { Box, Button } from "@mui/material";
3+
import { Box } from "@mui/material";
44
import type { Meta, StoryObj } from "@storybook/react";
55

66
type Story = StoryObj<typeof InlineAlert>;
@@ -82,7 +82,7 @@ export const InlineAlertWithActions: Story = {
8282
actions: (
8383
<Button
8484
startIcon={<Reload />}
85-
variant="contained"
85+
variant="primary"
8686
onClick={() => {
8787
alert("onRetry clicked");
8888
}}
@@ -104,7 +104,7 @@ export const InlineAlertWithMultipleActions: Story = {
104104
<Box sx={{ display: "flex", gap: 2 }}>
105105
<Button
106106
startIcon={<Reload />}
107-
variant="contained"
107+
variant="primary"
108108
onClick={() => {
109109
alert("onRetry clicked");
110110
}}

storybook/src/docs/components/SplitButton/SplitButton.stories.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { SplitButton } from "@comet/admin";
22
import { Home } from "@comet/admin-icons";
3+
// eslint-disable-next-line no-restricted-imports
34
import { Button, Typography } from "@mui/material";
45
import { useState } from "react";
56

0 commit comments

Comments
 (0)