mirror of
https://github.com/cypress-io/cypress.git
synced 2026-04-22 23:20:24 -05:00
eab801ae3f
* 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>
30 lines
518 B
JavaScript
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()
|
|
}
|