Skip to content

require-valid-file-annotation is too aggressive #165

Closed
@wagerfield

Description

@wagerfield

When configuring flowtype/require-valid-file-annotation like so:

"flowtype/require-valid-file-annotation": [ "error", "never" ]

I am getting the linting errors:

1/2 Flow file annotation not at the top of the file. (flowtype/require-valid-file-annotation)
2/2 Malformed Flow file annotation. (flowtype/require-valid-file-annotation)

I am experiencing this linting error inside a JS file that contain a bunch of eslint rule configurations that I have annotated with @fixable (for rules that are fixable) inside a JSDoc block comment (I appreciate this isn't an official JSDoc type annotation):

flowtype-bug

Looking at the rule implementation, I can see that the potentialFlowFileAnnotation boolean uses looksLikeFlowFileAnnotation to conditionally report errors.

To my mind, this test is a little aggressive since it just looks for comments starting @f (which @fixable obviously passes). I see that you have a utility function fuzzyStringMatch—could this not be used to increase the certainty that the comment is a @flow annotation instead of the @f regex?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions