Skip to content

fix: align lint target discovery with files config#1227

Open
fansenze wants to merge 13 commits into
mainfrom
fix/files-driven-target-discovery
Open

fix: align lint target discovery with files config#1227
fansenze wants to merge 13 commits into
mainfrom
fix/files-driven-target-discovery

Conversation

@fansenze

@fansenze fansenze commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR makes lint target selection files-driven and removes the old coupling where TypeScript Program membership could decide what gets linted.

  • Resolve lint targets from config files (or rslint's default JS/JSX/TS extensions), explicit CLI/API file/dir inputs, global ignores, and rslint's existing .gitignore product behavior.
  • Keep TypeScript Programs as execution containers only: selected files already covered by a tsconfig-backed Program reuse it; selected gap files get an AST-only fallback Program and no type-aware rules.
  • Preserve type-check behavior: semantic diagnostics still come from tsconfig-backed Programs; fallback Programs are skipped for --type-check.
  • Handle explicit files that miss files as selected 0-rule results, matching ESLint-style behavior, while suppressing syntax diagnostics when no config entry matches.
  • Keep multi-config ownership nearest-config based for discovery, rule resolution, eslint-plugin routing, and Program target assignment.

Architecture Changes

  • Added a shared programFileIndex so gap detection and target-to-Program binding use the same source-file index, including realpath aliases for symlink/path-canonicalization cases.
  • Added an explicit source-path to config-path alias map so rules, globals, syntax diagnostics, and eslint-plugin routing are resolved against the lint target path even when the Program source path differs.
  • Rebuild target bindings, type-info file sets, and config resolvers during --fix relint passes so relinting uses current Program state.
  • Added FileConfigResolver to cache per-run per-file merged config and enabled rules, including nil misses.
  • Added lintConfigResolver for CLI/API multi-config and single-config routing, reused by native lint, syntax diagnostic filtering, and eslint-plugin config resolution.
  • Kept API full-memory linting intact across symlink/realpath aliases by expanding in-memory file overlays and preserving realpath lookup for virtual files backed by disk paths.
  • Kept LSP aligned at the behavior level for file matching while leaving .gitignore parity as a separate follow-up.

Behavior Notes

  • Missing files means the default lintable extension set, not arbitrary files.
  • Empty/invalid files remains rejected by validation; JSON config migration still accepts legacy files: [] so it can drop unsupported empty fields while generating JS/TS config.
  • Files included by files but outside tsconfig are linted without type-aware rules.
  • CLI/API .gitignore behavior is preserved. LSP .gitignore parity is intentionally not changed in this PR and can be handled separately.

Real Repo Performance

Stage-prime results, 10 alternating old/new iterations, median wall time. The new build intentionally lints more files in both repos because missing files now uses the default lintable extension set.

Repo Mode Old New Delta Files
rsbuild plain 2620ms 3252ms +24.1% 2027 -> 2052
rsbuild type-check 3272ms 3755ms +14.7% 2027 -> 2052
rspack plain 2926ms 2740ms -6.4% 475 -> 478
rspack type-check 3124ms 2990ms -4.3% 475 -> 478

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 8, 2026

Copy link
Copy Markdown

Deploying rslint with  Cloudflare Pages  Cloudflare Pages

Latest commit: 7d1b519
Status:🚫  Build failed.

View logs

@fansenze fansenze force-pushed the fix/files-driven-target-discovery branch 2 times, most recently from ba48bda to c4cdb50 Compare July 9, 2026 08:40
@fansenze fansenze force-pushed the fix/files-driven-target-discovery branch from 949c28e to 7d1b519 Compare July 9, 2026 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant