-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy patheslint.config.js
More file actions
137 lines (125 loc) · 3.5 KB
/
eslint.config.js
File metadata and controls
137 lines (125 loc) · 3.5 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
import js from '@eslint/js';
import tseslint from 'typescript-eslint';
import react from 'eslint-plugin-react';
import reactHooks from 'eslint-plugin-react-hooks';
import importX from 'eslint-plugin-import-x';
import sonarjs from 'eslint-plugin-sonarjs';
import jsxA11y from 'eslint-plugin-jsx-a11y';
import vitestGlobals from 'eslint-plugin-vitest-globals';
import prettier from 'eslint-config-prettier';
import globals from 'globals';
export default tseslint.config(
// Ignore patterns (replaces .eslintignore)
{
ignores: ['src/serviceWorker.ts', 'build/**', 'dist/**', 'node_modules/**'],
},
// Base recommended configs
js.configs.recommended,
...tseslint.configs.recommended,
// Main configuration
{
files: ['**/*.{js,jsx,ts,tsx}'],
languageOptions: {
parser: tseslint.parser,
parserOptions: {
project: './tsconfig.json',
ecmaVersion: 'latest',
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
},
globals: {
...globals.browser,
...globals.node,
...vitestGlobals.environments.env.globals,
fetchMock: true,
},
},
plugins: {
'@typescript-eslint': tseslint.plugin,
react,
'react-hooks': reactHooks,
'import-x': importX,
sonarjs,
'jsx-a11y': jsxA11y,
'vitest-globals': vitestGlobals,
},
settings: {
react: {
version: 'detect',
},
'import-x/resolver': {
node: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
paths: ['src'],
},
},
},
rules: {
// ESLint core rules
'no-use-before-define': 'off',
'no-console': 'warn',
'no-plusplus': 'error',
'curly': 'error',
'consistent-return': 'error',
'no-shadow': [
'error',
{
hoist: 'all',
},
],
'arrow-body-style': ['error', 'as-needed'],
'object-shorthand': ['error', 'properties'],
// TypeScript rules
'@typescript-eslint/no-use-before-define': ['error'],
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/member-ordering': ['warn'],
'@typescript-eslint/no-require-imports': ['error'],
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
// React rules
...react.configs.recommended.rules,
'react/react-in-jsx-scope': 'off', // Not needed with React 17+ JSX transform
'react/no-unused-prop-types': [
'warn',
{
skipShapeProps: true,
},
],
// React Hooks rules
...reactHooks.configs.recommended.rules,
// Import rules
'import-x/order': [
'error',
{
groups: [
'builtin',
'external',
['internal', 'parent', 'sibling', 'index'],
],
'newlines-between': 'always',
},
],
'import-x/no-named-as-default': 'off',
'import-x/no-named-as-default-member': 'off',
// SonarJS rules
'sonarjs/no-duplicate-string': 'error',
// JSX a11y rules
...jsxA11y.configs.recommended.rules,
'jsx-a11y/no-autofocus': 'off',
// Vitest globals
...vitestGlobals.configs.recommended.rules,
},
},
// Disable TypeScript parsing for config files
{
files: ['*.config.{js,ts,mjs,mts}', '*.js', '*.mjs'],
languageOptions: {
parserOptions: {
project: null,
},
},
},
// Prettier config (disables conflicting rules) - must be last
prettier,
);