Skip to content

chore: fix the prettier format glob to target .ts sources - #276

Open
joris974 wants to merge 1 commit into
mainfrom
chore/fix-prettier-format-glob
Open

chore: fix the prettier format glob to target .ts sources#276
joris974 wants to merge 1 commit into
mainfrom
chore/fix-prettier-format-glob

Conversation

@joris974

Copy link
Copy Markdown
Member

What

A one-line change to package.json:

-"format": "prettier --write 'src/**/*.js'",
+"format": "prettier --write 'src/**/*.ts'",

That is the whole diff — 1 insertion, 1 deletion. No source changes, no dist/ changes, nothing touched in dependencies.

Why

This is a TypeScript package. src/ contains either.ts, formatting.ts, index.ts, index.test.ts, path.ts, test-helper.ts — and zero .js files. The glob could never match anything.

A correction to the audit's expectations

The audit made two predictions about this one. Neither held, and both are worth knowing before you read the diff.

1. pnpm format was not silently succeeding — it was failing. The audit expected the script to "exit green having done nothing". Prettier 3.9.6 treats an unmatched pattern as a hard error:

$ pnpm format          # on main, before the fix
$ prettier --write 'src/**/*.js'
[error] No files matching the pattern were found: "src/**/*.js".
[ELIFECYCLE] Command failed with exit code 2.

So this was visibly broken rather than quietly useless — which is the better version of the problem, since nobody could have mistaken it for working.

2. There is no formatting backlog. The audit expected a large first-run reformat diff. There is none:

$ pnpm format          # with the fixed glob
src/either.ts      147ms (unchanged)
src/formatting.ts   11ms (unchanged)
src/index.test.ts   31ms (unchanged)
src/index.ts        31ms (unchanged)
src/path.ts          2ms (unchanged)
src/test-helper.ts   2ms (unchanged)

$ git diff --stat src/
(no output)

All six files were already prettier-clean. The reason is .restyled.yaml, which already lists the .ts glob under its prettier restyler:

- prettier:
    include:
      - 'src/**/*.js'
      - 'src/**/*.ts'

The Restyled bot has been formatting these files all along — which is exactly why a broken local format script could sit here unnoticed. This PR just aligns the npm script with what CI already enforces.

Verification

Node 22.22.3, pnpm@11.23.0 (matching the packageManager field), pnpm install --frozen-lockfile.

pnpm build (tsc -p tsconfig.build.json -d) — clean, and git status shows no dist/ change. Expected: no source file was modified.

pnpm test:

 Test Files  1 passed (1)
      Tests  82 passed (82)

Same 82 tests as the baseline run on main before the change.

./check-git-clean.sh on the committed branch — PASS, no unstaged diff.

Branched from main at eda9cd8 (the merge of #275), confirmed current against origin/main at push time. Scope is strictly the format script, as requested — #273 (lodash) is untouched.

One pre-existing bug I did not fix

pnpm check-git-clean cannot run, on main or here:

$ git ls-files -s check-git-clean.sh
100644 ...   check-git-clean.sh

The file is committed without the executable bit, so "check-git-clean": "./check-git-clean.sh" dies with Permission denied (exit 126). I verified the script's logic by invoking it as bash ./check-git-clean.sh — that is the PASS reported above. No workflow in .github/ calls it, so nothing is broken today. Fix would be git update-index --chmod=+x check-git-clean.sh; left out to keep this PR to one line. Note the identical problem exists in non-empty-js.

Release impact

chore: under the conventionalcommits preset -> no release. A dev-script glob, no published artifact affected.

Generated from the Dead Weight audit of 31 active Freckle JS/TS repos.

🤖 Generated with Claude Code

`format` was `prettier --write 'src/**/*.js'`, but this is a TypeScript
repo with no .js sources under src/. Prettier treats an unmatched
pattern as an error, so `pnpm format` failed with exit code 2:

  [error] No files matching the pattern were found: "src/**/*.js".

Pointing the glob at 'src/**/*.ts' matches the six real sources and
mirrors what .restyled.yaml already enforces. No reformat resulted --
all six files report "(unchanged)".

Found by the Dead Weight audit of Freckle JS/TS repos.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@joris974
joris974 marked this pull request as ready for review August 25, 2026 20:21
@joris974
joris974 requested a review from a team as a code owner August 25, 2026 20:21
@joris974
joris974 requested review from cristygrant and removed request for a team August 25, 2026 20:21
@joris974 joris974 self-assigned this Aug 25, 2026
@joris974
joris974 enabled auto-merge August 25, 2026 22:04
@joris974
joris974 disabled auto-merge August 25, 2026 22:11
@joris974
joris974 enabled auto-merge August 25, 2026 22:12
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