Skip to content

component-selector and directive-selector issues #943

@PhiLhoSoft

Description

@PhiLhoSoft

Description and reproduction of the issue

I have defined these rules (in the overrides section for *.ts):

	'@angular-eslint/component-selector': ['error', { prefix: ['pr'] }],
	'@angular-eslint/directive-selector': ['error', { prefix: ['pr'] }],

I believe they worked the first time I tried them, as they reported relevant errors.
Later, I upgraded this package, and eventually found out they were no longer working.
It turns out I have to define all fields, event those marked as optional, even as the rule code seems to provide significant defaults (which, by the way, are not indicated in the rule documentations).

I found out I had to indicate these parameters:

	'@angular-eslint/component-selector': ['error', { type: 'element', prefix: ['pr'], style: 'kebab-case' }],
	'@angular-eslint/directive-selector': ['error', { type: 'attribute', prefix: ['pr'], style: 'camelCase' }],

They are actually needed, as they are different, but still, there is either (or both?) a problem with default handling or with documentation (should not be marked as optional).

Note: good or bad practice, I don't know, but our projects have some dual directive selectors, like selector: '[prDrop], pr-drop',, ie. defining the directive both as attribute and as element… I suppose I have to deactivate the rule for these cases. I wonder if directive-selector can handle both configurations, or if these cases are too marginal to be taken care of.

Versions

package version
@angular-eslint/eslint-plugin 13.1.0
@typescript-eslint/parser 5.15.0
ESLint 8.11.0
node 14.18.2
# Please run `npx ng version` in your project and paste the full output here:
Angular CLI: 13.3.0
Node: 14.18.2
Package Manager: npm 7.24.2
OS: win32 x64

Angular: 13.3.0
... cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1303.0
@angular-devkit/build-angular   13.3.0
@angular-devkit/core            13.3.0
@angular-devkit/schematics      13.3.0
@schematics/angular             13.3.0
ng-packagr                      13.3.0
rxjs                            7.5.5
  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest supported version of the packages and checked my ng version output per the instructions given here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    package: eslint-pluginAngular-specific TypeScript rulestriageThis issue needs to be looked at and categorized by a maintainer

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions