Skip to content
This repository was archived by the owner on Aug 20, 2026. It is now read-only.

Commit 97a78ee

Browse files
committed
chore(lint): ban node: imports and Buffer in runtime src (static Worker-isomorphism guard)
1 parent 6eee93a commit 97a78ee

1 file changed

Lines changed: 51 additions & 0 deletions

File tree

eslint.config.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,57 @@ export default tseslint.config(
4242
plugins: { local: { rules: { 'no-non-barrel-index': noNonBarrelIndex } } },
4343
rules: { 'local/no-non-barrel-index': 'error' },
4444
},
45+
{
46+
// Static Worker-isomorphism guard: byte-codec is a Worker-isomorphic library, so runtime src (the published code under src/) must not import node:* or bare Node builtins or use the Node-only Buffer global. Test files and test-support legitimately use node:fs for fixtures; they are not published and are exempted here.
47+
files: ['src/**/*.ts'],
48+
ignores: ['src/**/*.test.ts', 'src/test-support/**'],
49+
rules: {
50+
'no-restricted-imports': [
51+
'error',
52+
{
53+
patterns: [
54+
{
55+
group: ['node:*', 'node:*/**'],
56+
message:
57+
'This is a Worker-isomorphic library: node:* imports are banned in runtime src. Use a Web API or an isomorphic helper.',
58+
},
59+
{
60+
group: [
61+
'fs',
62+
'path',
63+
'crypto',
64+
'child_process',
65+
'os',
66+
'net',
67+
'http',
68+
'https',
69+
'stream',
70+
'util',
71+
'buffer',
72+
'url',
73+
'zlib',
74+
'readline',
75+
'worker_threads',
76+
'timers',
77+
'events',
78+
'assert',
79+
],
80+
message:
81+
'This is a Worker-isomorphic library: bare Node builtin imports are banned in runtime src. Use a Web API or an isomorphic helper.',
82+
},
83+
],
84+
},
85+
],
86+
'no-restricted-globals': [
87+
'error',
88+
{
89+
name: 'Buffer',
90+
message:
91+
'Buffer is Node-only; this Worker-isomorphic library uses Uint8Array.',
92+
},
93+
],
94+
},
95+
},
4596
{
4697
ignores: ['dist/**', 'node_modules/**'],
4798
},

0 commit comments

Comments
 (0)