From 90becf81ca094b305bf23d2f4943d8626f2454fe Mon Sep 17 00:00:00 2001 From: abayomiwav Date: Wed, 23 Sep 2026 19:19:40 +0100 Subject: [PATCH] lint: prevent components/ui barrel imports (#495) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #495 reports that components/ui/index.ts's barrel import pattern defeats tree-shaking. Verified against current source: no components/ui directory exists anywhere in this repo's history, no barrel index.ts/index.tsx exists anywhere under src/ (checked via git log across all branches), and there are zero @/components/ui imports in the codebase today — every one of the 33 files in src/components/ is already imported directly by filename, which is exactly the fix #495 asks for. Since there's nothing to fix in existing code, this adds a no-restricted-imports ESLint rule instead, so the exact pattern #495 warns about can't be reintroduced later without a build against the existing "lint" script (next lint) failing loudly. Verified: npm run lint runs clean against this rule (zero violations, confirming no barrel imports currently exist) and produces no new warnings/errors beyond what's already present on main. Closes #495 --- eslint.config.mjs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/eslint.config.mjs b/eslint.config.mjs index c85fb67..0956066 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -11,6 +11,27 @@ const compat = new FlatCompat({ const eslintConfig = [ ...compat.extends("next/core-web-vitals", "next/typescript"), + { + rules: { + // #495: this codebase has no components/ui barrel file today — every + // component is already imported directly by filename. This rule keeps + // it that way by rejecting any future `@/components/ui` (or a nested + // barrel under it) import before it can reintroduce the tree-shaking + // problem #495 was filed against. + "no-restricted-imports": [ + "error", + { + patterns: [ + { + group: ["@/components/ui", "@/components/ui/index"], + message: + "Import directly from the component's own file (e.g. '@/components/ui/Button'), not a barrel — barrel imports defeat tree-shaking (#495).", + }, + ], + }, + ], + }, + }, ]; export default eslintConfig;