Name
quick-lint-js - find bugs in JavaScript programs
Synopsis
quick-lint-js
[--output-format=format]
[<options>]
file [file…]
quick-lint-js
--lsp-server [<options>]
Description
quick-lint-js reads JavaScript files and reports syntax errors and other bugs.
This command has two modes:
- quick-lint-js [<options>] file [file…]
-
Batch mode (default). Check the given files, and report errors to the terminal (standard error). --output-format can be used to customize how errors look.
- quick-lint-js --lsp-server
-
LSP server mode. Start a Language Server Protocol server, communicating using standard input and standard output. Use this mode to integrate with code editors supporting LSP.
Options
- --output-format=format
-
Customize how errors are printed. format is one of the following:
- gnu-like (default): a human-readable format similar to GCC.
- vim-qflist-json: machine-readable JSON which can be given to Vim’s setqflist function.
Incompatible with --lsp-server.
- --vim-file-bufnr=number
-
Set the bufnr property for errors printed with the --output-format=vim-qflist-json option. --vim-file-bufnr applies only to files which are given later in the command line. Therefore, if multiple files are given, --vim-file-bufnr can be specified multiple times.
- --exit-fail-on=errors
-
Cause quick-lint-js to exit with a non-zero exit code if any of the discovered errors is listed in errors.
See the "ERROR LISTS" section for a description of the format for errors.
Incompatible with --lsp-server.
- --lsp
- --lsp-server
-
Run quick-lint-js in LSP server mode. Use this mode to integrate with code editors supporting LSP. An editor can send LSP requests and notifications to quick-lint-js via standard input, and receive LSP responses and notifications from standard output.
Incompatible with --output-format.
- -h
- --help
-
Print a help message and exit.
The output format is not intended to be machine-parsable and may change in the future.
- -v
- --version
-
Print version information and exit.
The output format is not intended to be machine-parsable and may change in the future.
Error lists
Some options, such as --exit-fail-on, accept an error list. An error list is a comma-separated list of error code predicates and error category predicates.
An error lists can contain any number of include, exclude, and default predicates. An include predicate is a '+' followed by the name of an error code or error category. An exclude predicate is a '-' followed by the name of an error code or error category. An default predicate is the name of an error code or error category with no sigil.
An error list containing only include and exclude predicates modifies a default set of error codes. The default set is decided by the option, but is often the set of all error codes. An error list containing at least one default predicate empties the set of error codes, then treats the default predicates as if they were include predicates.
The order of predicates within an error list does not matter. Included predicates are processed first, adding to the set of error codes. Excluded predicates are processed second, removing from the set of error codes.
Error codes have the form E000, where 000 is three decimal digits (0-9).
The following error categories are supported:
- all
-
All error codes.
Example error lists:
- E102,E110
-
Only error codes E102 and E110, excluding all other error codes.
- -E102
-
The default set of error codes, except for error code E102.
- +E102
-
The default set of error codes, and also error code E102.
- all,-E102
-
All error codes, except for error code E102.
- E100,-E100,+E200
-
Only error code E200, excluding all other error codes.
- +E200,-E100,E100
-
Only error code E200, excluding all other error codes.
Exit status
- 0
-
Batch mode: Linting succeeded with no errors or warnings.
LSP server mode: The LSP client requested that the server shut down. This exit status may change in the future.
- non-0
-
Batch mode: Linting failed with at least one error or warning, or at least one file could not be opened and read.
The specific status code may change in the future.
Environment
- LC_ALL
- LC_MESSAGES
-
Change the language used for error and warning messages. For example, set LC_ALL=en to see messages written in United States English.
Example
To lint a file called lib/index.js, writing error messages to the terminal:
$ quick-lint-js lib/index.js lib/index.js:1:20: error: variable used before declaration: language [E058] lib/index.js:2:7: note: variable declared here [E058] lib/index.js:3:1: error: assignment to const variable [E003] lib/index.js:1:7: note: const variable declared here [E003] lib/index.js:5:25: warning: use of undeclared variable: ocupation [E057]
To lint three files, writing machine-readable messages to /tmp/vim-qflist.json:
$ quick-lint-js --output-format=vim-qflist-json \ --vim-bufnr=3 lib/pizza-dough.js \ --vim-bufnr=4 lib/pizza-sauce.js \ --vim-bufnr=6 lib/pineapple.js \ >/tmp/vim-qflist.json
Errors for lib/pizza-dough.js will include "bufnr":3 in the output and errors for lib/pineapple.js will include "bufnr":6.
To lint a file called bad.js, but don’t fail on use-of-undeclared-variable errors:
$ quick-lint-js --exit-fail-on=-E057 bad.js bad.js:5:25: warning: use of undeclared variable: $ [E057] $ echo $? 0