Skip to content

Commit b559d45

Browse files
committed
[eslint config] [breaking] enable quote-props rule.
1 parent c98990c commit b559d45

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,28 @@ Other Style Guides
287287
};
288288
```
289289
290+
- [3.8](#3.8) <a name="3.8"></a> Only quote properties that are invalid identifiers.
291+
292+
> Why? In general we consider it subjectively easier to read. It improves syntax highlighting, and is also more easily optimized by many JS engines.
293+
294+
eslint rules: [`quote-props`](http://eslint.org/docs/rules/quote-props.html).
295+
296+
```javascript
297+
// bad
298+
const bad = {
299+
'foo': 3,
300+
'bar': 4,
301+
'data-blah': 5,
302+
};
303+
304+
// good
305+
const good = {
306+
foo: 3,
307+
bar: 4,
308+
'data-blah': 5,
309+
};
310+
```
311+
290312
**[⬆ back to top](#table-of-contents)**
291313
292314
## Arrays

packages/eslint-config-airbnb/rules/style.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ module.exports = {
7979
// enforce padding within blocks
8080
'padded-blocks': [2, 'never'],
8181
// require quotes around object literal property names
82-
'quote-props': 0,
82+
// http://eslint.org/docs/rules/quote-props.html
83+
'quote-props': [2, 'as-needed', { 'keywords': true, 'unnecessary': true, 'numbers': false }],
8384
// specify whether double or single quotes should be used
8485
'quotes': [2, 'single', 'avoid-escape'],
8586
// require identifiers to match the provided regular expression

0 commit comments

Comments
 (0)