- no-direct-socket-io: extend allowlist to cover apps/*/src/**/*.test.ts so the realtime-ping e2e integration test can import socket.io/socket.io-client directly; add two valid test cases to keep the rule's own test suite green - tsconfig.json (root): add root-level tsconfig with experimentalDecorators + emitDecoratorMetadata and no "include" so tsx 4.21.0's createFilesMatcher resolves decorator config for all workspace packages, not just web-next's own source tree - web-next dev script: pass TSX_TSCONFIG_PATH=../../tsconfig.json so the custom Node server uses the root tsconfig for all modules it loads - next.config.mjs: add @repo/core-events and @repo/core-realtime to transpilePackages so Next.js webpack can resolve their workspace source files - server.ts: replace static authContainer import with a dynamic import inside IRealtimeAuthenticator.authenticate so Inversify decorators are applied only after bindAll() has already populated the container All CI gates pass: lint (0 errors), typecheck, 20 tests (incl. realtime-ping e2e), boundaries (0 issues). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
35 lines
1.2 KiB
JavaScript
35 lines
1.2 KiB
JavaScript
// packages/core-eslint/rules/no-direct-socket-io.js
|
|
const ALLOWED = [
|
|
/\/packages\/core-realtime\/src\//,
|
|
/\/apps\/[^/]+\/server\.ts$/,
|
|
/\/apps\/[^/]+\/src\/.*\.test\.ts$/,
|
|
];
|
|
|
|
export default {
|
|
meta: {
|
|
type: "problem",
|
|
docs: { description: "Block direct socket.io imports outside core-realtime + app servers" },
|
|
messages: {
|
|
noDirectSocketIO: 'Import from "@repo/core-realtime" instead of "socket.io". Direct imports allowed only in packages/core-realtime/src/ and apps/*/server.ts.',
|
|
noDirectSocketIOClient: 'Use the realtime helpers from "@repo/core-realtime" / "@repo/core-testing/instrumentation" instead of "socket.io-client".',
|
|
},
|
|
schema: [],
|
|
},
|
|
create(context) {
|
|
const filename = context.filename ?? context.getFilename();
|
|
const allowed = ALLOWED.some((re) => re.test(filename));
|
|
if (allowed) return {};
|
|
|
|
return {
|
|
ImportDeclaration(node) {
|
|
const source = node.source.value;
|
|
if (source === "socket.io") {
|
|
context.report({ node, messageId: "noDirectSocketIO" });
|
|
} else if (source === "socket.io-client") {
|
|
context.report({ node, messageId: "noDirectSocketIOClient" });
|
|
}
|
|
},
|
|
};
|
|
},
|
|
};
|