From 3c504e9622588aadbb2c9f4163ea6699e75d6459 Mon Sep 17 00:00:00 2001 From: James Bunt Date: Wed, 23 Apr 2014 11:00:09 +1200 Subject: [PATCH 0001/1380] Remove unnecessary extra newline that confused some markdown previewers (in my case Atom.io). --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 3409c68ccd..ab248d07a1 100644 --- a/README.md +++ b/README.md @@ -137,7 +137,6 @@ ```javascript var someStack = []; - // bad someStack[someStack.length] = 'abracadabra'; From 5fd7c6f08c0650ed67297fc83c8a0590c9a92cc8 Mon Sep 17 00:00:00 2001 From: Estelle Date: Mon, 23 Mar 2015 18:48:19 -0700 Subject: [PATCH 0002/1380] added naming convention of UPPERCASE names --- README.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/README.md b/README.md index 2c6c5c6c7d..1116dcb4ba 100644 --- a/README.md +++ b/README.md @@ -3139,6 +3139,33 @@ Other Style Guides ]; ``` + + - [23.10](#naming--uppercase) Use UPPERCASE for nested object namespacing, global variables, and constants. + + + ```javascript + // bad + const namespace = namespace || {}; + + namespace.util.Widget = { + // ...stuff... + } + + // bad + const apiKey = '44b345234534t455245njkl523452-vbb9'; + + // good + const NAMESPACE = NAMESPACE || {}; + + NAMESPACE.util.Widget = { + // ...stuff... + } + + // good + const API_KEY = '44b345234534t455245njkl523452-vbb9'; + ``` + + **[⬆ back to top](#table-of-contents)** ## Accessors From 20c4d37b335384c86241c3e2578688374432a910 Mon Sep 17 00:00:00 2001 From: Jake Teton-Landis Date: Mon, 18 May 2015 11:55:36 -0700 Subject: [PATCH 0003/1380] add eslint rules for JSX style from issue #345 --- linters/.eslintrc | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/linters/.eslintrc b/linters/.eslintrc index 32eecff357..3b842c8538 100644 --- a/linters/.eslintrc +++ b/linters/.eslintrc @@ -1,5 +1,8 @@ { "parser": "babel-eslint", + "plugins": [ + "react" + ], "env": { "browser": true, "node": true @@ -164,6 +167,46 @@ "space-before-function-paren": [2, "never"], // http://eslint.org/docs/rules/space-before-function-paren "space-infix-ops": 2, // http://eslint.org/docs/rules/space-infix-ops "space-return-throw-case": 2, // http://eslint.org/docs/rules/space-return-throw-case - "spaced-line-comment": 2 // http://eslint.org/docs/rules/spaced-line-comment + "spaced-line-comment": 2, // http://eslint.org/docs/rules/spaced-line-comment + +/** + * JSX style + */ + "react/display-name": 0, + "react/jsx-boolean-value": 2, + "react/jsx-quotes": [2, "double"], + "react/jsx-no-undef": 2, + "react/jsx-sort-props": 0, + "react/jsx-sort-prop-types": 0, + "react/jsx-uses-react": 2, + "react/jsx-uses-vars": 2, + "react/no-did-mount-set-state": [2, "allow-in-func"], + "react/no-did-update-set-state": 2, + "react/no-multi-comp": 2, + "react/no-unknown-property": 2, + "react/prop-types": 2, + "react/react-in-jsx-scope": 2, + "react/self-closing-comp": 2, + "react/wrap-multilines": 2, + "react/sort-comp": [2, { + "order": [ + "displayName", + "mixins", + "statics", + "propTypes", + "getDefaultProps", + "getInitialState", + "componentWillMount", + "componentDidMount", + "componentWillReceiveProps", + "shouldComponentUpdate", + "componentWillUpdate", + "componentWillUnmount", + "/^on.+$/", + "/^get.+$/", + "/^render.+$/", + "render" + ] + }] } } From f87ddc012f12dac91f28b5be0fa6d2d522e2e2bb Mon Sep 17 00:00:00 2001 From: Jake Teton-Landis Date: Mon, 18 May 2015 12:02:48 -0700 Subject: [PATCH 0004/1380] add README describing eslintrc requirements --- linters/README.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 linters/README.md diff --git a/linters/README.md b/linters/README.md new file mode 100644 index 0000000000..6da3dcd984 --- /dev/null +++ b/linters/README.md @@ -0,0 +1,7 @@ +## `.eslintrc` + +Our `.eslintrc` requires the following NPM packages packages: + +- `eslint` +- `babel-eslint` +- `eslint-plugin-react` From a5704787e4695d128d59d83bf15a1e7a836c4d99 Mon Sep 17 00:00:00 2001 From: Josh Perez Date: Mon, 18 May 2015 14:09:46 -0700 Subject: [PATCH 0005/1380] Amend the arrow function rules This allows one to omit parens whenever it fits into a single line, which is similar to our if statement rules. --- README.md | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 0f0e5c908f..2a1209b04e 100644 --- a/README.md +++ b/README.md @@ -590,7 +590,7 @@ }); ``` - - [8.2](#8.2) If the function body fits on one line, feel free to omit the braces and use implicit return. Otherwise, add the braces and use a `return` statement. + - [8.2](#8.2) If the function body fits on one line and there is only a single argument, feel free to omit the braces and parenthesis, and use the implicit return. Otherwise, add the parenthesis, braces, and use a `return` statement. > Why? Syntactic sugar. It reads well when multiple functions are chained together. @@ -598,24 +598,12 @@ ```javascript // good - [1, 2, 3].map((x) => x * x); - - // good - [1, 2, 3].map((x) => { - return { number: x }; - }); - ``` - - - [8.3](#8.3) Always use parentheses around the arguments. Omitting the parentheses makes the functions less readable and only works for single arguments. - - > Why? These declarations read better with parentheses. They are also required when you have multiple parameters so this enforces consistency. - - ```javascript - // bad [1, 2, 3].map(x => x * x); // good - [1, 2, 3].map((x) => x * x); + [1, 2, 3].reduce((total, n) => { + return total + n; + }, 0); ``` **[⬆ back to top](#table-of-contents)** From cbcb09f99041ca3244735ea81fdea1f4a21d5958 Mon Sep 17 00:00:00 2001 From: Josh Perez Date: Mon, 18 May 2015 14:40:41 -0700 Subject: [PATCH 0006/1380] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2a1209b04e..5a11988c6f 100644 --- a/README.md +++ b/README.md @@ -590,7 +590,7 @@ }); ``` - - [8.2](#8.2) If the function body fits on one line and there is only a single argument, feel free to omit the braces and parenthesis, and use the implicit return. Otherwise, add the parenthesis, braces, and use a `return` statement. + - [8.2](#8.2) If the function body fits on one line and there is only a single argument, feel free to omit the braces and parentheses, and use the implicit return. Otherwise, add the parentheses, braces, and use a `return` statement. > Why? Syntactic sugar. It reads well when multiple functions are chained together. From 6b40c838fbf7154bc038835c5aaf6ae3b0b44047 Mon Sep 17 00:00:00 2001 From: Jake Teton-Landis Date: Fri, 22 May 2015 10:38:21 -0700 Subject: [PATCH 0007/1380] create package eslint-config-airbnb --- .gitignore | 1 + package.json | 3 +- packages/eslint-config-airbnb/index.js | 1 + packages/eslint-config-airbnb/package.json | 32 ++++++++++++++++++++++ 4 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 .gitignore create mode 100644 packages/eslint-config-airbnb/index.js create mode 100644 packages/eslint-config-airbnb/package.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..3c3629e647 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules diff --git a/package.json b/package.json index ff8167fad5..dc0225dc08 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,8 @@ "version": "2.0.0", "description": "A mostly reasonable approach to JavaScript.", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "test": "echo \"Error: no test specified\" && exit 1", + "publish-all": "npm publish && cd ./packages/eslint-config-airbnb && npm publish" }, "repository": { "type": "git", diff --git a/packages/eslint-config-airbnb/index.js b/packages/eslint-config-airbnb/index.js new file mode 100644 index 0000000000..8203f1e70d --- /dev/null +++ b/packages/eslint-config-airbnb/index.js @@ -0,0 +1 @@ +module.exports = require('airbnb-style/linters/.eslintrc'); diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json new file mode 100644 index 0000000000..3412d98d33 --- /dev/null +++ b/packages/eslint-config-airbnb/package.json @@ -0,0 +1,32 @@ +{ + "name": "eslint-config-airbnb", + "version": "0.0.1", + "description": "Airbnb's ESLint config, following our styleguide", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "https://github.com/airbnb/javascript" + }, + "keywords": [ + "eslint", + "config", + "airbnb", + "javascript", + "styleguide" + ], + "author": "Jake Teton-Landis (https://twitter.com/@jitl)", + "license": "MIT", + "bugs": { + "url": "https://github.com/airbnb/javascript/issues" + }, + "homepage": "https://github.com/airbnb/javascript", + "dependencies": { + "airbnb-style": "2.0.0", + "babel-eslint": "3.1.7", + "eslint": "0.21.2", + "eslint-plugin-react": "2.3.0" + } +} From f2da99e0584f67dc5794c25f2b12bc7e25692d1e Mon Sep 17 00:00:00 2001 From: Jake Teton-Landis Date: Fri, 22 May 2015 11:06:16 -0700 Subject: [PATCH 0008/1380] manually load commented JSON --- packages/eslint-config-airbnb/index.js | 12 +++++++++++- packages/eslint-config-airbnb/package.json | 4 +++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb/index.js b/packages/eslint-config-airbnb/index.js index 8203f1e70d..9c29ea31bd 100644 --- a/packages/eslint-config-airbnb/index.js +++ b/packages/eslint-config-airbnb/index.js @@ -1 +1,11 @@ -module.exports = require('airbnb-style/linters/.eslintrc'); +var resolve = require('resolve'); +var stripComments = require('strip-json-comments'); +var fs = require('fs'); + +// you could do this all at once if you wanted to look cool +var filename = resolve.sync('airbnb-style/linters/.eslintrc'); +var data = fs.readFileSync(filename, {encoding: 'utf-8'}); +var dataWithoutComments = stripComments(data); +var parsed = JSON.parse(dataWithoutComments); + +module.exports = parsed; diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 3412d98d33..4f0d4024ee 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -27,6 +27,8 @@ "airbnb-style": "2.0.0", "babel-eslint": "3.1.7", "eslint": "0.21.2", - "eslint-plugin-react": "2.3.0" + "eslint-plugin-react": "2.3.0", + "resolve": "1.1.6", + "strip-json-comments": "1.0.2" } } From 1676f2b1dc1a924e104ed7df0f2092fc9176269d Mon Sep 17 00:00:00 2001 From: Jake Teton-Landis Date: Fri, 22 May 2015 11:06:37 -0700 Subject: [PATCH 0009/1380] bump eslint-config-airbnb version to 0.0.2 --- packages/eslint-config-airbnb/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 4f0d4024ee..3f76ac271a 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-airbnb", - "version": "0.0.1", + "version": "0.0.2", "description": "Airbnb's ESLint config, following our styleguide", "main": "index.js", "scripts": { From c3a94c15fd5385828f47e45b1e329a810d0ecfc3 Mon Sep 17 00:00:00 2001 From: Jake Teton-Landis Date: Sat, 23 May 2015 18:53:27 -0700 Subject: [PATCH 0010/1380] add keyword "eslintconfig" to eslint-config-airbnb --- packages/eslint-config-airbnb/package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 3f76ac271a..0625134b82 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-airbnb", - "version": "0.0.2", + "version": "0.0.6", "description": "Airbnb's ESLint config, following our styleguide", "main": "index.js", "scripts": { @@ -12,6 +12,7 @@ }, "keywords": [ "eslint", + "eslintconfig", "config", "airbnb", "javascript", From 2539557e98f802a00513719ed9dd87891c7cde4f Mon Sep 17 00:00:00 2001 From: Sun Xingfan Date: Mon, 25 May 2015 22:15:38 +0800 Subject: [PATCH 0011/1380] Change Chinese Translation to a more official like version The current Chinese version translated by adamlu is a modified version which as he said change/delete some rules from the original and it's base on the version 2 years ago. I transalte a new version base on current style guide of es5 version. --- README.md | 2 +- es5/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5a11988c6f..cad368e92d 100644 --- a/README.md +++ b/README.md @@ -2082,7 +2082,7 @@ - ![bg](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Bulgaria.png) **Bulgarian**: [borislavvv/javascript](https://github.com/borislavvv/javascript) - ![ca](https://raw.githubusercontent.com/fpmweb/javascript-style-guide/master/img/catala.png) **Catalan**: [fpmweb/javascript-style-guide](https://github.com/fpmweb/javascript-style-guide) - ![tw](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Taiwan.png) **Chinese(Traditional)**: [jigsawye/javascript](https://github.com/jigsawye/javascript) - - ![cn](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/China.png) **Chinese(Simplified)**: [adamlu/javascript-style-guide](https://github.com/adamlu/javascript-style-guide) + - ![cn](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/China.png) **Chinese(Simplified)**: [sivan/javascript-style-guide](https://github.com/sivan/javascript-style-guide) - ![fr](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/France.png) **French**: [nmussy/javascript-style-guide](https://github.com/nmussy/javascript-style-guide) - ![de](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Germany.png) **German**: [timofurrer/javascript-style-guide](https://github.com/timofurrer/javascript-style-guide) - ![it](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Italy.png) **Italian**: [sinkswim/javascript-style-guide](https://github.com/sinkswim/javascript-style-guide) diff --git a/es5/README.md b/es5/README.md index 7626d0b9ea..b2b99f0947 100644 --- a/es5/README.md +++ b/es5/README.md @@ -1689,7 +1689,7 @@ - ![bg](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Bulgaria.png) **Bulgarian**: [borislavvv/javascript](https://github.com/borislavvv/javascript) - ![ca](https://raw.githubusercontent.com/fpmweb/javascript-style-guide/master/img/catala.png) **Catalan**: [fpmweb/javascript-style-guide](https://github.com/fpmweb/javascript-style-guide) - ![tw](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Taiwan.png) **Chinese(Traditional)**: [jigsawye/javascript](https://github.com/jigsawye/javascript) - - ![cn](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/China.png) **Chinese(Simplified)**: [adamlu/javascript-style-guide](https://github.com/adamlu/javascript-style-guide) + - ![cn](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/China.png) **Chinese(Simplified)**: [sivan/javascript-style-guide](https://github.com/sivan/javascript-style-guide) - ![fr](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/France.png) **French**: [nmussy/javascript-style-guide](https://github.com/nmussy/javascript-style-guide) - ![de](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Germany.png) **German**: [timofurrer/javascript-style-guide](https://github.com/timofurrer/javascript-style-guide) - ![it](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Italy.png) **Italian**: [sinkswim/javascript-style-guide](https://github.com/sinkswim/javascript-style-guide) From a6796f00981bc32685cb4eeb4fa2e89e90716c90 Mon Sep 17 00:00:00 2001 From: Baraa Hamodi Date: Wed, 27 May 2015 23:58:29 -0700 Subject: [PATCH 0012/1380] Update .eslintrc Just a consistency thing. :) --- linters/.eslintrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linters/.eslintrc b/linters/.eslintrc index 3b842c8538..93b84a54fe 100644 --- a/linters/.eslintrc +++ b/linters/.eslintrc @@ -53,7 +53,7 @@ * Possible errors */ "comma-dangle": [2, "never"], // http://eslint.org/docs/rules/comma-dangle - "no-cond-assign": [2, "always"], // http://eslint.org/docs/rules/no-cond-assign + "no-cond-assign": [2, "always"], // http://eslint.org/docs/rules/no-cond-assign "no-console": 1, // http://eslint.org/docs/rules/no-console "no-debugger": 1, // http://eslint.org/docs/rules/no-debugger "no-alert": 1, // http://eslint.org/docs/rules/no-alert From 394648033490fd8eaa18f08fe544a56cf165fbfd Mon Sep 17 00:00:00 2001 From: Arian Faurtosh Date: Sun, 31 May 2015 20:16:39 -0700 Subject: [PATCH 0013/1380] added trailing comma --- README.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 5a11988c6f..544112f71f 100644 --- a/README.md +++ b/README.md @@ -146,13 +146,13 @@ // bad const superman = { default: { clark: 'kent' }, - private: true + private: true, }; // good const superman = { defaults: { clark: 'kent' }, - hidden: true + hidden: true, }; ``` @@ -161,17 +161,17 @@ ```javascript // bad const superman = { - class: 'alien' + class: 'alien', }; // bad const superman = { - klass: 'alien' + klass: 'alien', }; // good const superman = { - type: 'alien' + type: 'alien', }; ``` @@ -234,12 +234,12 @@ // bad const obj = { - lukeSkywalker: lukeSkywalker + lukeSkywalker: lukeSkywalker, }; // good const obj = { - lukeSkywalker + lukeSkywalker, }; ``` @@ -1272,13 +1272,13 @@ // bad dog.set('attr',{ age: '1 year', - breed: 'Bernese Mountain Dog' + breed: 'Bernese Mountain Dog', }); // good dog.set('attr', { age: '1 year', - breed: 'Bernese Mountain Dog' + breed: 'Bernese Mountain Dog', }); ``` From 7a7bec17f3f1953ad93c16e1eb761cc40f5df30a Mon Sep 17 00:00:00 2001 From: ycavatars Date: Mon, 8 Jun 2015 12:56:32 +0800 Subject: [PATCH 0014/1380] add missing componentDidUpdate --- react/README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/react/README.md b/react/README.md index 6d9eb16921..3ff7bb9f37 100644 --- a/react/README.md +++ b/react/README.md @@ -232,10 +232,11 @@ 9. componentWillReceiveProps 10. shouldComponentUpdate 11. componentWillUpdate - 12. componentWillUnmount - 13. *clickHandlers or eventHandlers* like onClickSubmit() or onChangeDescription() - 14. *getter methods for render* like getSelectReason() or getFooterContent() - 15. *Optional render methods* like renderNavigation() or renderProfilePicture() - 16. render + 12. componentDidUpdate + 13. componentWillUnmount + 14. *clickHandlers or eventHandlers* like onClickSubmit() or onChangeDescription() + 15. *getter methods for render* like getSelectReason() or getFooterContent() + 16. *Optional render methods* like renderNavigation() or renderProfilePicture() + 17. render **[⬆ back to top](#table-of-contents)** From fb45e22b0e044eac25dd0f84d80d886260c4d953 Mon Sep 17 00:00:00 2001 From: Carter Chung Date: Sat, 13 Jun 2015 21:54:29 -0700 Subject: [PATCH 0015/1380] Added missing period --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5a11988c6f..1f7b4f2e35 100644 --- a/README.md +++ b/README.md @@ -1380,7 +1380,7 @@ .call(tron.led); ``` - - [18.6](#18.6) Leave a blank line after blocks and before the next statement + - [18.6](#18.6) Leave a blank line after blocks and before the next statement. ```javascript // bad From a2e235608c01ef9015b4d530b998b7c6be8366ae Mon Sep 17 00:00:00 2001 From: Carter Chung Date: Sat, 13 Jun 2015 21:56:21 -0700 Subject: [PATCH 0016/1380] Added bullet/indentation for consistency --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5a11988c6f..12cc02e8bf 100644 --- a/README.md +++ b/README.md @@ -1898,7 +1898,7 @@ ## ECMAScript 6 Styles -[27.1](#27.1) This is a collection of links to the various es6 features. + - [27.1](#27.1) This is a collection of links to the various es6 features. 1. [Arrow Functions](#arrow-functions) 1. [Classes](#constructors) From 1429a20c9734b7096fd091546b467f7837f8945a Mon Sep 17 00:00:00 2001 From: Aniss Bouraba Date: Wed, 17 Jun 2015 12:29:48 +0100 Subject: [PATCH 0017/1380] update(README.md): added Airbnb Style .eslintrc link --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 04162dcaf9..ff03a1bbf2 100644 --- a/README.md +++ b/README.md @@ -1959,6 +1959,7 @@ **Tools** - Code Style Linters + + [ESlint](http://eslint.org/) - [Airbnb Style .eslintrc](https://github.com/airbnb/javascript/blob/master/linters/.eslintrc) + [JSHint](http://www.jshint.com/) - [Airbnb Style .jshintrc](https://github.com/airbnb/javascript/blob/master/linters/jshintrc) + [JSCS](https://github.com/jscs-dev/node-jscs) - [Airbnb Style Preset](https://github.com/jscs-dev/node-jscs/blob/master/presets/airbnb.json) From 25a2430dc654b063d92c1935b1a685158af37c71 Mon Sep 17 00:00:00 2001 From: Tim Golen Date: Wed, 17 Jun 2015 13:30:29 -0600 Subject: [PATCH 0018/1380] Add Expensify to the list of organizations using this style guide --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 683a2f0d75..4a0280d15b 100644 --- a/README.md +++ b/README.md @@ -2038,6 +2038,7 @@ - **Digitpaint** [digitpaint/javascript](https://github.com/digitpaint/javascript) - **Evernote**: [evernote/javascript-style-guide](https://github.com/evernote/javascript-style-guide) - **ExactTarget**: [ExactTarget/javascript](https://github.com/ExactTarget/javascript) + - **Expensify** [Expensify/Style-Guide](https://github.com/Expensify/Style-Guide/blob/master/javascript.md) - **Flexberry**: [Flexberry/javascript-style-guide](https://github.com/Flexberry/javascript-style-guide) - **Gawker Media**: [gawkermedia/javascript](https://github.com/gawkermedia/javascript) - **GeneralElectric**: [GeneralElectric/javascript](https://github.com/GeneralElectric/javascript) From 53ac64adf5d52e89b34e01a2befe8fa9e990662f Mon Sep 17 00:00:00 2001 From: Christophe Hurpeau Date: Tue, 23 Jun 2015 18:00:55 +0200 Subject: [PATCH 0019/1380] 18.6: blocks and blank line: add example with array --- README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/README.md b/README.md index 0c94d2dd7a..0485737255 100644 --- a/README.md +++ b/README.md @@ -1415,6 +1415,26 @@ }; return obj; + + // bad + const arr = [ + function foo() { + }, + function bar() { + }, + ]; + return arr; + + // good + const arr = [ + function foo() { + }, + + function bar() { + }, + ]; + + return arr; ``` From 26dd0434141938a3e03ef4b37c38765f4c030137 Mon Sep 17 00:00:00 2001 From: Manoj Kumar Date: Tue, 23 Jun 2015 22:13:05 +0530 Subject: [PATCH 0020/1380] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 0c94d2dd7a..43244dc2d7 100644 --- a/README.md +++ b/README.md @@ -2000,6 +2000,7 @@ - [JSBooks](http://jsbooks.revolunet.com/) - Julien Bouquillon - [Third Party JavaScript](http://manning.com/vinegar/) - Ben Vinegar and Anton Kovalyov - [Effective JavaScript: 68 Specific Ways to Harness the Power of JavaScript](http://amzn.com/0321812182) - David Herman + - [Eloquent JavaScript](http://eloquentjavascript.net/) - Marijn Haverbeke **Blogs** From e9b59b76a5287a4aed3df94ed8b06ff0ad5fbd35 Mon Sep 17 00:00:00 2001 From: Chris Portela Date: Wed, 24 Jun 2015 15:51:25 -0400 Subject: [PATCH 0021/1380] Update .eslintrc with other react class properties In `eslint-plugin-react`'s page on their sorting rules they show the order I showed here. https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-comp.md#rule-options I noticed because according to the current rules `contextTypes` goes below `render` and I also noticed other methods were missing from the list. Since we're being specific we should also include the other methods and properties that `eslint-plugin-react` handles by default. --- linters/.eslintrc | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/linters/.eslintrc b/linters/.eslintrc index 93b84a54fe..c99a626e71 100644 --- a/linters/.eslintrc +++ b/linters/.eslintrc @@ -190,18 +190,23 @@ "react/wrap-multilines": 2, "react/sort-comp": [2, { "order": [ - "displayName", - "mixins", - "statics", - "propTypes", - "getDefaultProps", - "getInitialState", - "componentWillMount", - "componentDidMount", - "componentWillReceiveProps", - "shouldComponentUpdate", - "componentWillUpdate", - "componentWillUnmount", + 'displayName', + 'propTypes', + 'contextTypes', + 'childContextTypes', + 'mixins', + 'statics', + 'defaultProps', + 'getDefaultProps', + 'getInitialState', + 'getChildContext', + 'componentWillMount', + 'componentDidMount', + 'componentWillReceiveProps', + 'shouldComponentUpdate', + 'componentWillUpdate', + 'componentDidUpdate', + 'componentWillUnmount', "/^on.+$/", "/^get.+$/", "/^render.+$/", From fe42d0bfa3290efbeb3360e0f0b1e8c69c3ca3fd Mon Sep 17 00:00:00 2001 From: Chris Portela Date: Wed, 24 Jun 2015 16:02:21 -0400 Subject: [PATCH 0022/1380] Made single quotes to double quotes --- linters/.eslintrc | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/linters/.eslintrc b/linters/.eslintrc index c99a626e71..b904f3ec6e 100644 --- a/linters/.eslintrc +++ b/linters/.eslintrc @@ -190,23 +190,23 @@ "react/wrap-multilines": 2, "react/sort-comp": [2, { "order": [ - 'displayName', - 'propTypes', - 'contextTypes', - 'childContextTypes', - 'mixins', - 'statics', - 'defaultProps', - 'getDefaultProps', - 'getInitialState', - 'getChildContext', - 'componentWillMount', - 'componentDidMount', - 'componentWillReceiveProps', - 'shouldComponentUpdate', - 'componentWillUpdate', - 'componentDidUpdate', - 'componentWillUnmount', + "displayName", + "propTypes", + "contextTypes", + "childContextTypes", + "mixins", + "statics", + "defaultProps", + "getDefaultProps", + "getInitialState", + "getChildContext", + "componentWillMount", + "componentDidMount", + "componentWillReceiveProps", + "shouldComponentUpdate", + "componentWillUpdate", + "componentDidUpdate", + "componentWillUnmount", "/^on.+$/", "/^get.+$/", "/^render.+$/", From b020a431b0ffff92b37e3016cbd8fb7e9575fe77 Mon Sep 17 00:00:00 2001 From: Nikita Gusakov Date: Thu, 25 Jun 2015 16:31:27 +0300 Subject: [PATCH 0023/1380] Added "prefer-const" rule Added new ES6 rule, introduced in eslint 0.23.0 > This rule is aimed to flag variables that are declared using let keyword, but never modified after initial assignment. --- linters/.eslintrc | 1 + 1 file changed, 1 insertion(+) diff --git a/linters/.eslintrc b/linters/.eslintrc index b904f3ec6e..6ff0fa3b07 100644 --- a/linters/.eslintrc +++ b/linters/.eslintrc @@ -37,6 +37,7 @@ * ES6 */ "no-var": 2, // http://eslint.org/docs/rules/no-var + "prefer-const": 2, // http://eslint.org/docs/rules/prefer-const /** * Variables From d2792f27cbb91905a55b943edef68667c840ee66 Mon Sep 17 00:00:00 2001 From: Horace Ko Date: Thu, 25 Jun 2015 11:54:22 -0700 Subject: [PATCH 0024/1380] Recommend using .jsx extension for React components, rather than .js. --- react/README.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/react/README.md b/react/README.md index 3ff7bb9f37..afcf1020ad 100644 --- a/react/README.md +++ b/react/README.md @@ -24,8 +24,8 @@ ## Naming - - **Extensions**: Use `.js` extension for React components. - - **Filename**: Use PascalCase for filenames. E.g., `ReservationCard.js`. + - **Extensions**: Use `.jsx` extension for React components. + - **Filename**: Use PascalCase for filenames. E.g., `ReservationCard.jsx`. - **Reference Naming**: Use PascalCase for React components and camelCase for their instances: ```javascript // bad @@ -41,13 +41,13 @@ const reservationItem = ; ``` - **Component Naming**: Use the filename as the component name. So `ReservationCard.js` should have a reference name of ReservationCard. However, for root components of a directory, use index.js as the filename and use the directory name as the component name: + **Component Naming**: Use the filename as the component name. For example, `ReservationCard.jsx` should have a reference name of `ReservationCard`. However, for root components of a directory, use `index.jsx` as the filename and use the directory name as the component name: ```javascript // bad - const Footer = require('./Footer/Footer.js') + const Footer = require('./Footer/Footer.jsx') // bad - const Footer = require('./Footer/index.js') + const Footer = require('./Footer/index.jsx') // good const Footer = require('./Footer') @@ -55,7 +55,7 @@ ## Declaration - - Do not use displayName for naming components, instead name the component by reference. + - Do not use displayName for naming components. Instead, name the component by reference. ```javascript // bad @@ -72,7 +72,7 @@ ``` ## Alignment - - Follow these alignment styles for js syntax + - Follow these alignment styles for JS syntax ```javascript // bad @@ -98,7 +98,7 @@ ``` ## Quotes - - Always use double quotes (`"`) for JSX attributes, but single quotes for all other JavaScript. + - Always use double quotes (`"`) for JSX attributes, but single quotes for all other JS. ```javascript // bad @@ -197,7 +197,7 @@ ``` ## Methods - - Do not use underscore prefix for internal methods of a react component. + - Do not use underscore prefix for internal methods of a React component. ```javascript // bad React.createClass({ @@ -219,10 +219,10 @@ ``` ## Ordering - - Always follow the following order for methods in a react component: + - Always follow the following order for methods in a React component: 1. displayName - 2. mixins (as of React v0.13 mixins are deprecated) + 2. mixins (as of React v0.13, mixins are deprecated) 3. statics 4. propTypes 5. getDefaultProps From ee899996b6b6e3b2d098ee71725aef9d8b368ec8 Mon Sep 17 00:00:00 2001 From: Tomek Wiszniewski Date: Sat, 2 May 2015 00:14:17 +0200 Subject: [PATCH 0025/1380] Allow reserved words as keys in ES6 module context MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `