eslint-plugin-change-detection-strategy
This eslint plugin checks Angular ChangeDetectionStrategy is OnPush
Example of incorrect code:
@Component({
changeDetection: ChangeDetectionStrategy.Default
}) { }
@Component({
...
}) { }
Example of correct code:
@Component({
changeDetection: ChangeDetectionStrategy.OnPush
}) { }
Installation
npm install --save-dev eslint-plugin-change-detection-strategy
or
yarn add -D eslint-plugin-change-detection-strategy
Usage
- Add to .eslintrc plugins:
"plugins": [ "change-detection-strategy" ],
- Add to .eslintrc rules:
"rules": { "change-detection-strategy/on-push": "error" }
- Run
lint --fix
to fix the issues automatically. - Ignore the rule at some component if you like:
// eslint-disable-next-line change-detection-strategy/on-push
@Component({
changeDetection: ChangeDetectionStrategy.OnPush // <-- ok
}) { }