平均堆栈咕噜声显示一些错误'函数名称()'在定义之前使用过

时间:2017-01-06 10:54:54

标签: angularjs gruntjs mean-stack

跑步" jshint:全部" (jshint)任务

   modules/codes/client/config/codes.client.config.js
      6 |    function menuConfig(menuService) {
                                ^ 'menuConfig' was used before it was defined.
   modules/codes/client/config/codes.client.routes.js
      6 |    function routeConfig($stateProvider) {
                                 ^ 'routeConfig' was used before it was defined.
     58 |    function getCode($stateParams, CodesService) {
                             ^ 'getCode' was used before it was defined.
     65 |    function newCode(CodesService) {
                             ^ 'newCode' was used before it was defined.
   modules/codes/client/controllers/codes.client.controller.js
     11 |  function CodesController ($scope, $state, $window, Authentication, code) {
                                    ^ 'CodesController' was used before it was defined.
     22 |    function remove() {
                            ^ 'remove' was used before it was defined.
     29 |    function save(isValid) {
                          ^ 'save' was used before it was defined.
     42 |      function successCallback(res) {
                                       ^ 'successCallback' was used before it was defined.
     48 |      function errorCallback(res) {
                                     ^ 'errorCallback' was used before it was defined.
   modules/codes/client/controllers/list-codes.client.controller.js
     10 |  function CodesListController(CodesService) {
                                       ^ 'CodesListController' was used before it was defined.
   modules/codes/client/services/codes.client.service.js
     11 |  function CodesService($resource) {
                                ^ 'CodesService' was used before it was defined.

>> 11 errors in 99 files

我使用 Mongodb,Express,yo meanjs,nodejs,grunt 创建 MEAN Stack Applications ,然后使用 yo meanjs创建模块:crud-module myModuleName ,它已创建并在应用菜单上显示,但是当我正在运行grunt命令时,它在终端和浏览器控制台中显示上述错误返回404错误。这是我的代码..

(function() {
'use strict';
angular.module('codes').run(menuConfig);
menuConfig.$inject = ['Menus'];

function menuConfig(menuService) {
    // Set top bar menu items
    menuService.addMenuItem('topbar', {
        title: 'Codes',
        state: 'codes',
        type: 'dropdown',
        roles: ['*']
    });
    // Add the dropdown list item
    menuService.addSubMenuItem('topbar', 'codes', {
        title: 'List Codes',
        state: 'codes.list'
    });
    // Add the dropdown create item
    menuService.addSubMenuItem('topbar', 'codes', {
        title: 'Create Code',
        state: 'codes.create',
        roles: ['user']
    });
}

}());

1 个答案:

答案 0 :(得分:0)

这可能是发电机的一个问题。 您看到的linting错误定义为here

要绕过它,你应该找到jshint配置文件(通常名为.jshintrc),找到行
    "latedef" : true, 并将其更改为     "latedef" : "nofunc",或如果不存在则添加。

在我看来,吊装对于变量比对函数更危险,所以这应该是安全的操作。