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

[Fix] Compilation error when method name is string instead of identifier #2514

Merged
merged 1 commit into from Dec 9, 2019
Merged

Conversation

shijistar
Copy link
Contributor

I got a compilation error when a component method name is string instead of identifier. The sample code is,

class MyComponent {
    "special-method-name"() {
        // ...
    }
}

Normally method names should be valid identifiers. However for some reason, I need one of my methods must be in a special form. Eslint raises an error, but babel goes well and the code works well in chrome too.

The difference between Identifier and String method is that the node.key.type is Identifier/Literal. If method name is Identifier, the node.key.name is the identifier name, however if method name is String, we should get the method name by node.key.value.

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Can you please provide a regression test?

@shijistar shijistar requested a review from ljharb December 9, 2019 03:06
@shijistar
Copy link
Contributor Author

Thanks! Can you please provide a regression test?

Regression test added.

@ljharb ljharb merged commit 4fedc5f into jsx-eslint:master Dec 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants