-
-
Notifications
You must be signed in to change notification settings - Fork 328
Expand file tree
/
Copy pathoxlint.config.ts
More file actions
213 lines (209 loc) · 6.56 KB
/
Copy pathoxlint.config.ts
File metadata and controls
213 lines (209 loc) · 6.56 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
import nkzw from '@nkzw/oxlint-config';
import { defineConfig } from 'oxlint';
// Product source trees, where unit tests get scratch from the package tmp-dir helpers.
// scripts/, test/, and package test harnesses manage TMPDIR for child processes on purpose,
// so keeping the roots explicit holds them out of scope that a bare `**` would sweep in.
const PRODUCT_TEST_ROOTS = ['src', 'packages/*/src'];
const PRODUCT_TEST_SHAPES = [
'**/*.test.ts',
'**/*.fixtures.ts',
'**/__tests__/**/*.ts',
'**/test-utils/**/*.ts',
];
const PRODUCT_TEST_FILES = PRODUCT_TEST_ROOTS.flatMap((root) =>
PRODUCT_TEST_SHAPES.map((shape) => `${root}/${shape}`),
);
// The last matching override replaces `no-restricted-imports` options instead of merging them,
// so each override restates every ban that applies to the files it matches.
const CHILD_PROCESS_PATH = {
message:
'Use process helpers from @agent-device/host-kit/command instead of importing node:child_process directly.',
name: 'node:child_process',
};
const PROVIDER_IMPORT_PATTERN = {
group: ['@agent-device/provider-*'],
message:
'Command implementations must ask src/cli/connection/provider-policy.ts for provider capabilities.',
};
const NODE_OS_PATH = {
message:
'Create test scratch with mkdtempForTest()/mkdtempForTestSync() from the package tmp-dir helper instead of reading node:os.',
name: 'node:os',
};
const CHILD_PROCESS_BAN_ROOTS = ['src', 'packages/host-kit/src'];
const PROVIDER_BAN_ROOTS = ['src/commands', 'src/cli/commands'];
export default defineConfig({
env: {
builtin: true,
es2024: true,
node: true,
},
extends: [nkzw],
ignorePatterns: ['dist/**', 'node_modules/**'],
rules: {
'@typescript-eslint/array-type': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@nkzw/no-instanceof': 'off',
curly: 'off',
'import/default': 'error',
'import/no-duplicates': 'error',
'import/namespace': 'error',
'import/no-namespace': 'off',
'no-caller': 'error',
'no-console': 'off',
'no-empty': ['error', { allowEmptyCatch: true }],
'no-eval': 'error',
'no-iterator': 'error',
'no-unassigned-vars': 'error',
'no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
fix: {
imports: 'safe-fix',
variables: 'suggestion',
},
varsIgnorePattern: '^_',
},
],
'perfectionist/sort-object-types': 'off',
'perfectionist/sort-objects': 'off',
'typescript/no-this-alias': 'error',
'typescript/no-unnecessary-parameter-property-assignment': 'error',
'typescript/no-useless-empty-export': 'error',
'unicorn/consistent-function-scoping': 'off',
'unicorn/numeric-separators-style': 'off',
'unicorn/prefer-top-level-await': 'off',
'unicorn/prefer-structured-clone': 'off',
},
overrides: [
{
files: ['scripts/**/*.ts', 'scripts/**/*.mts', 'scripts/**/*.cts'],
rules: {
'no-undef': 'error',
},
},
{
files: CHILD_PROCESS_BAN_ROOTS.map((root) => `${root}/**/*.ts`),
rules: {
'no-restricted-imports': ['error', { paths: [CHILD_PROCESS_PATH] }],
},
},
{
files: PROVIDER_BAN_ROOTS.map((root) => `${root}/**/*.ts`),
rules: {
'no-restricted-imports': [
'error',
{
paths: [CHILD_PROCESS_PATH],
patterns: [PROVIDER_IMPORT_PATTERN],
},
],
},
},
{
files: ['examples/test-app/src/**/*.tsx'],
rules: {
'react/immutability': 'off',
'react/purity': 'off',
'react/refs': 'off',
},
},
{
files: ['examples/test-app/app.config.js'],
rules: {
'@typescript-eslint/no-require-imports': 'off',
},
},
{
files: [
'src/daemon-client/daemon-client-rpc.ts',
'src/daemon/downloadable-artifact-http.ts',
'src/remote/remote-request-diagnostics.ts',
'src/remote/upload-stream.ts',
],
rules: {
'unicorn/catch-error-name': 'off',
'unicorn/prefer-string-replace-all': 'off',
},
},
{
files: [
'src/daemon/replay/internal/__tests__/session-replay-target-verification-runtime.test.ts',
],
rules: {
'unicorn/prefer-string-raw': 'off',
},
},
{
files: ['scripts/maestro-conformance/corpus/authored/runscript.js'],
globals: {
output: 'writable',
},
},
{
// Product tests get scratch from the package tmp-dir helpers, which honor the run's
// redirected TMPDIR; reading node:os reuses a fixed path across the suite. A file with a
// justified read (mocking production, a real socket path, or the TMPDIR mechanism itself)
// oxlint-disables its one import line with a reason instead of widening this list.
files: PRODUCT_TEST_FILES,
rules: {
'no-restricted-imports': ['error', { paths: [NODE_OS_PATH] }],
},
},
{
files: CHILD_PROCESS_BAN_ROOTS.flatMap((root) =>
PRODUCT_TEST_SHAPES.map((shape) => `${root}/${shape}`),
),
rules: {
'no-restricted-imports': ['error', { paths: [CHILD_PROCESS_PATH, NODE_OS_PATH] }],
},
},
{
files: PROVIDER_BAN_ROOTS.flatMap((root) =>
PRODUCT_TEST_SHAPES.map((shape) => `${root}/${shape}`),
),
rules: {
'no-restricted-imports': [
'error',
{
paths: [CHILD_PROCESS_PATH, NODE_OS_PATH],
patterns: [PROVIDER_IMPORT_PATTERN],
},
],
},
},
{
// Tests may import node:child_process and provider packages directly.
files: ['packages/host-kit/src/**/*.test.ts', 'src/**/*.test.ts', 'src/**/__tests__/**/*.ts'],
rules: {
'no-restricted-imports': ['error', { paths: [NODE_OS_PATH] }],
},
},
{
// The tmp-dir helper modules are the sanctioned os.tmpdir() readers.
files: ['**/tmp-dir.ts', '**/tmp-dir.fixtures.ts'],
rules: {
'no-restricted-imports': ['error', { paths: [] }],
},
},
{
files: CHILD_PROCESS_BAN_ROOTS.flatMap((root) => [
`${root}/**/tmp-dir.ts`,
`${root}/**/tmp-dir.fixtures.ts`,
]),
rules: {
'no-restricted-imports': ['error', { paths: [CHILD_PROCESS_PATH] }],
},
},
{
// The host-kit process helpers are the sanctioned node:child_process importer.
files: ['packages/host-kit/src/internal/exec.ts'],
rules: {
'no-restricted-imports': ['error', { paths: [] }],
},
},
],
});