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

Nguyen Thanh Dat25795b593f03
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 ?? {});
}
}