# svelte/no-useless-mustaches
disallow unnecessary mustache interpolations
- 🔧 The
--fix
option on the command line can automatically fix some of the problems reported by this rule.
# 📖 Rule Details
This rule reports mustache interpolation with a string literal value.
The mustache interpolation with a string literal value can be changed to a static contents.
<script>
/* eslint svelte/no-useless-mustaches: "error" */
</script>
<!-- ✓ GOOD -->
Lorem ipsum {foo}
<div data-text="Lorem ipsum" />
<div data-text={bar} />
<!-- ✗ BAD -->
Unexpected mustache interpolation with a string literal value. (svelte/no-useless-mustaches){'Lorem ipsum'}
Unexpected mustache interpolation with a string literal value. (svelte/no-useless-mustaches){'Lorem ipsum'}
Unexpected mustache interpolation with a string literal value. (svelte/no-useless-mustaches){`Lorem ipsum`}
<div data-text=Unexpected mustache interpolation with a string literal value. (svelte/no-useless-mustaches){'Lorem ipsum'} />
# 🔧 Options
{
"svelte/no-useless-mustaches": [
"error",
{
"ignoreIncludesComment": false,
"ignoreStringEscape": false
}
]
}
ignoreIncludesComment
… Iftrue
, do not report expressions containing comments. defaultfalse
.ignoreStringEscape
… Iftrue
, do not report string literals with useful escapes. defaultfalse
.
# "ignoreIncludesComment": true
<script>
/* eslint svelte/no-useless-mustaches: ["error", { "ignoreIncludesComment": true }] */
</script>
<!-- ✓ GOOD -->
<div data-text={/* comment */ 'Lorem ipsum'} />
<!-- ✗ BAD -->
<div data-text=Unexpected mustache interpolation with a string literal value. (svelte/no-useless-mustaches){'Lorem ipsum'} />
# "ignoreStringEscape": true
<!-- ✓ GOOD -->
{'Lorem \n ipsum'}
<div data-text={'Lorem \n ipsum'} />
# 🚀 Version
This rule was introduced in eslint-plugin-svelte v0.0.4