1
- import { FlatCompat } from '@eslint/eslintrc' ;
2
- import { flatConfigs } from 'eslint-plugin-import-x' ;
1
+ import next from '@next/eslint-plugin-next' ;
3
2
import * as mdx from 'eslint-plugin-mdx' ;
4
3
import react from 'eslint-plugin-react' ;
5
- import tseslint from 'typescript- eslint' ;
4
+ import * as hooks from 'eslint-plugin-react-hooks ' ;
6
5
7
6
import baseConfig from '../../eslint.config.js' ;
8
7
9
- const compat = new FlatCompat ( ) ;
10
-
11
- const compatConfig = compat . config ( {
12
- extends : [
13
- // https://github.com/vercel/next.js/discussions/49337
14
- 'plugin:@next/eslint-plugin-next/core-web-vitals' ,
8
+ export default baseConfig . concat ( [
9
+ {
10
+ ignores : [ 'pages/en/blog/**/*.{md,mdx}/**' , 'public' , 'next-env.d.ts' ] ,
11
+ } ,
15
12
16
- // https://github.com/facebook/ react/issues/28313
17
- 'plugin:react- hooks/ recommended' ,
18
- ] ,
19
- } ) ;
13
+ react . configs . flat [ 'jsx-runtime' ] ,
14
+ hooks . configs [ ' recommended-latest' ] ,
15
+ next . flatConfig . coreWebVitals ,
16
+ mdx . flatCodeBlocks ,
20
17
21
- export default tseslint . config (
22
- ...baseConfig ,
23
- { ignores : [ 'pages/en/blog/**/*.{md,mdx}/**' , 'public' , 'next-env.d.ts' ] } ,
18
+ // Type-checking
24
19
{
25
- extends : [
26
- react . configs . flat [ 'jsx-runtime' ] ,
27
- ... tseslint . configs . recommended ,
28
- flatConfigs . typescript ,
29
- ... compatConfig ,
30
- ] ,
31
- files : [ '**/*.{js,md,mdx,mjs,ts,tsx}' ] ,
20
+ ignores : [ '**/*.{md,mdx}' , '**/*.{md,mdx}/**' ] ,
21
+ languageOptions : {
22
+ parserOptions : {
23
+ project : './tsconfig.json' ,
24
+ tsconfigRootDir : import . meta . dirname ,
25
+ } ,
26
+ } ,
32
27
rules : {
33
- '@typescript-eslint/array-type' : [ 'error' , { default : 'generic' } ] ,
34
28
'@typescript-eslint/consistent-type-imports' : 'error' ,
35
- '@typescript-eslint/no-require-imports' : 'off' ,
36
- '@next/next/no-duplicate-head' : 'off' ,
37
- 'import-x/no-duplicates' : 'off' ,
38
29
} ,
39
- settings : { react : { version : 'detect' } } ,
40
30
} ,
41
- {
42
- files : [ '**/*.{md,mdx}' ] ,
43
- extends : [ mdx . flat ] ,
44
- processor : mdx . createRemarkProcessor ( { lintCodeBlocks : true } ) ,
45
- rules : {
46
- 'no-irregular-whitespace' : 'off' ,
47
- '@next/next/no-img-element' : 'off' ,
48
- '@next/next/no-html-link-for-pages' : [ 'error' , 'apps/site/pages/' ] ,
49
31
50
- // https://github.com/typescript-eslint/typescript-eslint/issues/9860
51
- '@typescript-eslint/consistent-type-imports' : 'off' ,
52
- } ,
53
- } ,
54
32
{
55
- files : [ '**/*.{mdx,tsx}' ] ,
56
33
rules : {
57
- '@typescript-eslint/consistent-type-definitions' : [ 'error' , 'type' ] ,
58
34
'react/no-unescaped-entities' : 'off' ,
59
35
'react/function-component-definition' : [
60
36
'error' ,
@@ -63,22 +39,25 @@ export default tseslint.config(
63
39
unnamedComponents : 'arrow-function' ,
64
40
} ,
65
41
] ,
66
- 'no-restricted-syntax' : [
67
- 'error' ,
68
- {
69
- selector :
70
- "ImportDeclaration[source.value='react'][specifiers.0.type='ImportDefaultSpecifier']" ,
71
- message :
72
- 'Default React import not allowed since we use the TypeScript jsx-transform. If you need a global type that collides with a React named export (such as `MouseEvent`), try using `globalThis.MouseHandler`' ,
73
- } ,
74
- {
75
- selector :
76
- "ImportDeclaration[source.value='react'] :matches(ImportNamespaceSpecifier)" ,
77
- message :
78
- 'Named * React import is not allowed. Please import what you need from React with Named Imports' ,
79
- } ,
80
- ] ,
42
+ } ,
43
+ settings : { react : { version : 'detect' } } ,
44
+ } ,
45
+
46
+ {
47
+ files : [ '**/*.{md,mdx}/**' ] ,
48
+ rules : {
49
+ '@typescript-eslint/no-require-imports' : 'off' ,
50
+ } ,
51
+ } ,
52
+
53
+ {
54
+ ...mdx . flat ,
55
+ processor : mdx . createRemarkProcessor ( { lintCodeBlocks : true } ) ,
56
+ rules : {
57
+ ...mdx . flat . rules ,
58
+ 'no-irregular-whitespace' : 'off' ,
59
+ '@next/next/no-img-element' : 'off' ,
60
+ '@next/next/no-html-link-for-pages' : [ 'error' , 'apps/site/pages/' ] ,
81
61
} ,
82
62
} ,
83
- mdx . flatCodeBlocks
84
- ) ;
63
+ ] ) ;
0 commit comments