isFlowFileAnnotation.js 893 B

123456789101112131415161718192021222324252627282930
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports["default"] = void 0;
  6. var _lodash = _interopRequireDefault(require("lodash"));
  7. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  8. var FLOW_MATCHER = /^@(?:no)?flow$/;
  9. var _default = function _default(comment, strict) {
  10. return (// The flow parser splits comments with the following regex to look for the flag.
  11. // See https://github.com/facebook/flow/blob/a96249b93541f2f7bfebd8d62085bf7a75de02f2/src/parsing/docblock.ml#L39
  12. _lodash["default"].some(comment.split(/[\t\n\r \*\/\\]+/), function (commentPart) {
  13. var match = commentPart.match(FLOW_MATCHER);
  14. if (match === null) {
  15. return false;
  16. }
  17. return !strict || match[0] === '@flow';
  18. })
  19. );
  20. };
  21. exports["default"] = _default;
  22. module.exports = exports.default;