import { Program } from '@babel/types' ; import { VisitorFunction } from '../types' ; export const FLOW_DIRECTIVE = /(@flow(\s+(strict(-local)?|weak))?|@noflow)/ ; export const programVisitor = ( path , state ) : void => { const { comments } = state . file . ast ; if ( comments ) { comments . forEach ( comment => { if ( FLOW_DIRECTIVE . test ( comment . value ) ) { comment . value = comment . value . replace ( FLOW_DIRECTIVE , '' ) ; if ( ! comment . value . replace ( /\*/g , '' ) . trim ( ) ) { comment . ignore = true ; } } } ) ; } } ;