Skip to content

[mui-codemod] Fix CRLF handling in v6 codemod post-processing#48711

Open
Mohamedb91 wants to merge 4 commits into
mui:masterfrom
Mohamedb91:fix-v6-codemod-windows-newlines
Open

[mui-codemod] Fix CRLF handling in v6 codemod post-processing#48711
Mohamedb91 wants to merge 4 commits into
mui:masterfrom
Mohamedb91:fix-v6-codemod-windows-newlines

Conversation

@Mohamedb91

Copy link
Copy Markdown

This PR fixes a Windows-specific issue in the styled-v6, theme-v6, and sx-v6 codemods where extra blank lines are not cleaned up.

The current cleanup logic splits the transformed source by \n. On Windows, the source has \r\n line endings, so splitting by \n leaves a trailing \r on each line. This causes blank lines (which split as \r instead of "") to bypass the line !== '' check, leaving incorrect empty lines in the output.

This fix dynamically detects the line terminator from the transformed source and uses it to split and rejoin the code, fixing the bug on Windows while preserving the original line endings. All codemod tests are now passing on Windows.

@code-infra-dashboard

code-infra-dashboard Bot commented Jun 22, 2026

Copy link
Copy Markdown

Deploy preview

https://deploy-preview-48711--material-ui.netlify.app/

Bundle size

Bundle Parsed size Gzip size
@mui/material 0B(0.00%) 0B(0.00%)
@mui/lab 0B(0.00%) 0B(0.00%)
@mui/private-theming 0B(0.00%) 0B(0.00%)
@mui/system 0B(0.00%) 0B(0.00%)
@mui/utils 0B(0.00%) 0B(0.00%)

Details of bundle changes


Check out the code infra dashboard for more information about this PR.

@zannager zannager added the package: codemod Specific to codemod. label Jun 23, 2026
@zannager zannager requested a review from siriwatknp June 23, 2026 14:08
@siriwatknp

Copy link
Copy Markdown
Member

Thanks for the fix!

@Mohamedb91

Copy link
Copy Markdown
Author

Thanks for the fix!

I can't merge probably because I'm not a maintainer - if possible can you merge?

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

Labels

package: codemod Specific to codemod.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants