mirror of
https://github.com/airbnb/javascript.git
synced 2026-01-14 02:58:03 -05:00
Merge pull request #632 from airbnb/ljharb/quote_props
[eslint config] [breaking] enable `quote-props` rule.
This commit is contained in:
22
README.md
22
README.md
@@ -287,6 +287,28 @@ Other Style Guides
|
||||
};
|
||||
```
|
||||
|
||||
- [3.8](#3.8) <a name="3.8"></a> Only quote properties that are invalid identifiers.
|
||||
|
||||
> Why? In general we consider it subjectively easier to read. It improves syntax highlighting, and is also more easily optimized by many JS engines.
|
||||
|
||||
eslint rules: [`quote-props`](http://eslint.org/docs/rules/quote-props.html).
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
const bad = {
|
||||
'foo': 3,
|
||||
'bar': 4,
|
||||
'data-blah': 5,
|
||||
};
|
||||
|
||||
// good
|
||||
const good = {
|
||||
foo: 3,
|
||||
bar: 4,
|
||||
'data-blah': 5,
|
||||
};
|
||||
```
|
||||
|
||||
**[⬆ back to top](#table-of-contents)**
|
||||
|
||||
## Arrays
|
||||
|
||||
@@ -85,7 +85,8 @@ module.exports = {
|
||||
// enforce padding within blocks
|
||||
'padded-blocks': [2, 'never'],
|
||||
// require quotes around object literal property names
|
||||
'quote-props': 0,
|
||||
// http://eslint.org/docs/rules/quote-props.html
|
||||
'quote-props': [2, 'as-needed', { 'keywords': true, 'unnecessary': true, 'numbers': false }],
|
||||
// specify whether double or single quotes should be used
|
||||
'quotes': [2, 'single', 'avoid-escape'],
|
||||
// require identifiers to match the provided regular expression
|
||||
|
||||
Reference in New Issue
Block a user