quick-lint-js

Find bugs in JavaScript programs.

Configuring the Emacs plugin

After installing the Emacs plugin for quick-lint-js, you need to configure it.

Choose the plugin you want to use with quick-lint-js:

Eglot

In your init file (e.g. ~/.emacs), load the eglot-quicklintjs library:

(require 'eglot-quicklintjs)

TODO: TypeScript support

To speed up JavaScript linting, configure Eglot to send changes to quick-lint-js immediately without delay by adding the following to your init file:

(defun my-eglot-quicklintjs-setup ()
  "Configure eglot-quicklintjs for better experience."
  ;; Optional: Remove the time to wait after last change before automatically
  ;; checking buffer. The default is 0.5 (500ms)
  (setq-local eglot-send-changes-idle-time 0)

  ;; Optional: Make Eglot run automatically when `js-mode' is loaded
  (eglot-ensure))
(add-hook 'js-mode-hook #'my-eglot-quicklintjs-setup)

Flycheck

In your init file (e.g. ~/.emacs), load the flycheck-quicklintjs library and enable Flycheck for JavaScript buffers:

(require 'flycheck-quicklintjs)

(defun my-flycheck-quicklintjs-setup ()
  "Configure flycheck-quicklintjs for better experience."

  ;; Enable Flycheck
  (unless (bound-and-true-p flycheck-mode)
    (flycheck-mode))

  ;; Use quick-lint-js by default when in 'js-mode`
  (flycheck-select-checker 'javascript-quicklintjs)

  ;; Optional: Remove any delay after a change in buffer to run checkers.
  ;; The default is 0.5 (500ms)
  (setq-local flycheck-idle-change-delay 0)

  ;; Optional: Run quick-lint-js program when the buffer is changed and when
  ;; 'js-mode` is loaded
  (setq-local flycheck-check-syntax-automatically '(mode-enabled idle-change new-line)))
(add-hook 'js-mode-hook #'my-flycheck-quicklintjs-setup)

TODO: TypeScript support

Flymake

In your init file (e.g. ~/.emacs), load the flymake-quicklintjs library and enable Flymake for JavaScript and TypeScript buffers:

(require 'flymake-quicklintjs)

(defun my-flymake-quicklintjs-setup ()
  "Configure flymake-quicklintjs for better experience."

  ;; Enable Flymake
  (unless (bound-and-true-p flymake-mode)
    (flymake-mode))
  (add-hook 'flymake-diagnostic-functions #'flymake-quicklintjs nil t)

  ;; Optional: Remove the time to wait after last change before automatically
  ;; checking buffer. The default is 0.5 (500ms)
  (setq-local flymake-no-changes-timeout 0))
(add-hook 'js-mode-hook #'my-flymake-quicklintjs-setup)
(add-hook 'typescript-mode-hook #'my-flymake-quicklintjs-setup)

LSP Mode

In your init file (e.g. ~/.emacs), load the lsp-quicklintjs library:

(require 'lsp-quicklintjs)

TODO: TypeScript support

Then, open a JavaScript buffer and type M-x lsp RET.

To speed up JavaScript linting, configure LSP Mode to send changes to quick-lint-js immediately without delay by adding the following to your init file:

(defun my-lsp-quicklintjs-setup ()
  "Configure lsp-quicklintjs for better experience."
  ;; Optional: Remove the time to wait after last change before automatically
  ;; checking buffer. The default is 0.5 (500ms)
  (setq-local lsp-idle-delay 0))
(add-hook 'js-mode-hook #'my-lsp-quicklintjs-setup)