Detecting duplicate hooks in component

Hi

Is there any way to make ember-cli warn about duplicate hooks in a component?

Example:

didReceiveAttrs(){
	this._super(...arguments);
..
...

},
..
..
.
..
.
.
didReceiveAttrs(){
	this._super(...arguments);
..
..
},

I just wasted an hour figuring out why my code (the first one) was not being called :slight_smile:

kind regards

Bent Bracke

Hello @bracke :wave: !

Ember-cli doesn’t have this feature and I don’t think it will. BUT you could use eslint-plugin-ember and generate that new rule using the official yeoman generator.

I’m getting a linting error on a newly created project using ember-cli@3.1.4:

/home/foo/tmp/test-lint/app/components/my-component.js
  7:3  error  Duplicate key 'didReceiveAttrs'  no-dupe-keys

✖ 1 problem (1 error, 0 warnings)

The eslint rule is called no-duple-keys and part of the eslint:recommended base configuration.

1 Like