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
Fix: Improve keyword-spacing typescript support (fixes #8110) #8111
Conversation
@soda0289, thanks for your PR! By analyzing the history of the files in this pull request, we identified @mysticatea, @vitorbal and @gyandeeps to be potential reviewers. |
LGTM |
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.
Thanks! I think this looks fine, but may you please add tests for this change? Examples of tests with a custom parser can be found in arrow-parens.
Sure thing |
62d5d14
to
e8bf9d1
Compare
LGTM |
e8bf9d1
to
b0d5d25
Compare
LGTM |
b0d5d25
to
261f832
Compare
LGTM |
261f832
to
fd27ba8
Compare
LGTM |
@not-an-aardvark I also added back the check for |
@eslint/eslint-team What do you think if we have typescript in devDependencies? As my understanding, we have been avoiding that we have custom parsers in devDependencies. Though I'm not oppose it... |
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.
I'm not familiar with TypeScript and Decorators, but I guess that decorators can have parameters. I'd like to look at tests for decorators which have parameters, especially the cases that the parameters have keywords.
fd27ba8
to
f1b6fe8
Compare
LGTM |
@mysticatea |
The part of me that wants to see a resolution to a long-standing issue thinks "hellz yes!" 😄 Other immediate thoughts:
|
I can understand the concern of increasing the number of devDependencies and including parsers in the test suite. One way I can see to avoid this is to create another package or repository that handled eslint parser integration tests. That way if you change how eslint works you would not need to run all the parser integration tests unless it modified how parsing or rules were handled. New rules and rule modifications could run the integration tests and we could learn more about how these changes would effect users of those parser. A failing test in the integration test suite might indicate a problem with the parser itself and not eslint. Another idea would be to hardcode the AST that typescript-eslint-parser generates and use that as test input instead of code. |
I'm inclined to think that we shouldn't bundle the TypeScript parser and run a lot of TypeScript tests in this repo. Instead, I'd suggest creating a stub custom parser for testing purposes where you can return whatever AST you want (I did that for type annotations already). I'd just cover a couple basic cases rather than the large number of tests this PR adds. Then, I like the idea of having some kind of separate integration test. It seems like that could live in the TypeScript parser repo? I'm also not opposed to a separate repo for that. |
@soda0289 I'm sorry for my unclear request. My concern was a code like |
f1b6fe8
to
80cb5f6
Compare
LGTM |
@mysticatea @not-an-aardvark These test no longer depend on typescript or typescript-eslint-parser. Thanks for your patience and feedback I appreciate it. |
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.
Stubbed parser looks like a much cleaner approach!
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.
LGTM, thank you!
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.
LGTM. Thanks!
What is the purpose of this pull request? (put an "X" next to item)
[ ] Documentation update
[X ] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofixing to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ X] Other, please explain:
#8110
What changes did you make? (Give an overview)
Allow keyword-spacing rule to find the first token better by skipping over decorators, generated by typescript, and not including symbol keyword when parsing arrow functions.
Is there anything you'd like reviewers to focus on?
Is this the best solution to allow the typescript parser to work correctly with the keyword-spacing rule?