8000 discoverFiles sweeps tests/fixtures/** → eslint:fatal on consumer's own habit-hooks run · Issue #8 · habit-hooks/habit-hooks · GitHub
[go: up one dir, main page]

Skip to content

discoverFiles sweeps tests/fixtures/** → eslint:fatal on consumer's own habit-hooks run #8

Closed

Description

@devill

✅ Decision (locked for the wrapup loop)

Fix: option (b) — add an explicit scope.exclude config knob (array of
globs) honored by discoverFiles. Not .gitignore-based.

  • New optional scope.exclude: string[] in the config schema; discoverFiles
    unions it onto the existing hardcoded ignore set (node_modules, dist,
    coverage).
  • Default behaviour unchanged when the knob is unset.
  • The repo's own config sets scope.exclude: ['tests/fixtures/**'] so a
    self-run stops tripping on fixture subtrees.

Acceptance (in addition to the gate below): a fixture path excluded via
scope.exclude is not discovered; a test pins both the exclude and the
unchanged default.


Symptom

After fix(eslint-wrap): surface fatal parse/config errors (commit 59e18ba), node dist/cli.js --all on this repo reports 26 eslint:fatal violations, all under tests/fixtures/**. All four standard gates (pnpm typecheck, pnpm lint, pnpm test, pnpm build) stay clean — the failures only manifest through habit-hooks' own discovery path.

Sample violation:

/Users/.../tests/fixtures/_shared/eslint.config.js - Fatal parse/config error: Parsing error: No tsconfigRootDir was set, and multiple candidate TSConfigRootDirs are present:
 - /Users/.../habit-hooks
 - /Users/.../habit-hooks/tests/fixtures/_shared

Root cause

src/runner.ts:discoverFiles uses fast-glob with a hardcoded ignore set (node_modules, dist, coverage) and DOES NOT honor tests/fixtures/** or any project-level ignore. CLAUDE.md already documents this hazard for comment-check. As of Phase C the eslint wrap surfaces fatals (instead of swallowing them), so the same hazard now bites eslint too — fixture files get passed to typescript-eslint v8, which throws because the fixture subtree has its own tsconfig.json creating a second candidate root.

Direct npx eslint tests/fixtures/sample-project/src/comments.ts produces zero messages — the fixtures lint clean on their own. The fatals only fire when habit-hooks's wrap batches fixture files into a single ESLint invocation with the parent config.

Fix candidates

  1. Honor .gitignore in discoverFiles — fast-glob has a dot/ignore option that can read .gitignore. Most consumers will already gitignore their fixture / build / cache dirs, so this is the lowest-friction default.
  2. Expose a scope.exclude config knob — explicit opt-in for habit-hooks-specific paths. More verbose, less surprising.
  3. Filter via ESLint's isPathIgnored in the wrap — wrap-local rather than discovery-level. Doesn't help knip/jscpd, who shell out and may not have an equivalent check.

(1) is probably the right default; (2) for escape hatches.

Blast radius beyond this repo

ANY consumer with fixture / sample / vendored folders that aren't matched by node_modules|dist|coverage will hit this once they upgrade past 59e18ba. Worth a CHANGELOG callout for the alpha.

Workaround until fixed

Add the offending paths to the wrap's discovery ignore — currently no config surface for this, so consumers will need to wait for the fix or symlink the fixtures elsewhere.

Activity

  1. added 2 commits that reference this issue on Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0