fix(lexer) Fix spans for jsx children (#1030)

Closes #1026
This commit is contained in:
Cameron 2023-10-22 15:44:19 +01:00 committed by GitHub
parent 46207c0e4b
commit 76ac9cd4c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 9 deletions

View file

@ -95,7 +95,7 @@ expression: jsx_key
⚠ eslint-plugin-react(jsx-key): Missing "key" prop for element in iterator.
╭─[jsx_key.tsx:1:1]
1 │ [1, 2, 3]?.map(x => <><OxcCompilerHello /></>)
· ──────────────────────────────────────────
· ────────────────────
╰────
⚠ eslint-plugin-react(jsx-key): Missing "key" prop for element in iterator.

View file

@ -35,13 +35,13 @@ expression: jsx_no_useless_fragment
⚠ eslint-plugin-react(jsx-no-useless-fragment): Fragments should contain more than one child.
╭─[jsx_no_useless_fragment.tsx:1:1]
1 │ <p><>{meow}</></p>
· ──────────────
· ───────────
╰────
⚠ eslint-plugin-react(jsx-no-useless-fragment): Passing a fragment to a HTML element is useless.
╭─[jsx_no_useless_fragment.tsx:1:1]
1 │ <p><>{meow}</></p>
· ──────────────
· ───────────
╰────
⚠ eslint-plugin-react(jsx-no-useless-fragment): Fragments should contain more than one child.
@ -77,31 +77,31 @@ expression: jsx_no_useless_fragment
⚠ eslint-plugin-react(jsx-no-useless-fragment): Fragments should contain more than one child.
╭─[jsx_no_useless_fragment.tsx:1:1]
1 │ <Eeee><>foo</></Eeee>
· ──────────────
· ────────
╰────
⚠ eslint-plugin-react(jsx-no-useless-fragment): Fragments should contain more than one child.
╭─[jsx_no_useless_fragment.tsx:1:1]
1 │ <div><>foo</></div>
· ─────────────
· ────────
╰────
⚠ eslint-plugin-react(jsx-no-useless-fragment): Passing a fragment to a HTML element is useless.
╭─[jsx_no_useless_fragment.tsx:1:1]
1 │ <div><>foo</></div>
· ─────────────
· ────────
╰────
⚠ eslint-plugin-react(jsx-no-useless-fragment): Passing a fragment to a HTML element is useless.
╭─[jsx_no_useless_fragment.tsx:1:1]
1 │ <div><>{"a"}{"b"}</></div>
· ────────────────────
· ───────────────
╰────
⚠ eslint-plugin-react(jsx-no-useless-fragment): Passing a fragment to a HTML element is useless.
╭─[jsx_no_useless_fragment.tsx:1:1]
1 │ <div><>{"a"}{"b"}</></div>
· ────────────────────
· ───────────────
╰────
⚠ eslint-plugin-react(jsx-no-useless-fragment): Passing a fragment to a HTML element is useless.
@ -115,7 +115,7 @@ expression: jsx_no_useless_fragment
⚠ eslint-plugin-react(jsx-no-useless-fragment): Passing a fragment to a HTML element is useless.
╭─[jsx_no_useless_fragment.tsx:1:1]
1 │ <div><Fragment>{"a"}{"b"}</Fragment></div>
· ────────────────────────────────────
· ───────────────────────────────
╰────
⚠ eslint-plugin-react(jsx-no-useless-fragment): Passing a fragment to a HTML element is useless.

View file

@ -164,6 +164,7 @@ impl<'a> Lexer<'a> {
}
pub fn next_jsx_child(&mut self) -> Token<'a> {
self.current.token.start = self.offset();
let kind = self.read_jsx_child();
self.finish_next(kind)
}