Last active
August 16, 2017 21:39
-
-
Save cletusw/8a37bc41ee321a316bbd00300e35649a to your computer and use it in GitHub Desktop.
Remove top-level `"use strict";`. It can cause problems with bundlers that concatenate scripts, and so is not a recommended practice.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function transformer(file, api) { | |
const j = api.jscodeshift; | |
return j(file.source) | |
.find(j.ExpressionStatement).filter(path => ( | |
path.parentPath.node.type === "Program" && | |
path.value.expression.type === 'Literal' && | |
path.value.expression.value === 'use strict' | |
)) | |
.forEach(path => j(path).remove()) | |
.toSource(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment