Skip to content

Commit 37f26d6

Browse files
committed
style: apply ESLint rules to enforce correct import path
1 parent e49c5c1 commit 37f26d6

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

.eslintrc.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,16 @@ module.exports = {
8888
'@typescript-eslint/no-restricted-imports': [
8989
'error',
9090
{
91+
paths: [
92+
{
93+
name: '@mui/material',
94+
importNames: ['styled', 'createTheme', 'ThemeProvider'],
95+
message: `
96+
Use "import { styled } from '@mui/material/styles'" instead.
97+
Use "import { createTheme } from '@mui/material/styles'" instead.
98+
Use "import { ThemeProvider } from '@mui/system'" instead.`
99+
}
100+
],
91101
patterns: [
92102
{
93103
group: ['**/dist'],

src/components/DataKeyPair.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { Box, styled } from '@mui/material'
1+
import { Box } from '@mui/material'
2+
import { styled } from '@mui/material/styles'
23
import React, { useCallback, useMemo, useState } from 'react'
34

45
import { useTextColor } from '../hooks/useColor'

src/components/mui/DataBox.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { Box, styled } from '@mui/material'
1+
import { Box } from '@mui/material'
2+
import { styled } from '@mui/material/styles'
23

34
export const DataBox = styled(props => <Box component='div' {...props}/>)`
45
display: inline-block;

src/index.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
import {
2-
createTheme, Paper,
3-
ThemeProvider
4-
} from '@mui/material'
1+
import { Paper } from '@mui/material'
2+
import { createTheme, ThemeProvider } from '@mui/material/styles'
53
import React, { useCallback, useEffect, useMemo, useRef } from 'react'
64

75
import { DataKeyPair } from './components/DataKeyPair'

0 commit comments

Comments
 (0)