index.js 891 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _helperPluginUtils = require("@babel/helper-plugin-utils");
  7. var _default = (0, _helperPluginUtils.declare)((api, options) => {
  8. api.assertVersion(7);
  9. const {
  10. all,
  11. enums
  12. } = options;
  13. if (typeof all !== "boolean" && typeof all !== "undefined") {
  14. throw new Error(".all must be a boolean, or undefined");
  15. }
  16. if (typeof enums !== "boolean" && typeof enums !== "undefined") {
  17. throw new Error(".enums must be a boolean, or undefined");
  18. }
  19. return {
  20. name: "syntax-flow",
  21. manipulateOptions(opts, parserOpts) {
  22. if (parserOpts.plugins.some(p => (Array.isArray(p) ? p[0] : p) === "typescript")) {
  23. return;
  24. }
  25. parserOpts.plugins.push(["flow", {
  26. all,
  27. enums
  28. }]);
  29. }
  30. };
  31. });
  32. exports.default = _default;