From a6db32657baefcda8c889238c262f75318050a78 Mon Sep 17 00:00:00 2001 From: Alasdair Mercer Date: Mon, 3 Jul 2017 13:15:56 +0100 Subject: [PATCH 1/3] added configs for ES2016 and ES2017 as well as changes to be compatible with ESLint v4 --- README.md | 11 ++++++-- es5.js | 68 +++++++++++++++++++++++++++++++++++++---------- es6.js | 11 +++++++- es7.js | 30 +++++++++++++++++++++ es8.js | 36 +++++++++++++++++++++++++ package-lock.json | 5 ++++ 6 files changed, 144 insertions(+), 17 deletions(-) create mode 100644 es7.js create mode 100644 es8.js create mode 100644 package-lock.json diff --git a/README.md b/README.md index 9c1d26b..a2ed9dd 100644 --- a/README.md +++ b/README.md @@ -33,8 +33,15 @@ Create an ESLint configuration file within your package that extends this config } ``` -This will import the ECMAScript 5 configuration by default. This can also be done by extending `"notninja/es5"`. For -ECMAScript 6 packages, please extend `"notninja/es6"` instead. +This will extend the ECMAScript 5 configuration by default, but you can extend other ECMAScript versions by using the +following: + +| ECMAScript Version | Value | +| ------------------ | -------------------------------- | +| 5 | `"notninja"` or `"notninja/es5"` | +| 6 (2015) | `"notninja/es6"` | +| 7 (2016) | `"notninja/es7"` | +| 8 (2017) | `"notninja/es8"` | ## Bugs diff --git a/es5.js b/es5.js index 2735fcb..203f46a 100644 --- a/es5.js +++ b/es5.js @@ -27,6 +27,8 @@ module.exports = { ecmaVersion: 5 }, rules: { + 'for-direction': 'error', + 'no-compare-neg-zero': 'error', 'no-cond-assign': 'error', 'no-console': 'error', 'no-constant-condition': 'error', @@ -35,8 +37,8 @@ module.exports = { 'no-dupe-args': 'error', 'no-dupe-keys': 'error', 'no-duplicate-case': 'error', - 'no-empty-character-class': 'error', 'no-empty': 'error', + 'no-empty-character-class': 'error', 'no-ex-assign': 'error', 'no-extra-boolean-cast': 'error', 'no-extra-parens': [ @@ -90,7 +92,6 @@ module.exports = { 'no-div-regex': 'error', 'no-else-return': 'warn', 'no-empty-function': 'warn', - 'no-empty-pattern': 'error', 'no-eq-null': 'off', 'no-eval': 'error', 'no-extend-native': 'error', @@ -107,14 +108,14 @@ module.exports = { 'no-labels': 'error', 'no-lone-blocks': 'error', 'no-loop-func': 'error', - 'no-magic-numbers': 'off', + 'no-magic-numbers': 'warn', 'no-multi-spaces': 'error', 'no-multi-str': 'error', + 'no-new': 'error', 'no-new-func': 'error', 'no-new-wrappers': 'error', - 'no-new': 'error', - 'no-octal-escape': 'error', 'no-octal': 'error', + 'no-octal-escape': 'error', 'no-param-reassign': 'off', 'no-proto': 'error', 'no-redeclare': 'error', @@ -130,6 +131,7 @@ module.exports = { 'no-useless-call': 'error', 'no-useless-concat': 'error', 'no-useless-escape': 'error', + 'no-useless-return': 'error', 'no-void': 'error', 'no-warning-comments': 'warn', 'no-with': 'error', @@ -145,10 +147,10 @@ module.exports = { 'no-delete-var': 'error', 'no-label-var': 'error', 'no-restricted-globals': 'error', - 'no-shadow-restricted-names': 'error', 'no-shadow': 'error', - 'no-undef-init': 'error', + 'no-shadow-restricted-names': 'error', 'no-undef': 'error', + 'no-undef-init': 'error', 'no-undefined': 'error', 'no-unused-vars': 'warn', 'no-use-before-define': 'error', @@ -156,6 +158,7 @@ module.exports = { 'callback-return': 'warn', 'global-require': 'error', 'handle-callback-err': 'warn', + 'no-buffer-constructor': 'error', 'no-mixed-requires': 'warn', 'no-new-require': 'error', 'no-path-concat': 'error', @@ -164,13 +167,26 @@ module.exports = { 'no-restricted-modules': 'off', 'no-sync': 'off', + 'array-bracket-newline': [ + 'error', + { + 'multiline': true + } + ], 'array-bracket-spacing': [ 'error', 'always' ], + 'array-element-newline': [ + 'error', + { + 'multiline': true + } + ], 'block-spacing': 'error', 'brace-style': 'error', 'camelcase': 'error', + 'capitalized-comments': 'error', 'comma-dangle': 'error', 'comma-spacing': 'error', 'comma-style': 'error', @@ -197,6 +213,12 @@ module.exports = { 'jsx-quotes': 'error', 'key-spacing': 'error', 'keyword-spacing': 'error', + 'line-comment-position': [ + 'error', + { + 'position': 'above' + } + ], 'linebreak-style': [ 'error', 'unix' @@ -209,15 +231,22 @@ module.exports = { 2 ], 'max-lines': 'off', - 'max-nested-callbacks': 'error', - 'max-params': 'error', - 'max-statements-per-line': 'error', + 'max-nested-callbacks': [ + 'error', + 10 + ], + 'max-params': [ + 'error', + 3 + ], 'max-statements': 'off', + 'max-statements-per-line': [ + 'error', + 1 + ], 'multiline-ternary': 'off', 'new-cap': 'error', 'new-parens': 'error', - 'newline-after-var': 'off', - 'newline-before-return': 'off', 'newline-per-chained-call': 'off', 'no-array-constructor': 'error', 'no-bitwise': 'error', @@ -226,6 +255,7 @@ module.exports = { 'no-lonely-if': 'error', 'no-mixed-operators': 'warn', 'no-mixed-spaces-and-tabs': 'error', + 'no-multi-assign': 'error', 'no-multiple-empty-lines': 'error', 'no-negated-condition': 'off', 'no-nested-ternary': 'warn', @@ -238,6 +268,10 @@ module.exports = { 'no-underscore-dangle': 'off', 'no-unneeded-ternary': 'error', 'no-whitespace-before-property': 'error', + 'nonblock-statement-body-position': [ + 'error', + 'below' + ], 'object-curly-newline': [ 'error', { @@ -249,13 +283,13 @@ module.exports = { 'always' ], 'object-property-newline': 'off', - 'one-var-declaration-per-line': 'error', 'one-var': [ 'error', { 'initialized': 'never' } ], + 'one-var-declaration-per-line': 'error', 'operator-assignment': 'warn', 'operator-linebreak': 'error', 'padded-blocks': [ @@ -266,6 +300,7 @@ module.exports = { 'switches': 'never' } ], + 'padding-line-between-statements': 'off', 'quote-props': [ 'error', 'consistent-as-needed' @@ -275,11 +310,15 @@ module.exports = { 'single' ], 'require-jsdoc': 'off', - 'semi-spacing': 'error', 'semi': [ 'error', 'always' ], + 'semi-spacing': 'error', + 'semi-style': [ + 'error', + 'last' + ], 'sort-keys': 'off', 'sort-vars': 'off', 'space-before-blocks': 'error', @@ -291,6 +330,7 @@ module.exports = { 'space-infix-ops': 'error', 'space-unary-ops': 'error', 'spaced-comment': 'error', + 'switch-colon-spacing': 'error', 'unicode-bom': 'error', 'wrap-regex': 'off' } diff --git a/es6.js b/es6.js index 19f61f6..315ac0e 100644 --- a/es6.js +++ b/es6.js @@ -31,6 +31,14 @@ module.exports = { ecmaVersion: 6 }, rules: { + 'class-methods-use-this': 'warn', + 'no-empty-pattern': 'error', + 'prefer-promise-reject-errors': 'error', + 'template-tag-spacing': [ + 'error', + 'never' + ], + 'arrow-body-style': 'off', 'arrow-parens': [ 'error', @@ -54,7 +62,8 @@ module.exports = { 'object-shorthand': 'warn', 'prefer-arrow-callback': 'warn', 'prefer-const': 'warn', - 'prefer-reflect': 'off', + 'prefer-destructuring': 'off', + 'prefer-numeric-literals': 'warn', 'prefer-rest-params': 'warn', 'prefer-spread': 'warn', 'prefer-template': 'error', diff --git a/es7.js b/es7.js new file mode 100644 index 0000000..bbbc101 --- /dev/null +++ b/es7.js @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2017 Alasdair Mercer, !ninja + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +'use strict'; + +module.exports = { + extends: './es6.js', + parserOptions: { + ecmaVersion: 7 + } +}; diff --git a/es8.js b/es8.js new file mode 100644 index 0000000..f113040 --- /dev/null +++ b/es8.js @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2017 Alasdair Mercer, !ninja + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +'use strict'; + +module.exports = { + extends: './es7.js', + parserOptions: { + ecmaVersion: 8 + }, + rules: { + 'no-await-in-loop': 'error', + + 'no-return-await': 'error', + 'require-await': 'error' + } +}; diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..650c493 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,5 @@ +{ + "name": "eslint-config-notninja", + "version": "0.1.1", + "lockfileVersion": 1 +} From a95f5ed015e07107ee7a5e7d24ca81ac4efe70a2 Mon Sep 17 00:00:00 2001 From: Alasdair Mercer Date: Mon, 3 Jul 2017 13:27:50 +0100 Subject: [PATCH 2/3] minor changes to align with common usage --- es5.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/es5.js b/es5.js index 203f46a..4300126 100644 --- a/es5.js +++ b/es5.js @@ -91,7 +91,7 @@ module.exports = { 'no-case-declarations': 'error', 'no-div-regex': 'error', 'no-else-return': 'warn', - 'no-empty-function': 'warn', + 'no-empty-function': 'off', 'no-eq-null': 'off', 'no-eval': 'error', 'no-extend-native': 'error', @@ -152,8 +152,18 @@ module.exports = { 'no-undef': 'error', 'no-undef-init': 'error', 'no-undefined': 'error', - 'no-unused-vars': 'warn', - 'no-use-before-define': 'error', + 'no-unused-vars': [ + 'warn', + { + 'args': 'none' + } + ], + 'no-use-before-define': [ + 'error', + { + 'functions': false + } + ], 'callback-return': 'warn', 'global-require': 'error', @@ -237,7 +247,7 @@ module.exports = { ], 'max-params': [ 'error', - 3 + 5 ], 'max-statements': 'off', 'max-statements-per-line': [ @@ -249,7 +259,7 @@ module.exports = { 'new-parens': 'error', 'newline-per-chained-call': 'off', 'no-array-constructor': 'error', - 'no-bitwise': 'error', + 'no-bitwise': 'warn', 'no-continue': 'off', 'no-inline-comments': 'error', 'no-lonely-if': 'error', From ad1c4f22226b1abbc10c8923299bd20e06a6930a Mon Sep 17 00:00:00 2001 From: Alasdair Mercer Date: Mon, 3 Jul 2017 13:30:31 +0100 Subject: [PATCH 3/3] roll 0.2.0 --- CHANGES.md | 7 +++++++ package-lock.json | 2 +- package.json | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index c2f8f81..6f08caa 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,10 @@ +## Version 0.2.0, 2017.07.03 + +* Add missing rules as of ESLint 4 +* Remove deprecated/removed rules as of ESLint 4 +* Add ES7/2016 & ES8/2017 configurations +* Update rules to align with common usage + ## Version 0.1.1, 2017.05.01 * Fix bug with missing comma after `sort-keys` rule diff --git a/package-lock.json b/package-lock.json index 650c493..d46d0d3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { "name": "eslint-config-notninja", - "version": "0.1.1", + "version": "0.2.0", "lockfileVersion": 1 } diff --git a/package.json b/package.json index 806c2ec..30a9bb7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-notninja", - "version": "0.1.1", + "version": "0.2.0", "description": "Standard ESLint configurations for !ninja packages", "homepage": "https://github.com/NotNinja/eslint-config-notninja", "bugs": {