-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy patheslint.config.mjs
More file actions
88 lines (83 loc) · 2.27 KB
/
eslint.config.mjs
File metadata and controls
88 lines (83 loc) · 2.27 KB
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
import { defineConfig } from 'eslint/config';
import eslintPlugin from '@eslint/js';
import { configs as tseslintConfigs } from 'typescript-eslint';
import reactPlugin from 'eslint-plugin-react';
import reactHooksPlugin from 'eslint-plugin-react-hooks';
import nextPlugin from '@next/eslint-plugin-next';
// Global ignores configuration
const ignoresConfig = defineConfig([
{
name: 'project/ignores',
ignores: ['.next/', 'node_modules/', 'public/', '.vscode/', 'next-env.d.ts', 'out/', 'build/'],
},
]);
// ESLint recommended rules for JavaScript/TypeScript
const eslintConfig = defineConfig([
{
name: 'project/javascript-recommended',
files: ['**/*.{js,mjs,ts,tsx}'],
...eslintPlugin.configs.recommended,
},
]);
// TypeScript configuration
const typescriptConfig = defineConfig([
{
name: 'project/typescript',
files: ['**/*.{ts,tsx}'],
extends: [...tseslintConfigs.recommended],
languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
ecmaFeatures: {
jsx: true,
},
},
},
rules: {
'@typescript-eslint/no-unused-vars': [
'error',
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
],
},
},
{
name: 'project/javascript-disable-type-check',
files: ['**/*.{js,mjs,cjs}'],
...tseslintConfigs.disableTypeChecked,
},
]);
// React and Next.js configuration
const reactConfig = defineConfig([
{
name: 'project/react-next',
files: ['**/*.{jsx,tsx}'],
plugins: {
react: reactPlugin,
'react-hooks': reactHooksPlugin,
'@next/next': nextPlugin,
},
rules: {
...reactPlugin.configs.recommended.rules,
...reactPlugin.configs['jsx-runtime'].rules,
...reactHooksPlugin.configs.recommended.rules,
...nextPlugin.configs.recommended.rules,
...nextPlugin.configs['core-web-vitals'].rules,
'react/react-in-jsx-scope': 'off',
'react/prop-types': 'off',
// Disable stricter rules that flag existing patterns
'react-hooks/set-state-in-effect': 'off',
},
settings: {
react: {
version: 'detect',
},
},
},
]);
export default defineConfig([
...ignoresConfig,
...eslintConfig,
...typescriptConfig,
...reactConfig,
]);