-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy patheslint.config.js
More file actions
80 lines (80 loc) · 3.55 KB
/
Copy patheslint.config.js
File metadata and controls
80 lines (80 loc) · 3.55 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
module.exports = [
{
files: ['src/**/*.js'],
languageOptions: {
ecmaVersion: 2022,
sourceType: 'commonjs',
globals: {
require: 'readonly', module: 'readonly', exports: 'readonly',
__dirname: 'readonly', __filename: 'readonly',
process: 'readonly', console: 'readonly',
Buffer: 'readonly', setTimeout: 'readonly', setInterval: 'readonly',
clearTimeout: 'readonly', clearInterval: 'readonly', setImmediate: 'readonly', clearImmediate: 'readonly',
fetch: 'readonly', URL: 'readonly', URLSearchParams: 'readonly', AbortController: 'readonly',
TextEncoder: 'readonly', TextDecoder: 'readonly',
},
},
rules: {
'no-unused-vars': ['warn', { argsIgnorePattern: '^_|^err$|^e$|^next$', varsIgnorePattern: '^_', destructuredArrayIgnorePattern: '^_', caughtErrors: 'none' }],
'no-undef': 'error',
'no-constant-condition': 'warn',
'no-debugger': 'error',
'no-duplicate-case': 'error',
'no-empty': ['warn', { allowEmptyCatch: true }],
'no-extra-semi': 'warn',
'no-unreachable': 'warn',
'eqeqeq': ['warn', 'smart'],
'no-eval': 'error',
'no-implied-eval': 'error',
'no-new-func': 'error',
},
},
{
files: ['src/__tests__/**/*.js'],
languageOptions: {
globals: {
describe: 'readonly', it: 'readonly', test: 'readonly',
expect: 'readonly', beforeAll: 'readonly', afterAll: 'readonly',
beforeEach: 'readonly', afterEach: 'readonly', jest: 'readonly',
},
},
},
// Frontend (public/js/): single rule guarding the v5.0 promise that
// inline event handlers (onclick=, onchange=, etc.) are NOT used.
// CSP relies on this — `script-src-attr 'none'` would break otherwise.
{
files: ['public/js/**/*.js'],
languageOptions: {
ecmaVersion: 2022,
sourceType: 'script',
globals: {
window: 'readonly', document: 'readonly', console: 'readonly',
localStorage: 'readonly', sessionStorage: 'readonly',
fetch: 'readonly', WebSocket: 'readonly', URL: 'readonly',
FormData: 'readonly', Blob: 'readonly', File: 'readonly',
setTimeout: 'readonly', setInterval: 'readonly',
clearTimeout: 'readonly', clearInterval: 'readonly',
requestAnimationFrame: 'readonly', cancelAnimationFrame: 'readonly',
Event: 'readonly', CustomEvent: 'readonly', MouseEvent: 'readonly',
XMLHttpRequest: 'readonly', alert: 'readonly', confirm: 'readonly',
prompt: 'readonly', location: 'readonly', history: 'readonly',
navigator: 'readonly', getComputedStyle: 'readonly',
},
},
rules: {
// The only frontend rule we enforce — no inline handlers, ever.
// Reason: CSP `script-src-attr 'none'` blocks them; v5.0 milestone.
'no-restricted-syntax': [
'error',
{
selector: "Literal[value=/on(click|change|submit|input|keyup|keydown|mouseover|mouseout|focus|blur|load|error)\\s*=\\s*[\"']/]",
message: 'Inline event handlers (onclick=, onchange=, etc.) are forbidden in template strings — use addEventListener after render. CSP `script-src-attr none` blocks them at runtime.',
},
{
selector: "TemplateElement[value.raw=/on(click|change|submit|input|keyup|keydown|mouseover|mouseout|focus|blur|load|error)\\s*=\\s*[\"']/]",
message: 'Inline event handlers (onclick=, onchange=, etc.) are forbidden in template literals — use addEventListener after render. CSP `script-src-attr none` blocks them at runtime.',
},
],
},
},
];