Skip to content

eslint/rules/angular-components ​

Angular (angular-eslint): components, directives, pipes and services, every TypeScript rule listed, plus the TypeScript rules Angular code needs differently. Templates are in angular-templates.

59 rules, 49 on. Source: lint/eslint/rules/angular-components.mjs.

RuleSettingFilesWhat it checksWhy
@typescript-eslint/member-orderingoffTS—Off: Angular fields initialise in order (inject() first), conflicting with its default order.
new-capwarn, {"capIsNew":false}TSRequire constructor names to begin with a capital letterCustom: decorators are capitalised calls (`@Component()`), not constructors.
@typescript-eslint/naming-conventionwarn, [{"selector":"default","format":["camelCase"],"leadingUnd…TS—Custom: the shared naming, plus PascalCase readonly properties (an enum exposed to a template) and PascalCase stores (`export const UsersStore = signalStore(…)` is used like a class). Warn: external names (JSON keys, HTTP headers) keep their spelling.
@typescript-eslint/no-extraneous-classwarn, {"allowWithDecorator":true}TS—Angular classes are decorated (@Component, @Injectable…).
@angular-eslint/component-class-suffixwarnTSClasses decorated with @Component must have suffix "Component" (or custom) in their name. Note: As of v20, this is no longer recommended by the Angular Team.—
@angular-eslint/component-max-inline-declarationsinfoTSEnforces a maximum number of lines in inline template, styles and animations.Small components may stay inline; past 3 lines, template and styles go to their own files.
@angular-eslint/component-selectorwarn, {"type":"element","prefix":"app","style":"kebab-case"}TSComponent selectors should follow given naming rules. See more at https://angular.dev/style-guide#choosing-component-selectors.—
@angular-eslint/computed-must-returnerrorTSEnsures that computed() returns a value. Omitting the value is likely a mistake.—
@angular-eslint/consistent-component-styleserrorTSEnsures consistent usage of styles/styleUrls/styleUrl within Component metadata—
@angular-eslint/contextual-decoratorerrorTSEnsures that classes use contextual decorators in their body—
@angular-eslint/contextual-lifecycleerrorTSEnsures that lifecycle methods are used in a correct context—
@angular-eslint/directive-class-suffixwarnTSClasses decorated with @Directive must have suffix "Directive" (or custom) in their name. Note: As of v20, this is no longer recommended by the Angular Team.—
@angular-eslint/directive-selectorwarn, {"type":"attribute","prefix":"app","style":"camelCase"}TSDirective selectors should follow given naming rules. See more at https://angular.dev/style-guide#choosing-directive-selectors.—
@angular-eslint/inject-at-toperrorTSRequires inject() calls to be declared at the top of the class, before any other member—
@angular-eslint/no-async-lifecycle-methoderrorTSAngular Lifecycle methods should not be async. Angular does not wait for async lifecycle but the code incorrectly suggests it does.—
@angular-eslint/no-attribute-decoratorerrorTSThe @Attribute decorator is used to obtain a single value for an attribute. This is a much less common use case than getting a stream of values (using @Input), so the @Attribute decorator is often mistakenly used when @Input is intended. This rule disallows the usage of @Attribute decorator entirely to prevent these mistakes.—
@angular-eslint/no-developer-previewwarnTSDisallow using code which is marked as developer previewWarn: a developer-preview API may be used knowingly; it may still change before it is stable.
@angular-eslint/no-duplicates-in-metadata-arrayserrorTSEnsures that metadata arrays do not contain duplicate entries.—
@angular-eslint/no-empty-lifecycle-methodinfoTSDisallows declaring empty lifecycle methods—
@angular-eslint/no-experimentalerrorTSDisallow using code which is marked as experimental—
@angular-eslint/no-forward-refwarnTSDisallows usage of forwardRef references for DI—
@angular-eslint/no-implicit-take-until-destroyederrorTSEnsures that takeUntilDestroyed() is called with an explicit DestroyRef when used outside of an injection context—
@angular-eslint/no-input-prefixoffTSEnsures that input bindings, including aliases, are not named or prefixed by the configured disallowed prefixesOff: no input prefix to forbid (the rule does nothing without a list).
@angular-eslint/no-input-renameerrorTSEnsures that input bindings are not aliased—
@angular-eslint/no-inputs-metadata-propertywarnTSDisallows usage of the inputs metadata property—
@angular-eslint/no-lifecycle-callerrorTSDisallows explicit calls to lifecycle methods—
@angular-eslint/no-output-nativeerrorTSEnsures that output bindings, including aliases, are not named as standard DOM events—
@angular-eslint/no-output-on-prefixwarnTSEnsures that output bindings, including aliases, are not named "on", nor prefixed with it. See more at https://angular.dev/guide/components/outputs#choosing-event-names—
@angular-eslint/no-output-renameerrorTSEnsures that output bindings are not aliased—
@angular-eslint/no-outputs-metadata-propertywarnTSDisallows usage of the outputs metadata property—
@angular-eslint/no-pipe-impurewarnTSDisallows the declaration of impure pipes—
@angular-eslint/no-queries-metadata-propertywarnTSDisallows usage of the queries metadata property.—
@angular-eslint/no-uncalled-signalserrorTSWarns user about unintentionally doing logic on the signal, rather than the signal's value—
@angular-eslint/pipe-prefixoffTSEnforce consistent prefix for pipes.Off: pipe names are internal to the workspace; enable it in a library shared with other teams.
@angular-eslint/prefer-host-metadata-propertyinfoTSUse host metadata property instead of @HostBinding and HostListener—
@angular-eslint/prefer-injectinfoTSPrefer using the inject() function over constructor parameter injection—
@angular-eslint/prefer-on-push-component-change-detectionerror, {"allowExplicitOnPush":false}TSEnsures components do not opt out of the default ChangeDetectionStrategy.OnPush change detection strategyCustom: OnPush is the default since Angular 22, writing it is noise.
@angular-eslint/prefer-output-emitter-refinfoTSUse OutputEmitterRef instead of @Output()—
@angular-eslint/prefer-output-readonlyinfoTSPrefer to declare @Output, OutputEmitterRef and OutputRef as readonly since they are not supposed to be reassigned—
@angular-eslint/prefer-service-decoratorerrorTSPrefer the @Service() decorator over @Injectable({ providedIn: 'root' })—
@angular-eslint/prefer-signal-modelerror, {"useTypeChecking":true}TSUse model instead of input and output for two-way bindingsCustom: more accurate with type information (the typescript block enables it).
@angular-eslint/prefer-signalserror, {"useTypeChecking":true}TSUse readonly signals instead of @Input(), @ViewChild() and other legacy decoratorsCustom: more accurate with type information (the typescript block enables it).
@angular-eslint/prefer-standaloneinfoTSEnsures Components, Directives and Pipes do not opt out of standalone.—
@angular-eslint/reactive-context-must-read-signalerror, {"checkResources":true}TSEnsures that reactive contexts such as computed(), linkedSignal() and effect() read at least one reactive value (a signal). A reactive context with no reactive dependencies never re-runs, which is almost always a mistake.—
@angular-eslint/relative-url-prefixinfoTSThe ./ and ../ prefix is standard syntax for relative URLs; don't depend on Angular's current ability to do without that prefix.—
@angular-eslint/require-lifecycle-on-prototypeerrorTSEnsures that lifecycle methods are defined on the object's prototype instead of on an instance.—
@angular-eslint/require-localize-metadataoffTSEnsures that $localize tagged messages contain helpful metadata to aid with translations.Off: the texts are translated with Transloco, not @angular/localize.
@angular-eslint/runtime-localizeoffTSEnsures that $localize tagged messages can use runtime-loaded translations.Off: the texts are translated with Transloco, not @angular/localize.
@angular-eslint/sort-keys-in-type-decoratorerrorTSEnsures that keys in type decorators (Component, Directive, Injectable, NgModule, Pipe) are sorted in a consistent order—
@angular-eslint/sort-lifecycle-methodserrorTSEnsures that lifecycle methods are declared in order of execution—
@angular-eslint/use-component-selectorwarnTSComponent selector must be declared—
@angular-eslint/use-component-view-encapsulationwarnTSDisallows using ViewEncapsulation.None—
@angular-eslint/use-injectable-provided-inoffTSUsing the providedIn property makes Injectables tree-shakableOff: root services use @Service (prefer-service-decorator); a bare @Injectable() is component-scoped.
@angular-eslint/use-lifecycle-interfaceerrorTSEnsures that classes implement lifecycle interfaces corresponding to the declared lifecycle methods. See more at https://angular.dev/style-guide#use-lifecycle-hook-interfaces—
@angular-eslint/use-pipe-transform-interfaceerrorTSEnsures that Pipes implement PipeTransform interface—
@typescript-eslint/no-unsafe-assignmentoff**/*.spec.ts—Off: Angular types fixture.nativeElement and debugElement as any.
@typescript-eslint/no-unsafe-calloff**/*.spec.ts——
@typescript-eslint/no-unsafe-member-accessoff**/*.spec.ts——
@typescript-eslint/no-unsafe-type-assertionoff**/*.spec.ts——

Generated from the JSDoc of the sources.