简体   繁体   English

gulp-eslint不会在控制台上抛出任何错误

[英]gulp-eslint not throwing any error on console

I am working with gulp and reactjs . 我有工作gulpreactjs I have added eslint for static analysing of my code. 我添加了eslint用于静态分析我的代码。 I am using gulp-eslint as follows: 我正在使用gulp-eslint如下:

var eslint = require('gulp-eslint');
gulp.task('eslint', function() {
  // Process all script files, but ignore npm_modules
  gulp.src(['widgets/**/*.js', 'server/**/*.js', '!node_modules/**'])
    .pipe(eslint.format())
    .pipe(eslint.failAfterError());

My .eslintrc file is : 我的.eslintrc文件是:

{
  "parser": "babel-eslint",
  "plugins": [
  "react"
],
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
  "jsx": true
}
},
"extends": ["eslint:recommended", "plugin:react/recommended"],
"env": {
"browser": true,
"amd": true,
"es6": true,
"node": true,
"mocha": true
},
"rules": {
"comma-dangle": 1,
"quotes": [ 1, "single" ],
"no-undef": 1,
"global-strict": 0,
"no-extra-semi": 1,
"no-underscore-dangle": 0,
"no-console": 1,
"no-unused-vars": 1,
"no-trailing-spaces": [1, { "skipBlankLines": true }],
"no-unreachable": 1,
"no-alert": 0,
"react/jsx-uses-react": 1,
"react/jsx-uses-vars": 1
}
}

But, even if i have trailing spaces and alerts in my code, it won't show any error on the console. 但是,即使我的代码中有尾随空格和警报,它也不会在控制台上显示任何错误。 All it does is: 它所做的就是:

Starting 'eslint'...
Finished 'eslint' after 1.97 s

The directory structure is: 目录结构是:

root/
node_modules
widgets //contains the js files
server //contains the js files
.eslintrc
gulpfile.js
package.json

You've forgot to pipe estlint() properly. 你忘了管道estlint() Try: 尝试:

var eslint = require('gulp-eslint');
gulp.task('eslint', function() {
  // Process all script files, but ignore npm_modules
  gulp.src(['widgets/**/*.js', 'server/**/*.js', '!node_modules/**'])
    .pipe(eslint({
      useEslintrc: true
    }))
    .pipe(eslint.format())
    .pipe(eslint.failAfterError());

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

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