UNPKG

6.63 kBMarkdownView Raw
1# Eslint Watch
2
3[![](https://img.shields.io/badge/release-notes-blue.svg)](https://github.com/rizowski/eslint-watch/releases/latest)
4[![Build Status](https://travis-ci.org/rizowski/eslint-watch.svg?branch=master)](https://travis-ci.org/rizowski/eslint-watch)
5[![Code Climate](https://codeclimate.com/github/rizowski/eslint-watch/badges/gpa.svg)](https://codeclimate.com/github/rizowski/eslint-watch)
6[![Dependencies](https://www.versioneye.com/nodejs/eslint-watch/reference_badge.svg?style=flat-square)](https://github.com/rizowski/eslint-watch/network/dependencies)
7
8Don't want to import Webpack, Grunt, or some other task package into your project? Then this is the tool for you.
9Eslint Watch is a simple command line tool that wraps [Eslint](https://www.npmjs.com/package/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](https://github.com/rizowski/eslint-watch) or some of the features below!
10
11## Requirements
12
13To use this tool we require eslint to be installed on your project. The versions supported are:
14
15- `"eslint": ">=8 <9.0.0"`
16- `node >= 12.0.0 <= LTS` Non LTS versions will have limited support.
17
18## Getting started
19
20To run eslint-watch without the global install, make an npm script.
21
22### Installing
23
24- `npm i -g eslint eslint-watch` or `npm i -D eslint eslint-watch`
25- `yarn global add eslint eslint-watch` or `yarn add -D eslint eslint-watch`
26
27## Features added
28
29- Watching
30 - Multi-directory watching
31 - Runs a full directory lint before the watch
32 - Press `enter` to rerun directory lint while watching
33 - Include directories to ignore on watch
34- Eslint Overrides
35 - Default directory linting. A directory is no longer required.
36
37## Options/Usage
38
39Eslint-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.
40
41```md
42esw [options] [file.js ...] [dir ...]
43
44ESW Options:
45 -h, --help Show help
46 -w, --watch Enable file watch
47 --changed Enables single file linting while watch is enabled
48 --clear Clear terminal when running lint
49 -v, --version Prints Eslint-Watch Version
50 --versions Prints Eslint-Watch and Eslint Versions
51 --watch-ignore RegExp Regex string of folders to ignore when watching - default:
52 /.git|node_modules|bower_components|.eslintcache/
53 --watch-delay Int Delay(ms) for watcher to wait to trigger re-lint - default: 300
54
55Basic configuration:
56 --ext [String] Specify JavaScript file extensions - default: .js
57 --no-eslintrc Disable use of configuration from .eslintrc.*
58 -c, --config path::String Use this configuration, overriding .eslintrc.* config options if present
59 --env [String] Specify environments
60 --global [String] Define global variables
61 --parser String Specify the parser to be used
62 --parser-options Object Specify parser options
63 --resolve-plugins-relative-to path::String A folder where plugins should be resolved from CWD by default
64
65Specifying rules and plugins:
66 --rulesdir [path::String] Use additional rules from this directory
67 --plugin [String] Specify plugins
68 --rule Object Specify rules
69
70Fixing problems:
71 --fix Automatically fix problems
72 --fix-dry-run Automatically fix problems without saving the changes to the file system
73 --fix-type Array Specify the types of fixes to apply (directive problem, suggestion, layout)
74
75Ignoring files:
76 --ignore-path path::String Specify path of ignore file
77 --no-ignore Disable use of ignore files and patterns
78 --ignore-pattern [String] Pattern of files to ignore (in addition to those in .eslintignore)
79
80Using stdin:
81 --stdin Lint code provided on <STDIN> - default: false
82 --stdin-filename String Specify filename to process STDIN as
83
84Handling warnings:
85 --quiet Report errors only - default: false
86 --max-warnings Int Number of warnings to trigger nonzero exit code - default: -1
87
88Output:
89 -o, --output-file path::String Specify file to write report to
90 -f, --format String Use a specific output format - default: stylish
91 --color, --no-color Force enabling/disabling of color
92
93Inline configuration comments:
94 --no-inline-config Prevent comments from changing config or rules
95 --report-unused-disable-directives Adds reported errors for unused eslint-disable directives
96
97Caching:
98 --cache Only check changed files - default: false
99 --cache-file path::String Path to the cache file. Deprecated: use --cache-location - default: .eslintcache
100 --cache-location path::String Path to the cache file or directory
101 --cache-strategy String Strategy to use for detecting changed files in the cache - either: metadata or content - default:
102 metadata
103
104Miscellaneous:
105 --init Run config initialization wizard - default: false
106 --env-info Output execution environment information - default: false
107 --no-error-on-unmatched-pattern Prevent errors when pattern is unmatched
108 --exit-on-fatal-error Exit with exit code 2 in case of fatal error - default: false
109 --debug Output debugging information
110 --print-config path::String Print the configuration for the given file
111```
112
113### Other Options
114
115Eslint-Watch uses [`chokidar`](https://github.com/paulmillr/chokidar) under the hood to watch for changes. Chokidar can be configured to poll for changes (this might be necessary if you are running Eslint-Watch inside a VM or Container) by setting the `CHOKIDAR_USEPOLLING` environment variable to `true`.
116
117## Functionality
118
119[![Simple lint and watch](https://thumbs.gfycat.com/AgreeableForsakenIvorygull-size_restricted.gif)](https://fat.gfycat.com/AgreeableForsakenIvorygull.gif)
120
121Donate:
122
123- (Ƀitcoin): `13V7iDxBhnFASw7avGGRk64ExDGTirhx37`
124
125- (PayPal): [https://www.paypal.me/rizowski](https://www.paypal.me/rizowski)