mui / mui/material-ui

Mui Codemod does unneccessary formatting changes when it is executed in certain snippets of code

Open
#46,464 1 comment 0 reactions 1 assignee View on GitHub

@siriwatknp is already working on this.

Since Jul 1, 2025.

docs package: codemod scope: all components
Dominant language
JavaScript
Stars
99.1k
Forks
32.5k
Avg merge
2d 17h
Merged PRs (30d)
106

Description

Steps to reproduce

Steps:

  1. Run deprecations/all codemod for the below code snippet
  2. After running the codemod certain formatting changes are introduced like semicolon getting added at the end of line
Current behavior

original code - const numberWithCommas = (x: number = 0) => { return x?.toLocaleString('en-IN') } function shortenAmount(value: number) { if (value >= 10000000) { const crores = (value / 10000000).toString() return crores.indexOf('.') === -1 ? crores + 'Cr' : crores.replace(/\.?0+$/, '') + 'Cr' } else if (value >= 100000) { const lakhs = (value / 100000).toString() return lakhs.indexOf('.') === -1 ? lakhs + 'L' : lakhs.replace(/\.?0+$/, '') + 'L' } else { return numberWithCommas(value) } } function normalizePath(path: string) { return path.replace(/\/$/, '') // Remove trailing slash }

formatted code - const numberWithCommas = (x: number = 0) => { return x?.toLocaleString('en-IN') } function shortenAmount(value: number) { if (value >= 10000000) { const crores = (value / 10000000).toString() return crores.indexOf('.') === -1 ? crores + 'Cr' : crores.replace(/\.?0+$/, '') + 'Cr'; } else if (value >= 100000) { const lakhs = (value / 100000).toString() return lakhs.indexOf('.') === -1 ? lakhs + 'L' : lakhs.replace(/\.?0+$/, '') + 'L'; } else { return numberWithCommas(value) } } function normalizePath(path: string) { return path.replace(/\/$/, ''); // Remove trailing slash }

Expected behavior

If I run deprecations/all codemod for this code snippet, then ideally it should not make any formatting changes.

Context

codemod should make only intended changes and not unncessary formatting changes

Your environment
npx @mui/envinfo
System:
    OS: macOS 15.5
  Binaries:
    Node: 22.12.0 - /usr/local/bin/node
    npm: 10.9.0 - /usr/local/bin/npm
    pnpm: 8.14.3 - /usr/local/bin/pnpm
  Browsers:
    Chrome: 137.0.7151.120
    Edge: Not Found
    Safari: 18.5

Search keywords: codemod

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.