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
Closed

Flowtype comments markers #661

qzb opened this issue Oct 14, 2016 · 4 comments

Comments

@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
Copy link
Contributor

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
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?

@cesarandreu
Copy link
Contributor

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
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 as completed 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.
Projects
Archived in project
Development

No branches or pull requests

4 participants