How to use the eslint.CLIEngine.getFormatter 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 postmanlabs / postman-runtime / npm / test-lint.js View on Github external
function (report, next) {
            var errorReport = ESLintCLIEngine.getErrorResults(report.results);

            // log the result to CLI
            console.info(ESLintCLIEngine.getFormatter()(report.results));
            // log the success of the parser if it has no errors
            (errorReport && !errorReport.length) && console.info('eslint ok!'.green);
            // ensure that the exit code is non zero in case there was an error
            next(Number(errorReport && errorReport.length) || 0);
        }
    ], exit);
github postmanlabs / newman / npm / test-lint.js View on Github external
function (report, next) {
            var errorReport = ESLintCLIEngine.getErrorResults(report.results);
            // log the result to CLI
            console.info(ESLintCLIEngine.getFormatter()(report.results));
            // log the success of the parser if it has no errors
            (errorReport && !errorReport.length) && console.info('eslint ok!'.green);
            // ensure that the exit code is non zero in case there was an error
            next(Number(errorReport && errorReport.length) || 0);
        }
    ], exit);
github blogfoster / blogfoster-scripts / scripts / lint.js View on Github external
ignorePattern,
  useEslintrc: false,
  fix: !args.check,
});

const report = engine.executeOnFiles([target]);
let errorCount = report.errorCount;

if (!args.check) {
  // Write any fixes to disk
  CLIEngine.outputFixes(report);
  errorCount -= report.fixableErrorCount;
}

// Print the linting results
const formatter = CLIEngine.getFormatter();
const output = formatter(report.results);
console.log(output);

if (errorCount > 0) {
  process.exit(1);
}
github adidas / htmplar / src / tasks / lint.js View on Github external
};

  const lintingOptions = {};

  if (cliOptions) {
    cliOptions.forEach((option, index) => {
      if (option.startsWith('--')) {
        lintingOptions[option.replace('--', '')] = cliOptions[index + 1];
      }
    });
  }

  const cli = new CLIEngine(options);

  const report = cli.executeOnFiles([ source ]);
  const formatter = CLIEngine.getFormatter();

  log(formatter(report.results));

  // stop all remaining process when error occurred
  if (report.errorCount > 0 && lintingOptions.exitOnError === 'true') {
    warn('Further commands stopped due to errors in linting. Please fix them in order to continue!');
    info('If you do not want to stop process due to the errors, you can set "exitOnError: false" in linting options.');
    process.exit(1);
  }
};
github adametry / gulp-eslint / util.js View on Github external
exports.resolveFormatter = (formatter) => {
	// use ESLint to look up formatter references
	if (typeof formatter !== 'function') {
		// load formatter (module, relative to cwd, ESLint formatter)
		formatter =	CLIEngine.getFormatter(formatter) || formatter;
	}

	return formatter;
};
github goto-bus-stop / standard-action / index.js View on Github external
function printResults (results, formatStyle) {
  const formatter = CLIEngine.getFormatter(formatStyle)
  console.log(formatter(results.results, {}))
}
github b-mueller / sabre / lib / report.js View on Github external
const getFormatter = (name) => {
    const custom = ['text'];

    if (custom.includes(name)) {
        name = path.join(__dirname, 'formatters/', name + '.js');
    }

    return eslintCliEngine.getFormatter(name);
};
github x-orpheus / elint / src / workers / eslint / formatter.js View on Github external
'use strict'

const CLIEngine = require('eslint').CLIEngine
const stylish = CLIEngine.getFormatter('stylish')

/**
 * @typedef {Object} ESLintResultMessage
 *
 * @property {string} ruleId rules名
 * @property {number} severity 错误级别
 * @property {string} message 提示
 * @property {number} line 开始行号
 * @property {number} column 开始列号
 * @property {string} nodeType nodeType
 * @property {number} endLine 结束行号
 * @property {number} endColumn 结束列号
 */

/**
 * @typedef {Object} ESLintResult