lib/index.js
function gulpHtmlLint(options) {
	let htmlLintOptions = {},
		issueFileCount = 0,
		issueCount = 0;

	options = options || {};
	options.htmllintrc = options.htmllintrc || '.htmllintrc';
	options.useHtmllintrc = options.useHtmllintrc !== false;
	options.plugins = options.plugins || [];
	options.limitFiles = options.limitFiles || (options.bail ? 1 : Number.MAX_VALUE);
	options.limitIssuesPerFile = options.limitIssuesPerFile || Number.MAX_VALUE;
	options.limitIssues = options.limitIssues || Number.MAX_VALUE;

	// load htmllint rules
	if (options.useHtmllintrc && fs.existsSync(options.htmllintrc)) {
		htmlLintOptions = JSON.parse(fs.readFileSync(options.htmllintrc, 'utf8'));
	}
	if (options.rules && typeof options.rules === 'object') {
		Object.keys(options.rules).forEach((prop) => {
			htmlLintOptions[prop] = options.rules[prop];
		});
	}

	// use plugins
	htmllint.use(options.plugins);

	return transform((file, enc, cb) => {
		if (file.isNull()) return cb(null, file);
		if (file.isStream()) return cb(new gutil.PluginError(PLUGIN_NAME, 'Streaming not supported'));
		if (issueFileCount >= options.limitFiles ||
			issueCount >= options.limitIssues) return cb(null, file);
		const relativeFilePath = path.relative(process.cwd(), file.path);
		htmllint(file.contents.toString(), htmlLintOptions)
			.then((issues) => {
				if (issues && issues.length) {
					let errorCount = 0,
						warningCount = 0;
					issueFileCount++;
					issueCount += issues.length;
					issues.forEach((issue) => {
						if (issue.code.indexOf('E') === 0) {
							issue.error = true;
							errorCount++;
						} else {
							issue.error = false;
							warningCount++;
						}
						issue.warning = !issue.error;
						issue.message = issue.message || htmllint.messages.renderIssue(issue);
					});
					file.htmlLint = {
						filePath: file.path,
						issues: issues.splice(0, Math.min(issues.length, options.limitIssuesPerFile)),
						relativeFilePath,
						errorCount,
						warningCount
					};
				}
				cb(null, file);
			}, () => {
				return cb(new gutil.PluginError(PLUGIN_NAME, `Could not lint html file: ${relativeFilePath}`));
			});
	});
}
function gulpHtmlLint(options) {
	let htmlLintOptions = {},
		issueFileCount = 0,
		issueCount = 0;

	options = options || {};
	options.htmllintrc = options.htmllintrc || '.htmllintrc';
	options.useHtmllintrc = options.useHtmllintrc !== false;
	options.plugins = options.plugins || [];
	options.limitFiles = options.limitFiles || (options.bail ? 1 : Number.MAX_VALUE);
	options.limitIssuesPerFile = options.limitIssuesPerFile || Number.MAX_VALUE;
	options.limitIssues = options.limitIssues || Number.MAX_VALUE;

	// load htmllint rules
	if (options.useHtmllintrc && fs.existsSync(options.htmllintrc)) {
		htmlLintOptions = JSON.parse(fs.readFileSync(options.htmllintrc, 'utf8'));
	}
	if (options.rules && typeof options.rules === 'object') {
		Object.keys(options.rules).forEach((prop) => {
			htmlLintOptions[prop] = options.rules[prop];
		});
	}

	// use plugins
	htmllint.use(options.plugins);

	return transform((file, enc, cb) => {
		if (file.isNull()) return cb(null, file);
		if (file.isStream()) return cb(new gutil.PluginError(PLUGIN_NAME, 'Streaming not supported'));
		if (issueFileCount >= options.limitFiles ||
			issueCount >= options.limitIssues) return cb(null, file);
		const relativeFilePath = path.relative(process.cwd(), file.path);
		htmllint(file.contents.toString(), htmlLintOptions)
			.then((issues) => {
				if (issues && issues.length) {
					let errorCount = 0,
						warningCount = 0;
					issueFileCount++;
					issueCount += issues.length;
					issues.forEach((issue) => {
						if (issue.code.indexOf('E') === 0) {
							issue.error = true;
							errorCount++;
						} else {
							issue.error = false;
							warningCount++;
						}
						issue.warning = !issue.error;
						issue.message = issue.message || htmllint.messages.renderIssue(issue);
					});
					file.htmlLint = {
						filePath: file.path,
						issues: issues.splice(0, Math.min(issues.length, options.limitIssuesPerFile)),
						relativeFilePath,
						errorCount,
						warningCount
					};
				}
				cb(null, file);
			}, () => {
				return cb(new gutil.PluginError(PLUGIN_NAME, `Could not lint html file: ${relativeFilePath}`));
			});
	});
}
function gulpHtmlLint ( options ) { let htmlLintOptions = { } , issueFileCount = 0 , issueCount = 0 ; options = options || { } ; options . htmllintrc = options . htmllintrc || '.htmllintrc' ; options . useHtmllintrc = options . useHtmllintrc !== false ; options . plugins = options . plugins || [ ] ; options . limitFiles = options . limitFiles || ( options . bail ? 1 : Number . MAX_VALUE ) ; options . limitIssuesPerFile = options . limitIssuesPerFile || Number . MAX_VALUE ; options . limitIssues = options . limitIssues || Number . MAX_VALUE ; // load htmllint rules if ( options . useHtmllintrc && fs . existsSync ( options . htmllintrc ) ) { htmlLintOptions = JSON . parse ( fs . readFileSync ( options . htmllintrc , 'utf8' ) ) ; } if ( options . rules && typeof options . rules === 'object' ) { Object . keys ( options . rules ) . forEach ( ( prop ) => { htmlLintOptions [ prop ] = options . rules [ prop ] ; } ) ; } // use plugins htmllint . use ( options . plugins ) ; return transform ( ( file , enc , cb ) => { if ( file . isNull ( ) ) return cb ( null , file ) ; if ( file . isStream ( ) ) return cb ( new gutil . PluginError ( PLUGIN_NAME , 'Streaming not supported' ) ) ; if ( issueFileCount >= options . limitFiles || issueCount >= options . limitIssues ) return cb ( null , file ) ; const relativeFilePath = path . relative ( process . cwd ( ) , file . path ) ; htmllint ( file . contents . toString ( ) , htmlLintOptions ) . then ( ( issues ) => { if ( issues && issues . length ) { let errorCount = 0 , warningCount = 0 ; issueFileCount ++ ; issueCount += issues . length ; issues . forEach ( ( issue ) => { if ( issue . code . indexOf ( 'E' ) === 0 ) { issue . error = true ; errorCount ++ ; } else { issue . error = false ; warningCount ++ ; } issue . warning = ! issue . error ; issue . message = issue . message || htmllint . messages . renderIssue ( issue ) ; } ) ; file . htmlLint = { filePath : file . path , issues : issues . splice ( 0 , Math . min ( issues . length , options . limitIssuesPerFile ) ) , relativeFilePath , errorCount , warningCount } ; } cb ( null , file ) ; } , ( ) => { return cb ( new gutil . PluginError ( PLUGIN_NAME , ` ${ relativeFilePath } ` ) ) ; } ) ; } ) ; }
Append HtmlLint result to each file in gulp stream.

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