JSHint错误记录在哪里?

时间:2013-04-06 00:44:09

标签: gruntjs jshint

我刚开始搞乱Grunt。我有一个成功运行的基本实现,缩小我的代码并运行JSHint。

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

然而,我一直在谷歌搜索一个小时,而且有些不可思议,无法弄清楚这些错误在哪里被保存。

我是否需要在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 :(得分:1)

0文件lint free并不意味着你有错误的文件,这意味着检查零文件!

jshint-task会将错误输出到你的控制台(包括文件,亚麻和列)

指定要检查的文件的地方:

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

如果你将'gruntfile.js'改为'Gruntfile.js'(区分大小写!),它应该检查你的gruntfile(你当然已经拥有)。