-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy patheslint.config.mjs
More file actions
134 lines (125 loc) · 3.88 KB
/
Copy patheslint.config.mjs
File metadata and controls
134 lines (125 loc) · 3.88 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
import js from '@eslint/js';
import eslintReact from '@eslint-react/eslint-plugin';
import globals from 'globals';
import tsParser from '@typescript-eslint/parser';
import reactHooksPlugin from 'eslint-plugin-react-hooks';
import jsxA11yPlugin from 'eslint-plugin-jsx-a11y';
import importXPlugin from 'eslint-plugin-import-x';
import simpleImportSort from 'eslint-plugin-simple-import-sort';
const reactFiles = ['src/**/*.{js,jsx}', 'server/**/*.js'];
export default [
{ ignores: ['build/', 'dist/', 'node_modules/', 'coverage/'] },
// @eslint-react (replaces eslint-plugin-react; supports ESLint 10)
{ files: reactFiles, ...eslintReact.configs['recommended-typescript'] },
{ files: reactFiles, ...eslintReact.configs['disable-conflict-eslint-plugin-react-hooks'] },
{
files: reactFiles,
rules: {
'@eslint-react/exhaustive-deps': 'off',
'@eslint-react/set-state-in-effect': 'off',
'@eslint-react/naming-convention-ref-name': 'off',
'@eslint-react/use-state': 'off',
'@eslint-react/no-context-provider': 'off',
'@eslint-react/web-api-no-leaked-timeout': 'off',
'@eslint-react/rules-of-hooks': 'off',
'@eslint-react/no-use-context': 'off',
'@eslint-react/purity': 'off',
'@eslint-react/no-forward-ref': 'off',
},
},
// Shared plugins/rules for src + server
{
files: reactFiles,
languageOptions: {
parser: tsParser,
ecmaVersion: 'latest',
sourceType: 'module',
parserOptions: {
ecmaFeatures: { jsx: true },
},
},
plugins: {
'react-hooks': reactHooksPlugin,
'jsx-a11y': jsxA11yPlugin,
'import-x': importXPlugin,
'simple-import-sort': simpleImportSort,
},
rules: {
...js.configs.recommended.rules,
...reactHooksPlugin.configs.flat['recommended-latest'].rules,
...jsxA11yPlugin.flatConfigs.recommended.rules,
...importXPlugin.flatConfigs.recommended.rules,
'array-bracket-spacing': ['warn', 'never'],
'max-len': ['warn', { code: 120 }],
'no-plusplus': 'error',
'no-undef': 'warn',
'no-unused-vars': 'warn',
'no-useless-assignment': 'off',
'jsx-a11y/no-autofocus': 'off',
'object-curly-spacing': ['warn', 'always'],
'import-x/named': 'off',
'simple-import-sort/imports': 'error',
'simple-import-sort/exports': 'error',
// eslint-plugin-react-hooks v7 recommended-latest adds rules that
// require a wider codebase pass. Disable here to keep the plugin
// bump scoped; adopt them in follow-up work.
'react-hooks/set-state-in-effect': 'off',
'react-hooks/refs': 'off',
'react-hooks/immutability': 'off',
'react-hooks/error-boundaries': 'off',
},
},
// src — browser globals
{
files: ['src/**/*.{js,jsx}'],
languageOptions: {
globals: {
...globals.browser,
globalThis: 'readonly',
},
},
},
// server — Node.js globals + build-time injected constants
{
files: ['server/**/*.js'],
languageOptions: {
globals: {
...globals.node,
GIT_TAG: 'readonly',
GIT_COMMIT: 'readonly',
},
},
},
// test files — vitest globals
{
files: [
'src/**/*.{test,spec}.{js,jsx}',
'src/**/__tests__/**/*.{js,jsx}',
],
languageOptions: {
globals: {
...globals.jest,
vi: 'readonly',
},
},
},
// Files using CommonJS require() — SSR-safe leaflet loading + test bootstrap
{
files: ['src/views/MapView/**/*.js', 'src/setupTests.js'],
languageOptions: {
globals: {
require: 'readonly',
},
},
},
// serviceWorker — dead CRA scaffolding not currently imported anywhere;
// process.env is the CRA-era pattern preserved for potential reactivation.
{
files: ['src/serviceWorker.js'],
languageOptions: {
globals: {
process: 'readonly',
},
},
},
];