1- import { FlatCompat } from '@eslint/eslintrc' ;
2- import { flatConfigs } from 'eslint-plugin-import-x' ;
1+ import next from '@next/eslint-plugin-next' ;
32import * as mdx from 'eslint-plugin-mdx' ;
43import react from 'eslint-plugin-react' ;
5- import tseslint from 'typescript- eslint' ;
4+ import * as hooks from 'eslint-plugin-react-hooks ' ;
65
76import baseConfig from '../../eslint.config.js' ;
87
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+ } ,
1512
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 ,
2017
21- export default tseslint . config (
22- ...baseConfig ,
23- { ignores : [ 'pages/en/blog/**/*.{md,mdx}/**' , 'public' , 'next-env.d.ts' ] } ,
18+ // Type-checking
2419 {
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+ } ,
3227 rules : {
33- '@typescript-eslint/array-type' : [ 'error' , { default : 'generic' } ] ,
3428 '@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' ,
3829 } ,
39- settings : { react : { version : 'detect' } } ,
4030 } ,
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/' ] ,
4931
50- // https://github.com/typescript-eslint/typescript-eslint/issues/9860
51- '@typescript-eslint/consistent-type-imports' : 'off' ,
52- } ,
53- } ,
5432 {
55- files : [ '**/*.{mdx,tsx}' ] ,
5633 rules : {
57- '@typescript-eslint/consistent-type-definitions' : [ 'error' , 'type' ] ,
5834 'react/no-unescaped-entities' : 'off' ,
5935 'react/function-component-definition' : [
6036 'error' ,
@@ -63,22 +39,25 @@ export default tseslint.config(
6339 unnamedComponents : 'arrow-function' ,
6440 } ,
6541 ] ,
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/' ] ,
8161 } ,
8262 } ,
83- mdx . flatCodeBlocks
84- ) ;
63+ ] ) ;
0 commit comments