# svelte/mustache-spacing
enforce unified spacing in mustache
- 🔧 The
--fix
option on the command line can automatically fix some of the problems reported by this rule.
# 📖 Rule Details
This rule aims at enforcing unified spacing in mustaches.
<script>
/* eslint svelte/mustache-spacing: "error" */
</script>
<!-- ✓ GOOD -->
{name}
<input bind:value={text} class="foo {bar}" />
<input {id} {...attrs} />
{@html page}
{@debug o1, o2}
{#if c1}...{:else if c2}...{:else}...{/if}
{#each list as item}...{/each}
{#await p}...{:then val}...{:catch err}...{/await}
{#key id}...{/key}
<!-- ✗ BAD -->
Expected no space after '{', but found. (svelte/mustache-spacing){ Expected no space before '}', but found. (svelte/mustache-spacing)name }
<input bind:value=Expected no space after '{', but found. (svelte/mustache-spacing){ Expected no space before '}', but found. (svelte/mustache-spacing)Expected no space after '{', but found. (svelte/mustache-spacing)Expected no space before '}', but found. (svelte/mustache-spacing)text } class="foo { bar }" />
<input Expected no space after '{', but found. (svelte/mustache-spacing){ Expected no space before '}', but found. (svelte/mustache-spacing)Expected no space after '{', but found. (svelte/mustache-spacing)Expected no space before '}', but found. (svelte/mustache-spacing)id } { ...attrs } />
Expected no space after '{', but found. (svelte/mustache-spacing){ Expected no space before '}', but found. (svelte/mustache-spacing)@html page }
Expected no space after '{', but found. (svelte/mustache-spacing){ Expected no space before '}', but found. (svelte/mustache-spacing)@debug o1, o2 }
Expected no space after '{', but found. (svelte/mustache-spacing){ Expected no space before '}', but found. (svelte/mustache-spacing)Expected no space after '{', but found. (svelte/mustache-spacing)Expected no space before '}', but found. (svelte/mustache-spacing)Expected no space after '{', but found. (svelte/mustache-spacing)Expected no space before '}', but found. (svelte/mustache-spacing)Expected no space after '{', but found. (svelte/mustache-spacing)Expected no space before '}', but found. (svelte/mustache-spacing)#if c1 }...{ :else if c2 }...{ :else }...{ /if }
Expected no space after '{', but found. (svelte/mustache-spacing){ Expected no space before '}', but found. (svelte/mustache-spacing)Expected no space after '{', but found. (svelte/mustache-spacing)Expected no space before '}', but found. (svelte/mustache-spacing)#each list as item }...{ /each }
Expected no space after '{', but found. (svelte/mustache-spacing){ Expected no space before '}', but found. (svelte/mustache-spacing)Expected no space after '{', but found. (svelte/mustache-spacing)Expected no space before '}', but found. (svelte/mustache-spacing)Expected no space after '{', but found. (svelte/mustache-spacing)Expected no space before '}', but found. (svelte/mustache-spacing)Expected no space after '{', but found. (svelte/mustache-spacing)Expected no space before '}', but found. (svelte/mustache-spacing)#await p }...{ :then val }...{ :catch err }...{ /await }
Expected no space after '{', but found. (svelte/mustache-spacing){ Expected no space before '}', but found. (svelte/mustache-spacing)Expected no space after '{', but found. (svelte/mustache-spacing)Expected no space before '}', but found. (svelte/mustache-spacing)#key id }...{ /key }
# 🔧 Options
{
"svelte/mustache-spacing": [
"error",
{
"textExpressions": "never", // or "always"
"attributesAndProps": "never", // or "always"
"directiveExpressions": "never", // or "always"
"tags": {
"openingBrace": "never", // or "always"
"closingBrace": "never" // or "always" or "always-after-expression"
}
}
]
}
"never"
… Expect no spaces between token and curly brackets. This is default."always"
… Expect one space between token and curly brackets."always-after-expression"
… Expect one space between expression and closing curly brackets, if the expression before the closing curly bracket.textExpressions
… Enforces the style of the mustache for the text expressions. e.g.{text}
.attributesAndProps
… Enforces the style of the mustache for the attributes and props. e.g.<input value={text}
.directiveExpressions
… Enforces the style of the mustache for the directive expressions. e.g.<input bind:value={text}
.tags
… Enforces the style of the mustache for the mustache tags. e.g.{#if condition}
.
# 🚀 Version
This rule was introduced in eslint-plugin-svelte v0.15.0