Skip to content

Commit

Permalink
[core][docs] add Eslint rule to ensure main demo component match file… (
Browse files Browse the repository at this point in the history
#37278)

Co-authored-by: Michał Dudak <[email protected]>
  • Loading branch information
alexfauquette and michaldudak authored Jun 28, 2023
1 parent 54450e9 commit 7ca3214
Show file tree
Hide file tree
Showing 193 changed files with 236 additions and 181 deletions.
13 changes: 13 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ module.exports = {
'eslint-plugin-material-ui',
'eslint-plugin-react-hooks',
'@typescript-eslint/eslint-plugin',
'filenames',
],
settings: {
'import/resolver': {
Expand Down Expand Up @@ -297,6 +298,18 @@ module.exports = {
'no-console': 'off',
},
},
{
files: ['docs/data/**/*.tsx'],
excludedFiles: [
'docs/data/joy/getting-started/templates/**/*.tsx',
'docs/data/**/css/*.tsx',
'docs/data/**/system/*.tsx',
'docs/data/**/tailwind/*.tsx',
],
rules: {
'filenames/match-exported': ['error'],
},
},
{
files: ['*.d.ts'],
rules: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const CustomAutocomplete = React.forwardRef(function CustomAutocomplete(props, r
);
});

export default function UseAutocomplete() {
export default function UseAutocompletePopper() {
const [value, setValue] = React.useState(null);

const handleChange = (event, newValue) => setValue(newValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const CustomAutocomplete = React.forwardRef(function CustomAutocomplete(
);
});

export default function UseAutocomplete() {
export default function UseAutocompletePopper() {
const [value, setValue] = React.useState<(typeof top100Films)[number] | null>(
null,
);
Expand Down
2 changes: 1 addition & 1 deletion docs/data/base/components/menu/menu.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ The Menu serves as a replacement for the native HTML `<ul>`, and the Menu Item c
The following demo shows how to create and style a Menu component.
Click **Dashboard** to view the menu—notice that it uses the built-in [Popper](/base-ui/react-popper/) component to visually break out of its parent container:

{{"demo": "MenuSimple.js"}}
{{"demo": "UnstyledMenuSimple.js"}}

### Anatomy

Expand Down
2 changes: 1 addition & 1 deletion docs/data/base/components/modal/ModalUnstyled.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import clsx from 'clsx';
import { styled, Box } from '@mui/system';
import Modal from '@mui/base/Modal';

export default function ModalDemo() {
export default function ModalUnstyled() {
const [open, setOpen] = React.useState(false);
const handleOpen = () => setOpen(true);
const handleClose = () => setOpen(false);
Expand Down
2 changes: 1 addition & 1 deletion docs/data/base/components/modal/ModalUnstyled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import clsx from 'clsx';
import { styled, Box, Theme } from '@mui/system';
import Modal from '@mui/base/Modal';

export default function ModalDemo() {
export default function ModalUnstyled() {
const [open, setOpen] = React.useState(false);
const handleOpen = () => setOpen(true);
const handleClose = () => setOpen(false);
Expand Down
2 changes: 1 addition & 1 deletion docs/data/base/components/select/UnstyledSelectMultiple.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Option, { optionClasses } from '@mui/base/Option';
import Popper from '@mui/base/Popper';
import { styled } from '@mui/system';

export default function UnstyledSelectsMultiple() {
export default function UnstyledSelectMultiple() {
return (
<CustomMultiSelect defaultValue={[10, 20]}>
<StyledOption value={10}>Ten</StyledOption>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Option, { optionClasses } from '@mui/base/Option';
import Popper from '@mui/base/Popper';
import { styled } from '@mui/system';

export default function UnstyledSelectsMultiple() {
export default function UnstyledSelectMultiple() {
return (
<CustomMultiSelect defaultValue={[10, 20]}>
<StyledOption value={10}>Ten</StyledOption>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import { styled, alpha, Box } from '@mui/system';
import Slider, { sliderClasses } from '@mui/base/Slider';

export default function UnstyledSlider() {
export default function UnstyledSliderIntroduction() {
return (
<Box sx={{ width: 320 }}>
<StyledSlider defaultValue={50} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import { styled, alpha, Box } from '@mui/system';
import Slider, { sliderClasses } from '@mui/base/Slider';

export default function UnstyledSlider() {
export default function UnstyledSliderIntroduction() {
return (
<Box sx={{ width: 320 }}>
<StyledSlider defaultValue={50} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import CheckRoundedIcon from '@mui/icons-material/CheckRounded';
import CloseIcon from '@mui/icons-material/Close';
import Snackbar from '@mui/base/Snackbar';

export default function TransitionComponentSnackbar() {
export default function UnstyledSnackbarIntroduction() {
const [open, setOpen] = React.useState(false);
const [exited, setExited] = React.useState(true);
const nodeRef = React.useRef(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import CloseIcon from '@mui/icons-material/Close';
import Snackbar from '@mui/base/Snackbar';
import { SnackbarCloseReason } from '@mui/base/useSnackbar';

export default function TransitionComponentSnackbar() {
export default function UnstyledSnackbarIntroduction() {
const [open, setOpen] = React.useState(false);
const [exited, setExited] = React.useState(true);
const nodeRef = React.useRef(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import { styled } from '@mui/system';
import Switch, { switchClasses } from '@mui/base/Switch';

export default function UnstyledSwitches() {
export default function UnstyledSwitchIntroduction() {
const label = { slotProps: { input: { 'aria-label': 'Demo switch' } } };

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import { styled } from '@mui/system';
import Switch, { switchClasses } from '@mui/base/Switch';

export default function UnstyledSwitches() {
export default function UnstyledSwitchIntroduction() {
const label = { slotProps: { input: { 'aria-label': 'Demo switch' } } };

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import TablePagination, {
tablePaginationClasses as classes,
} from '@mui/base/TablePagination';

export default function UnstyledTable() {
export default function TableCustomized() {
const [page, setPage] = React.useState(0);
const [rowsPerPage, setRowsPerPage] = React.useState(5);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import TablePagination, {
tablePaginationClasses as classes,
} from '@mui/base/TablePagination';

export default function UnstyledTable() {
export default function TableCustomized() {
const [page, setPage] = React.useState(0);
const [rowsPerPage, setRowsPerPage] = React.useState(5);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import TablePagination, {
tablePaginationClasses as classes,
} from '@mui/base/TablePagination';

export default function UnstyledTable() {
export default function TableUnstyled() {
const [page, setPage] = React.useState(0);
const [rowsPerPage, setRowsPerPage] = React.useState(5);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import TablePagination, {
tablePaginationClasses as classes,
} from '@mui/base/TablePagination';

export default function UnstyledTable() {
export default function TableUnstyled() {
const [page, setPage] = React.useState(0);
const [rowsPerPage, setRowsPerPage] = React.useState(5);

Expand Down
2 changes: 1 addition & 1 deletion docs/data/base/components/tabs/KeyboardNavigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Tabs from '@mui/base/Tabs';
import Tab, { tabClasses } from '@mui/base/Tab';
import TabsList from '@mui/base/TabsList';

export default function AccessibleTabs() {
export default function KeyboardNavigation() {
return (
<div>
<p>Selection following focus:</p>
Expand Down
2 changes: 1 addition & 1 deletion docs/data/base/components/tabs/KeyboardNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Tabs from '@mui/base/Tabs';
import Tab, { tabClasses } from '@mui/base/Tab';
import TabsList from '@mui/base/TabsList';

export default function AccessibleTabs() {
export default function KeyboardNavigation() {
return (
<div>
<p>Selection following focus:</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import TextareaAutosize from '@mui/base/TextareaAutosize';
import { styled } from '@mui/system';

export default function EmptyTextarea() {
export default function MaxHeightTextarea() {
const blue = {
100: '#DAECFF',
200: '#b6daff',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import TextareaAutosize from '@mui/base/TextareaAutosize';
import { styled } from '@mui/system';

export default function EmptyTextarea() {
export default function MaxHeightTextarea() {
const blue = {
100: '#DAECFF',
200: '#b6daff',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import TextareaAutosize from '@mui/base/TextareaAutosize';
import { styled } from '@mui/system';

export default function EmptyTextarea() {
export default function MinHeightTextarea() {
const blue = {
100: '#DAECFF',
200: '#b6daff',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import TextareaAutosize from '@mui/base/TextareaAutosize';
import { styled } from '@mui/system';

export default function EmptyTextarea() {
export default function MinHeightTextarea() {
const blue = {
100: '#DAECFF',
200: '#b6daff',
Expand Down
2 changes: 1 addition & 1 deletion docs/data/base/getting-started/quickstart/BaseButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Button from '@mui/base/Button';
import useButton from '@mui/base/useButton';
import Stack from '@mui/material/Stack';

export default function App() {
export default function BaseButton() {
const { getRootProps } = useButton({});
return (
<Stack spacing={2} direction="row">
Expand Down
2 changes: 1 addition & 1 deletion docs/data/base/getting-started/quickstart/BaseButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Button from '@mui/base/Button';
import useButton from '@mui/base/useButton';
import Stack from '@mui/material/Stack';

export default function App() {
export default function BaseButton() {
const { getRootProps } = useButton({});
return (
<Stack spacing={2} direction="row">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const GitHubButtonComponent = styled(Button)(getStyles);

const GitHubButtonHook = styled('button')(getStyles);

export default function App() {
export default function BaseButtonMuiSystem() {
const { getRootProps } = useButton({});

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const GitHubButtonComponent = styled(Button)(getStyles);

const GitHubButtonHook = styled('button')(getStyles);

export default function App() {
export default function BaseButtonMuiSystem() {
const { getRootProps } = useButton({});

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const css = `
}
`;

export default function App() {
export default function BaseButtonPlainCss() {
const { getRootProps } = useButton({});
return (
<React.Fragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const css = `
}
`;

export default function App() {
export default function BaseButtonPlainCss() {
const { getRootProps } = useButton({});
return (
<React.Fragment>
Expand Down
2 changes: 1 addition & 1 deletion docs/data/base/getting-started/quickstart/Tutorial.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const CustomButton = styled(Button)(
`,
);

export default function App() {
export default function Tutorial() {
return (
<div style={{ marginTop: 16, paddingTop: 16, paddingBottom: 16 }}>
<CustomButton>Create Repository</CustomButton>
Expand Down
2 changes: 1 addition & 1 deletion docs/data/base/getting-started/quickstart/Tutorial.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const CustomButton = styled(Button)(
`,
);

export default function App() {
export default function Tutorial() {
return (
<div style={{ marginTop: 16, paddingTop: 16, paddingBottom: 16 }}>
<CustomButton>Create Repository</CustomButton>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import Select from '@mui/base/Select';
import Option from '@mui/base/Option';

export default function OrderedListSelect() {
export default function OverridingInternalSlot() {
return (
<Select slots={{ listbox: 'ol' }} defaultValue="First option">
<Option value="First option">First option</Option>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import Select from '@mui/base/Select';
import Option from '@mui/base/Option';

export default function OrderedListSelect() {
export default function OverridingInternalSlot() {
return (
<Select slots={{ listbox: 'ol' }} defaultValue="First option">
<Option value="First option">First option</Option>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import Button from '@mui/base/Button';

export default function DivButton() {
export default function OverridingRootSlot() {
return <Button slots={{ root: 'div' }}>Button</Button>;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import Button from '@mui/base/Button';

export default function DivButton() {
export default function OverridingRootSlot() {
return <Button slots={{ root: 'div' }}>Button</Button>;
}
2 changes: 1 addition & 1 deletion docs/data/joy/components/alert/AlertInvertedColors.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Check from '@mui/icons-material/Check';
import Close from '@mui/icons-material/Close';
import Warning from '@mui/icons-material/Warning';

export default function AlertBasic() {
export default function AlertInvertedColors() {
return (
<Stack spacing={2} sx={{ maxWidth: 400 }}>
<Alert
Expand Down
2 changes: 1 addition & 1 deletion docs/data/joy/components/alert/AlertInvertedColors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Check from '@mui/icons-material/Check';
import Close from '@mui/icons-material/Close';
import Warning from '@mui/icons-material/Warning';

export default function AlertBasic() {
export default function AlertInvertedColors() {
return (
<Stack spacing={2} sx={{ maxWidth: 400 }}>
<Alert
Expand Down
2 changes: 1 addition & 1 deletion docs/data/joy/components/aspect-ratio/ListStackRatio.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const data = [
},
];

export default function FlexRowRatio() {
export default function ListStackRatio() {
return (
<Sheet
variant="outlined"
Expand Down
2 changes: 1 addition & 1 deletion docs/data/joy/components/aspect-ratio/ListStackRatio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const data = [
},
];

export default function FlexRowRatio() {
export default function ListStackRatio() {
return (
<Sheet
variant="outlined"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Autocomplete from '@mui/joy/Autocomplete';
import Stack from '@mui/joy/Stack';
import LiveTv from '@mui/icons-material/LiveTv';

export default function ComboBox() {
export default function AutocompleteDecorators() {
return (
<Stack spacing={2}>
<Autocomplete
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Autocomplete from '@mui/joy/Autocomplete';
import Stack from '@mui/joy/Stack';
import LiveTv from '@mui/icons-material/LiveTv';

export default function ComboBox() {
export default function AutocompleteDecorators() {
return (
<Stack spacing={2}>
<Autocomplete
Expand Down
Loading

0 comments on commit 7ca3214

Please sign in to comment.