2 title: template-curly-spacing
9 We can embed expressions in template strings with using a pair of `${` and `}`.
11 This rule can force usage of spacing _within_ the curly brace pair according to style guides.
14 let hello = `hello, ${people.name}!`;
19 This rule aims to maintain consistency around the spacing inside of template literals.
25 "template-curly-spacing": ["error", "never"]
29 This rule has one option which has either `"never"` or `"always"` as value.
31 * `"never"` (by default) - Disallows spaces inside of the curly brace pair.
32 * `"always"` - Requires one or more spaces inside of the curly brace pair.
38 Examples of **incorrect** code for this rule with the default `"never"` option:
43 /*eslint template-curly-spacing: "error"*/
45 `hello, ${ people.name}!`;
46 `hello, ${people.name }!`;
48 `hello, ${ people.name }!`;
53 Examples of **correct** code for this rule with the default `"never"` option:
58 /*eslint template-curly-spacing: "error"*/
60 `hello, ${people.name}!`;
71 Examples of **incorrect** code for this rule with the `"always"` option:
76 /*eslint template-curly-spacing: ["error", "always"]*/
78 `hello, ${ people.name}!`;
79 `hello, ${people.name }!`;
81 `hello, ${people.name}!`;
86 Examples of **correct** code for this rule with the `"always"` option:
91 /*eslint template-curly-spacing: ["error", "always"]*/
93 `hello, ${ people.name }!`;
102 ## When Not To Use It
104 If you don't want to be notified about usage of spacing inside of template strings, then it's safe to disable this rule.