Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

lint(app): enforce the centralized-frontend-config rule, and fix its one violation\n\nAGENTS.md states the rule plainly: "Frontend config centralized in\napp/src/utils/config.ts -- never read import.meta.env directly elsewhere."\nNothing enforced it, and it had already drifted:\nTwoPanelLayout's debug() read import.meta.env.DEV directly.\n\nThe rule is not cosmetic. config.ts owns derived values a raw read cannot\ngive you -- IS_DEV_LIKE exists precisely because import.meta.env.DEV is\nfalse under the E2E harness (vite build --mode development sets PROD=true),\nwhich the comment beside it spells out. A raw read is also unstubbable once\nthe module graph has loaded; loopbackOauthListener.test.ts already documents\nthat, and reads through config for exactly this reason.\n\nAdds a no-restricted-syntax rule over src/**, exempting config.ts itself and\ntest files, with a message naming the replacement. Scoped narrowly: vite.config.ts\nmust define these values and is outside src/.\n\nThe one violation is fixed by importing IS_DEV. That is deliberately\nbehaviour-preserving -- IS_DEV is exactly import.meta.env.DEV. If the intent\nwas for this debug output to appear under the E2E harness too, IS_DEV_LIKE is\nthe one-word change, but that is a behaviour decision rather than a lint fix,\nso I left it alone.\n\nVerified: with the rule added and the source untouched, eslint reports exactly\none error, at TwoPanelLayout.tsx:17. After the fix the run returns to the\nbaseline 98 warnings / 0 errors -- no new warning anywhere. prettier --check\nclean on both files, tsc --noEmit clean, and TwoPanelLayout.test.tsx 7/7.\n

Nguyen Thanh Datd5fe545cb97c
diff --git a/app/eslint.config.js b/app/eslint.config.js
index 2395dc1caa..d606e1249f 100644
--- a/app/eslint.config.js
+++ b/app/eslint.config.js
@@ -228,6 +228,33 @@ export default [
},
},
+ // Frontend config is centralized in src/utils/config.ts (AGENTS.md). A direct
+ // import.meta.env read elsewhere bypasses the derived values that file owns --
+ // IS_DEV_LIKE exists precisely because import.meta.env.DEV is false under the
+ // E2E harness (vite build --mode development) -- and cannot be stubbed once the
+ // module graph has loaded, which is why the loopback OAuth test reads config
+ // instead. The rule was documented but unenforced, and had already drifted.
+ {
+ files: ['src/**/*.ts', 'src/**/*.tsx'],
+ ignores: [
+ 'src/utils/config.ts',
+ 'src/test/**',
+ 'src/**/__tests__/**',
+ 'src/**/*.test.ts',
+ 'src/**/*.test.tsx',
+ ],
+ rules: {
+ 'no-restricted-syntax': [
+ 'error',
+ {
+ selector: 'MemberExpression[object.type="MetaProperty"][property.name="env"]',
+ message:
+ 'Read frontend config from src/utils/config.ts (IS_DEV, IS_DEV_LIKE, ...) instead of import.meta.env directly; add the value there if it is missing.',
+ },
+ ],
+ },
+ },
+
// React files configuration
{
files: ['src/**/*.jsx', 'src/**/*.tsx'],
diff --git a/app/src/components/layout/TwoPanelLayout.tsx b/app/src/components/layout/TwoPanelLayout.tsx
index 3bffa0ca3a..ef0bafbbcf 100644
--- a/app/src/components/layout/TwoPanelLayout.tsx
+++ b/app/src/components/layout/TwoPanelLayout.tsx
@@ -12,13 +12,14 @@ import {
setSidebarWidth,
toggleSidebar,
} from '../../store/layoutSlice';
+import { IS_DEV } from '../../utils/config';
import { Button } from '../ui';
import { clampWidth, useResizableDivider } from './useResizableDivider';
const namespace = 'two-panel-layout';
function debug(message: string, payload?: Record<string, unknown>) {
- if (import.meta.env.DEV) {
+ if (IS_DEV) {
console.debug(`[${namespace}] ${message}`, payload ?? {});
}
}