mirror of
https://github.com/airbnb/javascript.git
synced 2026-01-14 08:38:08 -05:00
[eslint-v2][template strings] add template-curly-spacing rule, fix #716
This commit is contained in:
committed by
Jordan Harband
parent
1f12a12be4
commit
65609373bf
@@ -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}?`;
|
||||
|
||||
@@ -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']
|
||||
|
||||
Reference in New Issue
Block a user