fix(lint): correct glob-to-regex translation for oxlint excludes#603
Open
John-David Dalton (jdalton) wants to merge 1 commit intomainfrom
Open
fix(lint): correct glob-to-regex translation for oxlint excludes#603John-David Dalton (jdalton) wants to merge 1 commit intomainfrom
John-David Dalton (jdalton) wants to merge 1 commit intomainfrom
Conversation
`isExcludedByOxlint` had two defects that caused the pre-commit lint runner to exit non-zero whenever the only changed files were inside oxlint-excluded directories like `.claude/`: 1. `.replace(/\./g, '\\.')` ran *after* the glob substitutions, so it escaped the dots in the just-introduced `.*` and `[^/]*` patterns, corrupting them. The first `*` replacement also consumed the `*` inside the `.*` produced by the `**/` replacement. 2. The resulting regex used `$` anchoring, so a pattern like `**/dist` only matched the bare path `dist`, never files *inside* it like `dist/foo.js`. Fix: escape regex metacharacters on the original pattern first, then translate `**/` and `*` in a single callback-based pass so later substitutions can't corrupt earlier ones. Anchor with `(?:/|$)` so directory patterns also match descendants. Verified against all 13 patterns in `.oxlintrc.json` with a 21-case harness covering directories, descendants, file globs, lookalike siblings (e.g. `coverage-other` must not match `**/coverage`), and nested path prefixes.
Bill Li (billxinli)
approved these changes
Apr 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
isExcludedByOxlintinscripts/lint.mtshad two defects that caused the lint runner to exit non-zero whenever the only changed files were inside an oxlint-excluded directory like.claude/. Symptom:pnpm run check(and the pre-commit hook) emitsLinting failed / Expected at least one target file.The bugs
**/ → .*, then* → [^/]*, then. → \.. The last step escaped the dots in the just-introduced.*and[^/]*patterns; and the*replacement also consumed the*in the.*produced by the**/step.**/.claudeended up as\.[^/]*\.claude— wrong.$at the end so**/distonly matched the bare pathdist, never files inside likedist/foo.js.The fix
**/and*in a single callback-based pass so later substitutions can't corrupt earlier ones.(?:/|$)so directory patterns also match descendants.Test plan
pnpm run checkpasses on this branch.oxlintrc.json— directories (**/dist), descendants (dist/foo.js), nested patterns (**/test/fixtures), file globs (**/*.d.ts,**/*.tsbuildinfo), lookalike siblings that must NOT match (coverage-othervs**/coverage,distributedvs**/dist,.cachewhatevervs**/.cache), and deep paths (a/b/tsconfig.tsbuildinfo)pnpm run checkon a future PR that only touches.claude/files no longer reports spurious lint failure