javascript-no-undef-init-variable-declarations
Remove redundant bare = undefined initializers from var and let declarations so code matches ESLint no-undef-init without changing runtime behavior.
Installation
bash
Usage
This codemod updates JavaScript and TypeScript source files and removes only declarator initializers where all of the following are true:
- The declaration kind is
varorlet - The declarator name is a plain identifier
- The initializer is the bare identifier
undefined
Examples:
js
becomes:
js
The codemod intentionally leaves these cases unchanged:
const x = undefinedlet x = void 0let x = globalThis.undefined- Destructuring declarations such as
let { a = undefined } = obj - Ambient TypeScript declarations such as
declare let x = undefined - Declarations inside
with (...)blocks
workflow.yaml excludes common generated, vendored, and test locations such as node_modules, dist, build, vendor, tests, and __tests__, skips .d.ts files, and includes TSX files.
Development
bash
License
MIT