From 4cdc3fe4831c57b0eadd8127ab03a4753382ff78 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 22 Dec 2015 09:49:25 -0800 Subject: [PATCH] [eslint config] [breaking] enable `quote-props` rule. --- README.md | 22 ++++++++++++++++++++ packages/eslint-config-airbnb/rules/style.js | 3 ++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index cebc053b..d2378926 100644 --- a/README.md +++ b/README.md @@ -287,6 +287,28 @@ Other Style Guides }; ``` + - [3.8](#3.8) 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 diff --git a/packages/eslint-config-airbnb/rules/style.js b/packages/eslint-config-airbnb/rules/style.js index 284aac48..66e3a3f7 100644 --- a/packages/eslint-config-airbnb/rules/style.js +++ b/packages/eslint-config-airbnb/rules/style.js @@ -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