Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

eslint-nibble

IanVS353kMIT8.1.0

Ease into ESLint, by fixing one rule at a time

eslint, formatter, linting, linter, eslint-stats, eslint-summary, eslint-friendly-formatter

readme

eslint-nibble

npm Build Status

Sometimes running ESLint against an existing project and fixing the hundreds or thousands of errors is biting off more than you can chew.
Instead, eslint-nibble will give a quick overview of your failing rules, and then show the detailed error reports for one rule at a time.

If a rule can be automatically fixed by ESLint, eslint-nibble will allow you to run autofix on individual rules, allowing you to make more focused commits.

Read this excellent blog post from Paul Hands for a clear explanation of what eslint-nibble can do for your project: Hiring a gardener to trim the weeds.

Installation

npm install --no-save eslint-nibble

You can also install eslint-nibble globally, but it is not recommended.

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), 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.

Usage

There are a few methods you can use to run eslint-nibble, depending on the package manager you are using.

npx

If you're using `npm@5.2.0` or later, you can simply run:

npx eslint-nibble <directories and files to lint>

yarn

Similarly, if you are using yarn, you can run:

yarn eslint-nibble <directories and files to lint>

package.json script

Add something like the following to your package.json file:

"scripts": {
  "nibble": "eslint-nibble <directories and files to lint>"
}

Then, to run eslint-nibble, you can use:

npm run nibble

Eslint-nibble will then display a rundown of the rules that are failing and a summary of the results, using eslint-stats and eslint-summary, and will ask you to pick a rule to work on:

eslint-stats-screenshot

Select one of the rules by arrowing up/down and pressing enter.
If the rule can be fixed automatically, ESLint will ask if you'd like it to attempt perform fixes for you. If there are lint warnings, you will also be asked whether you want those to be auto-fixed.

If you decide not to make autofixes, or the autofix completes but cannot fix all the errors, then a detailed list of the errors will be presented, using eslint-friendly-formatter.
If you are using iTerm2 or Guake, you can set them up so that your text editor opens to the correct line when you click on the filename.

eslint-friendly-formatter-screenshot

Options

--config, -c

ESLint will automatically detect config files with standard naming. Add the --config option to specify a different config file for ESLint to use.

--cache

Highly recommended. ESLint will cache the results of linting, causing subsequent runs to be much faster. See the ESLint docs for more details.

--cache-location

When used in conjunction with the --cache flag, controls where the ESLint cache is written. See the ESLint docs for more details.

--ext

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:

eslint-nibble --ext .jsx,.js lib/

--format, -f

When used in conjunction with --no-interactive, controlls the output format from ESLint. 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

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.

--no-warnings

Only show results for linting errors, not warnings.

--resolve-plugins-relative-to

Changes the folder where plugins are resolved from. See the ESLint docs 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), or by using multiple --rule flags (e.g. --rule semi --rule quotes).

--rulesdir

This corresponds to the eslint --rulesdir option. Use it to specify a path to custom eslint rules.

globs

You are not limited to directory and file names as arguments, you can also specify a glob pattern. For example, to examine all *.jsx files in all test/ directories under lib/:

eslint-nibble lib/**/test/**/*.jsx

changelog

eslint-nibble Changelog

8.1.0

  • (Feature) Add --resolve-plugins-relative-to option by @ehoogeveen-medweb in #99

8.0.2

  • (Fix) Update cli.js with latest ESLint API changes by @brunoselvacj in #97
  • (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)
  • (Build) Remove babel compilation step (#89)

7.0.0

  • (Breaking) Drop node < 12 (#83)
  • (Feature) Adds --fixable-only option to only show fixable results (#82)
  • (Dep) Update dependencies (#83)

6.1.0

  • (Feature) Adds --rulesdir option to load custom rules at runtime (#76)
  • (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)
  • (Feature) Adds --no-interactive flag for use in CI environment (#61)
  • (Feature) Adds --format flag to control output when using --no-interactive (#61)
  • (Feature) Adds --multi flag to allow selection of multiple rules in interactive mode (#73)
  • (Dep) Update dependencies, replace github fork

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)
  • (Feature) Adds --no-interactive flag for use in CI environment (#61)
  • (Feature) Adds --format flag to control output when using --no-interactive (#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) 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.
  • 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
  • (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)
  • (Breaking) Drop support for Node < 6 (#51)
  • (Fix) Fix bad formatting of small error stats (#51)
  • (Feature) Add cache flags (#42)
  • (Dep) Upgrade dependencies (#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
  • (Dep) Bump versions of inquirer & eslint-friendly-formatter

2.1.0

  • (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
  • (Fix) Prevent formatter resolution error when dependencies are flattened
  • (Dep) Bump inquirer

1.0.0

  • (Breaking) Update to ESLint 1.0.0

0.3.0

  • (Enhance) Improve fatal error handling
  • (Enhance) Add tests

0.2.0

  • (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

  • (Docs) Update usage instructions to avoid global installation
  • (Fix) Check for first message existence before checking for fatal

0.0.2

  • (Fix) Use Babel to precompile ES6 down to ES5 for npm

0.0.1

  • (Enhance) Initial Release