Skip to content

Commit 8139e0a

Browse files
committed
feat(emacs): support TypeScript in Flymake plugin
Use --language=experimental-default in the Flymake plugin so quick-lint-js parses .ts files as TypeScript files. To make this work with --stdin, use --stdin-path as well.
1 parent bf0541d commit 8139e0a

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

docs/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ Semantic Versioning.
2929
* TypeScript support (still experimental):
3030
* CLI: The new `--language=experimental-default` option auto-detects the
3131
language based on the file's extension (`.ts`, `.tsx`, `.d.ts`, or `.js`).
32+
* Emacs: Flymake plugin users can now opt into TypeScript support. See the
33+
[Flymake configuration instructions][emacs-configure-flymake].
3234
* Class method overload signatures are now parsed.
3335
* [E0398][] is now reported when using both `abstract` and `static` on a
3436
single class property.
@@ -1066,6 +1068,7 @@ Beta release.
10661068
[coc.nvim]: https://github.com/neoclide/coc.nvim
10671069
[config-global-groups]: https://quick-lint-js.com/config/#global-groups
10681070
[cross-compiling-quick-lint-js]: https://quick-lint-js.com/contribute/build-from-source/cross-compiling/
1071+
[emacs-configure-flymake]: https://quick-lint-js.com/install/emacs/configure/#flymake
10691072
[install-powershell-completions]: https://github.com/quick-lint/quick-lint-js/blob/master/completions/README.md#powershell
10701073

10711074
[AidenThing]: https://github.com/AidenThing

plugin/emacs/flymake-quicklintjs.el

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@
3939
:group 'flymake-quicklintjs
4040
:type '(repeat string))
4141

42+
(defcustom flymake-quicklintjs-experimental-typescript nil
43+
"Enable experimental TypeScript support (EXPERIMENTAL; subject to change in future versions of quick-lint-js)."
44+
:group 'flymake-quicklintjs
45+
:type '(boolean))
46+
4247
(defvar-local flymake-quicklintjs--proc nil
4348
"Internal variable for `flymake-quicklintjs'")
4449

@@ -74,8 +79,11 @@ REPORT-FN is Flymake's callback."
7479
:command `(,flymake-quicklintjs-program
7580
,@(let ((file (buffer-file-name)))
7681
(if file
77-
`("--path-for-config-search" ,file)
82+
`("--stdin-path" ,file)
7883
()))
84+
,@(if flymake-quicklintjs-experimental-typescript
85+
`("--language=experimental-default")
86+
())
7987
"--stdin" "--output-format=emacs-lisp"
8088
,@flymake-quicklintjs-args)
8189
:sentinel

website/public/install/emacs/configure/index.ejs.html

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,15 @@ <h2 id="flymake">Flymake</h2>
121121
;; Optional: Remove the time to wait after last change before automatically
122122
;; checking buffer. The default is 0.5 (500ms)
123123
(setq-local flymake-no-changes-timeout 0))
124-
(add-hook 'js-mode-hook #'my-flymake-quicklintjs-setup)</code></pre>
124+
(add-hook 'js-mode-hook #'my-flymake-quicklintjs-setup)
125+
126+
;; Optional: Enable TypeScript support. Requires quick-lint-js version
127+
;; 2.17.0 or newer.
128+
;; EXPERIMENTAL. Subject to change in future versions of
129+
;; quick-lint-js.
130+
(add-hook 'typescript-mode-hook #'my-flymake-quicklintjs-setup)
131+
(setq flymake-quicklintjs-experimental-typescript t)
132+
</code></pre>
125133

126134
<h2 id="lsp-mode">LSP Mode</h2>
127135
<p>

0 commit comments

Comments
 (0)