fix(rome_js_syntax): pick trimmed text instead the raw text
MODIFY
crates/rome_js_syntax/src/expr_ext.rs
crates/rome_js_syntax/src/expr_ext.rs
@@ -469,13 +469,15 @@ impl JsStringLiteralExpression {
///
/// ```
/// use rome_js_factory::make::{js_string_literal_expression, ident};
+ /// use rome_rowan::TriviaPieceKind;
///
- ///let string = js_string_literal_expression(ident("foo"));
+ ///let string = js_string_literal_expression(ident("foo")
+ /// .with_leading_trivia(vec![(TriviaPieceKind::Whitespace, " ")]));
/// assert_eq!(string.inner_string_text().unwrap().text(), "foo");
/// ```
pub fn inner_string_text(&self) -> SyntaxResult<SyntaxTokenText> {
let value = self.value_token()?;
- let mut text = value.token_text();
+ let mut text = value.token_text_trimmed();
static QUOTES: [char; 2] = ['"', '\''];

MODIFY
crates/rome_js_syntax/src/import_ext.rs
crates/rome_js_syntax/src/import_ext.rs
@@ -36,13 +36,14 @@ impl JsModuleSource {
/// ```
/// use rome_js_factory::make::{ident, js_module_source};
/// use rome_js_syntax::{JsAnyBinding, JsAnyImportClause, T};
- /// let source = js_module_source(ident("react"));
+ /// use rome_rowan::TriviaPieceKind;
+ /// let source = js_module_source(ident("react").with_leading_trivia(vec![(TriviaPieceKind::Whitespace, " ")]));
/// let text = source.inner_string_text().unwrap();
/// assert_eq!(text.text(), "react");
/// ```
pub fn inner_string_text(&self) -> SyntaxResult<SyntaxTokenText> {
let value = self.value_token()?;
- let mut text = value.token_text();
+ let mut text = value.token_text_trimmed();
static QUOTES: [char; 2] = ['"', '\''];

MODIFY
crates/rome_js_syntax/src/jsx_ext.rs
crates/rome_js_syntax/src/jsx_ext.rs
@@ -11,13 +11,14 @@ impl JsxString {
///
/// ```
/// use rome_js_factory::make::{jsx_ident, jsx_string};
+ /// use rome_rowan::TriviaPieceKind;
///
- ///let string = jsx_string(jsx_ident("button"));
+ ///let string = jsx_string(jsx_ident("button").with_leading_trivia(vec![(TriviaPieceKind::Whitespace, " ")]));
/// assert_eq!(string.inner_string_text().unwrap().text(), "button");
/// ```
pub fn inner_string_text(&self) -> SyntaxResult<SyntaxTokenText> {
let value = self.value_token()?;
- let mut text = value.token_text();
+ let mut text = value.token_text_trimmed();
static QUOTES: [char; 2] = ['"', '\''];

fix(rome_js_syntax): pick trimmed text instead the raw text (#3337)