Files
cypress/scripts/decaff/no-cond-assign.js
T
renovate[bot] eab801ae3f chore(deps): Update dependency eslint to version 6.8.0 🌟 (#6509)
* chore(deps): Update eslint to 6.8.0 🌟

* fix missing dangling commas for linter

* fix missing dangling commas for linter

* more lint fixes

* yarn lock

Co-authored-by: WhiteSource Renovate <renovatebot@gmail.com>
Co-authored-by: Jennifer Shehane <shehane.jennifer@gmail.com>
2020-02-25 00:09:47 +06:30

30 lines
518 B
JavaScript

module.exports = (fileInfo, api) => {
const j = api.jscodeshift
return j(fileInfo.source)
.find(j.IfStatement, {
test: {
type: 'AssignmentExpression',
},
})
.replaceWith((nodePath) => {
const { node } = nodePath
const assign = j.expressionStatement(node.test)
assign.comments = node.comments
const ifStatement = j.ifStatement(
node.test.left,
node.consequent,
node.alternate,
)
return [
assign,
ifStatement,
]
})
.toSource()
}