diff options
-rw-r--r-- | lisp/progmodes/js.el | 6 | ||||
-rw-r--r-- | test/manual/indent/jsx-comment-string.jsx | 16 |
2 files changed, 21 insertions, 1 deletions
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index 65a2538c30a..3050e8f1a76 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -2358,7 +2358,11 @@ testing for syntax only valid as JSX." 'syntax-table (string-to-syntax "\"/")) (js-syntax-propertize-regexp end))))) ("\\`\\(#\\)!" (1 "< b")) - ("<" (0 (ignore (if js-jsx-syntax (js-jsx--syntax-propertize-tag end)))))) + ("<" (0 (ignore + (when js-jsx-syntax + ;; Not inside a comment or string. + (unless (nth 8 (save-excursion (syntax-ppss (match-beginning 0)))) + (js-jsx--syntax-propertize-tag end))))))) (point) end)) (defconst js--prettify-symbols-alist diff --git a/test/manual/indent/jsx-comment-string.jsx b/test/manual/indent/jsx-comment-string.jsx new file mode 100644 index 00000000000..37a6c3233d8 --- /dev/null +++ b/test/manual/indent/jsx-comment-string.jsx @@ -0,0 +1,16 @@ +// Local Variables: +// indent-tabs-mode: nil +// js-indent-level: 2 +// End: + +// The following tests go below any comments to avoid including +// misindented comments among the erroring lines. + +// The JSX-like text in comments/strings should be treated like the enclosing +// syntax, not like JSX. + +// <Foo> +void 0 + +"<Bar>" +void 0 |