-
-
Notifications
You must be signed in to change notification settings - Fork 475
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(lint/useTemplate): correctly escape characters (#2600)
- Loading branch information
Showing
4 changed files
with
54 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
crates/biome_js_analyze/tests/specs/style/useTemplate/invalidIssue2580.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Issue https://github.com/biomejs/biome/issues/2580 | ||
'```ts\n' + x + '\n```'; |
28 changes: 28 additions & 0 deletions
28
crates/biome_js_analyze/tests/specs/style/useTemplate/invalidIssue2580.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
source: crates/biome_js_analyze/tests/spec_tests.rs | ||
expression: invalidIssue2580.js | ||
--- | ||
# Input | ||
```jsx | ||
// Issue https://github.com/biomejs/biome/issues/2580 | ||
'```ts\n' + x + '\n```'; | ||
``` | ||
|
||
# Diagnostics | ||
``` | ||
invalidIssue2580.js:2:1 lint/style/useTemplate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
! Template literals are preferred over string concatenation. | ||
1 │ // Issue https://github.com/biomejs/biome/issues/2580 | ||
> 2 │ '```ts\n' + x + '\n```'; | ||
│ ^^^^^^^^^^^^^^^^^^^^^^^ | ||
i Unsafe fix: Use a template literal. | ||
1 1 │ // Issue https://github.com/biomejs/biome/issues/2580 | ||
2 │ - '```ts\n'·+·x·+·'\n```'; | ||
2 │ + `\`\`\`ts\n${x}\n\`\`\``; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters