-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy patheslint.config.mjs
118 lines (106 loc) · 2.99 KB
/
eslint.config.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import { FlatCompat } from '@eslint/eslintrc';
import js from '@eslint/js';
import prettierConfig from 'eslint-config-prettier';
import globals from 'globals';
import tseslint from 'typescript-eslint';
const compat = new FlatCompat({
baseDirectory: import.meta.dirname
});
const config = tseslint.config(
{
ignores: ['.next', 'node_modules', '**/*.d.ts', '/components/**/*']
},
// Base configs
js.configs.recommended,
...tseslint.configs.stylisticTypeChecked,
// Next.js config
...compat.extends('next/core-web-vitals'),
...compat.extends('next/typescript'),
{
linterOptions: {
reportUnusedDisableDirectives: true
},
files: ['**/*.{js,jsx,ts,tsx}'],
ignores: ['**/*.d.ts'],
languageOptions: {
parser: tseslint.parser,
ecmaVersion: 'latest',
sourceType: 'module',
parserOptions: {
project: ['./tsconfig.json'], // Specify the path to your tsconfig.json
tsconfigRootDir: import.meta.dirname,
ecmaFeatures: {
jsx: true
}
},
globals: {
...globals.browser,
...globals.node
}
},
settings: {
next: {
rootDir: './'
}
},
rules: {
// TypeScript specific rules
'@typescript-eslint/no-unused-vars': [
'error',
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' }
],
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/consistent-type-imports': [
'warn',
{ prefer: 'type-imports', fixStyle: 'separate-type-imports' }
],
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/prefer-nullish-coalescing': 'off',
// Next.js specific rules
'@next/next/no-html-link-for-pages': 'error',
'@next/next/no-img-element': 'error',
'@next/next/no-head-element': 'error',
'@next/next/no-sync-scripts': 'error',
'@next/next/google-font-display': 'error',
'@next/next/google-font-preconnect': 'error',
// React hooks rules
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
// Import rules
'no-restricted-imports': [
'error',
{
patterns: ['@mui/*/*/*']
}
],
// Turn off rules that conflict with Next.js
'react/react-in-jsx-scope': 'off',
'react/prop-types': 'off',
// Performance rules
'react/jsx-no-constructed-context-values': 'error',
'react/jsx-no-duplicate-props': 'error',
'react/jsx-key': ['error', { checkFragmentShorthand: true }],
'react/self-closing-comp': [
'error',
{
component: true,
html: true
}
]
}
},
// CommonJS files config
{
files: ['**/*.js', '**/*.jsx', '**/*.mjs', 'eslint.config.mjs'],
...tseslint.configs.disableTypeChecked
},
// CommonJS files config
{
files: ['**/*.cjs', '**/*.cts'],
languageOptions: {
sourceType: 'commonjs'
}
},
prettierConfig
);
export default config;