-
Notifications
You must be signed in to change notification settings - Fork 492
Expand file tree
/
Copy patheslint.config.js
More file actions
206 lines (186 loc) · 5.37 KB
/
Copy patheslint.config.js
File metadata and controls
206 lines (186 loc) · 5.37 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
import js from '@eslint/js';
import prettier from 'eslint-plugin-prettier';
import prettierConfig from 'eslint-config-prettier';
export default [
// Base JavaScript recommended rules
js.configs.recommended,
// Prettier integration
prettierConfig,
{
// Configuration for all JavaScript files.
// `.mjs` is included so build/tooling scripts get the same quality rules as
// src/ — without it they fall back to eslint:recommended with no globals at
// all, which reports every `process`/`console` reference as no-undef.
files: ['**/*.js', '**/*.mjs'],
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
globals: {
// Browser globals
window: 'readonly',
document: 'readonly',
console: 'readonly',
localStorage: 'readonly',
sessionStorage: 'readonly',
fetch: 'readonly',
setTimeout: 'readonly',
setInterval: 'readonly',
clearTimeout: 'readonly',
clearInterval: 'readonly',
alert: 'readonly',
confirm: 'readonly',
// Chart.js and other libraries (if used globally)
Chart: 'readonly',
L: 'readonly', // Leaflet
bootstrap: 'readonly',
// Google Maps (if used)
google: 'readonly',
// Common browser APIs
Element: 'readonly',
NodeList: 'readonly',
HTMLElement: 'readonly',
Event: 'readonly',
FormData: 'readonly',
URL: 'readonly',
URLSearchParams: 'readonly',
// Web APIs
ResizeObserver: 'readonly',
IntersectionObserver: 'readonly',
MutationObserver: 'readonly',
CustomEvent: 'readonly',
getComputedStyle: 'readonly',
requestAnimationFrame: 'readonly',
cancelAnimationFrame: 'readonly',
performance: 'readonly',
navigator: 'readonly'
}
},
plugins: {
prettier
},
rules: {
// Prettier formatting
'prettier/prettier': 'error',
// JavaScript best practices
'no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
// ESLint 9+ lints catch bindings by default (caughtErrors: 'all'),
// so the project's `_`-prefix convention has to cover them too —
// otherwise `catch (_e) { /* ignore */ }` is reported as unused.
caughtErrorsIgnorePattern: '^_'
}
],
'no-console': [
'warn',
{
allow: ['warn', 'error']
}
],
'no-debugger': 'error',
'no-alert': 'warn',
'no-eval': 'error',
'no-implied-eval': 'error',
// Modern JavaScript
'prefer-const': 'error',
'prefer-arrow-callback': 'error',
'prefer-template': 'error',
'template-curly-spacing': ['error', 'never'],
// Code quality
eqeqeq: ['error', 'always'],
curly: ['error', 'all'],
'brace-style': ['error', '1tbs'],
'comma-dangle': ['error', 'never'],
quotes: [
'error',
'single',
{
avoidEscape: true,
allowTemplateLiterals: true
}
],
semi: ['error', 'always'],
// Function and variable naming
camelcase: [
'error',
{
properties: 'never',
ignoreImports: true
}
],
// Import/Export
'no-duplicate-imports': 'error',
// Error prevention
'no-undef': 'error',
'no-unreachable': 'error',
'no-dupe-keys': 'error',
'no-dupe-args': 'error',
'no-duplicate-case': 'error',
// Best practices for DOM manipulation
'no-global-assign': 'error',
'no-implicit-globals': 'error',
// Async/await best practices
'require-await': 'error',
'no-async-promise-executor': 'error',
// Array and object methods
'array-callback-return': 'error',
'no-loop-func': 'error'
}
},
{
// Specific rules for module files
files: ['src/**/*.js'],
rules: {
// Module-specific rules
'no-undef': 'error'
}
},
{
// Configuration files don't need to be as strict
files: ['*.config.js', 'vite.config.js', 'eslint.config.js'],
languageOptions: {
globals: {
process: 'readonly',
__dirname: 'readonly',
module: 'readonly',
require: 'readonly',
exports: 'readonly'
}
},
rules: {
'no-console': 'off'
}
},
{
// Node-side tooling scripts (e.g. scripts/social-preview.mjs).
// These run under Node, so they need Node globals on top of the browser
// globals declared above — the browser ones stay relevant because
// Playwright `page.evaluate()` callbacks are authored inline here and are
// statically analysed as part of this file.
files: ['scripts/**/*.js', 'scripts/**/*.mjs'],
languageOptions: {
globals: {
process: 'readonly',
console: 'readonly',
Buffer: 'readonly',
__dirname: 'readonly',
__filename: 'readonly',
module: 'readonly',
require: 'readonly',
exports: 'readonly',
global: 'readonly',
URL: 'readonly'
}
},
rules: {
// Tooling scripts legitimately report progress on stdout.
'no-console': 'off'
}
},
{
// Ignore patterns
ignores: ['dist/**', 'node_modules/**', 'public/**', '*.min.js', 'coverage/**']
}
];