fix: .prettierignore in apigen task#3318
Draft
Noel Cothren (noeldevelops) wants to merge 2 commits intomainfrom
Draft
fix: .prettierignore in apigen task#3318Noel Cothren (noeldevelops) wants to merge 2 commits intomainfrom
Noel Cothren (noeldevelops) wants to merge 2 commits intomainfrom
Conversation
The `.prettierignore` added in #3256 includes `src/clients/` to prevent the Claude Code formatting hook from touching auto-generated code. However, the `apigen` gulp task's internal Prettier step uses the same `prettier()` helper, which consults `.prettierignore` — causing it to skip formatting entirely for all generated client files. This meant running `gulp apigen` produced raw openapi-generator output (4-space indent, single quotes) instead of Prettier-formatted output (2-space indent, double quotes per .prettierrc), creating large cosmetic diffs across all clients even when only one spec changed. Add an `ignoreIgnoreFile` option to the `prettier()` helper so `apigen` can bypass `.prettierignore` while all other callers remain unaffected. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Updates the Gulp apigen workflow so generated OpenAPI client code in src/clients/ is still formatted by Prettier even though the repository’s .prettierignore intentionally excludes src/clients/ to protect generated code from other format hooks.
Changes:
- Adds an
ignoreIgnoreFileoption to the internalprettier()gulp transform helper. - Updates
apigento callprettier({ ignoreIgnoreFile: true }), bypassing.prettierignorefor the generation pipeline while keeping other tasks (e.g.gulp format) unchanged.
Replace the custom Gulp streaming `prettier()` helper with direct `npx prettier` CLI calls via `spawnSync`. The CLI handles config resolution, .prettierignore, file discovery, and writing — eliminating the need for the manual async iterator, Gulp src/dest/pipeline wiring, and the `ignoreIgnoreFile` workaround from the previous commit. For `apigen`, uses `--ignore-path /dev/null` to bypass .prettierignore (which excludes src/clients/ to prevent other tools from reformatting generated code). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Comment on lines
+1046
to
+1049
| const result = spawnSync( | ||
| "npx", | ||
| ["prettier", "--write", "src/**/*.{ts,css,html,json}", "*.md", "*.js"], | ||
| { stdio: "inherit", shell: IS_WINDOWS }, |
Member
Author
There was a problem hiding this comment.
Dave Shoup (@shouples) this does everything the prettier() function below does
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.





DRAFT
Testing locally and exploring alternatives first.*
TL;DR a recent PR to add a Claude hook for prettier also added a
.prettierignorefile + check, which caused my run ofgulp apigen(the first since then) to skip re-formatting the client file changes.*Claude's first fix was to add an option to ignore the ignore file in the prettier function. Another option is to have
apigenrun it's own formatting command. Or, maybe Prettier doesn't need to ignoresrc/clients; those files should always follow our prettier config since they get formatted after generation.💡 Currently exploring the idea that we may not need this entire
prettier()function, since the prettierclihandles all of that automatically — it reads .prettierrc, respects .prettierignore, discovers files from the glob, and writes them in place.Summary
.prettierignoreadded in set up claude hook for file formatting with Prettier #3256 includessrc/clients/to prevent the Claude Code formatting hook from reformatting auto-generated client code. However, theapigengulp task's internal Prettier step uses the sameprettier()helper, which consults.prettierignore— causing it to silently skip formatting for all generated client files.gulp apigenproduced rawopenapi-generatoroutput (4-space indent, single quotes) instead of Prettier-formatted output (2-space indent, double quotes per.prettierrc), creating thousands of lines of cosmetic diffs across every client even when only one spec changed.ignoreIgnoreFileoption to theprettier()helper soapigencan bypass.prettierignorewhile all other callers (e.g. theformattask and Claude hook) remain unaffected.Investigation
When updating the Flink SQL OpenAPI spec and running
gulp apigen, all 10 generated clients showed massive formatting-only diffs (indentation, quote style, trailing whitespace). The root cause trace:apigencallsprettier()atGulpfile.js:1001to get a formatting transformprettier()callsgetFileInfo(file.path, { ignorePath: ".prettierignore" })for each file.prettierignorecontainssrc/clients/, sofileInfo.ignoredistruefor every generated filecontinues past every file — no formatting is appliedopenapi-generator-clioutput (which uses different defaults than our.prettierrc) gets written as-is, differing from the previously Prettier-formatted files onmainTest plan
gulp apigenon a cleanmaincheckout — verify no unexpected diffs in non-changed clientsgulp format— verify it still respects.prettierignoreand skipssrc/clients/🤖 Generated with Claude Code