首先,我知道我做错了什么,但grunt-contrib-jshint
没有正确地检查我的 JS,只是传递了文件。
我阅读了文档,但找不到我的错误。
这是出现问题的基本引导应用程序分支的链接。https://github.com/bengrunfeld/grunt_bower_app/tree/jshint-not-working
这是我的 Gruntfile.js 及其输出的完整副本:
Gruntfile.js
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
jshint: {
all: ['Gruntfile.js', 'dev/js/*.js']
},
clean: ['dist/'],
copy: {
main: {
files: [
{expand: true, src: ['bower_components/jquery/dist/jquery.min.js'], dest: 'dist/js', filter: 'isFile'},
{expand: true, src: ['bower_components/bootstrap/dist/js/bootstrap.min.js'], dest: 'dist/js', filter: 'isFile'},
{expand: true, src: ['bower_components/bootstrap/dist/css/bootstrap.min.css'], dest: 'dist/css', filter: 'isFile'} ,
{expand: true, src: ['bower_components/bootstrap/dist/fonts/*'], dest: 'dist/fonts', filter: 'isFile'},
],
}
},
});
// Load in Grunt's plugins
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-uglify');
// Default tasks
grunt.registerTask('default', ['jshint', 'clean', 'copy']);
};
输出
$ grunt
Running "jshint:all" (jshint) task
>> 3 files lint free.
Running "clean:0" (clean) task
>> 1 path cleaned.
Running "copy:main" (copy) task
Copied 8 files
但是我在 Javascript 中引入了一个非常明显的错误:
dooooooocument.getElementsByClassName("hero-btn")[0].addEventListener("click", function(){
console.log('The hero button was clicked');
});
document.getElementsByClassName("store-btn")[0].addEventListener("click", function(){
console.log('The store button was clicked');
});
所以,哦,可靠的互联网理事会,我做错了什么?