Ignore comments and strings when recognizing JSX

* lisp/progmodes/js.el (js-syntax-propertize): Ignore comments and
strings.
* test/manual/indent/jsx-comment-string.jsx: New test.
parent ee89c1cd
Pipeline #3259 failed with stage
in 90 minutes and 1 second
......@@ -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
......
// 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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment