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.
This commit is contained in:
parent
ee89c1cdb5
commit
9aacc443d9
2 changed files with 21 additions and 1 deletions
|
@ -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
|
||||
|
|
16
test/manual/indent/jsx-comment-string.jsx
Normal file
16
test/manual/indent/jsx-comment-string.jsx
Normal file
|
@ -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
|
Loading…
Add table
Reference in a new issue