You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP →
Socket
Book a DemoInstallSign in
Socket

eslint-nibble

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-nibble - npm Package Compare versions

Comparing version

to
9.0.0

.git-blame-ignore-revs

4

bin/eslint-nibble.js

@@ -8,4 +8,4 @@ #!/usr/bin/env node

/*
* Wait for the stdout buffer to drain.
*/
* Wait for the stdout buffer to drain.
*/
process.on('exit', function () {

@@ -12,0 +12,0 @@ process.exit(exitCode);

# eslint-nibble Changelog
### 8.2.0
- (Breaking) Change default extension to run on all files in #117
- (Breaking) Update eslint peer dependency range in #126
- (Dep) Vendorize eslint-summary in #108
- (Dep) Update internal eslint to 9.27.0 in #122
- (Dep) Update inquirer.js in #124
- (Dep) Add prettier for formatting in #125
- (Build) Set up GitHub CI in #123
### 8.1.0
- (Feature) Add --resolve-plugins-relative-to option by @ehoogeveen-medweb in #99
-
- (Dep) Update dependencies
### 8.0.2
- (Fix) Update cli.js with latest ESLint API changes by @brunoselvacj in #97

@@ -12,5 +24,7 @@ - (Dep) Bump hosted-git-info from 2.8.5 to 2.8.9 by @dependabot in #80

### 8.0.1
- (Fix) Correctly report results of autofix (#91)
### 8.0.0
- (Breaking) Require ESLint >= 7 (to support ESLint 8) (#88)

@@ -20,2 +34,3 @@ - (Build) Remove babel compilation step (#89)

### 7.0.0
- (Breaking) Drop node < 12 (#83)

@@ -26,2 +41,3 @@ - (Feature) Adds `--fixable-only` option to only show fixable results (#82)

### 6.1.0
- (Feature) Adds `--rulesdir` option to load custom rules at runtime (#76)

@@ -31,2 +47,3 @@ - (Build) Update versions of node to run in Travis CI.

### 6.0.0
- (Breaking) Requires node 8 or higher due to upgrades of internal dependencies. (#60)

@@ -39,12 +56,17 @@ - (Feature) Adds `--no-interactive` flag for use in CI environment (#61)

### 6.0.0-beta.3
Fixed build
### 6.0.0-beta.2
Note: do not use, broken build
### 6.0.0-beta.1
Note: do not use, broken build
- (Dep) Use namespaced @ianvs/eslint-stats
### 6.0.0-beta.0
- (Breaking) Requires node 8 or higher due to upgrades of internal dependencies. (#60)

@@ -55,18 +77,21 @@ - (Feature) Adds `--no-interactive` flag for use in CI environment (#61)

### 5.1.0
- (Feature) Add `--no-warnings` option
### 5.0.0
Here are the main changes in 5.0.0, for details, see the notes for each beta
- (Breaking) Move eslint to a peer dependency (#52). You should install eslint
yourself, and eslint-nibble will use the version that you've installed. This should
prevent confusion about which version this tool installed, and avoid potential problems
when removing this tool and adding eslint itself.
- (Breaking) Move eslint to a peer dependency (#52). You should install eslint
yourself, and eslint-nibble will use the version that you've installed. This should
prevent confusion about which version this tool installed, and avoid potential problems
when removing this tool and adding eslint itself.
- (Breaking) Drop support for Node < 6 (#51).
- A `--cache` option has been added to allow caching the results of linting.
This should result in _much_ faster operation, even when only running one time,
because of the way that eslint-nibble works internally. Highly recommended to use.
This should result in _much_ faster operation, even when only running one time,
because of the way that eslint-nibble works internally. Highly recommended to use.
- Added `--rule` flag to the command line, to limit which rules are shown in the list.
### 5.0.0-beta.4
- (Feature) Add `--rule` flag

@@ -76,11 +101,15 @@ - (Fix) Remove attempts to fix npx without local installation

### 5.0.0-beta.3
- Added some logging to try to troubleshoot npx
### 5.0.0-beta.2
- (Fix) Another attempt for remote npx
### 5.0.0-beta.1
- (Fix) Fix npx when run without local installation (#53)
### 5.0.0-beta.0
- (Breaking) Move eslint to a peer dependency (#52)

@@ -93,23 +122,31 @@ - (Breaking) Drop support for Node < 6 (#51)

### 4.2.1
- (Dep) Use ESLint version ^4.2.0
### 4.2.0
- (Feature) Add per-rule autofixing (#35)
### 4.1.0
- (Feature) Allow arrowing through results
### 4.0.0
- (Breaking) Update to ESLint ^4.1.0
### 3.1.2
- (Fix) Fix error about missing function
### 3.1.1
- (Dep) Upgrade dependencies (#29)
### 3.1.0
- (Enhance) Allow a custom eslint config file to be specified.
### 3.0.0
- (Breaking) Update to ESLint ^3.0.0

@@ -119,9 +156,12 @@ - (Dep) Bump versions of inquirer & eslint-friendly-formatter

### 2.1.0
- (Enhance) Add `--ext` option
- (Enhance) Add `--ext` option
- (Build) Drop node `0.10` & `0.12` from CI, and add `4`, `5`, & `6`
### 2.0.0
- (Breaking) Update to ESLint ^2.0.0
### 1.0.1
- (Build) Add Travis CI

@@ -132,5 +172,7 @@ - (Fix) Prevent formatter resolution error when dependencies are flattened

### 1.0.0
- (Breaking) Update to ESLint 1.0.0
### 0.3.0
- (Enhance) Improve fatal error handling

@@ -140,31 +182,37 @@ - (Enhance) Add tests

### 0.2.0
- (Breaking) Use optionator for parsing cli arguments. Stop defaulting to `cwd`
- (Breaking) Use optionator for parsing cli arguments. Stop defaulting to `cwd`
### 0.1.1
- (Fix) Remove require for babel polyfill
### 0.1.0
- (Fix) Update eslint-stats repo to avoid out-of-date deps notice
### 0.0.6
- (Fix) Check for warnings as well as errors, before giving the all clear
### 0.0.5
- (Fix) Import chalk correctly
### 0.0.4
- (Enhance) Eslint-stats now shows warnings as well as errors
- (Enhance) Added a summary to the report using eslint-summary
### 0.0.3
### 0.0.3
- (Docs) Update usage instructions to avoid global installation
- (Fix) Check for first message existence before checking for fatal
- (Fix) Check for first message existence before checking for fatal
### 0.0.2
### 0.0.2
- (Fix) Use Babel to precompile ES6 down to ES5 for npm
### 0.0.1
### 0.0.1
- (Enhance) Initial Release
{
"name": "eslint-nibble",
"version": "8.1.0",
"version": "9.0.0",
"description": "Ease into ESLint, by fixing one rule at a time",

@@ -13,5 +13,6 @@ "main": "index.js",

"scripts": {
"pretest": "npm run lint",
"test": "tape tests/src/*.js | tap-difflet",
"lint": "eslint src tests/src"
"lint": "eslint src tests/src",
"format": "prettier . --write",
"format:check": "prettier . --check"
},

@@ -24,3 +25,2 @@ "keywords": [

"eslint-stats",
"eslint-summary",
"eslint-friendly-formatter"

@@ -39,22 +39,23 @@ ],

"@ianvs/eslint-stats": "^2.0.0",
"@inquirer/prompts": "^7.5.3",
"chalk": "^4.1.1",
"eslint-filtered-fix": "^0.3.0",
"eslint-formatter-friendly": "^7.0.0",
"eslint-summary": "^1.0.0",
"inquirer": "^8.2.3",
"optionator": "^0.9.1"
"optionator": "^0.9.1",
"text-table": "^0.2.0"
},
"devDependencies": {
"eslint": "^8.22.0",
"eslint-config-standard": "^17.0.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^6.0.0",
"@ianvs/prettier-plugin-sort-imports": "^4.4.1",
"eslint": "^9.27.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-promise": "^7.2.1",
"globals": "^16.1.0",
"prettier": "^4.0.0-alpha.12",
"tap-difflet": "^0.7.2",
"tape": "^5.6.0",
"tape": "^5.9.0",
"tape-catch": "^1.0.6"
},
"peerDependencies": {
"eslint": ">=7.0.0"
"eslint": "7 || 8 || 9"
}
}

@@ -21,9 +21,8 @@ # eslint-nibble

Instead, try installing `eslint-nibble` in your project with `--no-save` (as shown above), because this tool is intended only to get you up and running. Once you're happy with your rules and your code, you can remove `eslint-nibble`.
Instead, try installing `eslint-nibble` in your project with `--no-save` (as shown above), because this tool is intended only to get you up and running. Once you're happy with your rules and your code, you can remove `eslint-nibble`.
Note: as of version `5.0.0`, `eslint-nibble` no longer comes with its own bundled version of `eslint`. Instead, you should install `eslint` into your project (see [getting started](https://eslint.org/docs/user-guide/getting-started)), and `eslint-nibble` will use the version you install.
Note: as of version `5.0.0`, `eslint-nibble` no longer comes with its own bundled version of `eslint`. Instead, you should install `eslint` into your project (see [getting started](https://eslint.org/docs/user-guide/getting-started)), and `eslint-nibble` will use the version you install.
This module does not make any decisions about which ESLint rules to run. Make sure your project has an `.eslintrc` file if you want ESLint to do anything. No linting rules are enabled by default.
This module does not make any decisions about which ESLint rules to run. Make sure your project has an `.eslintrc` file if you want ESLint to do anything. No linting rules are enabled by default.
## Usage

@@ -65,5 +64,4 @@

Eslint-nibble will then display a rundown of the rules that are failing and a summary of the results,
using [eslint-stats](https://github.com/ganimomer/eslint-stats)
and [eslint-summary](https://github.com/davidwaterston/eslint-summary), and will ask you to pick a rule to work on:
Eslint-nibble will then display a rundown of the rules that are failing and a summary of the results,
using [eslint-stats](https://github.com/ganimomer/eslint-stats) and will ask you to pick a rule to work on:

@@ -92,8 +90,9 @@ ![eslint-stats-screenshot](docs/eslint-stats-screenshot.png)

Highly recommended. ESLint will cache the results of linting, causing subsequent runs to be much faster. See the
Highly recommended. ESLint will cache the results of linting, causing subsequent runs to be much faster. See the
[ESLint docs](https://eslint.org/docs/user-guide/command-line-interface#--cache) for more details.
### `--cache-location`
When used in conjunction with the `--cache` flag, controls where the ESLint cache
is written. See the [ESLint docs](https://eslint.org/docs/user-guide/command-line-interface#--cache-location)
is written. See the [ESLint docs](https://eslint.org/docs/user-guide/command-line-interface#--cache-location)
for more details.

@@ -104,3 +103,3 @@

If your Javascript files have an extension other than `.js`, you can use the `--ext` flag to
specify which extensions to examine. For example, this will check all files ending in `.jsx` or `.js`:
specify which extensions to examine. For example, this will check all files ending in `.jsx` or `.js`:

@@ -112,15 +111,19 @@ ```shell

### `--format, -f`
When used in conjunction with `--no-interactive`, controlls the output [format from ESLint](https://eslint.org/docs/user-guide/formatters). Has no effect in interactive mode. The default ESLint formatter will be used if `--format` is not set.
When used in conjunction with `--no-interactive`, controlls the output [format from ESLint](https://eslint.org/docs/user-guide/formatters). Has no effect in interactive mode. The default ESLint formatter will be used if `--format` is not set.
### `--fixable-only`
Only show rules that are autofixable.
### `--multi`
### `--multi`
Allows selection of more than one rule at a time in the interactive cli.
### `--no-interactive`
Potentially useful in CI, or any other situation where you would like to run ESLint using your standard project config (`.eslintrc`), but only on a subset of rules (using the `--rule` flag). Using `--no-interactive` will prevent eslint-nibble from displaying a menu, but will instead print out any warnings/errors and return an exit code of 1 if there are errors, or 0 otherwise, just like ESLint itself does.
Potentially useful in CI, or any other situation where you would like to run ESLint using your standard project config (`.eslintrc`), but only on a subset of rules (using the `--rule` flag). Using `--no-interactive` will prevent eslint-nibble from displaying a menu, but will instead print out any warnings/errors and return an exit code of 1 if there are errors, or 0 otherwise, just like ESLint itself does.
### `--no-warnings`
Only show results for linting errors, not warnings.

@@ -130,3 +133,3 @@

Changes the folder where plugins are resolved from. See the
Changes the folder where plugins are resolved from. See the
[ESLint docs](https://eslint.org/docs/user-guide/command-line-interface#--resolve-plugins-relative-to)

@@ -136,9 +139,10 @@ for more details.

### `--rule`
If you have so many failing rules that navigating the list is cumbersome, use this flag to filter down
the rules that are displayed. Multiple rules can be included as comma-separated strings (e.g. `--rule semi,quotes`),
the rules that are displayed. Multiple rules can be included as comma-separated strings (e.g. `--rule semi,quotes`),
or by using multiple `--rule` flags (e.g. `--rule semi --rule quotes`).
### `--rulesdir`
This corresponds to the eslint `--rulesdir` [option](https://eslint.org/docs/user-guide/command-line-interface#-rulesdir). Use it to specify a path to custom eslint rules.
This corresponds to the eslint `--rulesdir` [option](https://eslint.org/docs/user-guide/command-line-interface#-rulesdir). Use it to specify a path to custom eslint rules.

@@ -145,0 +149,0 @@ ### globs

@@ -6,3 +6,3 @@ 'use strict';

const chalk = require('chalk');
const inquirer = require('inquirer');
const inquirer = require('@inquirer/prompts');
const options = require('./config/options');

@@ -12,18 +12,17 @@ const { version } = require('../package.json');

const cli = {
async execute(args) {
let currentOptions,
files,
extensions,
configFile,
resolvePluginsRelativeTo,
cache,
cacheLocation,
allowedRules,
rulesDir,
includeWarnings,
isInteractive,
isMulti,
format,
fixableOnly;
files,
extensions,
configFile,
resolvePluginsRelativeTo,
cache,
cacheLocation,
allowedRules,
rulesDir,
includeWarnings,
isInteractive,
isMulti,
format,
fixableOnly;

@@ -55,7 +54,10 @@ // Parse options

console.log('v' + version);
} else if (currentOptions.help || (!files.length)) {
} else if (currentOptions.help || !files.length) {
// Show help
console.log(options.generateHelp());
} else {
const configuration = { extensions };
const configuration = {};
if (extensions) {
configuration.extensions = extensions;
}
if (configFile) {

@@ -104,14 +106,14 @@ configuration.overrideConfigFile = configFile;

.split('\n')
.filter(stat => stat)
.map(stat => {
.filter((stat) => stat)
.map((stat) => {
const ruleName = stat.split(':')[0];
return {
name : stat,
name: stat,
value: ruleName,
short: ruleName
short: ruleName,
};
})
// Only include allowed rules, if given
.filter(stat => allowedRules ? allowedRules.includes(stat.value) : true);
.filter((stat) => (allowedRules ? allowedRules.includes(stat.value) : true));

@@ -140,5 +142,3 @@ if (!results.length) {

if (!isInteractive) {
const finalReport = allowedRules
? nibbler.getRuleResults(report, allowedRules)
: report;
const finalReport = allowedRules ? nibbler.getRuleResults(report, allowedRules) : report;
// Just give an exit code based on having any errors, no interactive menu

@@ -156,58 +156,59 @@ const output = await nibbler.getFormattedResults(finalReport, format);

// Ask user for the rule to narrow in on
inquirer.prompt([{
name : 'rule',
type : isMulti ? 'checkbox' : 'list',
message : isMulti ? 'Which rule(s) would you like to view?' : 'Which rule would you like to view?',
choices : results,
pageSize: results.length
},
{
name : 'fix',
type : 'confirm',
message: 'Would you like to attempt to auto-fix?',
default: false,
when(answers) {
const ruleReport = nibbler.getRuleResults(report, answers.rule);
return ruleReport.fixableErrorCount > 0 || ruleReport.fixableWarningCount > 0;
}
},
{
name : 'fixWarnings',
type : 'confirm',
message: 'Autofix warnings?',
default: true,
when(answers) {
if (!answers.fix) return false;
const ruleAnswer =
isMulti ?
await inquirer.checkbox({
message: 'Which rule(s) would you like to view?',
choices: results,
pageSize: results.length,
})
: await inquirer.select({
message: 'Which rule would you like to view?',
choices: results,
pageSize: results.length,
});
const ruleReport = nibbler.getRuleResults(report, answers.rule);
return ruleReport.fixableWarningCount > 0;
}
}])
.then(async function gotInput(answers) {
// Display detailed error reports
if (answers.fix) {
const fixOptions = {
rules : isMulti ? answers.rule : [answers.rule],
warnings: answers.fixWarnings
};
const fixedReport = await nibbler.fixNibbles(files, fixOptions, configuration);
const ruleResults = nibbler.getRuleResults(fixedReport, answers.rule);
if (ruleResults.errorCount > 0 || ruleResults.warningCount > 0) {
const detailed = await nibbler.getFormattedResults(ruleResults, fmt.detailed);
console.log(detailed);
} else {
if (isMulti) {
console.log(chalk.green(`Fixes applied: ${answers.rule.join(', ')} now passing`));
} else {
console.log(chalk.green(`Fixes applied, ${answers.rule} is now passing`));
}
}
const ruleReport = nibbler.getRuleResults(report, ruleAnswer);
const hasFixableLints = ruleReport.fixableErrorCount > 0 || ruleReport.fixableWarningCount > 0;
const fixAnswer =
hasFixableLints ?
await inquirer.confirm({
message: 'Would you like to attempt to auto-fix?',
default: false,
})
: false;
const hasFixableWarnings = nibbler.getRuleResults(report, ruleAnswer).fixableWarningCount > 0;
const fixWarningsAnswer =
hasFixableWarnings && fixAnswer ?
await inquirer.confirm({
message: 'Autofix warnings?',
default: true,
})
: false;
// Display detailed error reports
if (fixAnswer) {
const fixOptions = {
rules: isMulti ? ruleAnswer : [ruleAnswer],
warnings: fixWarningsAnswer,
};
const fixedReport = await nibbler.fixNibbles(files, fixOptions, configuration);
const ruleResults = nibbler.getRuleResults(fixedReport, ruleAnswer);
if (ruleResults.errorCount > 0 || ruleResults.warningCount > 0) {
const detailed = await nibbler.getFormattedResults(ruleResults, fmt.detailed);
console.log(detailed);
} else {
if (isMulti) {
console.log(chalk.green(`Fixes applied: ${ruleAnswer.join(', ')} now passing`));
} else {
const ruleResults = nibbler.getRuleResults(report, answers.rule);
const detailed = await nibbler.getFormattedResults(ruleResults, fmt.detailed);
console.log(detailed);
console.log(chalk.green(`Fixes applied, ${ruleAnswer} is now passing`));
}
});
}
} else {
const ruleResults = nibbler.getRuleResults(report, ruleAnswer);
const detailed = await nibbler.getFormattedResults(ruleResults, fmt.detailed);
console.log(detailed);
}
// No report or not any errors or warnings
// No report or not any errors or warnings
} else {

@@ -219,5 +220,5 @@ console.log(chalk.green('Great job, all lint rules passed.'));

return 0;
}
},
};
module.exports = cli;

@@ -6,3 +6,3 @@ /*

const stats = require.resolve('@ianvs/eslint-stats/byErrorAndWarning.js');
const summary = require.resolve('eslint-summary/summary.js');
const summary = require.resolve('../summary.js');
const detailed = require.resolve('eslint-formatter-friendly');

@@ -13,3 +13,3 @@

summary,
detailed
detailed,
};

@@ -17,78 +17,95 @@ /**

module.exports = optionator({
prepend: 'usage: eslint-nibble [file.js] [dir]',
options: [{
heading: 'Options'
}, {
option : 'help',
alias : 'h',
type : 'Boolean',
description: 'Show help'
}, {
option : 'version',
alias : 'v',
type : 'Boolean',
description: 'Outputs the version number'
}, {
option : 'ext',
type : '[String]',
default : '.js',
description: 'Specify JavaScript file extensions'
}, {
option : 'config',
alias : 'c',
type : 'path::String',
description: 'Use configuration from this file or shareable config'
}, {
option : 'resolve-plugins-relative-to',
type : 'path::String',
description: 'Changes the folder where plugins are resolved from'
}, {
option : 'cache',
type : 'Boolean',
default : 'false',
description: 'Only check changed files'
}, {
option : 'cache-location',
type : 'path::String',
description: 'Path to the cache file or directory'
}, {
option : 'rule',
type : '[String]',
concatRepeatedArrays: true,
description : 'Only show results for specified rule(s)'
}, {
option : 'rulesdir',
type : '[String]',
concatRepeatedArrays: true,
description : 'Path to custom eslint rules'
}, {
option : 'warnings',
type : 'Boolean',
default : 'true',
description: 'Include warning results'
}, {
option : 'multi',
type : 'Boolean',
default : 'false',
description: 'Allow fixing multiple rules at one time'
}, {
option : 'interactive',
type : 'Boolean',
default : 'true',
description: 'Provide interactive options to see/fix a particular error. If false, linting results are printed with appropriate exit code, useful for CI.'
}, {
option : 'format',
alias : 'f',
type : 'String',
description: 'If --no-interactive is used, this formatter will be used to output results. See https://eslint.org/docs/user-guide/formatters for options.'
}, {
option : 'fixable-only',
type : 'Boolean',
description: 'Only show fixable rules in output results'
}],
options: [
{
heading: 'Options',
},
{
option: 'help',
alias: 'h',
type: 'Boolean',
description: 'Show help',
},
{
option: 'version',
alias: 'v',
type: 'Boolean',
description: 'Outputs the version number',
},
{
option: 'ext',
type: '[String]',
default: '',
description: 'Specify JavaScript file extensions',
},
{
option: 'config',
alias: 'c',
type: 'path::String',
description: 'Use configuration from this file or shareable config',
},
{
option: 'resolve-plugins-relative-to',
type: 'path::String',
description: 'Changes the folder where plugins are resolved from',
},
{
option: 'cache',
type: 'Boolean',
default: 'false',
description: 'Only check changed files',
},
{
option: 'cache-location',
type: 'path::String',
description: 'Path to the cache file or directory',
},
{
option: 'rule',
type: '[String]',
concatRepeatedArrays: true,
description: 'Only show results for specified rule(s)',
},
{
option: 'rulesdir',
type: '[String]',
concatRepeatedArrays: true,
description: 'Path to custom eslint rules',
},
{
option: 'warnings',
type: 'Boolean',
default: 'true',
description: 'Include warning results',
},
{
option: 'multi',
type: 'Boolean',
default: 'false',
description: 'Allow fixing multiple rules at one time',
},
{
option: 'interactive',
type: 'Boolean',
default: 'true',
description:
'Provide interactive options to see/fix a particular error. If false, linting results are printed with appropriate exit code, useful for CI.',
},
{
option: 'format',
alias: 'f',
type: 'String',
description:
'If --no-interactive is used, this formatter will be used to output results. See https://eslint.org/docs/user-guide/formatters for options.',
},
{
option: 'fixable-only',
type: 'Boolean',
description: 'Only show fixable rules in output results',
},
],
helpStyle: {
maxPadFactor: 2.5
}
maxPadFactor: 2.5,
},
});

@@ -8,17 +8,20 @@ 'use strict';

function getCounts(messages) {
const counts = messages.reduce(function (result, message) {
if (message.severity === 1) {
result.warningCount++;
if (message.fix) {
result.fixableWarningCount++;
const counts = messages.reduce(
function (result, message) {
if (message.severity === 1) {
result.warningCount++;
if (message.fix) {
result.fixableWarningCount++;
}
}
}
if (message.severity === 2) {
result.errorCount++;
if (message.fix) {
result.fixableErrorCount++;
if (message.severity === 2) {
result.errorCount++;
if (message.fix) {
result.fixableErrorCount++;
}
}
}
return result;
}, { errorCount: 0, warningCount: 0, fixableErrorCount: 0, fixableWarningCount: 0 });
return result;
},
{ errorCount: 0, warningCount: 0, fixableErrorCount: 0, fixableWarningCount: 0 }
);

@@ -35,16 +38,19 @@ return counts;

function calculateStatsPerRun(results) {
return results.reduce((stat, result) => {
stat.errorCount += result.errorCount;
stat.fatalErrorCount += result.fatalErrorCount;
stat.warningCount += result.warningCount;
stat.fixableErrorCount += result.fixableErrorCount;
stat.fixableWarningCount += result.fixableWarningCount;
return stat;
}, {
errorCount : 0,
fatalErrorCount : 0,
warningCount : 0,
fixableErrorCount : 0,
fixableWarningCount: 0
});
return results.reduce(
(stat, result) => {
stat.errorCount += result.errorCount;
stat.fatalErrorCount += result.fatalErrorCount;
stat.warningCount += result.warningCount;
stat.fixableErrorCount += result.fixableErrorCount;
stat.fixableWarningCount += result.fixableWarningCount;
return stat;
},
{
errorCount: 0,
fatalErrorCount: 0,
warningCount: 0,
fixableErrorCount: 0,
fixableWarningCount: 0,
}
);
}

@@ -72,6 +78,6 @@

if (options.present) {
return (msg[msgKey]);
return msg[msgKey];
}
if (options.compareVal) {
return (msg[msgKey] === options.compareVal);
return msg[msgKey] === options.compareVal;
}

@@ -99,3 +105,3 @@ if (options.includes) {

fixableErrorCount,
fixableWarningCount
fixableWarningCount,
};

@@ -113,3 +119,2 @@ }

module.exports = {
configure(configuration) {

@@ -123,3 +128,3 @@ cli = new ESLint(configuration);

results,
...calculateStatsPerRun(results)
...calculateStatsPerRun(results),
};

@@ -133,3 +138,3 @@ return report;

results,
...calculateStatsPerRun(results)
...calculateStatsPerRun(results),
};

@@ -153,4 +158,5 @@ return report;

getRuleResults(report, ruleName) {
const ruleResults = Array.isArray(ruleName)
? filterResults(report, 'ruleId', { includes: ruleName })
const ruleResults =
Array.isArray(ruleName) ?
filterResults(report, 'ruleId', { includes: ruleName })
: filterResults(report, 'ruleId', { compareVal: ruleName });

@@ -168,3 +174,3 @@ return ruleResults;

return ruleResults;
}
},
};