Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active
TypeScript aianthropicartifactsawsazurechatgptchatgpt-cloneclaudeclonedeepseekgeminigooglegpt-5librechatmcpo1openairesponses-apivisionwebui
🧱 refactor: Judge Chat Package Imports on the Resolved Module (#16975)
Marco Beretta8e60a4185a0c
diff --git a/.github/workflows/static-checks.yml b/.github/workflows/static-checks.ymlindex 079535c486..1ce8492813 100644--- a/.github/workflows/static-checks.yml+++ b/.github/workflows/static-checks.yml@@ -315,7 +315,7 @@ jobs:run: |node_modules/.bin/eslint --config eslint.config.mjs \api/server/index.js client/src/main.jsx packages/api/src/index.ts- node --test scripts/eslint/design.test.mjs+ node --test scripts/eslint/design.test.mjs scripts/eslint/chat.test.mjs- name: Validate the design-rule suppressions baselineid: suppressionsdiff --git a/e2e/specs/mock/scenarios/chat-package.spec.ts b/e2e/specs/mock/scenarios/chat-package.spec.tsindex 004d800ab0..a976691ce9 100644--- a/e2e/specs/mock/scenarios/chat-package.spec.ts+++ b/e2e/specs/mock/scenarios/chat-package.spec.ts@@ -26,102 +26,122 @@ const UI_MODULES = ['@librechat/client',];-const restricted = (relativePath: string, source: string): string[] =>- messagesFor(lintStdin(relativePath, source), 'no-restricted-imports');--/** `import()` and `require()` are not static imports; their own rule reports them. */-const restrictedLoad = (relativePath: string, specifier: string): string[] =>- messagesFor(- lintStdin(- relativePath,- [- `export const load = () => import('${specifier}');`,- `export const sync = () => require('${specifier}');`,- `export const template = () => import(\`${specifier}\`);`,- `export const templateSync = () => require(\`${specifier}\`);`,- '',- ].join('\n'),- ),- 'no-restricted-syntax',+/** The forms a source can load a module in; the boundary judges each the same way. */+const FORMS = (specifier: string): string[] => [+ `import x from '${specifier}';\nexport default x;\n`,+ `export * from '${specifier}';\n`,+ `export const load = () => import('${specifier}');\n`,+ `export const load = () => import(\`${specifier}\`);\n`,+ `export const load = () => require('${specifier}');\n`,+ `export type X = typeof import('${specifier}');\n`,+];++/** One row of the boundary table: a file, a specifier, and whether the boundary rejects it. */+type BoundaryRow = { file: string; specifier: string; rejected: boolean };++const CORE = 'packages/chat/src/core/streaming/probe.ts';+const BINDING = 'packages/chat/src/react/probe.ts';+const COMPONENT = 'packages/chat/src/components/Probe.tsx';++/** Every spelling of the `/react` and `/components` entries from a nested core file. */+const ENTRY_SPELLINGS = ['react', 'components'].flatMap((entry) => [+ `../../${entry}`,+ `../../${entry}/`,+ `../../${entry}.ts`,+ `../../${entry}.tsx`,+ `../../${entry}.js`,+ `../../${entry}.mjs`,+ `../../${entry}.cjs`,+ `../../${entry}/index`,+ `../../${entry}/index.js`,+]);++const row = (file: string, rejected: boolean) => (specifier: string) => ({+ file,+ specifier,+ rejected,+});++const CORE_TABLE: BoundaryRow[] = [+ ...ENTRY_SPELLINGS.map(row(CORE, true)),+ ...[+ 'react',+ 'react/jsx-runtime',+ 'react-dom/client',+ 'jotai/utils',+ '@tanstack/react-query',+ '@librechat/client',+ '@librechat/chat/react',+ '@librechat/chat/components',+ ].map(row(CORE, true)),+ ...['react', './components/'].map(row('packages/chat/src/index.ts', true)),+ ...['librechat-data-provider', '../types', '../types.js', './react-utils', '../reactive.js'].map(+ row(CORE, false),+ ),+ ...['react', 'jotai', '../core', '../components'].map(row(BINDING, false)),+];++const APP_TABLE: BoundaryRow[] = [BINDING, COMPONENT, CORE].flatMap((file) =>+ [+ '~/store',+ '@librechat/frontend',+ '@librechat/frontend/src/store/filesDialog',+ 'recoil',+ '@librechat/chat',+ '@librechat/chat/components',+ ].map(row(file, true)),+);++/**+ * Lints every row in every form through the real flat config in one process, and returns the+ * sources whose verdict differs from the table, so a failure names the spelling that slipped.+ */+function boundaryMismatches(rows: BoundaryRow[]): string[] {+ const sources = rows.flatMap((entry) =>+ FORMS(entry.specifier).map((code) => ({ ...entry, code })),+ );+ const query = `+ const { ESLint } = require('eslint');+ const sources = JSON.parse(require('fs').readFileSync(0, 'utf8'));+ (async () => {+ const eslint = new ESLint({ overrideConfigFile: 'eslint.config.mjs' });+ const verdicts = [];+ for (const source of sources) {+ const [result] = await eslint.lintText(source.code, { filePath: source.file });+ verdicts.push(result.messages.filter((m) => m.ruleId === 'chat/boundary').length);+ }+ process.stdout.write(JSON.stringify(verdicts));+ })();+ `;+ const answered = run(process.execPath, ['-e', query], { input: JSON.stringify(sources) });+ if (answered.status !== 0) throw new Error(`no lint verdicts: ${answered.output}`);+ const verdicts = JSON.parse(answered.stdout) as number[];+ return sources.flatMap((source, index) =>+ verdicts[index] > 0 === source.rejected+ ? []+ : [+ `${source.file}: ${source.code.trim()} should be ${source.rejected ? 'rejected' : 'allowed'}`,+ ],);+}test.describe('the @librechat/chat package boundary', () => {test.beforeEach(() => inOneProject());test('the chat core rejects a UI framework import @scenario:the-chat-core-rejects-a-ui-framework-import', () => {- test.setTimeout(120_000);- const source = "import { useState } from 'react';\nexport const probe = useState;\n";+ test.setTimeout(180_000);+ expect(boundaryMismatches(CORE_TABLE)).toEqual([]);- const core = restricted('packages/chat/src/core/probe.ts', source);- expect(core.join('\n')).toContain("'react' import is restricted");- expect(restricted('packages/chat/src/index.ts', source)).toHaveLength(1);- expect(restricted('packages/chat/src/core/Probe.tsx', source)).toHaveLength(1);const jsx = lintStdin('packages/chat/src/core/Probe.tsx','export const Probe = () => <div />;\n',);expect(messagesFor(jsx, 'no-restricted-syntax')).toHaveLength(1);- for (const entry of ['../../react', '../../components']) {- const nested = `import * as entry from '${entry}';\nexport const probe = entry;\n`;- expect(restricted('packages/chat/src/core/streaming/probe.ts', nested), entry).toHaveLength(- 1,- );- }- expect(- restricted(- 'packages/chat/src/core/probe.ts',- "import { atom } from 'jotai';\nexport const a = atom;\n",- ),- ).toHaveLength(1);-- for (const specifier of [- 'react',- 'react/jsx-runtime',- 'jotai',- '@librechat/client',- '../components',- '../react',- '../react.js',- '../components.mjs',- ]) {- expect(restrictedLoad('packages/chat/src/core/probe.ts', specifier), specifier).toHaveLength(- 4,- );- }- expect(restrictedLoad('packages/chat/src/core/probe.ts', 'librechat-data-provider')).toEqual(- [],- );-- expect(restricted('packages/chat/src/react/probe.ts', source)).toEqual([]);- expect(restrictedLoad('packages/chat/src/react/probe.ts', 'react')).toEqual([]);});test('the chat package rejects an import from the app @scenario:the-chat-package-rejects-an-import-from-the-app', () => {- test.setTimeout(120_000);- const probes = [- "import store from '~/store';\nexport const s = store;\n",- "import { useAuthContext } from '../../../../client/src/hooks';\nexport const h = useAuthContext;\n",- "import { useRecoilValue } from 'recoil';\nexport const r = useRecoilValue;\n",- "export { showFilesDialogAtom } from '@librechat/frontend/src/store/filesDialog';\n",- "export * from '@librechat/chat/components';\n",- ];- for (const path of [- 'packages/chat/src/react/probe.ts',- 'packages/chat/src/components/probe.tsx',- ]) {- for (const source of probes) {- expect(restricted(path, source), `${path}\n${source}`).toHaveLength(1);- }- for (const specifier of [- '~/store',- '../../../../client/src/hooks',- 'recoil',- '@librechat/frontend/src/store/filesDialog',- '@librechat/chat/components',- ]) {- expect(restrictedLoad(path, specifier), `${path}\n${specifier}`).toHaveLength(4);- }- }+ test.setTimeout(180_000);+ expect(boundaryMismatches(APP_TABLE)).toEqual([]);});test('chat components reject literal copy @scenario:chat-components-reject-literal-copy', () => {diff --git a/e2e/specs/mock/scenarios/suppression-baseline.spec.ts b/e2e/specs/mock/scenarios/suppression-baseline.spec.tsindex d28c0f5faa..49ac1510a8 100644--- a/e2e/specs/mock/scenarios/suppression-baseline.spec.ts+++ b/e2e/specs/mock/scenarios/suppression-baseline.spec.ts@@ -633,6 +633,10 @@ test.describe('the recorded design-rule backlog', () => {resolve(repoRoot, 'scripts/eslint/design.mjs'),join(emptyRoot, 'scripts/eslint/design.mjs'),);+ copyFileSync(+ resolve(repoRoot, 'scripts/eslint/chat.mjs'),+ join(emptyRoot, 'scripts/eslint/chat.mjs'),+ );copyFileSync(resolve(repoRoot, 'package.json'), join(emptyRoot, 'package.json'));symlinkSync(resolve(repoRoot, 'node_modules'), join(emptyRoot, 'node_modules'), 'dir');const deleted = run(@@ -1103,6 +1107,7 @@ function syntheticRoot(): string {'scripts/i18n.mts',/** The local design rules the config registers and the runner validates against. */'scripts/eslint/design.mjs',+ 'scripts/eslint/chat.mjs','package.json','package-lock.json','eslint.config.mjs',diff --git a/eslint.config.mjs b/eslint.config.mjsindex 8ddf00ad8c..bdf63fc104 100644--- a/eslint.config.mjs+++ b/eslint.config.mjs@@ -15,6 +15,7 @@ import jest from 'eslint-plugin-jest';import globals from 'globals';import js from '@eslint/js';import design from './scripts/eslint/design.mjs';+import chat from './scripts/eslint/chat.mjs';const __filename = fileURLToPath(import.meta.url);const __dirname = path.dirname(__filename);@@ -42,53 +43,6 @@ const tenantModelRestrictions = [},];-/** `@librechat/chat` is consumed by the app, never the reverse: nothing in it reaches into `client/src`. */-const chatPackageRestrictions = [- {- group: [- '~/*',- '**/client/src',- '**/client/src/**',- '@librechat/frontend',- '@librechat/frontend/*',- ],- message: '@librechat/chat cannot import the app; take what it needs from the host instead.',- },- {- group: ['recoil'],- message:- '@librechat/chat holds no Recoil state; per-pane run state is Jotai in the React binding.',- },- {- group: ['@librechat/chat', '@librechat/chat/*'],- message: '@librechat/chat imports its own modules by relative path, not through its entries.',- },-];--/**- * `no-restricted-imports` reads only static imports, so the same boundaries are restated for- * `import()` and `require()` of a literal specifier. Each pattern is an esquery regex body, which- * cannot hold a slash, so `\x2F` stands for one.- */-const restrictedLoads = (pattern, message) => ({- selector: [- `ImportExpression[source.value=/${pattern}/]`,- `ImportExpression[source.quasis.0.value.cooked=/${pattern}/]`,- `CallExpression[callee.name='require'][arguments.0.value=/${pattern}/]`,- `CallExpression[callee.name='require'][arguments.0.quasis.0.value.cooked=/${pattern}/]`,- ].join(', '),- message,-});--const chatPackageLoads = [- restrictedLoads(- '^~\\x2F|^@librechat\\x2Ffrontend(\\x2F|$)|(^|\\x2F)client\\x2Fsrc(\\x2F|$)',- chatPackageRestrictions[0].message,- ),- restrictedLoads('^recoil(\\x2F|$)', chatPackageRestrictions[1].message),- restrictedLoads('^@librechat\\x2Fchat(\\x2F|$)', chatPackageRestrictions[2].message),-];-/** Attributes a person reads or hears; a literal in one ships untranslated copy. */const chatLiteralAttributeNames ='/^(title|alt|placeholder|label|aria-label|aria-description|aria-placeholder|aria-roledescription|aria-valuetext)$/';@@ -101,40 +55,6 @@ const chatLiteralAttributes = {message: 'Localize user-facing attribute text with useLocalize().',};-/** The core entry runs without a UI framework, so a non-React host or a worker can drive a chat. */-const chatCoreRestrictions = [- ...chatPackageRestrictions,- {- group: [- 'react',- 'react-dom',- 'react-dom/*',- 'jotai',- 'jotai/*',- '@tanstack/*',- '@librechat/client',- ],- message:- 'The @librechat/chat core has no UI dependency; React and Jotai belong in the /react entry.',- },- {- group: ['**/components', '**/components/**', '**/components.*', '../**/react.*', './react.*'],- message: 'The core cannot import the /react or /components entries; they build on the core.',- },-];--const chatCoreLoads = [- ...chatPackageLoads,- restrictedLoads(- '^(react|react-dom|jotai|@librechat\\x2Fclient)(\\x2F|$)|^@tanstack\\x2F',- chatCoreRestrictions[chatPackageRestrictions.length].message,- ),- restrictedLoads(- '(^|\\x2F)components(\\.[cm]?[jt]sx?)?(\\x2F|$)|^\\.\\.?\\x2F(.*\\x2F)?react(\\.[cm]?[jt]sx?)?(\\x2F|$)',- chatCoreRestrictions[chatPackageRestrictions.length + 1].message,- ),-];-export default [{ignores: [@@ -707,10 +627,15 @@ export default [},},{+ // What a chat source may load, judged on the resolved target however the specifier is+ // spelled (scripts/eslint/chat.mjs): nothing from the app, and no UI code in the core.files: ['packages/chat/src/**/*.{ts,tsx,js,jsx}'],+ plugins: { chat },rules: {- 'no-restricted-imports': ['error', { patterns: chatPackageRestrictions }],- 'no-restricted-syntax': ['error', ...chatPackageLoads],+ 'chat/boundary': [+ 'error',+ { sourceRoot: path.join(__dirname, 'packages/chat/src'), packageName: '@librechat/chat' },+ ],},},{@@ -726,17 +651,15 @@ export default ['should-validate-template': true,},],- 'no-restricted-syntax': ['error', ...chatPackageLoads, chatLiteralAttributes],+ 'no-restricted-syntax': ['error', chatLiteralAttributes],},},{files: ['packages/chat/src/index.ts', 'packages/chat/src/core/**/*.{ts,tsx,js,jsx}'],ignores: ['**/*.{spec,test}.{ts,tsx,js,jsx}'],rules: {- 'no-restricted-imports': ['error', { patterns: chatCoreRestrictions }],'no-restricted-syntax': ['error',- ...chatCoreLoads,{selector: 'JSXElement, JSXFragment',message:diff --git a/scripts/eslint/chat.mjs b/scripts/eslint/chat.mjsnew file mode 100644index 0000000000..a50bc7ccc3--- /dev/null+++ b/scripts/eslint/chat.mjs@@ -0,0 +1,147 @@+import path from 'node:path';++/**+ * `chat/boundary`: what a `@librechat/chat` source may load. Every way of naming a module is+ * reduced to one target before it is judged, so the rule holds however the specifier is spelled:+ * a relative path is resolved against the file and stripped of its extension, trailing slash and+ * `/index`; a bare specifier is reduced to its package name. Static imports, re-exports, `import()`+ * and `require()` of a literal or a substitution-free template, `import x = require()` and+ * `import('...')` types are all checked.+ *+ * - Anywhere in the package: nothing outside the package's own sources (the app's `~/` alias,+ * `client/src`, `@librechat/frontend`), no Recoil, and no import through the package's own name.+ * - In the core (`index.ts` and `core/**`): no UI framework (React, React DOM, Jotai, React Query,+ * `@librechat/client`, or any subpath of them) and none of the `/react` or `/components` entries.+ * A core `import()` or `require()` whose specifier cannot be read statically is reported too,+ * since the rule could not tell what it loads.+ */++const EXTENSION = /\.(?:[cm]?[jt]sx?)$/;+const UI_PACKAGES = new Set(['react', 'react-dom', 'jotai', '@librechat/client']);+const UI_SCOPES = ['@tanstack/'];+const ENTRIES = new Set(['react', 'components']);++const packageName = (specifier) => {+ const parts = specifier.split('/');+ return specifier.startsWith('@') ? parts.slice(0, 2).join('/') : parts[0];+};++/** `dir/react.ts`, `dir/react/`, `dir/react/index.mjs` all name `dir/react`. */+const normalizePath = (target) => {+ let normalized = target.replace(/[\\/]+$/, '').replace(EXTENSION, '');+ normalized = normalized.replace(/[\\/]index$/, '');+ return normalized;+};++const specifierOf = (node) => {+ if (!node) return { known: false };+ if (node.type === 'Literal' && typeof node.value === 'string') {+ return { known: true, value: node.value };+ }+ if (node.type === 'TemplateLiteral' && node.expressions.length === 0) {+ return { known: true, value: node.quasis[0].value.cooked };+ }+ if (node.type === 'TSLiteralType') return specifierOf(node.literal);+ return { known: false };+};++const boundary = {+ meta: {+ type: 'problem',+ docs: { description: 'Keeps @librechat/chat self-contained and its core free of UI code.' },+ schema: [+ {+ type: 'object',+ properties: {+ sourceRoot: { type: 'string' },+ packageName: { type: 'string' },+ },+ additionalProperties: false,+ },+ ],+ messages: {+ app: '@librechat/chat cannot load {{specifier}}; take what it needs from the host instead.',+ recoil:+ '@librechat/chat holds no Recoil state; per-pane run state is Jotai in the React binding.',+ self: '@librechat/chat imports its own modules by relative path, not through {{specifier}}.',+ ui: 'The @librechat/chat core has no UI dependency; {{specifier}} belongs in the /react entry.',+ entry: 'The core cannot load {{specifier}}; the /{{entry}} entry builds on the core.',+ opaque: 'The @librechat/chat core loads only specifiers the boundary can read.',+ },+ },+ create(context) {+ const options = context.options[0] ?? {};+ const self = options.packageName ?? '@librechat/chat';+ const root = path.resolve(context.cwd, options.sourceRoot ?? 'packages/chat/src');+ const filename = path.resolve(context.filename);+ const relativeFile = path.relative(root, filename);+ if (relativeFile.startsWith('..') || path.isAbsolute(relativeFile)) return {};+ const segments = relativeFile.split(path.sep);+ const isCore =+ (segments.length === 1 && /^index\.[cm]?[jt]sx?$/.test(segments[0])) ||+ (segments[0] === 'core' &&+ !segments.includes('__tests__') &&+ !/\.(spec|test)\./.test(relativeFile));++ const judge = (node, specifier) => {+ const report = (messageId, data = {}) =>+ context.report({ node, messageId, data: { specifier, ...data } });++ if (specifier.startsWith('.') || path.isAbsolute(specifier)) {+ const target = normalizePath(path.resolve(path.dirname(filename), specifier));+ const fromRoot = path.relative(root, target);+ if (fromRoot.startsWith('..') || path.isAbsolute(fromRoot)) return report('app');+ const entry = fromRoot.split(path.sep)[0];+ if (isCore && ENTRIES.has(entry)) return report('entry', { entry });+ return;+ }++ if (specifier === '~' || specifier.startsWith('~/')) return report('app');+ const bareSegments = normalizePath(specifier).split('/');+ /** A path alias (`baseUrl`, a bundler alias) can still name the app or an entry bare. */+ if (+ bareSegments.some(+ (segment, index) => segment === 'client' && bareSegments[index + 1] === 'src',+ )+ ) {+ return report('app');+ }+ const name = packageName(specifier);+ if (name === '@librechat/frontend') return report('app');+ if (name === 'recoil') return report('recoil');+ if (name === self) return report('self');+ /** `react` itself is the UI package; any other bare path through `react` or `components`+ * (`src/react`, `@/components`) is an alias for an entry. */+ const bareEntry =+ name === 'react' ? undefined : bareSegments.find((segment) => ENTRIES.has(segment));+ if (isCore && bareEntry) return report('entry', { entry: bareEntry });+ if (isCore && (UI_PACKAGES.has(name) || UI_SCOPES.some((scope) => name.startsWith(scope)))) {+ return report('ui');+ }+ };++ const check = (node, sourceNode) => {+ const { known, value } = specifierOf(sourceNode);+ if (known) return judge(node, value);+ if (isCore) context.report({ node, messageId: 'opaque' });+ };++ return {+ ImportDeclaration: (node) => check(node, node.source),+ ExportNamedDeclaration: (node) => node.source && check(node, node.source),+ ExportAllDeclaration: (node) => check(node, node.source),+ ImportExpression: (node) => check(node, node.source),+ TSImportType: (node) => check(node, node.argument),+ TSExternalModuleReference: (node) => check(node, node.expression),+ CallExpression(node) {+ if (node.callee.type !== 'Identifier' || node.callee.name !== 'require') return;+ check(node, node.arguments[0]);+ },+ };+ },+};++export default {+ meta: { name: 'chat' },+ rules: { boundary },+};diff --git a/scripts/eslint/chat.test.mjs b/scripts/eslint/chat.test.mjsnew file mode 100644index 0000000000..0768a60b69--- /dev/null+++ b/scripts/eslint/chat.test.mjs@@ -0,0 +1,153 @@+import path from 'node:path';+import { describe, it } from 'node:test';+import tsParser from '@typescript-eslint/parser';+import { RuleTester } from 'eslint';+import chat from './chat.mjs';++RuleTester.describe = describe;+RuleTester.it = it;++const root = path.resolve(import.meta.dirname, '../..');+const options = [{ sourceRoot: 'packages/chat/src', packageName: '@librechat/chat' }];+const at = (file) => path.join(root, 'packages/chat/src', file);++const tester = new RuleTester({+ languageOptions: { parser: tsParser, parserOptions: { ecmaFeatures: { jsx: true } } },+});++/** Every spelling a source can use to load one target, in each syntactic form the rule reads. */+const forms = (specifier) => [+ `import x from '${specifier}';`,+ `import type { X } from '${specifier}';`,+ `export * from '${specifier}';`,+ `export { x } from '${specifier}';`,+ `export const load = () => import('${specifier}');`,+ `export const load = () => import(\`${specifier}\`);`,+ `export const load = () => require('${specifier}');`,+ `import x = require('${specifier}');`,+ `export type X = typeof import('${specifier}');`,+];++/** Ways of naming the `/react` and `/components` entries from `src/core/streaming/`. */+const entrySpellings = ['react', 'components'].flatMap((entry) => [+ `../../${entry}`,+ `../../${entry}/`,+ `../../${entry}.ts`,+ `../../${entry}.tsx`,+ `../../${entry}.js`,+ `../../${entry}.mjs`,+ `../../${entry}.cjs`,+ `../../${entry}/index`,+ `../../${entry}/index.js`,+ `../../${entry}/Part.tsx`,+ `../.././${entry}`,+ `../../core/../${entry}`,+]);++const uiSpellings = [+ 'react',+ 'react/jsx-runtime',+ 'react-dom',+ 'react-dom/client',+ 'jotai',+ 'jotai/utils',+ '@tanstack/react-query',+ '@librechat/client',+ '@librechat/client/theme.css',+];++const appSpellings = [+ 'client/src/hooks',+ 'src/client/src',+ '~/store',+ '~',+ '@librechat/frontend',+ '@librechat/frontend/src/store/filesDialog',+ '../../../../client/src/hooks',+ '../../../client/src',+ '../../package.json',+];++const selfSpellings = ['@librechat/chat', '@librechat/chat/react', '@librechat/chat/components'];++const cases = (file, specifiers, messageId) =>+ specifiers.flatMap((specifier) =>+ forms(specifier).map((code) => ({+ code,+ filename: at(file),+ options,+ errors: [{ messageId }],+ })),+ );++const allowed = (file, specifiers) =>+ specifiers.flatMap((specifier) =>+ forms(specifier).map((code) => ({ code, filename: at(file), options })),+ );++tester.run('chat/boundary', chat.rules.boundary, {+ valid: [+ ...allowed('core/streaming/probe.ts', [+ 'librechat-data-provider',+ './types',+ '../types.js',+ '../../core/types',+ './react-utils',+ '../reactive.js',+ '../../index',+ ]),+ ...allowed('index.ts', ['./core', './core/index.ts']),+ ...allowed('react/probe.tsx', [+ 'react',+ 'jotai',+ '@tanstack/react-query',+ '../core',+ '../components',+ ]),+ ...allowed('components/Probe.tsx', ['react', '@librechat/client', '../react']),+ ...allowed('__tests__/core.spec.ts', ['react']),+ {+ code: "const name = 'react'; export const load = () => import(name);",+ filename: at('react/probe.ts'),+ options,+ },+ { code: "import x from '~/store';", filename: path.join(root, 'client/src/x.ts'), options },+ ],+ invalid: [+ ...cases('core/streaming/probe.ts', entrySpellings, 'entry'),+ ...cases('core/streaming/probe.ts', uiSpellings, 'ui'),+ ...cases('index.ts', ['react'], 'ui'),+ ...cases(+ 'core/probe.ts',+ ['components', 'components/Part', 'src/components', 'src/react', '@/react', '@/components/'],+ 'entry',+ ),+ ...cases('index.ts', ['./react', './components/'], 'entry'),+ ...cases('core/probe.ts', appSpellings.slice(0, 4), 'app'),+ ...cases('react/probe.ts', appSpellings, 'app'),+ ...cases('components/Probe.tsx', ['recoil', 'recoil/x'], 'recoil'),+ ...cases('react/probe.ts', selfSpellings, 'self'),+ ...cases('core/probe.ts', selfSpellings, 'self'),+ {+ // An absolute root holds when ESLint runs from another directory, as a workspace script does.+ code: "import x from 'react';",+ filename: at('core/probe.ts'),+ options: [+ { sourceRoot: path.join(root, 'packages/chat/src'), packageName: '@librechat/chat' },+ ],+ errors: [{ messageId: 'ui' }],+ },+ {+ code: 'export const load = (name: string) => import(name);',+ filename: at('core/probe.ts'),+ options,+ errors: [{ messageId: 'opaque' }],+ },+ {+ code: 'export const load = (name: string) => require(`./${name}`);',+ filename: at('core/probe.ts'),+ options,+ errors: [{ messageId: 'opaque' }],+ },+ ],+});diff --git a/scripts/static-checks.mts b/scripts/static-checks.mtsindex eda1c75c17..dc36fce501 100644--- a/scripts/static-checks.mts+++ b/scripts/static-checks.mts@@ -805,7 +805,11 @@ function validateEslintConfig(): CheckOutcome {const ruleTests = runCommand({command: process.execPath,- args: ['--test', resolve(ROOT, 'scripts/eslint/design.test.mjs')],+ args: [+ '--test',+ resolve(ROOT, 'scripts/eslint/design.test.mjs'),+ resolve(ROOT, 'scripts/eslint/chat.test.mjs'),+ ],},[],);