turbo
8919ddf3 - fix: Stop the clean-globs codemod from rewriting negated globs (#15187)

Commit
1 day ago
fix: Stop the clean-globs codemod from rewriting negated globs (#15187) `clean-globs` reads a leading `!` as a folder name, so an exclusion like `!**/dist` was rewritten to `!*/**/dist`, which needs one directory before `dist` and no longer excludes `dist` at the package root. Turborepo strips the negation before it validates a glob, so the codemod now cleans the body of a negated pattern and leaves the `!` where it is. `!**/dist` and `!**/node_modules` come through untouched, while a negated pattern that really does need cleaning still gets it: `!pre**` becomes `!pre*/**`, `!**md` becomes `!**/*md`, and `!**/**/result.json` becomes `!**/result.json`. Fixes #15186 <details><summary>Validation and details</summary> ### Validation - `pnpm install --frozen-lockfile --filter @turbo/codemod...` in the repository root, to get the package's dependencies. - `pnpm run build` in `packages/turbo-workspaces`, because `@turbo/codemod`'s suite loads that workspace's `dist`. - `node_modules/.bin/jest --runInBand --forceExit` in `packages/turbo-codemod`: 20 suites, 276 tests, 85 snapshots, all passing, coverage thresholds met. - `pnpm exec tsc --noEmit` in `packages/turbo-codemod`. - `pnpm exec oxlint --disable-nested-config --deny-warnings packages/turbo-codemod` and `pnpm exec oxfmt --check` on both changed files. - `node dist/cli.js transform clean-globs <fixture copy> --dry --print` on the `clean-globs` fixture: `case_2` is unchanged and `case_1` and `case_3` are still cleaned as before. No crates are touched, so the cargo checks do not apply. ### Before and after On the `case_2` fixture with the previous code, `--dry --print` showed `"!**/dist"` and `"!**/node_modules"` each also becoming `"!*/**/dist"` and `"!*/**/node_modules"`; with this change those two lines are absent from the diff, and the file's addition and deletion counts drop from 6 to 4. The regression tests fail without the source change (`fixGlobPattern("!**/dist")` returned `"!*/**/dist"`, and the written fixture config carried the rewritten inputs and outputs) and pass with it. </details> Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
Author
Parents
Loading