test('load config in eslint to validate all rule syntax is correct', function (t) { var CLIEngine = eslint.CLIEngine var cli = new CLIEngine({ useEslintrc: false, configFile: 'eslintrc.json' }) var code = 'var foo = 1\nvar bar = function () {}\nbar(foo)\n' t.equal(cli.executeOnText(code).errorCount, 0) t.end() })
assert.deepStrictEqual(report.results[0].messages, [ assert.deepStrictEqual(report.results[0].messages, [ assert.deepStrictEqual(report.results[0].messages, [ assert.deepStrictEqual(report.results[0].messages, [ assert.deepStrictEqual(report.results[0].messages, [ assert.deepStrictEqual(report.results[0].messages, [
const eslint = (paths) => { const engine = new CLIEngine(); const report = engine.executeOnFiles(paths); const formatter = engine.getFormatter(); return formatter(report.results); }
test('api usage', function (t) { t.plan(3) healthier.lintFiles([], { cwd: path.join(__dirname, '../bin') }, function (err, result) { t.error(err, 'no error while linting') t.equal(typeof result, 'object', 'result is an object') t.equal(result.errorCount, 0, 'no errors') }) })
async.waterfall([ // execute the CLI engine function (next) { next(null, (new ESLintCLIEngine()).executeOnFiles(LINT_SOURCE_DIRS)); }, // output results function (report, next) { var errorReport = ESLintCLIEngine.getErrorResults(report.results); // log the result to CLI console.log(ESLintCLIEngine.getFormatter()(report.results)); // log the success of the parser if it has no errors (errorReport && !errorReport.length) && console.log(chalk.green('eslint ok!')); // ensure that the exit code is non zero in case there was an error next(Number(errorReport && errorReport.length) || 0); } ], exit);
api.hook('lint').add('eslint', api => { const engine = new CLIEngine({ fix, root: true, env: {node: true}, baseConfig: useEslintrc ? undefined : api.config.eslint.toConfig(), useEslintrc }) const formatter = engine.getFormatter(format) const report = engine.executeOnFiles([api.config.context]) if (fix) { CLIEngine.outputFixes(report) } if (report.errorCount || report.warningCount) { api.print(formatter(report.results)) } else { api.print( report.results.some(f => f.output) ? '🎉 All lint errors auto-fixed' : '🎉 No lint errors found' ) } })
test('standard code quality', function (t) { t.plan(3) const result = healthier.lintTextSync(`a();\n`) t.equal(typeof result, 'object', 'result is an object') t.equal(result.errorCount, 1, '1 error') t.equal(result.results[0].messages[0].message, "'a' is not defined.", 'first message') })
}); const report = cliEngine.executeOnText(content, path.basename(filename)); const first = report.results[0];
let results = eslint.executeOnFiles(FILES).results;
if (!lintResult.errorCount) { if (lintResult.warningCount) { spinner = spinner.warn( chalk.yellowBright( `App compiled with ${lintResult.warningCount} warning${ lintResult.warningCount > 1 ? "s" : "" }` const warnings = getLintWarnings(lintResult.results); consoleLintWarnings(warnings); log(); const errorResults = LinterEngine.getErrorResults(lintResult.results); lintResult.errorCount > 1 ? "s" : "" }:` consoleLintErrors(errorResults); log(); spinner = spinner.fail(chalk.redBright(`Compilation Errors: ${lintResult.errorCount}`));
next(null, (new ESLintCLIEngine()).executeOnFiles(LINT_SOURCE_DIRS)); },
test('load config in eslint to validate all rule syntax is correct', function (t) { var CLIEngine = eslint.CLIEngine var cli = new CLIEngine({ useEslintrc: false, configFile: 'eslintrc.json' }) var code = 'var foo = 1\nvar bar = function () {}\nbar(foo)\n' t.equal(cli.executeOnText(code).errorCount, 0) t.end() })
const eslint = (paths) => { const engine = new CLIEngine(); const report = engine.executeOnFiles(paths); const formatter = engine.getFormatter(); return formatter(report.results); }
test('load config in eslint to validate all rule syntax is correct', function (t) { var CLIEngine = eslint.CLIEngine var cli = new CLIEngine({ useEslintrc: false, configFile: 'eslintrc.json' }) var code = 'var foo = 1\nvar bar = function () {}\nbar(foo)\n' t.equal(cli.executeOnText(code).errorCount, 0) t.end() })
test('standard 14 checks', function (t) { t.plan(3) const result = healthier.lintTextSync(`let a = 1\nmodule.exports = a\n`) t.equal(typeof result, 'object', 'result is an object') t.equal(result.errorCount, 1, '1 error') t.equal(result.results[0].messages[0].message, "'a' is never reassigned. Use 'const' instead.", 'first message') })