Skip to content

Commit

Permalink
fix(lint/useTemplate): preserve leading non-string addition
Browse files Browse the repository at this point in the history
  • Loading branch information
Conaclos committed Aug 28, 2023
1 parent b0cedb8 commit 982ac70
Show file tree
Hide file tree
Showing 19 changed files with 934 additions and 735 deletions.
319 changes: 143 additions & 176 deletions crates/rome_js_analyze/src/analyzers/style/use_template.rs

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion crates/rome_js_analyze/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use std::iter;

pub mod batch;
pub mod case;
pub mod escape;
pub mod rename;
#[cfg(test)]
pub mod tests;
Expand Down
51 changes: 51 additions & 0 deletions crates/rome_js_analyze/tests/specs/style/useTemplate/invalid.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
foo + 'baz';

1 * 2 + 'foo';

1 + 2 + 3 + "px" + 4 + 5;

a + b + c + 'px' + d + e;

1 + 'foo' + 2 + 'bar' + 'baz' + 3;

(1 + 'foo') * 2;

1 * (2 + 'foo') + 'bar';

'foo' + 1;

'foo' + `bar${`baz${'bat' + 'bam'}`}` + 'boo';

'foo' + 1 + 2;

1 + '2' - 3;

foo() + ' bar';

foo() + '\n';

1 * /**leading*/'foo' /**trailing */ + 'bar';

// strings including `${`

'${foo.' + bar + '.baz}';

'foo: ${bar.' + baz + '.bat}';

'foo: `bar.' + baz + '.bat}';

'${foo}: `bar.' + baz + '.bat}';

'foo: ${bar.' + baz + '.bat}';

'foo: `bar.' + baz + '.bat}';

'foo: \\${bar.' + baz + '.bat}';

'foo: \\${bar.' + baz + '.bat}';

// parentheses

const x = a + ("b") + c;

("a") + (b) + ("c");
Loading

0 comments on commit 982ac70

Please sign in to comment.