Files
babel/packages/babel-plugin-transform-strict-mode/src/index.js
Amjad Masad 3667527d04 Revert "Remove flow"
This reverts commit 2827ff6b01.
2016-03-03 14:49:20 -08:00

20 lines
459 B
JavaScript

import * as t from "babel-types";
export default function () {
return {
visitor: {
Program(path, state) {
if (state.opts.strict === false) return;
let { node } = path;
for (let directive of (node.directives: Array<Object>)) {
if (directive.value.value === "use strict") return;
}
path.unshiftContainer("directives", t.directive(t.directiveLiteral("use strict")));
}
}
};
}