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

Rule suggestion: events hash key should always be quoted #65

Open
niksy opened this issue Jul 10, 2016 · 4 comments
Open

Rule suggestion: events hash key should always be quoted #65

niksy opened this issue Jul 10, 2016 · 4 comments

Comments

@niksy
Copy link

niksy commented Jul 10, 2016

When you use events hash, you always quote key since it contains spaces:

{
    'click .foo': function ( e ) {
        // ...
    }
}

But if you try to set event handle on el itself, it is allowed to omit those quotes:

{
    click: function ( e ) {
        // ...
    }
}

Suggested rule will warn user to always put quotes around events hash key to keep it consistent with majority of use cases.

Potential issue I can see is that it could clash with quote-props rule.

What do you think?

@ilyavolodin
Copy link
Owner

You are correct. It would clash with quote-props rule in the core. I don't usually quote click when it's set on the root object, but it's a personal preference. I'd be fine with including this in. Do you want to submit a PR for this? I'd name it something like quoted-events, maybe.

@niksy
Copy link
Author

niksy commented Jul 10, 2016

Is there any rule on how to handle clashing rules? It seems like that kind of behavior is greatly discouraged and should probably be handled inside original rule with custom option.

@ilyavolodin
Copy link
Owner

Yes, usually you would want to resolve it in the core rule. However, ESLint doesn't make exceptions for specific frameworks, all of the rules are framework agnostic. Now that I'm looking at the rule, I think you can just use 'quote-props': ['error', 'consistant'] that will enforce the rule you are looking for. It will apply to everything, but I figured that if you want it in events, you probably wouldn't mind it in other places as well.

@platinumazure
Copy link
Contributor

It might be possible to create a plugin version of this rule using eslint-rule-composer.

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

No branches or pull requests

3 participants