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

时间:2016-08-08 09:12:54

标签: javascript reactjs gulp eslint

我正在使用gulpreactjs。我添加了eslint来静态分析我的代码。我正在使用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());

我的.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
}
}

但是,即使我的代码中有尾随空格和警报,它也不会在控制台上显示任何错误。它所做的就是:

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

目录结构是:

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

1 个答案:

答案 0 :(得分:0)

您忘了正确管道desc Employee。尝试:

estlint()