看起来我的 .eslintrc
文件没有找到我的 gulp-eslint
我定义了一个 lint
任务:
gulp.task('lint', function () {
gulp.src(['src/**/*.js', 'src/**/*.jsx'])
.pipe(eslint())
.pipe(eslint.format());
})
它运行但没有显示任何错误。
我的.eslintrc
文件在src
文件夹中定义。我尝试将其移至项目的根文件夹,但没有改变任何内容。
这是一个非常简单的文件:
{
"parser": "babel-eslint",
"ecmaFeatures": {
"classes": true,
"jsx": true
},
"plugins": [
"react"
],
"extends": "eslint-config-airbnb"
}
当我在终端中运行 eslint src
时,我收到一堆 eslint 错误,这很好。
知道什么地方不能正常工作吗?
最佳答案
根据docs您需要因管道中的错误而失败。
gulp.task('lint', function () {
// ESLint ignores files with "node_modules" paths.
// So, it's best to have gulp ignore the directory as well.
// Also, Be sure to return the stream from the task;
// Otherwise, the task may end before the stream has finished.
return gulp.src(['**/*.js','!node_modules/**'])
// eslint() attaches the lint output to the "eslint" property
// of the file object so it can be used by other modules.
.pipe(eslint())
// eslint.format() outputs the lint results to the console.
// Alternatively use eslint.formatEach() (see Docs).
.pipe(eslint.format())
// To have the process exit with an error code (1) on
// lint error, return the stream and pipe to failAfterError last.
.pipe(eslint.failAfterError());
});
关于javascript - Gulp eslint 找不到我的 .eslintrc 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36136737/