2013-04-06 94 views
1

我刚开始搞乱Grunt。我有一个基本的实现成功运行,缩小我的代码并运行JSHint。JSHint错误记录在哪里?

它说0文件lint免费,我收集意味着它检查的所有文件都有lint。

但是,我一直在Google上搜索一个小时,而且somehwat令人难以置信,无法弄清楚这些错误在哪里被保存。

我需要在grunt配置中指定一个日志文件吗?我在JSHint或grunt文档中没有看到类似的东西。

下面的Gruntfile,从Grunt的“入门”中直接获得。我掏出qunit因为我目前没有任何测试 -

module.exports = function(grunt) { 
    grunt.initConfig({ 

    pkg: grunt.file.readJSON('package.json'), 

    concat: { 
     options: { 
     // define a string to put between each file in the concatenated output 
     separator: ';' 
     }, 
     dist: { 
     // the files to concatenate 
     src: ['spin/**/*.js'], 
     // the location of the resulting JS file 
     dest: 'dist/<%= pkg.name %>.js' 
     } 
    }, 

    uglify: { 
     options: { 
     // the banner is inserted at the top of the output 
     banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n' 
     }, 
     dist: { 
     files: { 
      'dist/<%= pkg.name %>.min.js': ['<%= concat.dist.dest %>'] 
     } 
     } 
    }, 

    jshint: { 
     // define the files to lint 
     files: ['gruntfile.js', 'src/**/*.js', 'test/**/*.js'], 
     // configure JSHint (documented at http://www.jshint.com/docs/) 
     options: { 
      // more options here if you want to override JSHint defaults 
      "curly": true, 
    "eqnull": true, 
    "eqeqeq": true, 
    "undef": true, 
     globals: { 
      jQuery: true, 
      console: true, 
      module: true 
     } 
     } 
    }, 

    watch: { 
     files: ['<%= jshint.files %>'], 
     tasks: ['jshint'] 
    } 

    }); 

     grunt.loadNpmTasks('grunt-contrib-uglify'); 
     grunt.loadNpmTasks('grunt-contrib-jshint'); 
     grunt.loadNpmTasks('grunt-contrib-watch'); 
     grunt.loadNpmTasks('grunt-contrib-concat'); 

     grunt.registerTask('test', ['jshint']); 

     grunt.registerTask('default', ['jshint', 'concat', 'uglify']); 

}; 

回答

1

0文件无尘并不意味着你必须具有错误的文件,这意味着零文件签!

的jshint任务将输出错误控制台(包括文件,行号和列),您可以指定文件

多数民众赞成检查:

files: ['gruntfile.js', 'src/**/*.js', 'test/**/*.js'], 

,如果你改变“gruntfile.js”到'Gruntfile.js'(区分大小写!)它应该检查你的gruntfile(你当然已经有了)。

+0

是的,这似乎是会起作用的。愚蠢的错误。你知道是否有一种方法来指定一个日志文件,而不是只是在控制台中转储的结果? – iabw 2013-04-07 00:47:59

+0

所以是的,这工作。我觉得没有抓住那个很愚蠢。但是,它的记录像成千上万条线。我是否需要逐个删除我的文件,直到它们更接近平价,或者我可以指定要忽略的库文件,或者只是将我的“可接受的”皮棉列入正式列表? – iabw 2013-04-07 00:52:35

+0

你的第一步可能会使用grunt-beautify插件:https://github.com/pix/grunt-beautify – hereandnow78 2013-04-07 20:03:51