-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.ts
More file actions
91 lines (89 loc) Β· 3.1 KB
/
Copy patheslint.config.ts
File metadata and controls
91 lines (89 loc) Β· 3.1 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
import eslintPlugin from '@typescript-eslint/eslint-plugin';
import parser from '@typescript-eslint/parser';
import sonarjs from 'eslint-plugin-sonarjs';
import type { Linter } from 'eslint';
const config: Linter.Config[] = [
{
ignores: [
'dist/**',
'dist-test/**',
'node_modules/**',
'coverage/**',
'*.tsbuildinfo',
'eslint.config.ts',
// VitePress site config is built by Vite, not by our tsc project.
// Linting it would require adding it to a tsconfig, which would
// pull docs-site code into the main type-check pass.
'.vitepress/**',
],
},
{
files: ['**/*.ts', '**/*.tsx'],
languageOptions: {
parser,
parserOptions: {
project: ['./tsconfig.json', './tsconfig.test.json'],
},
},
plugins: {
'@typescript-eslint': eslintPlugin,
sonarjs,
},
rules: {
// This is a CLI β console.log is the UI, not leftover debug output.
'no-console': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
ignoreRestSiblings: true,
},
],
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/no-misused-promises': 'error',
'@typescript-eslint/consistent-type-imports': ['error', { fixStyle: 'inline-type-imports' }],
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/prefer-nullish-coalescing': 'error',
'@typescript-eslint/switch-exhaustiveness-check': [
'error',
{ considerDefaultExhaustiveForUnions: true },
],
},
},
{
// Complexity ceiling for source code. Existing violators carry an inline
// `eslint-disable-next-line ... -- TODO(complexity)` so the door is locked
// against new bloat; grep for `TODO(complexity)` to inventory the debt.
files: ['src/**/*.ts', 'src/**/*.tsx'],
rules: {
complexity: ['error', { max: 25 }],
'max-lines': ['error', { max: 700, skipBlankLines: true, skipComments: true }],
'max-lines-per-function': [
'error',
{ max: 300, skipBlankLines: true, skipComments: true, IIFEs: true },
],
'max-depth': ['error', 5],
'max-params': ['error', 6],
'max-statements': ['error', 60],
'max-nested-callbacks': ['error', 4],
'sonarjs/cognitive-complexity': ['error', 30],
'sonarjs/no-identical-functions': 'error',
},
},
{
// node:test accepts async test/describe callbacks and handles them internally,
// so the floating-promise/misused-promise rules produce false positives there.
// Tests legitimately get long (table-driven cases, fixtures, mocks) so
// complexity caps don't apply.
files: ['test/**/*.ts', 'test/**/*.tsx'],
rules: {
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/no-misused-promises': 'off',
// Tests legitimately use `any` for ad-hoc mocks and partial doubles.
// Source code is held to the stricter `error` setting.
'@typescript-eslint/no-explicit-any': 'off',
},
},
];
export default config;