grunt jshint angular service缺少' new'调用构造函数时的前缀

时间:2014-03-14 22:04:47

标签: angularjs gruntjs jshint grunt-contrib-jshint

gruntfile

module.exports = function(grunt) {

    // Project configuration.
    grunt.initConfig({
        // This line makes your node configurations available for use
        pkg: grunt.file.readJSON('package.json'),
        banner:
            '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>\n' +
            '<%= pkg.homepage ? " * " + pkg.homepage + "\\n" : "" %>' +
            ' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author %>;\n' +
            ' * Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %>\n */\n',
        src: {
            js: ['src/**/*.js']
        },
        // This is where we configure JSHint
        jshint: {
           myFiles: ['gruntFile.js', '<%= src.js %>'],
           options:{
                newcap:true,
                globals:{}
           } 
        }
    });
    // Each plugin must be loaded following this pattern
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.registerTask('default', ['jshint']);

};

为什么当我跑咕噜的时候我仍然有

  

缺少新的&#39;调用构造函数时的前缀。           $ scope.paginator = Paginator(2,5,medias);

Paginator是一家有角度的服务/工厂/供应商

更新

它应该是:

options:{
    newcap:false,
    globals:{}
} 

1 个答案:

答案 0 :(得分:1)

我不确定你的jshint配置对象。这是我从npm使用grunt-contrib-jshint https://www.npmjs.org/package/grunt-contrib-jshint

的模式
    jshint: {
        options: {
            jshintrc: 'jshintrc'
        },
        main: {
            src: [
                'app/js/**/*.js',
                'test/unit/**/*.js'
            ]
        }
    },

也许用grunt-contrib-jshint包给那个人一个机会