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']);
};
是的,这似乎是会起作用的。愚蠢的错误。你知道是否有一种方法来指定一个日志文件,而不是只是在控制台中转储的结果? – iabw 2013-04-07 00:47:59
所以是的,这工作。我觉得没有抓住那个很愚蠢。但是,它的记录像成千上万条线。我是否需要逐个删除我的文件,直到它们更接近平价,或者我可以指定要忽略的库文件,或者只是将我的“可接受的”皮棉列入正式列表? – iabw 2013-04-07 00:52:35
你的第一步可能会使用grunt-beautify插件:https://github.com/pix/grunt-beautify – hereandnow78 2013-04-07 20:03:51