-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.ts
More file actions
86 lines (85 loc) · 3.37 KB
/
eslint.config.ts
File metadata and controls
86 lines (85 loc) · 3.37 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
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import unicorn from 'eslint-plugin-unicorn';
import importX from 'eslint-plugin-import-x';
import prettier from 'eslint-plugin-prettier/recommended';
// eslint-disable-next-line @typescript-eslint/no-deprecated -- defineConfig not yet available in this version
export default tseslint.config(
{
ignores: [
'**/dist/',
'**/node_modules/',
'**/bin/',
'**/coverage/',
'packages/site/',
'scripts/',
'**/test/integration/bun.test.ts',
'**/test/integration/deno.test.ts',
'**/test/integration/node.test.mts'
]
},
eslint.configs.recommended,
tseslint.configs.strictTypeChecked,
{
languageOptions: {
parserOptions: {
project: 'tsconfig.eslint.json',
tsconfigRootDir: import.meta.dirname
}
}
},
unicorn.configs['recommended'],
{
plugins: {
'import-x': importX
}
},
{
rules: {
// Short variable names are fine in this codebase
'unicorn/prevent-abbreviations': 'off',
// We use null returns
'unicorn/no-null': 'off',
// forEach is fine for side-effectful iteration
'unicorn/no-array-for-each': 'off',
// Nested ternaries are sometimes the clearest expression
'unicorn/no-nested-ternary': 'off',
// We use process.exit
'unicorn/no-process-exit': 'off',
// Our files use camelCase
'unicorn/filename-case': 'off',
// Lonely if in else is fine
'unicorn/no-lonely-if': 'off',
// Enforce `import type` for type-only imports
'@typescript-eslint/consistent-type-imports': ['error', { disallowTypeAnnotations: false }],
// Prefer `import type` over `import { type ... }`
'import-x/consistent-type-specifier-style': ['error', 'prefer-top-level']
}
},
// Relaxed rules for test files
{
files: ['packages/*/test/**/*.ts', 'packages/*/test/**/*.mts'],
rules: {
// Tests use `any` casts for mock objects
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/no-unused-expressions': 'off',
'@typescript-eslint/no-misused-promises': 'off',
// Tests use non-null assertions on known-good values
'@typescript-eslint/no-non-null-assertion': 'off',
// Test describe/it return promises that don't need handling
'@typescript-eslint/no-floating-promises': 'off',
// Test helpers defined inside describe blocks for locality
'unicorn/consistent-function-scoping': 'off',
// Async handlers without await are valid in tests
'@typescript-eslint/require-await': 'off',
// mockResolvedValue(undefined) is idiomatic in vitest
'unicorn/no-useless-undefined': 'off'
}
},
// Prettier must be last to override all formatting rules
prettier
);