-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.js
More file actions
100 lines (98 loc) · 3.97 KB
/
Copy patheslint.config.js
File metadata and controls
100 lines (98 loc) · 3.97 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
// Root ESLint flat config. Governs every workspace EXCEPT
// `packages/app/` (which keeps its own React-specific config at
// packages/app/eslint.config.js) and the generated/test
// scaffolding (dist, node_modules, fragments/example).
//
// The rule set is intentionally conservative for the first landing:
// - typescript-eslint `recommended` (no `any`, no unused vars, etc.)
// - no-console for server packages (warn — the structured logger
// replaces these incrementally; honoring the existing
// `eslint-disable-next-line no-console` directives so we don't get
// re-noised when they're added intentionally)
// - eqeqeq + prefer-const
// - no-empty (allowing catch on purpose — we have many fire-and-forget
// sites)
//
// Type-aware rules (no-floating-promises, no-misused-promises) are NOT
// enabled yet: turning them on requires every TS file (including
// integration test files) to live inside a tsconfig project, and the
// scattershot test-only files would all need to be added. That's a
// separate cleanup. The structured logger conversion is similarly
// deferred.
//
// To run: `npx eslint .` from the repo root (or `npm run lint`).
import js from '@eslint/js';
import tseslint from 'typescript-eslint';
export default tseslint.config(
{
ignores: [
'**/dist/**',
'**/node_modules/**',
'**/.nx/**',
'packages/desktop/**',
'packages/app/**', // app keeps its own config
'packages/app-scaffold/fragments/example/**',
],
},
{
files: ['packages/**/*.ts', 'packages/**/*.tsx', 'packages/**/*.mts', 'packages/**/*.cts'],
extends: [js.configs.recommended, ...tseslint.configs.recommended],
languageOptions: {
ecmaVersion: 2022,
sourceType: 'module',
},
linterOptions: {
// The codebase has many "// eslint-disable-next-line no-console"
// directives that pre-date this root config. Don't fail on
// unused directives — they document operator-visible logging
// that's intentionally exempted from a future no-console rule.
reportUnusedDisableDirectives: 'off',
},
rules: {
eqeqeq: ['error', 'always', { null: 'ignore' }],
'prefer-const': 'error',
'no-empty': ['error', { allowEmptyCatch: true }],
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
},
],
// The `no-explicit-any` rule is enabled by the recommended set;
// soften to a warning for now so the long-tail doesn't gate this
// landing. Promote to error once the cleanup catches up.
'@typescript-eslint/no-explicit-any': 'warn',
// File-size guardrail. Hard error at 1000 lines (skipping blank
// lines and comments). Every server file now lives well under
// this; flipping it to 'error' prevents the next monolith from
// re-appearing. Test files are exempted (see overrides below).
'max-lines': ['error', { max: 1000, skipBlankLines: true, skipComments: true }],
},
},
{
files: ['packages/server/**/*.ts', 'packages/server/**/*.tsx'],
rules: {
// Structured logger (pino) lands as a follow-up. Until then,
// every console.* in server source carries an explicit
// disable directive on the line above so the call site is auditable.
'no-console': 'warn',
},
},
{
// Test files relax a couple of rules that get in the way of
// pragmatic test code (expressive any-cast, _ unused captures).
files: ['packages/**/test/**', 'packages/**/*.test.ts', 'packages/**/*.test.tsx'],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'no-console': 'off',
// Test files are allowed to grow longer — they accrete fixtures
// and assertions across many test cases. Splitting them is
// valuable but never urgent the way a 1600-line route dispatcher
// is.
'max-lines': 'off',
},
},
);