From 35a5faa9192c989c9e18e4ea6c2f5449dd1b4162 Mon Sep 17 00:00:00 2001 From: Christian Rackerseder Date: Wed, 16 Sep 2015 09:14:50 +0200 Subject: [PATCH 1/3] Added max-len rule --- README.md | 26 ++++++++++++++++++--- packages/eslint-config-airbnb/base/index.js | 1 + 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ab8b9b28ae..8b0c08abd6 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,7 @@ Other Style Guides 1. [Accessors](#accessors) 1. [Events](#events) 1. [jQuery](#jquery) + 1. [Line length](#line-length) 1. [ECMAScript 5 Compatibility](#ecmascript-5-compatibility) 1. [ECMAScript 6 Styles](#ecmascript-6-styles) 1. [Testing](#testing) @@ -1986,16 +1987,35 @@ Other Style Guides **[⬆ back to top](#table-of-contents)** +## Line length + + - [26.1](#26.1) Avoid very long lines of code. + + > Why? This ensures readability and maintainability. + + ```javascript + // bad + var foo = { "bar": "This is a bar.", "baz": { "qux": "This is a qux" }, "difficult": "to read" }; + + // good + var foo = { + "bar": "This is a bar.", + "baz": { + "qux": "This is a qux" + }, + "difficult": "to read" + }; + ``` ## ECMAScript 5 Compatibility - - [26.1](#26.1) Refer to [Kangax](https://twitter.com/kangax/)'s ES5 [compatibility table](http://kangax.github.com/es5-compat-table/). + - [27.1](#27.1) Refer to [Kangax](https://twitter.com/kangax/)'s ES5 [compatibility table](http://kangax.github.com/es5-compat-table/). **[⬆ back to top](#table-of-contents)** ## ECMAScript 6 Styles - - [27.1](#27.1) This is a collection of links to the various es6 features. + - [28.1](#28.1) This is a collection of links to the various es6 features. 1. [Arrow Functions](#arrow-functions) 1. [Classes](#constructors) @@ -2015,7 +2035,7 @@ Other Style Guides ## Testing - - [28.1](#28.1) **Yup.** + - [29.1](#29.1) **Yup.** ```javascript function() { diff --git a/packages/eslint-config-airbnb/base/index.js b/packages/eslint-config-airbnb/base/index.js index ee578638f0..31e93d52e7 100644 --- a/packages/eslint-config-airbnb/base/index.js +++ b/packages/eslint-config-airbnb/base/index.js @@ -83,6 +83,7 @@ module.exports = { }], 'eqeqeq': 2, // http://eslint.org/docs/rules/eqeqeq 'guard-for-in': 2, // http://eslint.org/docs/rules/guard-for-in + 'max-len': [2, 80, 4] // http://eslint.org/docs/rules/max-len 'no-caller': 2, // http://eslint.org/docs/rules/no-caller 'no-else-return': 2, // http://eslint.org/docs/rules/no-else-return 'no-eq-null': 2, // http://eslint.org/docs/rules/no-eq-null From 27ad7922de54d87e51c499c031874ddd1396a083 Mon Sep 17 00:00:00 2001 From: Christian Rackerseder Date: Wed, 16 Sep 2015 11:19:15 +0200 Subject: [PATCH 2/3] Removed object key quotes --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 8b0c08abd6..49cf786ec9 100644 --- a/README.md +++ b/README.md @@ -1995,15 +1995,15 @@ Other Style Guides ```javascript // bad - var foo = { "bar": "This is a bar.", "baz": { "qux": "This is a qux" }, "difficult": "to read" }; + var foo = { bar: "This is a bar.", baz: { "qux": "This is a qux" }, difficult: "to read" }; // good var foo = { - "bar": "This is a bar.", - "baz": { - "qux": "This is a qux" + bar: "This is a bar.", + baz: { + qux: "This is a qux" }, - "difficult": "to read" + difficult: "to read" }; ``` From 0f196f4ed862a4b9169e792b2fcf8a23f364b1dc Mon Sep 17 00:00:00 2001 From: Christian Rackerseder Date: Wed, 16 Sep 2015 11:22:08 +0200 Subject: [PATCH 3/3] max-len increased to 100 characters --- README.md | 2 +- packages/eslint-config-airbnb/base/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 49cf786ec9..8f24a95fc1 100644 --- a/README.md +++ b/README.md @@ -1989,7 +1989,7 @@ Other Style Guides ## Line length - - [26.1](#26.1) Avoid very long lines of code. + - [26.1](#26.1) Avoid very long lines of code longer than 100 characters. > Why? This ensures readability and maintainability. diff --git a/packages/eslint-config-airbnb/base/index.js b/packages/eslint-config-airbnb/base/index.js index 31e93d52e7..83fa0989ff 100644 --- a/packages/eslint-config-airbnb/base/index.js +++ b/packages/eslint-config-airbnb/base/index.js @@ -83,7 +83,7 @@ module.exports = { }], 'eqeqeq': 2, // http://eslint.org/docs/rules/eqeqeq 'guard-for-in': 2, // http://eslint.org/docs/rules/guard-for-in - 'max-len': [2, 80, 4] // http://eslint.org/docs/rules/max-len + 'max-len': [2, 100, 4] // http://eslint.org/docs/rules/max-len 'no-caller': 2, // http://eslint.org/docs/rules/no-caller 'no-else-return': 2, // http://eslint.org/docs/rules/no-else-return 'no-eq-null': 2, // http://eslint.org/docs/rules/no-eq-null