-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy patheslint.config.mjs
189 lines (170 loc) · 5.55 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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
/* eslint-disable import/no-extraneous-dependencies */
/* eslint-disable no-underscore-dangle */
/* eslint-disable import/no-anonymous-default-export */
// ESLint core and compatibility utilities
import js from '@eslint/js';
import { FlatCompat } from '@eslint/eslintrc';
// import { fixupPluginRules } from '@eslint/compat';
import globals from 'globals';
// ESLint plugins for various technologies and best practices
import react from 'eslint-plugin-react';
import reactHooks from 'eslint-plugin-react-hooks';
import jsxA11Y from 'eslint-plugin-jsx-a11y';
import typescriptEslint from '@typescript-eslint/eslint-plugin';
// import tseslint from 'typescript-eslint';
import unusedImports from 'eslint-plugin-unused-imports';
import tailwindcss from 'eslint-plugin-tailwindcss';
import tsdoc from 'eslint-plugin-tsdoc';
import _import from 'eslint-plugin-import';
import prettier from 'eslint-plugin-prettier';
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
import testingLibrary from 'eslint-plugin-testing-library';
import vitest from '@vitest/eslint-plugin';
import deprecation from 'eslint-plugin-deprecation';
// import nextPlugin from '@next/eslint-plugin-next';
import pluginQuery from '@tanstack/eslint-plugin-query';
const compat = new FlatCompat({
baseDirectory: import.meta.dirname, // Added in: v21.2.0, v20.11.0 @ https://nodejs.org/api/esm.html#importmetadirname
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});
export default [
// Ignore specific files and directories
{
ignores: [
'**/dist/**',
'**/out/**',
'**/build/**',
'**/node_modules/**',
'**/playwright-report/**',
'**/coverage/**',
'**/.next/**',
'**/.storybook/**',
'**/*.config.{js,cjs,mjs}',
'**/vendor/**',
],
},
// Base configuration extensions
...compat.extends('airbnb', 'airbnb-typescript'),
// Detailed settings for TypeScript and React files
{
files: ['**/*.{ts,tsx}', '**/*.{test,spec}.{ts,tsx}'],
plugins: {
react,
'react-hooks': reactHooks,
'jsx-a11y': jsxA11Y,
'@typescript-eslint': typescriptEslint,
// '@typescript-eslint': tseslint.plugin, // Commented out. This is because the @typescript-eslint plugin is already loaded by ...compat.extends('airbnb-typescript').
// '@next/next': nextPlugin,
'unused-imports': unusedImports,
'@tanstack/query': pluginQuery,
// deprecation: fixupPluginRules(deprecationPlugin),
deprecation,
tailwindcss,
tsdoc,
import: _import,
prettier,
'testing-library': testingLibrary,
vitest,
},
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
// parser: tseslint.parser,
parserOptions: {
project: './tsconfig.json',
},
globals: {
...globals.browser,
...globals.node,
...globals.jquery,
window: true,
lazySizes: true,
},
},
settings: {
react: {
version: '19.0.0',
},
},
rules: {
// Prettier rules
'prettier/prettier': 'error',
// React rules
'react/require-default-props': 'off',
'react/jsx-props-no-spreading': 'off',
'react/no-danger': 'off',
'react/function-component-definition': [
2,
{
namedComponents: 'arrow-function',
unnamedComponents: 'arrow-function',
},
],
// Performance and optimization rules
'react/jsx-no-useless-fragment': 'error',
// Accessibility rules
'jsx-a11y/anchor-is-valid': 'off',
'jsx-a11y/label-has-associated-control': [
2,
{
assert: 'either',
},
],
'jsx-a11y/control-has-associated-label': 'off',
// Next.js rules
// '@next/next/no-img-element': 'off',
// Import rules
'import/order': [
'error',
{
groups: ['builtin', 'external', 'internal'],
pathGroups: [
{
pattern: 'react',
group: 'external',
position: 'before',
},
],
pathGroupsExcludedImportTypes: ['react'],
'newlines-between': 'always',
alphabetize: {
order: 'asc',
caseInsensitive: true,
},
},
],
'import/prefer-default-export': 'off',
'import/no-duplicates': 'error',
// TypeScript rules
'@typescript-eslint/comma-dangle': 'off',
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/no-unnecessary-condition': 'error',
// '@typescript-eslint/strict-boolean-expressions': 'error',
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/prefer-optional-chain': 'error',
// Unused imports/variables rules
'unused-imports/no-unused-imports': 'error',
'unused-imports/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
// Other miscellaneous rules
'no-underscore-dangle': 'off',
'tailwindcss/no-custom-classname': 'off',
'tsdoc/syntax': 'warn',
'no-console': ['warn', { allow: ['warn', 'error'] }],
},
},
// Additional rules for test files
{
files: ['**/*.{test,spec}.{ts,tsx}'],
rules: {
'vitest/consistent-test-it': ['error', { fn: 'test' }],
'vitest/require-top-level-describe': [
'error',
{ maxNumberOfTopLevelDescribes: 2 },
],
},
},
// Keep Prettier configuration last to avoid conflicts
eslintPluginPrettierRecommended,
];