How to use the eslint.cli function in eslint

To help you get started, we’ve selected a few eslint examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github anthill / 6element / core / pre-commit-code.js View on Github external
"use strict";

var eslint = require('eslint');
// 'git ls-files -om --exclude-standard' to list all files that were changed then filter out non-JS files

process.chdir(__dirname);

var exitCode = eslint.cli.execute("./");

/*
 * Wait for the stdout buffer to drain.
 * See https://github.com/eslint/eslint/issues/317
 */
process.on("exit", function() {
    process.exit(exitCode);
});
github tinymce / tinymce / tools / BuildTools.js View on Github external
exports.eslint = function(options) {
	var eslint = require('eslint').cli, args = [];

	function globFiles(patterns) {
		var files = [], glob = require("glob");

		if (patterns instanceof Array) {
			patterns.forEach(function(pattern) {
				if (pattern[0] == '!') {
					glob.sync(pattern.substr(1)).forEach(function(file) {
						var idx = files.indexOf(file);

						if (idx != -1) {
							files.splice(idx, 1);
						}
					});
				} else {
					files = files.concat(glob.sync(pattern));
github iancmyers / eslint-grunt / tasks / lib / eslint.js View on Github external
args.push("-c", options.config);
    }

    if (options.formatter) {
      args.push("-f", options.formatter);
    }

    if (options.rulesDir) {
      args.push("--rulesdir", options.rulesDir);
    }

    if (options.force) {
      return 0;
    }

    return eslint.cli.execute(args.concat(files));
  }
};