Skip to content

Instantly share code, notes, and snippets.

@macklinu
Last active October 23, 2018 00:42
Show Gist options
  • Save macklinu/8c3fee395bfc13b1e6afaa1221d0106a to your computer and use it in GitHub Desktop.
Save macklinu/8c3fee395bfc13b1e6afaa1221d0106a to your computer and use it in GitHub Desktop.

Performs the following codemod:

- if (module.hot) {
-   // any code inside the if statement
- }

To run, execute the following command:

npx jscodeshift <GLOB> -t https://gist.githubusercontent.com/macklinu/8c3fee395bfc13b1e6afaa1221d0106a/raw/43e1fdeb996db39099d133ac74cadd60daab3d6a/remove-module-hot.js

Replace <GLOB> with a glob of source files you'd like to modify, like src/**/*.js.

module.exports = (file, { jscodeshift }) => {
return jscodeshift(file.source)
.find(j.IfStatement, {
test: {
type: 'MemberExpression',
object: { name: 'module' },
property: { name: 'hot' },
},
})
.remove()
.toSource()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment