-
-
Notifications
You must be signed in to change notification settings - Fork 195
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
Test: missing tests for modules & classes (refs #72) #75
Conversation
This will clash with 731d54f a bit |
yes, that has to be fixed in espree and esprima. For anonymous classes and functions for |
Thanks so much for your work on this @caridy Really amazing work! Do you want me to look into this last class issue? |
Can you both yeah take a look at #73 for my changes? I'd like to use that as a bad before making further changes. |
Okay will look at fixing that last test tomorrow! |
Looking quickly at |
Initially appears to be related to case "class":
if (allowClasses) {
return parseClassDeclaration();
}
break; Inside of expectKeyword("class");
id = parseVariableIdentifier();
if (matchKeyword("extends")) {
lex();
superClass = parseLeftHandSideExpressionAllowCall();
} |
What's your definition of "not working"? I'm not clear on the bug you're trying to fix. |
Here is a related issue: when doing |
/cc @jeffmo |
@nzakas the issue is that Let me know what to change! |
Updated the PR description with clearer info and asks. |
Ah, I see, so this is the unnamed function declaration discussion. Got it. (Ref: estree/estree#38) So the change here is to allow a |
@nzakas correct. |
"body": [ | ||
{ | ||
"type": "ExportDefaultDeclaration", | ||
"declaration": 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.
I feel like this is missing a declaration
:|
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.
ha, that's a bug. related to what I mentioned before.
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.
awesome i'll try to take a stab at this tonight :)
Okay took care of the |
Ahh the |
also added a number of tests.
Ok, should be good to go. Let me know if you need anything else on this (like FunctionDecl stuff)... |
Cool, I'm hanging out in #eslint on Freenode as I try to get all of this merged and into ESLint |
@@ -5114,7 +5113,9 @@ function parseClassDeclaration() { | |||
|
|||
expectKeyword("class"); | |||
|
|||
id = parseVariableIdentifier(); | |||
if (lookahead.type === Token.Identifier) { |
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 isn't quite right because parseClassDeclaration()
normally must have an identifier. So you really need to pass in a flag specifying whether the ID is optional or required.
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.
Let me know if you have a specific class
declaration that breaks, at the moment I think this code-path may only be called in export
statements, so maybe it works by accident? maybe.
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 going to be out for most of the day taking kids to the zoo, but may be able to help later!
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.
That's okay, I'll just merge and fix it. Thanks!
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.
Just FYI, the problem case is:
class {}
This should throw an error because class declarations require names, but this change parsed it okay.
Test: missing tests for modules & classes (refs #72)
Added tests for the following:
export default class extends bar {};
export default class {};
export default class foo extends bar {};
export default class foo {};
export class foo extends bar {};
export class foo {};
Fixed the following:
export default class foo extends bar {};
such that it would notthrow
Need to check the following:
export default class {};
inclass-default-anonymous.result.js
export default class foo extends bar {};
inclass-default-anonymous-extends.result.js
The ASTs are tricky and need to be verified as accurate, because they were generated by espree.