codelyzer icon indicating copy to clipboard operation
codelyzer copied to clipboard

directive-selector to allow button[xcButton] style selectors

Open intellix opened this issue 9 years ago • 4 comments

My Component/Directive prefixes are xc like so:

"directive-selector": [
  true,
  "attribute",
  "xc",
  "camelCase"
],

And I've created a Directive for button loaders that looks like:

<button xcButton [loading]="true">Submit</button>

The selector is: selector: 'button[xcButton]' but Codelyzer complains that it should be prefixed with xc. I feel like something like this should be allowed, or at least configurable to be

intellix avatar Sep 05 '17 10:09 intellix

Hi @intellix , it seems legitimate. We will investigate. Thank you for this issue.

wKoza avatar Sep 06 '17 08:09 wKoza

@intellix, the following spec passes:

it.only('should work with valid selector', () => {
  const source = `
      @Directive({
        selector: 'button[xcButton]'
      })
      class Test {}
      `;
  assertSuccess('directive-selector', source, ['attribute', 'xc', 'camelCase']);
});

Would you provide a code snippet so we can reproduce the problem?

mgechev avatar Sep 08 '17 05:09 mgechev

Ahah, now I see my folly :)

directive-selector: camelCase component-selector: kebab-case

I'm using a Component with an attribute selector because I wanna have styles and a template. It seems what I'd like to enforce is:

Attribute based selectors: camelCase Element based selectors: kebab-case

Currently I have to use kebab-case because it's a component: button[xc-button]

intellix avatar Sep 08 '17 10:09 intellix

@mgechev It would be great to be able to achieve what @intellix said:

It seems what I'd like to enforce is:

Attribute based selectors: camelCase Element based selectors: kebab-case

If we configure "component-selector" like this: "component-selector": [true, ["element", "attribute"], ["prefix"], ["kebab-case", "camelCase"], nothing is really enforced and one can create a component with kebab-case atrribute selector, which I would like to avoid.

jakpaw avatar Mar 16 '18 14:03 jakpaw