Skip to content

Conversation

@timtebeek
Copy link
Member

@timtebeek timtebeek commented Nov 10, 2025

Summary

  • Fix RemoveTrailingWhitespace recipe removing shebang lines from JavaScript files
  • Add COMPILATION_UNIT_PREFIX to the list of locations to skip when removing trailing whitespace
  • Add test case to verify shebang preservation in JavaScript files

Changes

  • RemoveTrailingWhitespaceVisitor.java: Skip COMPILATION_UNIT_PREFIX location to preserve shebangs and other file-level prefixes
  • RemoveTrailingWhitespaceTest.java (JavaScript): Add integration test for shebang preservation

Test plan

🤖 Generated with Claude Code

@github-project-automation github-project-automation bot moved this to In Progress in OpenRewrite Nov 10, 2025
@timtebeek timtebeek added the bug Something isn't working label Nov 10, 2025
@timtebeek timtebeek changed the title Fix RemoveTrailingWhitespace to preserve shebang lines Fix RemoveTrailingWhitespace to preserve shebang lines Nov 10, 2025
@Override
public void defaults(RecipeSpec spec) {
spec.recipe(new RemoveTrailingWhitespace())
.typeValidationOptions(TypeValidation.builder().allowNonWhitespaceInWhitespace(true).build());
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might hint at a parser issue as well, but I've not yet gotten the local server running to troubleshoot this one.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, the Shebang lines were parsed improperly in JavaScript. #6349 solves this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for diving in!

@timtebeek timtebeek added question Further information is requested javascript parser labels Nov 10, 2025
@timtebeek timtebeek marked this pull request as draft November 11, 2025 13:19
@greg-at-moderne greg-at-moderne self-requested a review November 27, 2025 13:36
@greg-at-moderne
Copy link
Contributor

CI taking more than 1hr to run? Is it stuck or what's wrong with this?

@timtebeek timtebeek marked this pull request as ready for review November 27, 2025 15:30

import static org.openrewrite.javascript.Assertions.javascript;

class RemoveTrailingWhitespaceTest implements RewriteTest {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been told these tests might not execute in CI, and locally I'm getting IllegalStateException: JavaScript RPC process shut down early with exit code 1. Do you think we still need this following #6349 @greg-at-moderne ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working javascript parser question Further information is requested

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

Remove trailing whitespace removes prefix from generate-llms-txt.js

3 participants