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
Computed names for object getters and setters #2871
Comments
@nicolo-ribaudo @jugglinmike would like to take this one once I have completed the PR for #2975. Is that ok with you two? Thanks |
Go for it! |
Thanks @jugglinmike was reading the MDN docs on getters and setters of computed names and saw this warning.... Also, this ideally would be run by a user with Thank you |
This should always be parsed correctly, but if esversion < 6 JSHint should report W119 |
Perfect, thanks, should have a PR open this week for it. |
@nicolo-ribaudo && @jugglinmike I believe I found a clean solution for the first part of the issue.
I am now tackling the second error and part of the ticket for Let me know if you have any feedback or suggestions and should have a PR open this weekend, thank you guys |
I think your latest idea is closer to the solution, but still not quite there. As I see it, the problem is in the difference between how JSHint parses property names for ES2015 method definitions and accessor method definitions. The code path for the former includes this logic: if (state.tokens.next.id === "[") {
i = computedPropertyName();
state.nameStack.set(i);
} else {
state.nameStack.set(state.tokens.next);
i = propertyName();
saveProperty(props, i, state.tokens.next);
if (typeof i !== "string") {
break;
}
} ...while the code path for the latter does not account for the possibility of a computed property: i = propertyName(); |
Perfect thank you, will hopefully have a PR open for this and #2920 by monday. |
@jugglinmike PR Opened #2993 Let me know your thoughts, thank you. |
JSHint throws
Expected '(' and instead saw '['.
andExpected an identifier and instead saw 'a'.
.The text was updated successfully, but these errors were encountered: