Skip to content

[WIP] Revive JavaScript formatting and ensure stability when running multiple times#6851

Merged
pelikhan merged 4 commits into
mainfrom
copilot/revive-javascript-formatting
Dec 18, 2025
Merged

[WIP] Revive JavaScript formatting and ensure stability when running multiple times#6851
pelikhan merged 4 commits into
mainfrom
copilot/revive-javascript-formatting

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 18, 2025

JavaScript Formatting Stability Fix - COMPLETE ✓

  • Investigate current JavaScript formatting setup
  • Identify root causes of formatting instability
  • Fix prettier invocation to use npx consistently
  • Exclude node_modules from terser processing
  • Remove --comments all to prevent comment duplication
  • Test formatting idempotency (verified stable ✓)
  • Verify all JavaScript files format correctly
  • Run tests to ensure no functionality breaks (2218 tests pass ✓)
  • Final validation: make fmt runs successfully with no changes ✓

Problem Summary

The JavaScript formatting pipeline had three critical issues:

  1. Permission errors - prettier was called without npx, leading to permission denied errors when the binary wasn't executable
  2. node_modules corruption - terser was processing files in node_modules/, including prettier's own binary, removing its execute permissions
  3. Comment duplication - terser's --comments all option was causing inline comments to be duplicated on each formatting run

Solution

pkg/workflow/js/package.json changes:

// Before:
"format:terser": "find . -name '*.cjs' -type f | ... --comments all ...",
"format:cjs": "prettier --write ...",

// After:
"format:terser": "find . -name '*.cjs' -type f -not -path './node_modules/*' | ...",
"format:cjs": "npx prettier --write ...",
// Removed --comments all from terser

Results

Formatting is now truly idempotent

  • Running make fmt multiple times produces identical results
  • No duplicate comments
  • No permission errors
  • All files show "(unchanged)" on subsequent runs

All tests pass: 2218 tests passing

Code optimization: Net reduction of 2,703 lines while maintaining readability

Ready for merge: Formatting pipeline is stable and production-ready

Original prompt

Revived JavaScript formatting and make sure it is stable when running multiple times.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits December 18, 2025 12:42
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
- Add npx prefix to all prettier commands to avoid permission issues
- Exclude node_modules from terser processing to prevent breaking prettier binary
- JavaScript formatting now stable when run multiple times
- All 2218 tests pass after formatting

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
- Remove --comments all from terser to prevent comment duplication
- Add npx prefix to all prettier commands to avoid permission issues
- Exclude node_modules from terser processing
- JavaScript formatting now fully idempotent (3+ runs produce identical results)
- All 2218 tests pass after formatting
- Net result: 2,703 lines reduced, no duplicate comments

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan pelikhan marked this pull request as ready for review December 18, 2025 13:12
@pelikhan pelikhan merged commit ef76ed5 into main Dec 18, 2025
4 checks passed
@pelikhan pelikhan deleted the copilot/revive-javascript-formatting branch December 18, 2025 13:12
Copilot AI requested a review from pelikhan December 18, 2025 13:13
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.

2 participants