utils/web_ui/eslint.config.js
Krzysztof kuhy Rudnicki eaa5683ff1 web_ui: add the CI + pre-commit gate, and make pnpm lint actually run
Matches the Phase 1 design_system pattern the brief points at: own lint config,
own tests, own coverage gate enforced in CI.

The lint script was declared but unrunnable -- there was no eslint flat config,
and the build tsconfig excludes tests (correctly; they must not ship in dist/),
so type-aware linting had no project for them. Adds eslint.config.js and a
lint-only tsconfig that widens the include without emitting. Running it surfaced
one real defect: nth() interpolated a number into a template literal without
String(), which the consumers' configs would have flagged.

The gate also checks that the committed dist/ matches a fresh build. This is not
theoretical -- the check caught the stale dist/ produced by that very String()
fix on its first run. A stale dist/ in a tag ships old code to every consumer
with no error anywhere, which is the one failure mode this packaging choice
introduces. dist/ is excluded from the whitespace hooks: they would "fix"
generated output that the next build immediately reverts.

CI additionally re-runs the categorical ramp's constraint proof, so the palette
cannot regress silently either.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01U4Rj3s7K2qzrLNgJqqPhno
2026-08-15 15:08:18 +02:00

43 lines
1.6 KiB
JavaScript

// Type-aware flat config for the shared component layer.
//
// A trimmed version of awesome-mcp-explorer's: typescript-eslint's
// *type-checked* strict + stylistic presets, so anything they flag is an error.
// The consumers layer unicorn/sonarjs/perfectionist on top; this package keeps
// to the presets its own devDependencies actually declare, because a config
// referencing plugins that are not installed is a lint script that cannot run.
import js from "@eslint/js";
import tseslint from "typescript-eslint";
export default tseslint.config(
// eslint.config.js itself is not in tsconfig.lint.json, so type-aware
// rules cannot run on it; linting the linter config buys nothing anyway.
{ ignores: ["dist", "coverage", "eslint.config.js"] },
{ linterOptions: { reportUnusedDisableDirectives: "error" } },
js.configs.recommended,
...tseslint.configs.strictTypeChecked,
...tseslint.configs.stylisticTypeChecked,
{
files: ["**/*.{ts,tsx}"],
languageOptions: {
parserOptions: {
project: ["./tsconfig.lint.json"],
tsconfigRootDir: import.meta.dirname,
},
},
rules: {
// Every exported symbol here is consumed across a package boundary, so
// an explicit return type is documentation, not ceremony.
"@typescript-eslint/explicit-function-return-type": "error",
},
},
{
// Tests reach for non-null assertions on queries that cannot return null
// in a passing test; asserting them again would only add noise.
files: ["**/*.test.{ts,tsx}"],
rules: { "@typescript-eslint/no-non-null-assertion": "off" },
},
);