Skip to content

Commit

Permalink
fix: account for \n and \r in TemplateLiteral handling for the `no-…
Browse files Browse the repository at this point in the history
…useless-mustaches` rule (#1040)
  • Loading branch information
baseballyama authored Jan 26, 2025
1 parent 38a963b commit ac7115c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/old-numbers-pull.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'eslint-plugin-svelte': patch
---

fix: account for \n and \r in `TemplateLiteral` handling for the `no-useless-mustaches` rule
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ export default createRule('no-useless-mustaches', {
return;
}

if (expression.type === 'TemplateLiteral' && /[\n\r]/.test(rawValue)) {
return;
}

let hasEscape = false;
if (rawValue !== strValue) {
// check escapes
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<HyperMD
value={`# Doc
Text goes here`}
/>

0 comments on commit ac7115c

Please sign in to comment.