Repository navigation
Expand file tree
/
Copy patheslint.config.js
More file actions
229 lines (228 loc) · 8.87 KB
/
Copy patheslint.config.js
File metadata and controls
229 lines (228 loc) · 8.87 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
import tseslint from 'typescript-eslint';
export default tseslint.config(
{
ignores: ['**/dist/**', '**/node_modules/**', '**/coverage/**', '**/*.js', '**/*.cjs'],
},
{
linterOptions: {
reportUnusedDisableDirectives: 'warn',
},
},
...tseslint.configs.recommended,
{
rules: {
'@typescript-eslint/no-unused-vars': [
'warn',
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
],
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-empty-object-type': 'off',
// `verbatimModuleSyntax: true` in tsconfig.base.json requires explicit
// `import type` for type-only imports. Enforce via lint to catch missing
// `type` keywords (helps tree-shaking + ESM correctness).
// `disallowTypeAnnotations: false` lets inline `import('./x').T`
// type annotations through — those are circular-dep workarounds
// and should be removed by restructuring, not mechanical lint-fix.
'@typescript-eslint/consistent-type-imports': [
'warn',
{
prefer: 'type-imports',
fixStyle: 'separate-type-imports',
disallowTypeAnnotations: false,
},
],
'@typescript-eslint/no-require-imports': 'off',
'@typescript-eslint/no-unsafe-function-type': 'warn',
'@typescript-eslint/no-unused-expressions': 'warn',
'prefer-const': 'warn',
// Forbid silent `.catch(() => {})` and `.catch((_) => {})`.
// Use `ignoreError(promise, tag)` / `silentCatch(tag)` from
// `packages/ui/src/utils/ignore-error.ts` instead so swallowed
// rejections still surface in dev tools with a domain tag.
'no-restricted-syntax': [
'warn',
{
selector:
"CallExpression[callee.property.name='catch'][arguments.0.type='ArrowFunctionExpression'][arguments.0.body.type='BlockStatement'][arguments.0.body.body.length=0]",
message:
'Silent .catch(() => {}) swallows rejections invisibly. Use ignoreError(promise, tag) or silentCatch(tag) from utils/ignore-error.ts.',
},
],
},
},
{
// Gateway source files: prevent importing tool symbols from
// '@ownpilot/core/agent'. These are now re-exported from
// '@ownpilot/core/tools' and should be imported from there.
// Non-tool symbols (Message, Agent, createProvider, etc.) are still
// allowed from '@ownpilot/core/agent'.
files: ['packages/gateway/src/**/*.ts', 'packages/gateway/src/**/*.tsx'],
rules: {
'no-restricted-imports': [
'warn',
{
paths: [
{
name: '@ownpilot/core/agent',
importNames: [
'ToolDefinition',
'ToolExecutor',
'RegisteredTool',
'ToolContext',
'ToolExecutionResult',
'ToolCall',
'ToolResult',
'ToolProvider',
'ToolMiddleware',
'ToolSource',
'ToolConfigRequirement',
'ExecutionPermissions',
'ExecutionCategory',
'PermissionMode',
'ToolRegistry',
'createToolRegistry',
'registerCoreTools',
'DEFAULT_EXECUTION_PERMISSIONS',
'qualifyToolName',
'getBaseName',
'getNamespace',
'isQualifiedName',
'sanitizeToolName',
'desanitizeToolName',
'TOOL_GROUPS',
'DEFAULT_ENABLED_GROUPS',
'getGroupForTool',
'findSimilarToolNames',
'formatFullToolHelp',
'buildToolHelpText',
'validateRequiredParams',
'createPluginSecurityMiddleware',
'setModuleResolver',
'tryImport',
'isCallToolHardBlocked',
'isToolCallAllowed',
'TOOL_SEARCH_TAGS',
'TOOL_MAX_LIMITS',
'applyToolLimits',
'isPathAllowedAsync',
'createDynamicToolRegistry',
'searchToolsDefinition',
'getToolHelpDefinition',
'useToolDefinition',
'batchUseToolDefinition',
'registerAllTools',
'ALL_TOOLS',
'MEMORY_TOOLS',
'GOAL_TOOLS',
'CUSTOM_DATA_TOOLS',
'PERSONAL_DATA_TOOLS',
'FILE_SYSTEM_TOOLS',
'CODE_EXECUTION_TOOLS',
'WEB_FETCH_TOOLS',
'DYNAMIC_TOOL_DEFINITIONS',
],
message:
"Import tool symbols from '@ownpilot/core/tools' instead of '@ownpilot/core/agent'. See packages/core/src/agent/tools/index.ts for the full export surface.",
},
{
name: '@ownpilot/core/services',
importNames: [
'IClawService',
'ClawMode',
'ClawState',
'ClawSandboxMode',
'ClawConfig',
'CreateClawInput',
'UpdateClawInput',
'ClawEscalation',
'ClawSession',
'ClawToolCall',
'ClawCycleResult',
'ClawHistoryEntry',
'ClawTask',
'ClawTaskStatus',
'ClawPlanHistoryEntry',
'DEFAULT_CLAW_LIMITS',
'MAX_CLAW_DEPTH',
'CLAW_RECENT_FAILURES_MAX',
'CLAW_REFLECTION_THRESHOLD',
'CLAW_MAX_TASKS',
'CLAW_TASK_STALL_THRESHOLD',
'CLAW_TASK_STALL_AUTO_ESCALATE',
'CLAW_TASK_STALL_FORCE_BLOCK',
'CLAW_NEXT_INTENT_MAX',
'CLAW_PLAN_HISTORY_MAX',
'getClawService',
'setClawService',
'hasClawService',
'ClawToken',
],
message:
"Import claw symbols from '@ownpilot/core/services/claw' instead of '@ownpilot/core/services'. Run: node scripts/detect-mock-mismatch.mjs after migrating.",
},
{
name: '@ownpilot/core/services',
importNames: [
'ICodingAgentService',
'BuiltinCodingAgentProvider',
'CodingAgentProvider',
'CodingAgentMode',
'CodingAgentSessionMode',
'CodingAgentSessionState',
'CodingAgentTask',
'CodingAgentResult',
'CodingAgentStatus',
'CodingAgentSession',
'CreateCodingSessionInput',
'CodingAgentOutputFormat',
'CodingAgentFileAccess',
'CodingAgentAutonomy',
'CodingAgentPermissions',
'CodingAgentSkill',
'OrchestrationRunStatus',
'OrchestrationStep',
'OrchestrationAnalysis',
'StartOrchestrationInput',
'OrchestrationRun',
'isBuiltinProvider',
'getCustomProviderName',
'DEFAULT_CODING_AGENT_PERMISSIONS',
'getCodingAgentService',
'setCodingAgentService',
'hasCodingAgentService',
'CodingAgentToken',
],
message:
"Import coding-agent symbols from '@ownpilot/core/services/coding-agent' instead of '@ownpilot/core/services'. Run: node scripts/detect-mock-mismatch.mjs after migrating.",
},
],
},
],
},
},
{
// Test files: relax `no-explicit-any` so production warnings stay visible
// in the noise floor. Mock typing is rarely worth the ergonomic cost.
// Silent catches are still allowed in tests (e.g. seed cleanup) — the
// ban is on production behaviour.
//
// no-restricted-syntax is overridden for tests with a narrower rule:
// flag `vi.mock('@ownpilot/core', ...)` without a sub-path. Source code
// imports from sub-paths (e.g. '@ownpilot/core/services'), so mocking the
// bare entry point silently fails — the mock factory is never applied.
// See docs/ADR/vi-mock-sub-path-alignment.md for details.
files: ['**/*.test.ts', '**/*.test.tsx', '**/*.spec.ts', '**/*.spec.tsx', '**/test-helpers.ts'],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'no-restricted-syntax': [
'warn',
{
selector:
"CallExpression[callee.object.name='vi'][callee.property.name='mock'][arguments.0.value='@ownpilot/core']",
message:
"vi.mock('@ownpilot/core') doesn't intercept sub-path imports (e.g. '@ownpilot/core/services'). Use vi.mock('@ownpilot/core/<sub-path>', ...) instead. Run: node scripts/detect-mock-mismatch.mjs",
},
],
},
}
);