Skip to content

Commit 853f612

Browse files
committed
chore(lint): forbid node:os in product tests
Add a no-restricted-imports override so a product *.test.ts that imports node:os is a lint error pointing at mkdtempForTest, mirroring the existing node:child_process ban. A follow-up override clears it for the handful of tests that mock production's os.tmpdir()/os.homedir() or assert a real /tmp socket.
1 parent f8fd863 commit 853f612

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

‎oxlint.config.ts‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,5 +146,41 @@ export default defineConfig({
146146
output: 'writable',
147147
},
148148
},
149+
{
150+
// Product tests get scratch from the package tmp-dir helpers, which honor
151+
// the run's redirected TMPDIR; reading node:os in a test reuses a fixed path.
152+
files: ['src/**/*.test.ts', 'packages/*/src/**/*.test.ts'],
153+
rules: {
154+
'no-restricted-imports': [
155+
'error',
156+
{
157+
paths: [
158+
{
159+
name: 'node:os',
160+
message:
161+
'Create test scratch with mkdtempForTest()/mkdtempForTestSync() from the package tmp-dir helper instead of reading node:os.',
162+
},
163+
],
164+
},
165+
],
166+
},
167+
},
168+
{
169+
// Tests that mock production's os.tmpdir()/os.homedir() or assert a real /tmp socket path.
170+
files: [
171+
'src/__tests__/cli-diff.test.ts',
172+
'src/__tests__/daemon-process-takeover.test.ts',
173+
'src/__tests__/hermetic-env-setup.test.ts',
174+
'src/__tests__/install-source.test.ts',
175+
'src/commands/replay/source-discovery.test.ts',
176+
'src/daemon/__tests__/session-store.test.ts',
177+
'packages/host-kit/src/code-signature-cache.test.ts',
178+
'packages/platform-android/src/__tests__/install-artifact-cancellation.test.ts',
179+
'packages/platform-apple/src/runner/__tests__/runner-xctestrun.test.ts',
180+
],
181+
rules: {
182+
'no-restricted-imports': ['error', { paths: [] }],
183+
},
184+
},
149185
],
150186
});

0 commit comments

Comments
 (0)