index.js
function gulpEslint(options) {
	options = migrateOptions(options) || {};
	const linter = new CLIEngine(options);

	return transform((file, enc, cb) => {
		const filePath = relative(process.cwd(), file.path);

		if (file.isNull()) {
			cb(null, file);
			return;
		}

		if (file.isStream()) {
			cb(new PluginError('gulp-eslint', 'gulp-eslint doesn\'t support vinyl files with Stream contents.'));
			return;
		}

		if (linter.isPathIgnored(filePath)) {
			// Note:
			// Vinyl files can have an independently defined cwd, but ESLint works relative to `process.cwd()`.
			// (https://github.com/gulpjs/gulp/blob/master/docs/recipes/specifying-a-cwd.md)
			// Also, ESLint doesn't adjust file paths relative to an ancestory .eslintignore path.
			// E.g., If ../.eslintignore has "foo/*.js", ESLint will ignore ./foo/*.js, instead of ../foo/*.js.
			// Eslint rolls this into `CLIEngine.executeOnText`. So, gulp-eslint must account for this limitation.

			if (linter.options.ignore && options.warnFileIgnored) {
				// Warn that gulp.src is needlessly reading files that ESLint ignores
				file.eslint = createIgnoreResult(file);
			}
			cb(null, file);
			return;
		}

		let result;

		try {
			result = linter.executeOnText(file.contents.toString(), filePath).results[0];
		} catch (e) {
			cb(new PluginError('gulp-eslint', e));
			return;
		}
		// Note: Fixes are applied as part of "executeOnText".
		// Any applied fix messages have been removed from the result.

		if (options.quiet) {
			// ignore warnings
			file.eslint =  filterResult(result, options.quiet);
		} else {
			file.eslint = result;
		}

		// Update the fixed output; otherwise, fixable messages are simply ignored.
		if (file.eslint.hasOwnProperty('output')) {
			file.contents = Buffer.from(file.eslint.output);
			file.eslint.fixed = true;
		}
		cb(null, file);
	});
}
function gulpEslint(options) {
	options = migrateOptions(options) || {};
	const linter = new CLIEngine(options);

	return transform((file, enc, cb) => {
		const filePath = relative(process.cwd(), file.path);

		if (file.isNull()) {
			cb(null, file);
			return;
		}

		if (file.isStream()) {
			cb(new PluginError('gulp-eslint', 'gulp-eslint doesn\'t support vinyl files with Stream contents.'));
			return;
		}

		if (linter.isPathIgnored(filePath)) {
			// Note:
			// Vinyl files can have an independently defined cwd, but ESLint works relative to `process.cwd()`.
			// (https://github.com/gulpjs/gulp/blob/master/docs/recipes/specifying-a-cwd.md)
			// Also, ESLint doesn't adjust file paths relative to an ancestory .eslintignore path.
			// E.g., If ../.eslintignore has "foo/*.js", ESLint will ignore ./foo/*.js, instead of ../foo/*.js.
			// Eslint rolls this into `CLIEngine.executeOnText`. So, gulp-eslint must account for this limitation.

			if (linter.options.ignore && options.warnFileIgnored) {
				// Warn that gulp.src is needlessly reading files that ESLint ignores
				file.eslint = createIgnoreResult(file);
			}
			cb(null, file);
			return;
		}

		let result;

		try {
			result = linter.executeOnText(file.contents.toString(), filePath).results[0];
		} catch (e) {
			cb(new PluginError('gulp-eslint', e));
			return;
		}
		// Note: Fixes are applied as part of "executeOnText".
		// Any applied fix messages have been removed from the result.

		if (options.quiet) {
			// ignore warnings
			file.eslint =  filterResult(result, options.quiet);
		} else {
			file.eslint = result;
		}

		// Update the fixed output; otherwise, fixable messages are simply ignored.
		if (file.eslint.hasOwnProperty('output')) {
			file.contents = Buffer.from(file.eslint.output);
			file.eslint.fixed = true;
		}
		cb(null, file);
	});
}
function gulpEslint ( options ) { options = migrateOptions ( options ) || { } ; const linter = new CLIEngine ( options ) ; return transform ( ( file , enc , cb ) => { const filePath = relative ( process . cwd ( ) , file . path ) ; if ( file . isNull ( ) ) { cb ( null , file ) ; return ; } if ( file . isStream ( ) ) { cb ( new PluginError ( 'gulp-eslint' , 'gulp-eslint doesn\'t support vinyl files with Stream contents.' ) ) ; return ; } if ( linter . isPathIgnored ( filePath ) ) { // Note: // Vinyl files can have an independently defined cwd, but ESLint works relative to `process.cwd()`. // (https://github.com/gulpjs/gulp/blob/master/docs/recipes/specifying-a-cwd.md) // Also, ESLint doesn't adjust file paths relative to an ancestory .eslintignore path. // E.g., If ../.eslintignore has "foo/*.js", ESLint will ignore ./foo/*.js, instead of ../foo/*.js. // Eslint rolls this into `CLIEngine.executeOnText`. So, gulp-eslint must account for this limitation. if ( linter . options . ignore && options . warnFileIgnored ) { // Warn that gulp.src is needlessly reading files that ESLint ignores file . eslint = createIgnoreResult ( file ) ; } cb ( null , file ) ; return ; } let result ; try { result = linter . executeOnText ( file . contents . toString ( ) , filePath ) . results [ 0 ] ; } catch ( e ) { cb ( new PluginError ( 'gulp-eslint' , e ) ) ; return ; } // Note: Fixes are applied as part of "executeOnText". // Any applied fix messages have been removed from the result. if ( options . quiet ) { // ignore warnings file . eslint = filterResult ( result , options . quiet ) ; } else { file . eslint = result ; } // Update the fixed output; otherwise, fixable messages are simply ignored. if ( file . eslint . hasOwnProperty ( 'output' ) ) { file . contents = Buffer . from ( file . eslint . output ) ; file . eslint . fixed = true ; } cb ( null , file ) ; } ) ; }
Append ESLint result to each file

@param {(Object|String)} [options] - Configure rules, env, global, and other options for running ESLint
@returns {stream} gulp file stream
Append ESLint result to each file