This page documents the quick-lint-js command-line interface (CLI).

## 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.

  - emacs-lisp: Emacs Lisp association list format.

  Incompatible with --lsp-server.

--diagnostic-hyperlinks=when

  Control whether to hyperlink error codes or not. This option is only used if --output-format=gnu-like. when is one of the following:

  - auto (default): shows error codes as hyperlinks only if the error output is a terminal. On Windows it behaves like 'never'.

  - always: always shows error codes as hyperlinks.

  - never: never shows error codes as hyperlinks.

  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 the next input file given in the command line. Therefore, if multiple input files are given, --vim-file-bufnr can be specified multiple times.

--path-for-config-search=path

  For the following input file or --stdin, use path as the file’s path when searching for a configuration file.

  path must be a syntactically-valid path. path does not need to exist in the filesystem.

  --path-for-config-search applies only to the next input file given in the command line. Therefore, if multiple input files are given, --path-for-config-search can be specified multiple times. If --path-for-config-search is the last option, it has no effect.

  Incompatible with --lsp-server.

--config-file=file

  Read configuration options from file and apply them to input files which are given later in the command line. See the config docs for the format of configuration files.

  If --config-file is given twice, then the file for the first --config-file option applies only to the input files between the two --config-file options, and the file for the second --config-file option apples only to the input files after the second --config-file option. See the Example section for an example.

  If --config-file is not given, quick-lint-js searches for a configuration file.

  Incompatible with --lsp-server.

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

--stdin

  Read standard input as a JavaScript file.

  If neither --config-file nor --path-for-config-search is specified, an empty configuration file is assumed. If --config-file is specified, file is used for linting standard input. If --path-for-config-search is specified and --config-file is not specified, quick-lint-js searches for a configuration file starting from --path-for-config-search's path.

  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 E0000, where 0000 is four decimal digits (0-9).

The following error categories are supported:

all

  All error codes.

Example error lists:

E0102,E0110

  Only error codes E0102 and E0110, excluding all other error codes.

-E0102

  The default set of error codes, except for error code E0102.

+E0102

  The default set of error codes, and also error code E0102.

all,-E0102

  All error codes, except for error code E0102.

E0100,-E0100,+E0200

  Only error code E0200, excluding all other error codes.

+E0200,-E0100,E0100

  Only error code E0200, 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 [E0058]
>     lib/index.js:2:7: note: variable declared here [E0058]
>     lib/index.js:3:1: error: assignment to const variable [E0003]
>     lib/index.js:1:7: note: const variable declared here [E0003]
>     lib/index.js:5:25: warning: use of undeclared variable: ocupation [E0057]

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=-E0057 bad.js
>     bad.js:5:25: warning: use of undeclared variable: $ [E0057]
>     $ echo $?
>     0

To lint source files with a strict configuration file and lint test files with a lax configuration file:

>     $ quick-lint-js \
>         --config-file strict-quick-lint-js.config src/index.js src/helpers.js \
>         --config-file lax-quick-lint-js.config test/test-app.js

To lint a temporary file, but use the configuration file of a project:

>     $ quick-lint-js --path-for-config-search=src/server.js /tmp/unsaved12m1uz.js
>     /tmp/unsaved12m1uz.js:12:5: warning: use of undeclared variable: document [E0057]