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

JS tokeniser incorrectly setting some function and class names to control structure tokens #808

Closed
vrobic opened this issue Dec 7, 2015 · 1 comment

Comments

@vrobic
Copy link

vrobic commented Dec 7, 2015

Hi,

I'm using PHPCS to check Javascript files, with the Squiz standard. I don't know yet if a better Javascript standard exists for PHPCS ?

Well, here's the issue. It's a working example.

SomeClass.prototype.switch = function() {
    // do something
};

I know I shouldn't use such keywords to name a function, but since it's not a switch statement, PHPCS shouldn't have thrown an error for this ?

The sniff is "Inline control structures are not allowed" (Generic.ControlStructures.InlineControlStructure.NotAllowed) but it simply checks for control structure tokens. That's why I think the issue is deeper than this particular sniff. Maybe an issue with the tokens detection ?

I could simply disable this sniff, but I would prefer avoid it.
Thanks for your help.

@gsherwood gsherwood changed the title Reserved keywords detection JS tokeniser incorrectly setting some function and class names to control structure tokens Dec 8, 2015
gsherwood added a commit that referenced this issue Dec 8, 2015
@gsherwood
Copy link
Member

Thanks for reporting. The issue was in the tokenizer itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants