Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DI validation error for a function without parameters #442

Closed
karan-kang opened this issue Feb 14, 2017 · 0 comments
Closed

DI validation error for a function without parameters #442

karan-kang opened this issue Feb 14, 2017 · 0 comments
Assignees
Labels
Milestone

Comments

@karan-kang
Copy link

karan-kang commented Feb 14, 2017

I get the following error, when using $inject DI pattern rule for a function without parameters.

C:\Development\MyApp\app\common\helpViewer\helpBtn.directive.js
  15:5  error  You should use the $inject syntax for DI  angular/di

Function Body:
(function() {
'use strict';

angular.module('app.common')
       .directive('appHelpBtn', helpBtn);

/**
 * Help button template generator
 * @name appHelpBtn
 * @memberof app.common
 * @class
 * @example
 * <app-help-btn link="help/something.html"></app-help-btn>
 */
function helpBtn() {
    return {
        restrict: 'AE',
        scope: {
            classes: '@class',
            link: '@'
        },
        template: [
            '<a ng-href="{{link}}" href="#" ng-classes="classes"',
            'title="Show help for this view" app-help-viewer="{{link}}">',
            '<i class="fa fa-lg fa-question"></i>',
            '</a>'
        ].join('')
    };
}

})();

Rule defined in .eslintrc.json file
"angular/di": [ 2, "$inject" ]

Plugins in use
"eslint-config-angular": "~0.5.0"
"eslint-config-google": "~0.7.1"
"eslint-plugin-angular": "~1.6.1"
"gulp-eslint": "~3.0.1",
"gulp": "~3.9.1"

Workaround:
Add this line after declaring the directive.

helpBtn.$inject = [];

@karan-kang karan-kang changed the title DI validation error for a function with no parameters DI validation error for a function without parameters Feb 14, 2017
@EmmanuelDemey EmmanuelDemey self-assigned this Mar 19, 2017
@EmmanuelDemey EmmanuelDemey added this to the 1.6.4 milestone Mar 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants