1 # Enforce Usage of Spacing in Template Strings (template-curly-spacing)
3 We can embed expressions in template strings with using a pair of `${` and `}`.
5 This rule can force usage of spacing _within_ the curly brace pair according to style guides.
8 let hello = `hello, ${people.name}!`;
13 This rule aims to maintain consistency around the spacing inside of template literals.
19 "template-curly-spacing": ["error", "never"]
23 This rule has one option which has either `"never"` or `"always"` as value.
25 * `"never"` (by default) - Disallows spaces inside of the curly brace pair.
26 * `"always"` - Requires one or more spaces inside of the curly brace pair.
32 Examples of **incorrect** code for this rule with the default `"never"` option:
35 /*eslint template-curly-spacing: "error"*/
37 `hello, ${ people.name}!`;
38 `hello, ${people.name }!`;
40 `hello, ${ people.name }!`;
43 Examples of **correct** code for this rule with the default `"never"` option:
46 /*eslint template-curly-spacing: "error"*/
48 `hello, ${people.name}!`;
57 Examples of **incorrect** code for this rule with the `"always"` option:
60 /*eslint template-curly-spacing: ["error", "always"]*/
62 `hello, ${ people.name}!`;
63 `hello, ${people.name }!`;
65 `hello, ${people.name}!`;
68 Examples of **correct** code for this rule with the `"always"` option:
71 /*eslint template-curly-spacing: ["error", "always"]*/
73 `hello, ${ people.name }!`;
82 If you don't want to be notified about usage of spacing inside of template strings, then it's safe to disable this rule.