fix(transformer/react-jsx): undetectable comments in multiline comments (#1211)

This commit is contained in:
Dunqing 2023-11-10 16:20:55 +08:00 committed by GitHub
parent 57d24e569b
commit 3e15fa624b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 5 deletions

View file

@ -69,9 +69,11 @@ impl ReactJsxOptions {
/// This behavior is aligned with babel.
pub(crate) fn with_comments(mut self, semantic: &Semantic) -> Self {
for (_, span) in semantic.trivias().comments_spans() {
let comment = span.source_text(semantic.source_text());
let mut comment = span.source_text(semantic.source_text()).trim_start();
// strip leading jsdoc comment `*` and then whitespaces
let comment = comment.strip_prefix('*').unwrap_or(comment).trim_start();
while let Some(cur_comment) = comment.strip_prefix('*') {
comment = cur_comment.trim_start();
}
// strip leading `@`
let Some(comment) = comment.strip_prefix('@') else { continue };

View file

@ -1,4 +1,4 @@
Passed: 263/1113
Passed: 264/1113
# All Passed:
* babel-plugin-transform-numeric-separator
@ -852,7 +852,7 @@ Passed: 263/1113
* regression/11061/input.mjs
* variable-declaration/non-null-in-optional-chain/input.ts
# babel-plugin-transform-react-jsx (128/170)
# babel-plugin-transform-react-jsx (129/170)
* autoImport/after-polyfills-compiled-to-cjs/input.mjs
* autoImport/auto-import-react-source-type-script/input.js
* autoImport/complicated-scope-module/input.js
@ -864,7 +864,6 @@ Passed: 263/1113
* react/handle-spread-with-proto-babel-7/input.js
* react/optimisation.react.constant-elements/input.js
* react/should-add-quotes-es3/input.js
* react/should-allow-jsx-docs-comment-with-pragma/input.js
* react/should-disallow-spread-children/input.js
* react/should-disallow-valueless-key/input.js
* react/should-disallow-xml-namespacing/input.js