Repository navigation
Expand file tree
/
Copy patheslint.config.js
More file actions
117 lines (108 loc) · 4.32 KB
/
Copy patheslint.config.js
File metadata and controls
117 lines (108 loc) · 4.32 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
// Flat ESLint config for the slop-detect monorepo.
//
// Mixed JS + TS, several runtimes. The packages do not share a global env:
// • core (TypeScript) → Node ESM, plus DOM for the in-page detectors
// • cli / mcp / action (JS) → Node ESM
// • web/functions (JS) → Cloudflare Workers (fetch, Response, URL,
// crypto, caches…) plus node:* via nodejs_compat
// • *.test.{js,ts} → Node + node:test
//
// Formatting is owned by Prettier, so eslint-config-prettier is applied last to
// switch off every stylistic rule that would fight it. ESLint here is for
// *correctness* (undefined vars, unreachable code, bad regex), not style.
import js from '@eslint/js';
import globals from 'globals';
import tseslint from 'typescript-eslint';
import prettier from 'eslint-config-prettier';
const unusedVars = ['warn', { argsIgnorePattern: '^_', caughtErrors: 'none' }];
export default tseslint.config(
// Never lint generated, vendored, or static-asset trees.
{
ignores: [
'node_modules/**',
'**/dist/**',
'**/build/**',
'**/.astro/**',
'**/.next/**',
'**/.turbo/**',
'**/coverage/**',
'**/out/**',
'**/next-env.d.ts',
'apps/web/public/**',
'assets-raw/**',
'package-lock.json',
],
},
js.configs.recommended,
// JavaScript: Node ESM (cli, mcp, action, calibration, web/functions, scripts).
{
files: ['**/*.{js,mjs}'],
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
globals: { ...globals.node },
},
rules: {
'no-unused-vars': unusedVars,
'no-constant-condition': ['error', { checkLoops: false }],
// Empty `catch {}` is a deliberate best-effort-swallow idiom throughout
// the codebase (KV reads, optional parsing). Allow it; flag other empties.
'no-empty': ['error', { allowEmptyCatch: true }],
},
},
// TypeScript + TSX (core/cli/mcp packages, web/jsx views). Scope
// typescript-eslint's recommended rules to .ts/.tsx only so its parser/rules
// never touch the JS files.
{
files: ['**/*.{ts,tsx}'],
extends: [tseslint.configs.recommended],
languageOptions: {
// core's detector modules run in the headless browser; DOM globals are
// declared via tsconfig `lib`, and the compiler — not eslint — checks them.
globals: { ...globals.node, ...globals.browser },
},
rules: {
// TypeScript resolves identifiers; core no-undef double-reports + can't see
// ambient/lib globals. Off for TS, per typescript-eslint guidance.
'no-undef': 'off',
'@typescript-eslint/no-unused-vars': unusedVars,
// The engine is mid-migration to strict types; `any` is allowed for now and
// ramped down per-module (see MIGRATION.md). Keep correctness rules on.
'@typescript-eslint/no-explicit-any': 'off',
'no-empty': ['error', { allowEmptyCatch: true }],
// Style, not correctness — and the JS half of the repo doesn't enforce
// these either. `var` is intentional in the in-page serialized detectors
// (text.ts/rules.ts run inside the browser), so leave it alone.
'no-var': 'off',
'prefer-const': 'off',
},
},
// Cloudflare Workers runtime for the Pages Functions (now TypeScript). For .ts
// the compiler resolves globals (no-undef is off above); these globals also
// cover any remaining .js and keep the worker env explicit.
{
files: ['apps/web/functions/**/*.{js,ts,tsx}'],
languageOptions: {
globals: { ...globals.node, ...globals.worker, ...globals.browser },
},
},
// In-browser evaluation JS modules (the CLI's Puppeteer runner). These export
// functions serialized + executed inside the headless page, so document/window/
// getComputedStyle are defined at runtime. (core's equivalents are .ts above.)
{
files: ['packages/cli/src/detector.ts', 'packages/cli/bin/*.ts'],
languageOptions: {
globals: { ...globals.node, ...globals.browser },
},
},
// Test files also get the node:test harness via imports; just ensure Node env.
{
files: ['**/test/**/*.{js,ts}', '**/*.test.{js,ts}'],
languageOptions: {
globals: { ...globals.node },
},
},
// Must come last: disable all formatting rules so Prettier is the only
// authority on layout.
prettier
);