简体   繁体   中英

Exclude a subdirectory from JSHint in my Gruntfile?

I am running JSHint automatically from a Gruntfile, and would like to exclude my vendor scripts, since lots of them fail JSHint.

How can I do this? At the moment I am running JSHint across anything in /app/scripts/ or any subdirectories.

jshint: {
  options: {
    jshintrc: '.jshintrc',
    reporter: require('jshint-stylish')
  },
  all: [
    'Gruntfile.js',
    '<%= yeoman.app %>/scripts/{,*/}*.js' 
  ]
},

I would like to exclude anything in /app/scripts/vendor . Is this possible?

Just prefix the path with ! to tell minimatch that it is an exclusion; note when doing this order is important.

jshint: {
  options: {
    jshintrc: '.jshintrc',
    reporter: require('jshint-stylish')
  },
  all: [
    'Gruntfile.js',
    '<%= yeoman.app %>/scripts/{,*/}*.js',
    '!<%= yeoman.app %>/scripts/vendor/**',
  ]
},

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM