Nicolò Ribaudo 8c7d4b55c9
Add plugins name (#8769)
* Add plugins name

* Add missing names found by the plugin

* Add eslint plugin
2018-11-18 23:02:58 +01:00

32 lines
793 B
JavaScript

import { declare } from "@babel/helper-plugin-utils";
export default declare((api, options) => {
api.assertVersion(7);
// When enabled and plugins includes flow, all files should be parsed as if
// the @flow pragma was provided.
const { all } = options;
if (typeof all !== "boolean" && typeof all !== "undefined") {
throw new Error(".all must be a boolean, or undefined");
}
return {
name: "syntax-flow",
manipulateOptions(opts, parserOpts) {
// If the file has already enabled TS, assume that this is not a
// valid Flowtype file.
if (
parserOpts.plugins.some(
p => (Array.isArray(p) ? p[0] : p) === "typescript",
)
) {
return;
}
parserOpts.plugins.push(["flow", { all }]);
},
};
});