utils/ts_config/eslint/index.js
Krzysztof kuhy Rudnicki 0f9699d4f3 ts_config: project option, entry-point barrel and className carve-outs
Surfaced by making ts_core and web_ui the first consumers:

- base({ project }) uses an explicit tsconfig list instead of the project
  service. Both packages exclude tests from tsconfig.json so they never land
  in dist/, and widen the include in tsconfig.lint.json for lint only; the
  project service would have reported every test file as "not found".
- unicorn/no-barrel-files is off for src/index.ts: a package entry point IS
  a barrel, that is its job. Stays on everywhere else.
- unicorn/no-keyword-prefix is off in the React layer: `className` is
  React's prop name and fires on every styled element.
- pnpm-workspace.yaml: allowBuilds for unrs-resolver set to false explicitly
  (pnpm 12 had written a placeholder); the resolver's prebuilt binding is
  used, no install script runs.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DnAYyNH1Sm4iJNidfYbrZJ
2026-09-16 21:45:59 +02:00

56 lines
2.0 KiB
JavaScript

// One call for the common case, the pieces for everything else.
//
// import { defineConfig } from "@kuhyx/ts-config";
// export default defineConfig({
// tsconfigRootDir: import.meta.dirname,
// react: true,
// boundaries: { elements: folderElements(["components", "services"]) },
// });
import { base } from "./base.js";
import { boundaries } from "./boundaries.js";
import { playwrightConfig } from "./playwright.js";
import { react } from "./react.js";
import { vitestConfig } from "./vitest.js";
export { base } from "./base.js";
export { boundaries, DEFAULT_ALLOW, folderElements } from "./boundaries.js";
export { playwrightConfig } from "./playwright.js";
export { react } from "./react.js";
export { vitestConfig } from "./vitest.js";
/**
* @param {object} options
* @param {string} options.tsconfigRootDir `import.meta.dirname` of the
* consumer's eslint.config.js.
* @param {string[]} [options.ignores]
* @param {boolean} [options.aliasOnly]
* @param {string[]} [options.project] See base().
* @param {boolean} [options.react] Stack the React layer.
* @param {boolean} [options.vitest] Stack the vitest rules (default true).
* @param {boolean} [options.playwright] Stack the Playwright rules.
* @param {object} [options.boundaries] Options for boundaries(); omitted
* means no layer enforcement (a repo that has not declared its layers).
* @param {import("eslint").Linter.Config[]} [options.overrides] Repo-specific
* config objects appended last, so they win. Each needs a reason comment.
*/
export function defineConfig({
aliasOnly,
boundaries: boundariesOptions,
ignores,
overrides = [],
playwright = false,
project,
react: withReact = false,
tsconfigRootDir,
vitest = true,
}) {
return [
...base({ aliasOnly, ignores, project, tsconfigRootDir }),
...(withReact ? react : []),
...(vitest ? vitestConfig : []),
...(playwright ? playwrightConfig : []),
...(boundariesOptions ? boundaries({ tsconfigRootDir, ...boundariesOptions }) : []),
...overrides,
];
}