← 全部工具

eslint-watch

热度 65 更新于 开发与构建

Run eslint with watch mode

npmauto-collected

安装

npm
npm install -g eslint-watch

通过 npm 安装。

Eslint Watch

Don't want to import Webpack, Grunt, or some other task package into your project? Then this is the tool for you. Eslint Watch is a simple command line tool that wraps Eslint. Eslint Watch provides file watching and command line improvements to the currently existing Eslint command line interface. All commands that Eslint offers can be used with the addition of a watch command and a couple new templating views. Don't believe me? Checkout the code or some of the features below!

Requirements

To use this tool we require eslint to be installed on your project. The versions supported are:

  • "eslint": "=8 <9.0.0"
  • node = 12.0.0 <= LTS Non LTS versions will have limited support.

Getting started

To run eslint-watch without the global install, make an npm script.

Installing

  • npm i -g eslint eslint-watch or npm i -D eslint eslint-watch
  • yarn global add eslint eslint-watch or yarn add -D eslint eslint-watch

Features added

  • Watching
  • Multi-directory watching
  • Runs a full directory lint before the watch
  • Press enter to rerun directory lint while watching
  • Include directories to ignore on watch
  • Eslint Overrides
  • Default directory linting. A directory is no longer required.

Options/Usage

Eslint-Watch replaces only a few commands that it needs to take control over. All other commands are forwarded to Eslint unmodified. Please refer to their help text for full command support as the one provided below might not be up to date with the latest Eslint changes.

esw [options] [file.js ...] [dir ...]

ESW Options:
  -h, --help                     Show help
  -w, --watch                    Enable file watch
  --changed                      Enables single file linting while watch is enabled
  --clear                        Clear terminal when running lint
  -v, --version                  Prints Eslint-Watch Version
  --versions                     Prints Eslint-Watch and Eslint Versions
  --watch-ignore RegExp          Regex string of folders to ignore when watching - default:
                                 /.git|node_modules|bower_components|.eslintcache/
  --watch-delay Int              Delay(ms) for watcher to wait to trigger re-lint - default: 300

Basic configuration: --ext [String] Specify JavaScript file extensions - default: .js --no-eslintrc Disable use of configuration from .eslintrc. -c, --config path::String Use this configuration, overriding .eslintrc. config options if present --env [String] Specify environments --global [String] Define global variables --parser String Specify the parser to be used --parser-options Object Specify parser options --resolve-plugins-relative-to path::String A folder where plugins should be resolved from CWD by default

Specifying rules and plugins: --rulesdir [path::String] Use additional rules from this directory --plugin [String] Specify plugins --rule Object Specify rules

Fixing problems: --fix Automatically fix problems --fix-dry-run Automatically fix problems without saving the changes to the file system --fix-type Array Specify the types of fixes to apply (directive problem, suggestion, layout)