* lisp/progmodes/js.el (js-syntax-propertize): Ignore comments and
strings.
* test/manual/indent/jsx-comment-string.jsx: New test.
'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
--- /dev/null
+// 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