-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy patheslint.config.js
More file actions
134 lines (132 loc) · 5.24 KB
/
Copy patheslint.config.js
File metadata and controls
134 lines (132 loc) · 5.24 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
import tseslint from 'typescript-eslint';
import prettier from 'eslint-config-prettier';
import jsdoc from 'eslint-plugin-jsdoc';
export default tseslint.config(
{
ignores: ['**/dist/**', '**/node_modules/**', '**/coverage/**', '**/.turbo/**', '**/*.cjs'],
},
...tseslint.configs.recommended,
// Type-aware lint pass — scoped to package source + tests so it gets the
// SDK surface and its tests. Examples have their own tsconfig contexts and
// are intentionally excluded from typed lint to avoid pinning every
// example's tsconfig to this lint runner.
//
// Uses explicit `project` paths (not `projectService: true`) because each
// package keeps tests in `tsconfig.test.json` rather than `tsconfig.json` —
// projectService's auto-discovery only finds `tsconfig.json` files, which
// wouldn't pick up test files. `tsconfig.test.json` extends `tsconfig.json`
// and includes both `src/**` and `test/**`, so a single project per package
// covers both.
...tseslint.configs.recommendedTypeChecked.map((config) => ({
...config,
files: ['packages/**/src/**/*.ts', 'packages/**/test/**/*.ts'],
languageOptions: {
...config.languageOptions,
parserOptions: {
...config.languageOptions?.parserOptions,
project: ['./packages/*/tsconfig.test.json'],
tsconfigRootDir: import.meta.dirname,
},
},
})),
{
files: ['**/*.ts'],
languageOptions: {
ecmaVersion: 2022,
sourceType: 'module',
},
rules: {
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
},
],
},
},
// Public-surface hygiene — these rules need type info, so they only run on
// the type-aware pass above (packages/**/src + packages/**/test). The set
// mirrors what the audit (CODE_REVIEW.md Finding 3) recommended; tests
// share most of the bar with src but skip the no-non-null-assertion rule
// because table-driven cases routinely look up fixtures by key.
{
files: ['packages/**/src/**/*.ts'],
rules: {
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/no-misused-promises': 'error',
'@typescript-eslint/no-non-null-assertion': 'error',
'@typescript-eslint/no-unnecessary-condition': 'error',
'@typescript-eslint/prefer-readonly': 'warn',
'@typescript-eslint/switch-exhaustiveness-check': 'error',
'@typescript-eslint/consistent-type-imports': [
'error',
{ prefer: 'type-imports', fixStyle: 'separate-type-imports' },
],
'no-restricted-imports': [
'error',
{
patterns: [
{
group: ['@inflow/*/src', '@inflow/*/src/*'],
message: "Import from the package public API instead of another package's src internals.",
},
],
},
],
},
},
{
files: ['packages/**/test/**/*.ts'],
rules: {
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/no-misused-promises': 'error',
'@typescript-eslint/no-unnecessary-condition': 'error',
'@typescript-eslint/switch-exhaustiveness-check': 'error',
'@typescript-eslint/consistent-type-imports': [
'error',
{ prefer: 'type-imports', fixStyle: 'separate-type-imports' },
],
},
},
// TSDoc quality bar — see AGENTS.md for the principles these rules encode.
// Goal: prevent regression of the patterns trimmed in the doc audit; not to
// force every symbol to carry TSDoc. Rules are scoped to package source only.
{
files: ['packages/**/src/**/*.ts'],
plugins: { jsdoc },
settings: {
jsdoc: { mode: 'typescript' },
},
rules: {
// Hard errors — these were all clean post-audit; keep them clean.
'jsdoc/no-types': 'error', // TSDoc on TS shouldn't restate types
'jsdoc/no-blank-blocks': 'error', // empty /** */ blocks
'jsdoc/empty-tags': 'error', // @returns with no description, etc.
// `@typeParam` is the official TSDoc tag for generic type parameters (typedoc renders it natively). The
// built-in JSDoc tag set the rule defaults to doesn't include it, so list it here alongside `@internal`.
'jsdoc/check-tag-names': ['error', { definedTags: ['internal', 'typeParam'] }],
'jsdoc/check-alignment': 'error',
'jsdoc/multiline-blocks': 'error',
'jsdoc/no-multi-asterisks': 'error',
'jsdoc/require-asterisk-prefix': 'error',
// Warnings — would flag noise that snuck back in but isn't load-bearing.
'jsdoc/check-param-names': 'warn', // @param name must match actual param
'jsdoc/no-defaults': 'warn', // don't restate TS default-param values
'jsdoc/require-hyphen-before-param-description': ['warn', 'always'],
},
},
// Publishable source is the SDK surface — no console output leaks. Throw
// typed errors instead and let the caller decide. Examples and scripts are
// unaffected; the audit confirmed all current `console.*` calls live there.
{
files: ['packages/**/src/**/*.ts'],
rules: {
'no-console': 'error',
},
},
prettier,
);