EmmanuelDemey / eslint-plugin-angular

ESLint plugin for AngularJS applications
https://www.npmjs.com/package/eslint-plugin-angular
618 stars 131 forks source link

Allow property based dependency specification in ng_di #143

Open britter opened 9 years ago

britter commented 9 years ago

As discussed in #138, ng_di currently doesn't allow property based dependency specifications like:

class MyController {

    static get $inject() {
        return ['DataStore'];
    }

    constructor(DataStore) {
        this.dataStore = DataStore;
    }

    toggle() {
        this.active = !this.active;
        this.dataStore.addData('active', this.active);
    }
}

Proposal: add possibility to configure 'ng_di': [2, 'property']

britter commented 9 years ago

In ES5 this should look like:

function MyFunction(Service1) {
  this.service1 = Service1;
}
MyFunction.$inject = ['Service1'];

@bripkens can you confirm?

bripkens commented 9 years ago

@britter: Right, although from an AST point of view there are multiple ways to specify an $injector property. Although the one you mentioned is probably the most common.