isFlowFile.js 1023 B

12345678910111213141516171819202122232425262728293031323334
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports["default"] = void 0;
  6. var _isFlowFileAnnotation = _interopRequireDefault(require("./isFlowFileAnnotation"));
  7. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  8. /**
  9. * Checks whether a file has an or @noflow annotation.
  10. *
  11. * @param context
  12. * @param [strict] - By default, the function returns true if the file
  13. * starts with @flow but not if it starts by @noflow. When the strict flag
  14. * is set to false, the function returns true if the flag has @noflow also.
  15. */
  16. var _default = function _default(context) {
  17. var strict = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  18. var comments = context.getAllComments();
  19. if (!comments.length) {
  20. return false;
  21. }
  22. return comments.some(function (comment) {
  23. return (0, _isFlowFileAnnotation["default"])(comment.value, strict);
  24. });
  25. };
  26. exports["default"] = _default;
  27. module.exports = exports.default;