# quick-lint-js CLI documentation

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>]
quick-lint-js --debug-apps
quick-lint-js --help
quick-lint-js --version

## Description

quick-lint-js reads JavaScript files and reports syntax errors and other bugs.

This command has three 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. Use this mode to integrate with code editors supporting LSP. For more information, see the LSP server documentation.

quick-lint-js --debug-apps
quick-lint-js --help
quick-lint-js --version

  Information mode. Prints information about quick-lint-js then exits.

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

  Added in quick-lint-js version 0.7.0.

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

  --path-for-config-search overrides --stdin-path.

  Incompatible with --lsp-server.

  Added in quick-lint-js version 0.4.0.

--stdin-path=path

  Change the behavior of --stdin. --stdin still reads a string from standard input, but otherwise it behaves as if the file at path was specified instead:

  - The default language is determined by path (unless overridden by --language). See --language for details.

  - Searching for a configuration file is based on path (unless overridden by --config-file or --path-for-config-file).

  --stdin-path applies to only --stdin, not file paths (even special files such as /dev/stdin).

  --stdin-path may appear anywhere in the command line (except after --).

  path must be a syntactically-valid path. path does not need to exist in the filesystem. path may be a relative path or an absolute path.

  Incompatible with --lsp-server.

  Added in quick-lint-js version 2.17.0.

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

  --config-file overrides --path-for-config-file and --stdin-path.

  Incompatible with --lsp-server.

  Added in quick-lint-js version 0.3.0.

--language=languageid

  Interpret input files which are given later in the command line as if they were written in languageid. languageid is one of the following:

  - default (default): infer the languageid from the file’s extension:

    - .js: javascript-jsx

    - .jsx: javascript-jsx

    - (anything else): javascript-jsx

  - experimental-default: infer the languageid from the file’s extension (EXPERIMENTAL; subject to change in future versions of quick-lint-js):

    - .js: javascript-jsx

    - .jsx: javascript-jsx

    - .d.ts: experimental-typescript-definition

    - .ts: experimental-typescript

    - .tsx: experimental-typescript-jsx

    - (anything else): javascript-jsx

  - javascript: the latest ECMAScript standard with proposed features.

  - javascript-jsx: like javascript but with JSX (React) extensions.

  - experimental-typescript: the latest TypeScript version. (EXPERIMENTAL. Subject to change in future versions of quick-lint-js.)

  - experimental-typescript-definition: the latest TypeScript version (.d.ts file). (EXPERIMENTAL. Subject to change in future versions of quick-lint-js.)

  - experimental-typescript-jsx: like experimental-typescript but with JSX (React) extensions. (EXPERIMENTAL. Subject to change in future versions of quick-lint-js.)

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

  If --language is the last option, it has no effect.

  If the input file is --stdin:

  - If --stdin-path is specified, its path is used for --language=default.

  - If --stdin-path is not specified, then the path is assumed to be example.js. This means that --language=default will behave like --language=javascript-jsx.

  Incompatible with --lsp-server.

  Added in quick-lint-js version 2.10.0.

--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 an input file.

  If none of --config-file, --path-for-config-search, or --stdin-path are specified, an empty configuration file is assumed. If --config-file is specified, file is used for linting standard input. If --config-file is not specified and either --stdin-path or --path-for-config-search is specified, quick-lint-js searches for a configuration file starting from --stdin-path's path or --path-for-config-search's path.

  If neither --stdin-path nor --language are specified, the javascript-jsx language is used.

  Incompatible with --lsp-server.

  Added in quick-lint-js version 0.3.0.

--lsp
--lsp-server

  Run quick-lint-js in LSP server mode. Use this mode to integrate with code editors supporting LSP. For more information, see the LSP server documentation.

  Incompatible with --output-format.

--snarky

  Add spice to your failures. This option makes error messages more interesting.

  Added in quick-lint-js version 2.5.0.

-h
--help

  Print a help message and exit.

  The output format is not intended to be machine-parsable and may change in the future.

--debug-apps

  Print a list of running quick-lint-js instances which have the debug app enabled.

  The output format is not intended to be machine-parsable and may change in the future.

  --debug-apps is only supported on Linux, macOS, and Windows.

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

To lint .js files as JavaScript, and .jsx files as JavaScript+JSX:

>     $ quick-lint-js \
>         --language javascript *.js \
>         --language javascript-jsx *.jsx

To lint standard input as JavaScript:

>     $ quick-lint-js --language javascript --stdin