-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy patheslint.config.mjs
154 lines (143 loc) · 4.2 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
// @ts-check
import { fixupConfigRules } from '@eslint/compat';
import { FlatCompat } from '@eslint/eslintrc';
import js from '@eslint/js';
import prettierConfigRecommended from 'eslint-plugin-prettier/recommended';
import globals from 'globals';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import ts from 'typescript-eslint';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});
const patchedConfig = fixupConfigRules([
...compat.extends('next/core-web-vitals')
]);
const config = [
...patchedConfig,
...ts.configs.recommended,
prettierConfigRecommended,
{
files: ['**/*.{js,jsx,ts,tsx}'],
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
parser: ts.parser,
parserOptions: {
ecmaFeatures: {
jsx: true
},
project: './tsconfig.json', // Add this line
tsconfigRootDir: __dirname // Add this line
},
globals: {
...globals.browser,
...globals.node,
...globals.es2022
}
},
settings: {
react: {
version: 'detect'
}
},
rules: {
// Original rules
'react/no-is-mounted': 'error',
'react/jsx-filename-extension': ['warn', { extensions: ['.tsx'] }],
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
'no-unused-vars': 'off',
'no-restricted-imports': [
'error',
{
patterns: ['@mui/*/*/*']
}
],
'@typescript-eslint/no-unused-expressions': [
'error',
{
allowShortCircuit: true,
allowTernary: true
}
],
'@typescript-eslint/no-unused-vars': [
'error',
{
vars: 'all',
args: 'after-used',
ignoreRestSiblings: false,
argsIgnorePattern: '^_',
varsIgnorePattern: '^_'
}
],
'@typescript-eslint/dot-notation': ['error', { allowKeywords: true }],
'@typescript-eslint/no-empty-function': [
'error',
{ allow: ['arrowFunctions'] }
],
'@typescript-eslint/no-explicit-any': 'off',
'prettier/prettier': 'error',
// Additional React recommended rules
'react/jsx-no-duplicate-props': 'error',
'react/jsx-no-undef': 'error',
'react/jsx-uses-react': 'error',
'react/jsx-uses-vars': 'error',
'react/no-deprecated': 'error',
'react/no-direct-mutation-state': 'error',
'react/no-find-dom-node': 'error',
'react/no-unknown-property': 'error',
'react/prop-types': 'off', // Since we're using TypeScript
'react/react-in-jsx-scope': 'off', // Not needed in Next.js
'react/require-render-return': 'error',
// JSX-specific rules
'react/jsx-key': ['error', { checkFragmentShorthand: true }],
'react/jsx-no-comment-textnodes': 'error',
'react/jsx-no-target-blank': 'error',
'react/jsx-pascal-case': 'error',
// Hooks rules
'react/hook-use-state': 'error',
// Best practices
'react/jsx-fragments': ['error', 'syntax'],
'react/jsx-no-useless-fragment': 'warn',
'react/no-access-state-in-setstate': 'error',
'react/no-unused-state': 'error',
'react/jsx-boolean-value': ['error', 'never'],
'react/jsx-curly-brace-presence': [
'error',
{
props: 'never',
children: 'never'
}
],
'react/self-closing-comp': [
'error',
{
component: true,
html: true
}
],
// Accessibility
'react/jsx-no-script-url': 'error',
'react/jsx-no-bind': [
'warn',
{
allowArrowFunctions: true,
allowFunctions: false,
allowBind: false
}
],
// Performance
'react/jsx-no-constructed-context-values': 'error',
// TypeScript specific React rules
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off'
}
},
{ ignores: ['.next/*'] }
];
export default config;