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

Support for multiple selector type in directive-selector and component-selector rules #290

Closed
eugechielli opened this issue Apr 10, 2017 · 8 comments
Assignees

Comments

@eugechielli
Copy link

The rules directive-selector and component-selector should allow the directives/components to accept both element and attribute type . With the rule definition, I'm forced to choose between an element and an attribute because If I don't respect it I get the following warning: "this.typeValidator is not function"

I would be great if I can set this type as null (so it would accept elements and attributes) or as a string/array with the both types accepted. For example:

"directive-selector": [true, null, "bm", "kebab-case"]
or
"directive-selector": [true, "attribute|element", "bm", "kebab-case"]
or
"directive-selector": [true, [ "attribute", "element" ], "bm", "kebab-case"]

Thanks for taking a look at it :)

@eugechielli eugechielli changed the title Support for multiple selector type for directive-selector and component-selector rules Support for multiple selector type in directive-selector and component-selector rules Apr 10, 2017
@mgechev
Copy link
Owner

mgechev commented Apr 20, 2017

It makes sense to be more configurable. I'll try to introduce it as part of 3.0.0.

@mgechev mgechev self-assigned this Apr 20, 2017
@mgechev mgechev added this to the 3.0.0 - Lamido milestone Apr 20, 2017
@karol-depka
Copy link
Contributor

Hi. Thanks for taking care of this.
Is the doc updated?
http://codelyzer.com/rules/component-selector/

Currently, the schema there says:

{
"enum": [
"element",
"attribute"
]
},

What is the syntax to allow both attribute selector and element-based selector?
Is it this, as in changelog?

"component-selector": [true, ["element", "attribute"], "sg", "kebab-case"],

Can I submit a pull request to the docs?

Thanks!

@mgechev
Copy link
Owner

mgechev commented May 31, 2017

The schema has different format compared to the example. This seems corrext to me.

@karol-depka
Copy link
Contributor

@mgechev Not sure what you mean.

Consider:

  1. "element" or "attribute" forces components either to be elements or attributes.

either

-- http://codelyzer.com/rules/component-selector/

It does not mention the option of allowing both.

Another thing is how to use it to allow both: is it:

"component-selector": [true, ["element", "attribute"], "sg", "kebab-case"],

?

I guess you understood that I confused/assumed that the schema should look the same as the example :). Which is not the case. I think the schema in the doc should have "oneOf" allowing enum or array.

@mgechev
Copy link
Owner

mgechev commented May 31, 2017

Yes, "either" might not be the most appropriate. I'll be happy to merge a more detailed description of the configuration options if you want to open a PR.

@karol-depka
Copy link
Contributor

master...karol-depka:patch-1 - wdyt?

@mgechev
Copy link
Owner

mgechev commented May 31, 2017

LGTM! Open the PR so I can merge.

@AbakumovAlexandr
Copy link

@mgechev , can you provide an example of how the rule should look like to set up kebab style for elements and camel case for attributes, please?

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

4 participants