This is a repository containing custom ESLint rules for Angular projects
destroy-service-provider
: When usingDestroyService
to automatically unsubscribe from an observable, this service MUST be provided in Component/Directive class providers in order for the Service to work properly. This rule ensures the DestroyService is always provided in theproviders
array of the Component or Directive.
npm install --save-dev eslint-plugin-ngx-eslint
Edit your .eslintrc
config file as follow
{
"plugins": ["ngx-eslint"],
"rules": {
"ngx-eslint/destroy-service-provider": "error"
}
}
If your destroy service class name is different than DestroyService
, the configuration would be like this
{
"plugins": ["ngx-eslint"],
"rules": {
"ngx-eslint/destroy-service-provider": [
"error",
{
"destroyServiceName": "MyDestroyService"
}
]
}
}
Result
MIT