From 6bf2458e785957453a3d33afd92751f715ca2a8c Mon Sep 17 00:00:00 2001 From: Charlie Date: Mon, 3 Apr 2017 14:05:14 -0500 Subject: [PATCH 01/12] style guide proposal --- index.js | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/index.js b/index.js index e69de29..f14e2b5 100644 --- a/index.js +++ b/index.js @@ -0,0 +1,47 @@ +const config = { + "env": { + "browser": true, + "es6": true, + "mocha": true, + "node": true + }, + "extends": "eslint:recommended", + "parser": "babel-eslint", + "parserOptions": { + "ecmaFeatures": { + "experimentalObjectRestSpread": true, + "jsx": true + }, + "ecmaVersion": 6, + "sourceType": "module" + }, + "plugins": [ + "react" + ], + "rules": { + "comma-dangle": ["error", "always-multiline"], + "indent": ["error", 2, { "SwitchCase": 1 }], + "keyword-spacing": "error", + "object-curly-spacing": ["error", "always"], + "no-multiple-empty-lines": ["error", { "max": 1 }], + "linebreak-style": ["error", "unix"], + "max-len": ["error", 120, 4, { "ignoreUrls": true }], + "no-param-reassign": ["error", { "props": false }], + "quotes": ["error", "single"], + "react/jsx-uses-react": 1, + "react/jsx-uses-vars": 1, + "semi": ["error", "always"], + "strict": ["error", "never"] + }, + "indent": ["error", 2], + "linebreak-style": ["error", "unix"], + "max-len": ["error", 120, 4, { "ignoreUrls": true }], + "no-param-reassign": ["error", { "props": false }], + "quotes": ["error", "single"], + "react/jsx-uses-react": 1, + "react/jsx-uses-vars": 1, + "semi": ["error", "always"], + "strict": ["error", "never"] +}; + +module.exports = config; From a0fb598db47dd531b11fe1ffbb2794b7e6826cbd Mon Sep 17 00:00:00 2001 From: Charlie Date: Mon, 3 Apr 2017 14:15:00 -0500 Subject: [PATCH 02/12] added react eslint dependency" --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 4a4fed9..878ebc6 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "description": "", "main": "index.js", "peerDependencies": { - "eslint": ">=3" + "eslint": ">=3", + "eslint-plugin-react": "^4.0.0" }, "scripts": { "test": "echo \"Error: no test specified\" && exit 1" From 9d0de109be10b18da0a4ee14cb40b822bb7182a6 Mon Sep 17 00:00:00 2001 From: Charlie Date: Tue, 4 Apr 2017 13:08:20 -0500 Subject: [PATCH 03/12] separation of rules --- .gitignore | 1 + base/index.js | 25 +++++++++++++++++++++++++ browser/index.js | 14 ++++++++++++++ index.js | 48 +----------------------------------------------- 4 files changed, 41 insertions(+), 47 deletions(-) create mode 100644 .gitignore create mode 100644 base/index.js create mode 100644 browser/index.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c8f50f7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +npm-debug.log diff --git a/base/index.js b/base/index.js new file mode 100644 index 0000000..5cc33d2 --- /dev/null +++ b/base/index.js @@ -0,0 +1,25 @@ +module.exporst = { + "extends": "eslint:recommended", + "parserOptions": { + "ecmaFeatures": { + "experimentalObjectRestSpread": true, + "jsx": true + }, + "ecmaVersion": 2016, + "sourceType": "module" + }, + "rules": { + "comma-dangle": ["error", "always-multiline"], + "indent": ["error", 2, { "SwitchCase": 1 }], + "keyword-spacing": "error", + "object-curly-spacing": ["error", "always"], + "no-multiple-empty-lines": ["error", { "max": 1 }], + "linebreak-style": ["error", "unix"], + "max-len": ["error", 120, 4, { "ignoreUrls": true }], + "no-param-reassign": ["error", { "props": false }], + "quotes": ["error", "single"], + "semi": ["error", "always"], + "strict": ["error", "never"] + } +}; + diff --git a/browser/index.js b/browser/index.js new file mode 100644 index 0000000..f5c788a --- /dev/null +++ b/browser/index.js @@ -0,0 +1,14 @@ +module.exports = { + "extends": "eslint-config-wizeline", + "env": { + "browser": true + }, + "plugins": [ + "react" + ], + "rules": { + "react/jsx-uses-react": 1, + "react/jsx-uses-vars": 1, + "react/prefer-stateless-function": "error" + } +}; diff --git a/index.js b/index.js index f14e2b5..5931c88 100644 --- a/index.js +++ b/index.js @@ -1,47 +1 @@ -const config = { - "env": { - "browser": true, - "es6": true, - "mocha": true, - "node": true - }, - "extends": "eslint:recommended", - "parser": "babel-eslint", - "parserOptions": { - "ecmaFeatures": { - "experimentalObjectRestSpread": true, - "jsx": true - }, - "ecmaVersion": 6, - "sourceType": "module" - }, - "plugins": [ - "react" - ], - "rules": { - "comma-dangle": ["error", "always-multiline"], - "indent": ["error", 2, { "SwitchCase": 1 }], - "keyword-spacing": "error", - "object-curly-spacing": ["error", "always"], - "no-multiple-empty-lines": ["error", { "max": 1 }], - "linebreak-style": ["error", "unix"], - "max-len": ["error", 120, 4, { "ignoreUrls": true }], - "no-param-reassign": ["error", { "props": false }], - "quotes": ["error", "single"], - "react/jsx-uses-react": 1, - "react/jsx-uses-vars": 1, - "semi": ["error", "always"], - "strict": ["error", "never"] - }, - "indent": ["error", 2], - "linebreak-style": ["error", "unix"], - "max-len": ["error", 120, 4, { "ignoreUrls": true }], - "no-param-reassign": ["error", { "props": false }], - "quotes": ["error", "single"], - "react/jsx-uses-react": 1, - "react/jsx-uses-vars": 1, - "semi": ["error", "always"], - "strict": ["error", "never"] -}; - -module.exports = config; +module.exports = require('./base'); From ae5b890f44a234988ea7203cca627fcb20b04094 Mon Sep 17 00:00:00 2001 From: Charlie Date: Tue, 4 Apr 2017 13:09:54 -0500 Subject: [PATCH 04/12] Create README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..52d488a --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# javascript-style-guide +JavaScript Style Guide From acb9af0a7d127247c30e1a28ae67faab3d4896df Mon Sep 17 00:00:00 2001 From: Charlie Date: Tue, 4 Apr 2017 13:33:23 -0500 Subject: [PATCH 05/12] Update README.md --- README.md | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 52d488a..7fc933b 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,20 @@ -# javascript-style-guide -JavaScript Style Guide +# Wizeline Javascript Style Guide +Wizeline's ESLint rules for js environments + +## Installation +Add ESLint and Wizeline's lintern configs + +```npm install --save-dev eslint``` + +``` npm install --save-dev wizeline/eslint-config-wizeline ``` + +## Usage +These configs are divided by environments. Use the one you need for your project. + +For example, if you're working with a browser-related stack, you will need to add the following to your project's `.eslintrc` + +```json +{ + "extends": "eslint-config-wizeline/browser" +} +``` From b0c298dd99a45f836d0be73e0e5792db6ca0b5d0 Mon Sep 17 00:00:00 2001 From: Charlie Date: Tue, 4 Apr 2017 15:10:49 -0500 Subject: [PATCH 06/12] rules for browser environments --- base/index.js | 11 ++++++----- browser/index.js | 13 ++++++++++--- package.json | 4 +++- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/base/index.js b/base/index.js index 5cc33d2..8bb4a1a 100644 --- a/base/index.js +++ b/base/index.js @@ -1,11 +1,13 @@ -module.exporst = { +module.exports = { "extends": "eslint:recommended", + "env": { + "es6": true, + "node": true + }, "parserOptions": { "ecmaFeatures": { - "experimentalObjectRestSpread": true, - "jsx": true + "experimentalObjectRestSpread": true }, - "ecmaVersion": 2016, "sourceType": "module" }, "rules": { @@ -22,4 +24,3 @@ module.exporst = { "strict": ["error", "never"] } }; - diff --git a/browser/index.js b/browser/index.js index f5c788a..0587ff0 100644 --- a/browser/index.js +++ b/browser/index.js @@ -3,12 +3,19 @@ module.exports = { "env": { "browser": true }, + "parser": "babel-eslint", + "parserOptions": { + "ecmaFeatures": { + "jsx": true + } + }, "plugins": [ - "react" + "react", + "flowtype" ], "rules": { - "react/jsx-uses-react": 1, - "react/jsx-uses-vars": 1, + "react/jsx-uses-react": "error", + "react/jsx-uses-vars": "error", "react/prefer-stateless-function": "error" } }; diff --git a/package.json b/package.json index 878ebc6..d7ee612 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,9 @@ "main": "index.js", "peerDependencies": { "eslint": ">=3", - "eslint-plugin-react": "^4.0.0" + "eslint-plugin-react": "^4.0.0", + "eslint-plugin-flowtype": "^2.30.2", + "babel-eslint": "^7.1.1" }, "scripts": { "test": "echo \"Error: no test specified\" && exit 1" From fb261db964215e49e1c6d8c8d221e1f3dc7ba4f2 Mon Sep 17 00:00:00 2001 From: Charlie Date: Tue, 4 Apr 2017 16:17:45 -0500 Subject: [PATCH 07/12] dependencies --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d7ee612..3b6bf3b 100644 --- a/package.json +++ b/package.json @@ -3,8 +3,8 @@ "version": "1.0.0", "description": "", "main": "index.js", - "peerDependencies": { - "eslint": ">=3", + "devDependencies": { + "eslint": "^3.19.0", "eslint-plugin-react": "^4.0.0", "eslint-plugin-flowtype": "^2.30.2", "babel-eslint": "^7.1.1" From 84653fd4af405b7079fee9e5bc2ec772abf3605a Mon Sep 17 00:00:00 2001 From: Charlie Date: Tue, 4 Apr 2017 16:19:36 -0500 Subject: [PATCH 08/12] Update README.md --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index 7fc933b..af4fa23 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,7 @@ Wizeline's ESLint rules for js environments ## Installation -Add ESLint and Wizeline's lintern configs - -```npm install --save-dev eslint``` +Install Wizeline's lintern configs (ESLint is already included by default) ``` npm install --save-dev wizeline/eslint-config-wizeline ``` From facdf101f237c14a8d3ea01637ea99ff915f82e5 Mon Sep 17 00:00:00 2001 From: Charlie Date: Tue, 4 Apr 2017 16:22:07 -0500 Subject: [PATCH 09/12] .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index c8f50f7..71b051e 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ npm-debug.log +node_modules/ From cc9d7fdefead30eaa0b5d512fa510a9cb70e5951 Mon Sep 17 00:00:00 2001 From: Charlie Date: Tue, 4 Apr 2017 17:48:33 -0500 Subject: [PATCH 10/12] set peerdependencies --- base/index.js | 3 ++- package.json | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/base/index.js b/base/index.js index 8bb4a1a..155c55c 100644 --- a/base/index.js +++ b/base/index.js @@ -21,6 +21,7 @@ module.exports = { "no-param-reassign": ["error", { "props": false }], "quotes": ["error", "single"], "semi": ["error", "always"], - "strict": ["error", "never"] + "strict": ["error", "never"], + "require-yield": "off" } }; diff --git a/package.json b/package.json index 3b6bf3b..ae598a8 100644 --- a/package.json +++ b/package.json @@ -3,11 +3,11 @@ "version": "1.0.0", "description": "", "main": "index.js", - "devDependencies": { - "eslint": "^3.19.0", - "eslint-plugin-react": "^4.0.0", - "eslint-plugin-flowtype": "^2.30.2", - "babel-eslint": "^7.1.1" + "peerDependencies": { + "eslint": ">=3.19.0", + "eslint-plugin-react": ">=4.0.0", + "eslint-plugin-flowtype": ">=2.30.2", + "babel-eslint": ">=7.1.1" }, "scripts": { "test": "echo \"Error: no test specified\" && exit 1" From e096ca609a95911277412a32ebfed5e53f2ba0bd Mon Sep 17 00:00:00 2001 From: Charlie Date: Wed, 5 Apr 2017 17:39:17 -0500 Subject: [PATCH 11/12] requesting a newer eslint-plugin-react --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ae598a8..97ba37b 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "index.js", "peerDependencies": { "eslint": ">=3.19.0", - "eslint-plugin-react": ">=4.0.0", + "eslint-plugin-react": ">=6.0.0", "eslint-plugin-flowtype": ">=2.30.2", "babel-eslint": ">=7.1.1" }, From ddaf272a4bfc3a170c65d4eb3ea30af442251307 Mon Sep 17 00:00:00 2001 From: Charlie Date: Wed, 5 Apr 2017 17:47:29 -0500 Subject: [PATCH 12/12] Update README.md --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index af4fa23..3d8ddc2 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,16 @@ Wizeline's ESLint rules for js environments ## Installation -Install Wizeline's lintern configs (ESLint is already included by default) +First, install ESLint as a dev dependency + +``` npm install --save-dev eslint ``` + +Then, install Wizeline's lintern configs ``` npm install --save-dev wizeline/eslint-config-wizeline ``` +Finally, add the required peer dependencies. You will be warned after running the above command. + ## Usage These configs are divided by environments. Use the one you need for your project.