简体   繁体   English

如何让gulp-jshint忽略文件夹

[英]How to get gulp-jshint to ignore folders

I have the following folder structure within a solution that I have inherited 我在继承的解决方案中有以下文件夹结构

.\gulp.config.js
.\gulpfile.js
.\.jscsrc
.\.jshintrc
.\default.js
.\Resources\js\main.js
.\Resources\js\modules\   various user created js files
.\Resources\js\vendor\    various js files i.e jQuery

I have installed gulp-jscs and gulp-jshint. 我已经安装了gulp-jscs和gulp-jshint。

The .jscsrc I have taken from https://github.com/johnpapa/pluralsight-gulp/blob/master/.jscsrc . .jscsrc我来自https://github.com/johnpapa/pluralsight-gulp/blob/master/.jscsrc

I have the following within gulpfile.js: 我在gulpfile.js中有以下内容:

'use strict'

var gulp = require('gulp');
var jshint = require('gulp-jshint');
var jscs = require('gulp-jscs');

gulp.task('verifyJS',function(){
    gulp.src([
        './Resources/**/*.js',
        './*.js'
    ])
    .pipe(jscs())
    .pipe(jshint())
    .pipe(jshint.reporter('jshint-stylish', { verbose: true }));
});

I am trying to update the excludeFiles within .jscsrc to exclude the following: 我正在尝试更新.jscsrc中的excludeFiles以排除以下内容:

.\default.js 
.\resources\js\vendor

This is what I have tried: 这是我尝试过的:

 "excludeFiles": [
     "node_modules/**",
     "bower_components/**",
     "Resources/js/vendor/**", // vendor supplied files. ie jQuery
     "./Resources/js/vendor/**", 
     "default.js", 
     "/default.js", 
     "./default.js", 
 ],

I have included all the combinations that I have tried. 我已经包含了我尝试过的所有组合。

But when i run gulp verifyJS it is still including the files that I want to exclude. 但是当我运行gulp verifyJS它仍然包含我想要排除的文件。

How do I correctly set excludeFiles to exclude the file within the root of the project and the subfolder with all subsequent files and folders? 如何正确设置excludeFiles以排除项目根目录中的文件以及包含所有后续文件和文件夹的子文件夹?

gulp-jshint doesn't care what's in your .jscsrc since that is the config file for gulp-jscs . gulp-jshint并不关心.jscsrc因为这是gulp-jscs的配置文件。 You need a .jshintignore file instead. 你需要一个.jshintignore文件。

Here's how to ignore your vendor files in both gulp-jscs and gulp-jshint : 以下是如何忽略gulp-jscsgulp-jshint gulp-jscs供应商文件:

.jscsrc .jscsrc

"excludeFiles": [
  "node_modules/**",
  "bower_components/**",
  "Resources/js/vendor/**",
  "default.js", 
],

.jshintignore .jshintignore

node_modules/**
bower_components/**
Resources/js/vendor/**
default.js

gulpfile.js gulpfile.js

gulp.task('verifyJS', function(){
  return gulp.src([
    './Resources/**/*.js',
    './*.js'
  ])
  .pipe(jscs())
  .pipe(jscs.reporter()) // you forgot this
  .pipe(jshint())
  .pipe(jshint.reporter('jshint-stylish', { verbose: true }));
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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