Socket
Socket
Sign inDemoInstall

@angular-eslint/eslint-plugin

Package Overview
Dependencies
126
Maintainers
1
Versions
650
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@angular-eslint/eslint-plugin

ESLint plugin for Angular applications, following angular.io/styleguide


Version published
Maintainers
1
Weekly downloads
1,530,230
decreased by-1.58%
Install size
5.61 MB

Weekly downloads

Package description

What is @angular-eslint/eslint-plugin?

The @angular-eslint/eslint-plugin package is designed to provide linting rules specifically for Angular projects using ESLint. It helps in maintaining code quality and consistency across Angular applications by enforcing best practices and coding standards specific to Angular development.

What are @angular-eslint/eslint-plugin's main functionalities?

Component selector naming

This rule ensures that component selectors are prefixed correctly and use kebab-case. It helps in maintaining a consistent naming convention across your Angular application.

"@angular-eslint/component-selector": ["error", { "type": "element", "prefix": "app", "style": "kebab-case" }]"

No input rename

This rule disallows the renaming of directive inputs by providing an alias when using the Input decorator. It encourages the use of consistent and predictable names for directive inputs.

"@angular-eslint/no-input-rename": "error"

Use lifecycle interface

This rule warns when lifecycle methods are used without implementing the corresponding lifecycle interface. It ensures that components and directives explicitly declare their intention to use Angular lifecycle hooks.

"@angular-eslint/use-lifecycle-interface": "warn"

Other packages similar to @angular-eslint/eslint-plugin

Readme

Source

@angular-eslint/eslint-plugin

Premade configs

  • Premade configs

Rules

Possible problems

Key

  • :white_check_mark: = recommended
  • :wrench: = fixable
  • :bulb: = has suggestions
RuleDescription:white_check_mark::wrench::bulb:
contextual-lifecycleEnsures that lifecycle methods are used in a correct context:white_check_mark:
no-async-lifecycle-methodAngular Lifecycle methods should not be async. Angular does not wait for async lifecycle but the code incorrectly suggests it does.
no-attribute-decoratorThe @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 often the @Attribute decorator is mistakenly used when @Input was what was intended. This rule disallows usage of @Attribute decorator altogether in order to prevent these mistakes.
sort-lifecycle-methodsEnsures that lifecycle methods are declared in order of execution

Suggestions

Key

  • :white_check_mark: = recommended
  • :wrench: = fixable
  • :bulb: = has suggestions
RuleDescription:white_check_mark::wrench::bulb:
component-class-suffixClasses decorated with @Component must have suffix "Component" (or custom) in their name. See more at https://angular.io/styleguide#style-02-03:white_check_mark:
component-max-inline-declarationsEnforces a maximum number of lines in inline template, styles and animations. See more at https://angular.io/guide/styleguide#style-05-04
component-selectorComponent selectors should follow given naming rules. See more at https://angular.io/guide/styleguide#style-02-07, https://angular.io/guide/styleguide#style-05-02 and https://angular.io/guide/styleguide#style-05-03.
consistent-component-stylesEnsures component styles/styleUrl with string is used over styles/styleUrls when there is only a single string in the array:wrench:
contextual-decoratorEnsures that classes use contextual decorators in its body
directive-class-suffixClasses decorated with @Directive must have suffix "Directive" (or custom) in their name. See more at https://angular.io/styleguide#style-02-03:white_check_mark:
directive-selectorDirective selectors should follow given naming rules. See more at https://angular.io/guide/styleguide#style-02-06 and https://angular.io/guide/styleguide#style-02-08.
no-conflicting-lifecycleEnsures that directives not implement conflicting lifecycle interfaces.
no-empty-lifecycle-methodDisallows declaring empty lifecycle methods:white_check_mark::bulb:
no-forward-refDisallows usage of forwardRef references for DI
no-host-metadata-propertyDisallows usage of the host metadata property. See more at https://angular.io/styleguide#style-06-03:white_check_mark:
no-input-prefixEnsures that input bindings, including aliases, are not named or prefixed by the configured disallowed prefixes
no-input-renameEnsures that input bindings are not aliased:white_check_mark::wrench::bulb:
no-inputs-metadata-propertyDisallows usage of the inputs metadata property. See more at https://angular.io/styleguide#style-05-12:white_check_mark:
no-lifecycle-callDisallows explicit calls to lifecycle methods
no-output-nativeEnsures that output bindings, including aliases, are not named as standard DOM events:white_check_mark:
no-output-on-prefixEnsures that output bindings, including aliases, are not named "on", nor prefixed with it. See more at https://angular.io/guide/styleguide#style-05-16:white_check_mark:
no-output-renameEnsures that output bindings are not aliased:white_check_mark::wrench::bulb:
no-outputs-metadata-propertyDisallows usage of the outputs metadata property. See more at https://angular.io/styleguide#style-05-12:white_check_mark:
no-pipe-impureDisallows the declaration of impure pipes:bulb:
no-queries-metadata-propertyDisallows usage of the queries metadata property. See more at https://angular.io/styleguide#style-05-12.
pipe-prefixEnforce consistent prefix for pipes.
prefer-on-push-component-change-detectionEnsures component's changeDetection is set to ChangeDetectionStrategy.OnPush:bulb:
prefer-output-readonlyPrefer to declare @Output as readonly since they are not supposed to be reassigned:bulb:
prefer-standaloneEnsures component, directive and pipe standalone property is set to true in the component decorator:wrench:
relative-url-prefixThe ./ and ../ prefix is standard syntax for relative URLs; don't depend on Angular's current ability to do without that prefix. See more at https://angular.io/styleguide#style-05-04
require-localize-metadataEnsures that $localize tagged messages contain helpful metadata to aid with translations.
sort-ngmodule-metadata-arraysEnsures ASC alphabetical order for NgModule metadata arrays for easy visual scanning:wrench:
use-component-selectorComponent selector must be declared
use-component-view-encapsulationDisallows using ViewEncapsulation.None:bulb:
use-injectable-provided-inUsing the providedIn property makes Injectables tree-shakable:bulb:
use-lifecycle-interfaceEnsures that classes implement lifecycle interfaces corresponding to the declared lifecycle methods. See more at https://angular.io/styleguide#style-09-01
use-pipe-transform-interfaceEnsures that Pipes implement PipeTransform interface:white_check_mark::wrench:

Deprecated

RuleReplaced by
prefer-standalone-componentprefer-standalone

FAQs

Last updated on 15 Mar 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc