isNoFlowFile.js.flow 605 B

12345678910111213141516171819
  1. import isNoFlowFileAnnotation from './isNoFlowFileAnnotation';
  2. /**
  3. * Checks whether a file has an @flow or @noflow annotation.
  4. *
  5. * @param context
  6. * @param [strict] - By default, the function returns true if the file
  7. * starts with @flow but not if it starts by @noflow. When the strict flag
  8. * is set to false, the function returns true if the flag has @noflow also.
  9. */
  10. export default (context, strict = true) => {
  11. const comments = context.getAllComments();
  12. if (!comments.length) {
  13. return false;
  14. }
  15. return comments.some((comment) => isNoFlowFileAnnotation(comment.value, strict));
  16. };