【问题标题】:grunt jshint angular service Missing 'new' prefix when invoking a constructorgrunt jshint 角度服务调用构造函数时缺少“新”前缀
【发布时间】:2014-03-14 22:04:46
【问题描述】:

咕噜文件

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']);

};

为什么当我运行 grunt 时我仍然得到了

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

Paginator 是一个角度服务/工厂/提供者

更新

应该是:

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

【问题讨论】:

    标签: angularjs gruntjs jshint grunt-contrib-jshint


    【解决方案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 包

    【讨论】:

    • 我更新了我设置为 true 而不是 false 的问题:)
    猜你喜欢
    • 2015-02-07
    • 1970-01-01
    • 2012-05-26
    • 2016-03-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多