-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.js
More file actions
217 lines (203 loc) · 5.99 KB
/
eslint.config.js
File metadata and controls
217 lines (203 loc) · 5.99 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
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
import js from '@eslint/js';
import tseslint from '@typescript-eslint/eslint-plugin';
import tsparser from '@typescript-eslint/parser';
import react from 'eslint-plugin-react';
import reactHooks from 'eslint-plugin-react-hooks';
import importPlugin from 'eslint-plugin-import';
import jsxA11y from 'eslint-plugin-jsx-a11y';
import betterTailwindcss from 'eslint-plugin-better-tailwindcss';
import sonarjs from 'eslint-plugin-sonarjs';
import prettier from 'eslint-config-prettier';
import globals from 'globals';
export default [
// Base JavaScript recommended rules
js.configs.recommended,
// Global ignores
{
ignores: ['dist*/**', 'node_modules/**', 'coverage/**'],
},
// Node.js config files (vite configs, etc.)
{
files: ['*.config.ts', '*.config.js', 'custom-vite-plugins.ts'],
languageOptions: {
globals: {
...globals.node,
__dirname: 'readonly',
__filename: 'readonly',
process: 'readonly',
require: 'readonly',
},
},
},
// Test files
{
files: ['**/*.test.ts', '**/*.test.tsx', '**/test/**/*.ts'],
languageOptions: {
globals: {
...globals.browser,
...globals.node,
...globals.jest,
chrome: 'readonly',
global: 'readonly',
require: 'readonly',
},
},
rules: {
'@typescript-eslint/no-var-requires': 'off',
// Allow custom classes in test files for testing purposes
'better-tailwindcss/no-unregistered-classes': 'off',
},
},
// TypeScript files
{
files: ['**/*.{ts,tsx}'],
languageOptions: {
parser: tsparser,
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
project: './tsconfig.json',
},
globals: {
...globals.browser,
...globals.node,
...globals.es2021,
chrome: 'readonly',
__DEV_MODE__: 'readonly',
__dirname: 'readonly',
process: 'readonly',
global: 'readonly',
require: 'readonly',
},
},
plugins: {
'@typescript-eslint': tseslint,
react,
'react-hooks': reactHooks,
import: importPlugin,
'jsx-a11y': jsxA11y,
'better-tailwindcss': betterTailwindcss,
sonarjs,
},
rules: {
// TypeScript rules
...tseslint.configs.recommended.rules,
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
},
],
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-non-null-assertion': 'warn',
// React rules
...react.configs.recommended.rules,
'react/react-in-jsx-scope': 'off', // Not needed in React 17+
'react/prop-types': 'off', // Using TypeScript for prop validation
'react/display-name': 'off',
// React Hooks rules
...reactHooks.configs.recommended.rules,
// Import ordering
'import/order': [
'error',
{
groups: [
'builtin',
'external',
'internal',
'parent',
'sibling',
'index',
],
'newlines-between': 'always',
alphabetize: {
order: 'asc',
caseInsensitive: true,
},
pathGroups: [
{
pattern: '@src/**',
group: 'internal',
position: 'before',
},
{
pattern: '@assets/**',
group: 'internal',
},
{
pattern: '@pages/**',
group: 'internal',
},
{
pattern: '@components/**',
group: 'internal',
},
{
pattern: '@lib/**',
group: 'internal',
},
{
pattern: '@hooks/**',
group: 'internal',
},
],
pathGroupsExcludedImportTypes: ['builtin'],
},
],
'import/no-unresolved': 'off', // TypeScript handles this
'import/no-duplicates': 'error',
// Accessibility rules
'jsx-a11y/alt-text': 'error',
'jsx-a11y/aria-props': 'error',
'jsx-a11y/aria-proptypes': 'error',
'jsx-a11y/aria-unsupported-elements': 'error',
'jsx-a11y/role-has-required-aria-props': 'error',
'jsx-a11y/role-supports-aria-props': 'error',
'jsx-a11y/click-events-have-key-events': 'warn',
'jsx-a11y/no-static-element-interactions': 'warn',
'jsx-a11y/anchor-is-valid': 'warn',
// Tailwind CSS rules
...betterTailwindcss.configs.recommended.rules,
// SonarJS rules
...sonarjs.configs.recommended.rules,
// Disable false-positive SonarJS rules
'sonarjs/assertions-in-tests': 'off', // Vitest expect() assertions are not detected
'sonarjs/no-unused-vars': 'off', // TypeScript ESLint already handles this
},
settings: {
react: {
version: 'detect',
},
'import/resolver': {
typescript: {
alwaysTryTypes: true,
project: './tsconfig.json',
},
node: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
},
'better-tailwindcss': {
// Tailwind CSS 4: path to the entry file of the css based tailwind config
entryPoint: 'src/assets/styles/tailwind.css',
},
},
},
// UI component files (shadcn/ui components use animation classes from tailwindcss-animate)
{
files: ['src/components/ui/**/*.{ts,tsx}'],
rules: {
// Disable unregistered classes check for UI components as they use shadcn/ui animation classes
// that are valid but not recognized by the plugin
'better-tailwindcss/no-unregistered-classes': 'off',
},
},
// Prettier config (must be last to override other configs)
prettier,
];