-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.js
More file actions
66 lines (62 loc) · 2.11 KB
/
Copy patheslint.config.js
File metadata and controls
66 lines (62 loc) · 2.11 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
// Flat ESLint config (eslint v9+). Minimal on purpose — this is a hand-rolled,
// zero-runtime-dependency site, so we want syntax/correctness signal, not style
// dogma. Two source contexts with different globals:
// public/app.js -> browser (window, document, fetch, timers …)
// worker/index.js -> Cloudflare Workers (Response, Request, fetch, URL …)
// public/data.js is a generated build artifact and is ignored.
const browserGlobals = {
window: "readonly", document: "readonly", fetch: "readonly",
setTimeout: "readonly", clearTimeout: "readonly",
setInterval: "readonly", clearInterval: "readonly",
location: "readonly", navigator: "readonly", localStorage: "readonly",
console: "readonly", getComputedStyle: "readonly", matchMedia: "readonly",
requestAnimationFrame: "readonly",
addEventListener: "readonly", removeEventListener: "readonly",
innerWidth: "readonly", innerHeight: "readonly",
URLSearchParams: "readonly", URL: "readonly",
};
const workerGlobals = {
Response: "readonly", Request: "readonly", fetch: "readonly",
URL: "readonly", console: "readonly", crypto: "readonly",
addEventListener: "readonly", caches: "readonly",
};
const rules = {
// correctness signal we actually care about:
"no-undef": "error", // catch typos / missing globals
"no-unused-vars": ["warn", { args: "none", varsIgnorePattern: "^_" }],
"no-dupe-keys": "error",
"no-unreachable": "error",
"no-cond-assign": "error",
"no-constant-condition": ["error", { checkLoops: false }],
"valid-typeof": "error",
};
export default [
{ ignores: ["public/data.js", "node_modules/**"] },
{
files: ["public/app.js"],
languageOptions: {
ecmaVersion: 2022,
sourceType: "script",
globals: browserGlobals,
},
rules,
},
{
files: ["worker/index.js"],
languageOptions: {
ecmaVersion: 2022,
sourceType: "module",
globals: workerGlobals,
},
rules,
},
{
files: ["scripts/*.mjs"],
languageOptions: {
ecmaVersion: 2022,
sourceType: "module",
globals: { process: "readonly", console: "readonly" },
},
rules,
},
];