Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flowtype comments markers #661

Closed
qzb opened this Issue Oct 14, 2016 · 4 comments

Comments

4 participants
@qzb
Copy link

qzb commented Oct 14, 2016

Flowtype supports annotating code with comments (only block comments /* ... */). It uses three different markers ( :, ::, flow-include), none of them is currently recognized by standard. Flowtype ignores whitespaces before markers, so standard doesn't brake anything, but placing spaces before these markers is inconsistent - they are not required before other markers like * and !. My proposition is to add : and :: to list of markers for block comments. I'm not sure if flow-include should be also added, it is just an alias for ::, and markers like this looks kind of strange without whitespace:

/*flow-include declare type foo = number */    // looks strange, currently disallowed
/* flow-include declare type foo = number */   // looks ok

On other hand space before : marker could actually improve readability:

function foo (arg /* : number */) {}   // with whitespace - currently valid
function foo (arg /*: number */) {}    // without whitespace - currently invalid
@josephfrazier

This comment has been minimized.

Copy link
Contributor

josephfrazier commented Dec 11, 2016

I just ran up against this, but didn't know that Flowtype ignores whitespace before markers. Thanks for pointing out how to work around it!

It looks like gajus/eslint-plugin-flowtype#87 might be the place to add support for the syntax without whitespace.

@feross

This comment has been minimized.

Copy link
Member

feross commented Dec 18, 2016

I think it's probably fine to add an exception for : and ::. The point of this rule is generally to avoid writing comments like //this is a comment.

Can you provide a link to the Flow documentation where this comment marker is discussed?

@feross feross added the enhancement label Dec 18, 2016

@cesarandreu

This comment has been minimized.

Copy link
Contributor

cesarandreu commented Dec 18, 2016

Comment Syntax section in the docs points to the following blog post.

@feross feross added this to the standard v9 milestone Feb 9, 2017

feross added a commit to standard/eslint-config-standard that referenced this issue Feb 9, 2017

@feross

This comment has been minimized.

Copy link
Member

feross commented Feb 9, 2017

This will be part of standard v9. Since it's relaxing a rule, there is no impact on the ecosystem. Except of course, now you can use Flow Comments!

🎉

@feross feross closed this Feb 9, 2017

feross added a commit to standard/eslint-config-standard that referenced this issue Feb 9, 2017

@lock lock bot locked as resolved and limited conversation to collaborators May 10, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.