javascript - 错误 : No ESLint configuration found

标签 javascript json gulp eslint grunt-eslint

无法让 ESLint 识别并使用 Gulp 运行。 gulpfile.js 的代码是:

"use strict";

var gulp = require('gulp');
var connect = require('gulp-connect'); //Runs a local dev server
var open = require('gulp-open'); //Open a URL in a web browser
var browserify = require('browserify'); // Bundles JS
var reactify = require('reactify');  // Transforms React JSX to JS
var source = require('vinyl-source-stream'); // Use conventional text streams with Gulp
var concat = require('gulp-concat'); //Concatenates files
var lint = require('gulp-eslint'); //Lint JS files, including JSX

var config = {
	port: 9005,
	devBaseUrl: 'http://localhost',
	paths: {
		html: './src/*.html',
		js: './src/**/*.js',
		css: [
      		'node_modules/bootstrap/dist/css/bootstrap.min.css',
      		'node_modules/bootstrap/dist/css/bootstrap-theme.min.css'
    	],
		dist: './dist',
		mainJs: './src/main.js'
	}
}

//Start a local development server
gulp.task('connect', function() {
	connect.server({
		root: ['dist'],
		port: config.port,
		base: config.devBaseUrl,
		livereload: true
	});
});

gulp.task('open', ['connect'], function() {
	gulp.src('dist/index.html')
		.pipe(open({ url: config.devBaseUrl + ':' + config.port + '/'}));
});

gulp.task('html', function() {
	gulp.src(config.paths.html)
		.pipe(gulp.dest(config.paths.dist))
		.pipe(connect.reload());
});

gulp.task('js', function() {
	browserify(config.paths.mainJs)
		.transform(reactify)
		.bundle()
		.on('error', console.error.bind(console))
		.pipe(source('bundle.js'))
		.pipe(gulp.dest(config.paths.dist + '/scripts'))
		.pipe(connect.reload());
});

gulp.task('css', function() {
	gulp.src(config.paths.css)
		.pipe(concat('bundle.css'))
		.pipe(gulp.dest(config.paths.dist + '/css'));
});

gulp.task('lint', function() {
	return gulp.src(config.paths.js)
		.pipe(lint({config: 'eslint.config.json'}))
		.pipe(lint.format());
});

gulp.task('watch', function() {
	gulp.watch(config.paths.html, ['html']);
	gulp.watch(config.paths.js, ['js', 'lint']);
});

gulp.task('default', ['html', 'js', 'css', 'lint', 'open', 'watch']);

eslint.config.json 是:

{
  "ecmaFeatures": {
    "jsx": true
  },
  "env": {
    "browser": true,
    "node": true,
    "jquery": true
  },
  "rules": {
    "quotes": 0,
    "no-trailing-spaces": 0,
    "eol-last": 0,
    "no-unused-vars": 0,
    "no-underscore-dangle": 0,
    "no-alert": 0,
    "no-lone-blocks": 0
  },
  "globals": {
    jQuery: true,
    $: true
  }
}

最后 package.json 依赖项是:

  "dependencies": {
    "bootstrap": "^3.3.7",
    "browserify": "^14.1.0",
    "gulp": "^3.9.1",
    "gulp-concat": "^2.6.1",
    "gulp-connect": "^5.0.0",
    "gulp-eslint": "^3.0.1",
    "gulp-open": "^2.0.0",
    "jquery": "^3.1.1",
    "reactify": "^1.1.1",
    "vinyl-source-stream": "^1.1.0"
  }

我可以编辑什么以使三个文件中的一个或多个起作用?

最佳答案

正如您可以在 https://github.com/adametry/gulp-eslint#optionsconfigfile 上看到的那样

key 名称已更改为 configFile

关于javascript - 错误 : No ESLint configuration found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42404269/

相关文章:

javascript - 将 d3.json 方法与 Json 对象一起使用

.net - 将 JSON 反序列化为对象 (VB.NET)

javascript - 在 gulp 任务中使用 Inkscape 处理 SVG 时遇到问题

python - 接收 "TypeError: the JSON object must be str, bytes or bytearray, not dict"

wordpress - 在 WordPress (MAMP) 中使用 BrowserSync 和 Gulp

javascript - Gulp - 从 javascript 文件中删除注释

javascript - 在登台服务器中有效但在生产中失败的 URL 无效

javascript - 将对象数组作为 ajax 发布数据发送?

php - 未设置($_GET ['someVariable'])不起作用

javascript - LG Webos TV 项目单击按钮后传递参数或消息