-
Notifications
You must be signed in to change notification settings - Fork 11
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
extend genericSpacing
to cover funtion annotations
#25
base: master
Are you sure you want to change the base?
Conversation
Thanks, looks like some good effort here initially. Some input here would be,
|
Yeah, agreed. I will merge the rules.
Can do.
Ah, forgot to mention there seems to be an issue in the underlying test runner. When I add
Yeah, scratching my head at that too. I will check my linting version, mostly I use CRA + Relay + Flow outside of work (where all this stuff magically works for me). |
Amazing, that's so interesting that this use case was never tested. I'll try look into a fix too but if you find one feel free to contribute it |
genericSpacing
to cover funtion annotations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also you can remove package-lock.json
and why idea why there was a large yarn.lock diff? Not a biggie we can cleanup later
src/configs/recommended.json
Outdated
@@ -44,6 +44,10 @@ | |||
2, | |||
"never" | |||
], | |||
"ft-flow/type-annotation-spacing": [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should remove this now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, forgot to stage that change
ef00cf8
to
8f1f4c8
Compare
8f1f4c8
to
5333a0c
Compare
I am still seeing failures when the lint tester tries to parse the |
Yeah I've just spent the better part of my day trying to figure this one out. I'm a bit confused.. I dug into the code and in the end At this rate if we can't solve it but your improvement works i'm ok to merge it as an alpha release initially whenever you think your change is ready |
}, | ||
{ | ||
code: 'useState<string >(null)', | ||
errors: [{ message: 'There must be no space at start of type annotations' }], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should say end
of type annotations
// Type annotations | ||
{ | ||
code: 'const [state, setState] = useState<?string >(null)', | ||
errors: [{ message: 'There must be no space at start of type annotations' }], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
errors: [{ message: 'There must be no space at start of type annotations' }], | |
errors: [{ message: 'There must be no space at end of type annotations' }], |
}, | ||
{ | ||
code: 'const [state, setState] = useState<?string > (null)', | ||
errors: [{ message: 'There must be no space at start of type annotations' }], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
errors: [{ message: 'There must be no space at start of type annotations' }], | |
errors: [{ message: 'There must be no space at end of type annotations' }], |
code: 'useState< string >(null)', | ||
errors: [{ message: 'There must be no space at start of type annotations' }], | ||
output: 'useState<string>(null)', | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a test that's something like the following if it doesn't already exist elsewhere I'm interested to know if it strips all spaces blindly or only when it's between maybe types ?
and arrow brackets </>
{
code: 'useState< string | number >(null)',
errors: [{ message: 'There must be no space at start of type annotations' }],
output: 'useState<string | number>(null)',
},
Ok found something. I believe this is unrelated to the test runner itself. If you go to any file in |
Right as it turns out, it's because it's not parsing the token correctly unless you have |
This is a guess but I'm imagining it has something to do with how TS doesn't have maybe types so flow token parsing doesn't actually run with babel unless the flow pragma is first detected. |
I was looking at the TS side of things, so I think you are right. I will pull out my laptop tonight after work and action your comments here. Thanks for the time - it feels nice to use Flow at home :) |
I put this together - it's ended up being fairly complex, so if I missed the mark let me know.
It works if I call
eslint . --fix
on my code, but the tests are failing saying the expected rule is not throwing. If I deploy this branch to my project'spackage.json
I get all the warnings and fixers.Fixes #24