簡體   English   中英

grunt-contrib-jshint不刪除我的代碼中的錯誤

[英]grunt-contrib-jshint not linting errors in my code

首先,我知道我做錯了事,但是grunt-contrib-jshint不能正確地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');
});

那么,明智的無誤互聯網理事會,我在做什么錯呢?

問題是,默認情況下,jshint不檢查任何規則。 因此,在您將所需的規則設置為.jshintrc文件或grunt選項之前,文件可以通過,並且並不是很有用。

例如,如果您想要與網站jshint.com進行相同級別的檢查,則需要一個非常強大的規則列表: https : //github.com/jshint/jshint/blob/master/examples/.jshintrc

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM