-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.js
More file actions
103 lines (99 loc) · 4.47 KB
/
Copy patheslint.config.js
File metadata and controls
103 lines (99 loc) · 4.47 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
import js from '@eslint/js'
import globals from 'globals'
import tseslint from 'typescript-eslint'
import { defineConfig, globalIgnores } from 'eslint/config'
// athar has three JS/TS surfaces, each backed differently:
//
// backend/internal/tracker/athar.ts real TypeScript, its own
// tsconfig.json (strict).
// backend/internal/webui/static/*.js plain JS served via go:embed,
// typechecked in place against
// JSDoc via its own tsconfig.json
// (allowJs + checkJs).
// scripts/**/*.mjs Node build/test/tooling scripts,
// no tsconfig backs them — they are
// never typechecked today, so they
// get plain (untyped) recommended
// JS linting rather than a fabricated
// type-aware setup.
//
// backend/internal/tracker/athar.js and athar.min.js are generated build
// output (see scripts/build-tracker.mjs) — committed so a Go-only toolchain
// can build the binary, but not hand-written, so they're excluded the same
// way dist/ is. site/assets/vendor/* is third-party, also excluded.
export default defineConfig([
globalIgnores([
'node_modules',
'site/assets/vendor',
'backend/internal/tracker/athar.js',
'backend/internal/tracker/athar.min.js',
'backend/cmd/athar/dist',
'backend/cmd/athar/site',
'.site-check',
]),
// The tracker: real TypeScript, type-aware. projectService walks up from
// each file to find its nearest tsconfig.json — for this file that's
// backend/internal/tracker/tsconfig.json, the same program `npm run
// typecheck` already builds against, so no-floating-promises and friends
// run against real type information, not a name-only preset.
{
files: ['backend/internal/tracker/athar.ts'],
extends: [js.configs.recommended, ...tseslint.configs.recommendedTypeChecked],
languageOptions: {
ecmaVersion: 2022,
sourceType: 'module',
globals: globals.browser,
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
rules: {
// hookHistory's one finding: `window.history[method]` is captured
// into `original` and later invoked as `original.apply(this, ...)` in
// the returned wrapper — a deliberate "torn off, rebind at call time"
// idiom, not a forgotten-bind bug. The rule flags any method
// reference that isn't immediately invoked as a member expression and
// has no way to see that .apply(this, ...) restores the right `this`
// a few lines down. Single hit in this file (confirmed via `npx
// eslint . | grep unbound-method`); downgraded to warn here rather
// than disabled inline, per fleet convention for a single measured
// false positive.
'@typescript-eslint/unbound-method': 'warn',
},
},
// The dashboard's plain-JS-with-JSDoc static files. Same mechanism as
// above — projectService finds backend/internal/webui/static/tsconfig.json
// (allowJs + checkJs) as the nearest ancestor tsconfig for these files, so
// the type-aware TS rules run against the same JSDoc types `npm run
// typecheck:webui` already checks.
{
files: ['backend/internal/webui/static/*.js'],
extends: [js.configs.recommended, ...tseslint.configs.recommendedTypeChecked],
languageOptions: {
ecmaVersion: 2020,
sourceType: 'script',
globals: globals.browser,
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
},
// Node tooling scripts: build/screenshot/site-check scripts and the
// node:test suites. Untyped — no tsconfig covers this tree today, so
// there is no type information to resolve honestly. Several of these
// (demo-capture, screenshots, site-check, site-screenshots) drive
// Playwright and pass `page.evaluate(() => document...)` callbacks —
// real code that runs in-page, in the same file as the Node driver code
// around it — so both global sets genuinely apply here, not just Node's.
{
files: ['scripts/**/*.mjs'],
extends: [js.configs.recommended],
languageOptions: {
ecmaVersion: 2022,
sourceType: 'module',
globals: { ...globals.node, ...globals.browser },
},
},
])