[eslint-v2][template strings] add template-curly-spacing rule, fix #716

This commit is contained in:
Harrison Shoff
2016-02-14 18:56:49 -08:00
committed by Jordan Harband
parent 1f12a12be4
commit 65609373bf
2 changed files with 9 additions and 1 deletions

View File

@@ -493,7 +493,7 @@ Other Style Guides
```
<a name="es6-template-literals"></a>
- [6.4](#6.4) <a name='6.4'></a> When programmatically building up strings, use template strings instead of concatenation. eslint: [`prefer-template`](http://eslint.org/docs/rules/prefer-template.html) jscs: [`requireTemplateStrings`](http://jscs.info/rule/requireTemplateStrings)
- [6.4](#6.4) <a name='6.4'></a> When programmatically building up strings, use template strings instead of concatenation. eslint: [`prefer-template`](http://eslint.org/docs/rules/prefer-template.html) [`template-curly-spacing`](http://eslint.org/docs/rules/template-curly-spacing) jscs: [`requireTemplateStrings`](http://jscs.info/rule/requireTemplateStrings)
> Why? Template strings give you a readable, concise syntax with proper newlines and string interpolation features.
@@ -508,6 +508,11 @@ Other Style Guides
return ['How are you, ', name, '?'].join();
}
// bad
function sayHi(name) {
return `How are you, ${ name }?`;
}
// good
function sayHi(name) {
return `How are you, ${name}?`;

View File

@@ -68,6 +68,9 @@ module.exports = {
// import sorting
// http://eslint.org/docs/rules/sort-imports
'sort-imports': 0,
// enforce usage of spacing in template strings
// http://eslint.org/docs/rules/template-curly-spacing
'template-curly-spacing': 2,
// enforce spacing around the * in yield* expressions
// http://eslint.org/docs/rules/yield-star-spacing
'yield-star-spacing': [2, 'after']