From d1980e9c920a25f52571feddca253196905b293d Mon Sep 17 00:00:00 2001 From: Flo Edelmann Date: Fri, 14 Sep 2018 22:28:44 +0200 Subject: [PATCH 01/16] Update eslint to version 5.5.0 --- src/main/resources/docs/patterns.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/docs/patterns.json b/src/main/resources/docs/patterns.json index 2c0f4be..c266fd5 100644 --- a/src/main/resources/docs/patterns.json +++ b/src/main/resources/docs/patterns.json @@ -1,6 +1,6 @@ { "name": "eslint", - "version": "4.15.0", + "version": "5.5.0", "patterns": [ { "patternId": "comma-dangle", From 4519436f25761a1d7fe459393422147712850661 Mon Sep 17 00:00:00 2001 From: Flo Edelmann Date: Fri, 14 Sep 2018 22:30:46 +0200 Subject: [PATCH 02/16] Remove deprecated no-catch-shadow rule see https://github.com/eslint/eslint/pull/10526 --- .../docs/description/no-catch-shadow.md | 26 ------------------- src/main/resources/docs/patterns.json | 5 ---- 2 files changed, 31 deletions(-) delete mode 100644 src/main/resources/docs/description/no-catch-shadow.md diff --git a/src/main/resources/docs/description/no-catch-shadow.md b/src/main/resources/docs/description/no-catch-shadow.md deleted file mode 100644 index 9f3cf21..0000000 --- a/src/main/resources/docs/description/no-catch-shadow.md +++ /dev/null @@ -1,26 +0,0 @@ -In IE 8 and earlier, the catch clause parameter can overwrite the value of a variable in the outer scope, if that variable has the same name as the catch clause parameter. -This rule is aimed at preventing unexpected behavior in your program that may arise from a bug in IE 8 and earlier, in which the catch clause parameter can leak into outer scopes. This rule will warn whenever it encounters a catch clause parameter that has the same name as a variable in an outer scope. - - -``` - -//Bad: -var err = "x"; -try { - throw "problem"; -} catch (err) { - -} - -//Good: -var err = "x"; - -try { - throw "problem"; -} catch (e) { - -} - -``` - -[Source](http://eslint.org/docs/rules/no-catch-shadow) diff --git a/src/main/resources/docs/patterns.json b/src/main/resources/docs/patterns.json index c266fd5..e6d0fe9 100644 --- a/src/main/resources/docs/patterns.json +++ b/src/main/resources/docs/patterns.json @@ -522,11 +522,6 @@ } ] }, - { - "patternId": "no-catch-shadow", - "level": "Warning", - "category": "ErrorProne" - }, { "patternId": "no-delete-var", "level": "Warning", From 24a0f2f80627e263d0d158f60618a618de432509 Mon Sep 17 00:00:00 2001 From: Flo Edelmann Date: Fri, 14 Sep 2018 22:33:46 +0200 Subject: [PATCH 03/16] Add require-atomic-updates rule See https://github.com/eslint/eslint/pull/10655 --- .../description/require-atomic-updates.md | 39 +++++++++++++++++++ src/main/resources/docs/patterns.json | 5 +++ 2 files changed, 44 insertions(+) create mode 100644 src/main/resources/docs/description/require-atomic-updates.md diff --git a/src/main/resources/docs/description/require-atomic-updates.md b/src/main/resources/docs/description/require-atomic-updates.md new file mode 100644 index 0000000..fc3ed7d --- /dev/null +++ b/src/main/resources/docs/description/require-atomic-updates.md @@ -0,0 +1,39 @@ +This rule aims to report assignments to variables or properties where all of the following are true: + +* A variable or property is reassigned to a new value which is based on its old value. +* A `yield` or `await` expression interrupts the assignment after the old value is read, and before the new value is set. +* The rule cannot easily verify that the assignment is safe (e.g. if an assigned variable is local and would not be readable from anywhere else while the function is paused). + +Examples of **incorrect** code for this rule: + +``` +//Bad: +let result; +async function foo() { + result += await somethingElse; + result = result + await somethingElse; + result = result + doSomething(await somethingElse); +} +function* bar() { + result += yield; + result = result + (yield somethingElse); + result = result + doSomething(yield somethingElse); +} + +//Good: +let result; +async function foo() { + result = await somethingElse + result; + let tmp = await somethingElse; + result += tmp; + let localVariable = 0; + localVariable += await somethingElse; +} +function* bar() { + result += yield; + result = (yield somethingElse) + result; + result = doSomething(yield somethingElse, result); +} +``` + +[Source](http://eslint.org/docs/rules/require-atomic-updates) diff --git a/src/main/resources/docs/patterns.json b/src/main/resources/docs/patterns.json index e6d0fe9..acd2e51 100644 --- a/src/main/resources/docs/patterns.json +++ b/src/main/resources/docs/patterns.json @@ -983,6 +983,11 @@ } ] }, + { + "patternId": "require-atomic-updates", + "level": "Error", + "category": "ErrorProne" + }, { "patternId": "require-jsdoc", "level": "Info", From 276b972af8e4a3415d2db9dc56fed68ce91aae9c Mon Sep 17 00:00:00 2001 From: Flo Edelmann Date: Fri, 14 Sep 2018 22:37:25 +0200 Subject: [PATCH 04/16] Add require-unicode-regexp rule See https://github.com/eslint/eslint/pull/10698 --- .../docs/description/require-unicode-regexp.md | 17 +++++++++++++++++ src/main/resources/docs/patterns.json | 5 +++++ 2 files changed, 22 insertions(+) create mode 100644 src/main/resources/docs/description/require-unicode-regexp.md diff --git a/src/main/resources/docs/description/require-unicode-regexp.md b/src/main/resources/docs/description/require-unicode-regexp.md new file mode 100644 index 0000000..b350c11 --- /dev/null +++ b/src/main/resources/docs/description/require-unicode-regexp.md @@ -0,0 +1,17 @@ +This rule aims to enforce the use of `u` flag on regular expressions. + +``` +//Bad: +const a = /aaa/ +const b = /bbb/gi +const c = new RegExp("ccc") +const d = new RegExp("ddd", "gi") + +//Good: +const a = /aaa/u +const b = /bbb/giu +const c = new RegExp("ccc", "u") +const d = new RegExp("ddd", "giu") +``` + +[Source](http://eslint.org/docs/rules/require-unicode-regexp) diff --git a/src/main/resources/docs/patterns.json b/src/main/resources/docs/patterns.json index acd2e51..f75883d 100644 --- a/src/main/resources/docs/patterns.json +++ b/src/main/resources/docs/patterns.json @@ -993,6 +993,11 @@ "level": "Info", "category": "CodeStyle" }, + { + "patternId": "require-unicode-regexp", + "level": "Warning", + "category": "ErrorProne" + }, { "patternId": "semi-spacing", "level": "Info", From 6f92a1f76e7e57fc9383db95e9816390dcc846aa Mon Sep 17 00:00:00 2001 From: Flo Edelmann Date: Fri, 14 Sep 2018 22:40:02 +0200 Subject: [PATCH 05/16] Add prefer-object-spread See https://github.com/eslint/eslint/pull/9955 --- .../docs/description/prefer-object-spread.md | 24 +++++++++++++++++++ src/main/resources/docs/patterns.json | 5 ++++ 2 files changed, 29 insertions(+) create mode 100644 src/main/resources/docs/description/prefer-object-spread.md diff --git a/src/main/resources/docs/description/prefer-object-spread.md b/src/main/resources/docs/description/prefer-object-spread.md new file mode 100644 index 0000000..5e49328 --- /dev/null +++ b/src/main/resources/docs/description/prefer-object-spread.md @@ -0,0 +1,24 @@ +Prefer use of an object spread over `Object.assign`. + +``` +//Bad: +Object.assign({}, foo) +Object.assign({}, {foo: 'bar'}) +Object.assign({ foo: 'bar'}, baz) +Object.assign({ foo: 'bar' }, Object.assign({ bar: 'foo' })) +Object.assign({}, { foo, bar, baz }) +Object.assign({}, { ...baz }) +// Object.assign with a single argument that is an object literal +Object.assign({}); +Object.assign({ foo: bar }); + +//Good: +Object.assign(...foo); +// Any Object.assign call without an object literal as the first argument +Object.assign(foo, { bar: baz }); +Object.assign(foo, Object.assign(bar)); +Object.assign(foo, { bar, baz }) +Object.assign(foo, { ...baz }); +``` + +[Source](http://eslint.org/docs/rules/prefer-object-spread) diff --git a/src/main/resources/docs/patterns.json b/src/main/resources/docs/patterns.json index f75883d..fe98338 100644 --- a/src/main/resources/docs/patterns.json +++ b/src/main/resources/docs/patterns.json @@ -1164,6 +1164,11 @@ "level": "Info", "category": "CodeStyle" }, + { + "patternId": "prefer-object-spread", + "level": "Info", + "category": "CodeStyle" + }, { "patternId": "prefer-spread", "level": "Info", From a955a6ef9f696c2971f68e5efb8e10a0395c547c Mon Sep 17 00:00:00 2001 From: Flo Edelmann Date: Fri, 14 Sep 2018 22:41:53 +0200 Subject: [PATCH 06/16] Add max-classes-per-file rule See https://github.com/eslint/eslint/pull/10163 --- .../docs/description/max-classes-per-file.md | 13 +++++++++++++ src/main/resources/docs/patterns.json | 11 +++++++++++ 2 files changed, 24 insertions(+) create mode 100644 src/main/resources/docs/description/max-classes-per-file.md diff --git a/src/main/resources/docs/description/max-classes-per-file.md b/src/main/resources/docs/description/max-classes-per-file.md new file mode 100644 index 0000000..adea18f --- /dev/null +++ b/src/main/resources/docs/description/max-classes-per-file.md @@ -0,0 +1,13 @@ +This rule enforces that each file may contain only a particular number +of classes and no more. + +``` +//Bad (with parameter 1): +class Foo {} +class Bar {} + +//Good (with parameter 1): +class Foo {} +``` + +[Source](http://eslint.org/docs/rules/max-classes-per-file) diff --git a/src/main/resources/docs/patterns.json b/src/main/resources/docs/patterns.json index fe98338..f669f1e 100644 --- a/src/main/resources/docs/patterns.json +++ b/src/main/resources/docs/patterns.json @@ -1269,6 +1269,17 @@ "level": "Warning", "category": "CodeStyle" }, + { + "patternId": "max-classes-per-file", + "level": "Warning", + "category": "CodeStyle", + "parameters": [ + { + "name": "unnamedParam", + "default": 0 + } + ] + }, { "patternId": "max-depth", "level": "Warning", From 4dc788bfa82dfdd9f44c16d407864713dab15823 Mon Sep 17 00:00:00 2001 From: Flo Edelmann Date: Fri, 14 Sep 2018 22:46:40 +0200 Subject: [PATCH 07/16] Add max-lines-per-function rule I didn't add the full description because it looks wrong to me, but I can't investigate that further now. See https://github.com/eslint/eslint/pull/10188 --- .../description/max-lines-per-function.md | 3 +++ src/main/resources/docs/patterns.json | 23 +++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 src/main/resources/docs/description/max-lines-per-function.md diff --git a/src/main/resources/docs/description/max-lines-per-function.md b/src/main/resources/docs/description/max-lines-per-function.md new file mode 100644 index 0000000..65ad86d --- /dev/null +++ b/src/main/resources/docs/description/max-lines-per-function.md @@ -0,0 +1,3 @@ +This rule enforces a maximum number of lines per function, in order to aid in maintainability and reduce complexity. + +[Source](http://eslint.org/docs/rules/max-lines-per-function) diff --git a/src/main/resources/docs/patterns.json b/src/main/resources/docs/patterns.json index f669f1e..9069585 100644 --- a/src/main/resources/docs/patterns.json +++ b/src/main/resources/docs/patterns.json @@ -1295,6 +1295,29 @@ "level": "Warning", "category": "CodeStyle" }, + { + "patternId": "max-lines-per-function", + "level": "Warning", + "category": "CodeStyle", + "parameters": [ + { + "name": "max", + "default": 50 + }, + { + "name": "skipBlankLines", + "default": false + }, + { + "name": "skipComments", + "default": false + }, + { + "name": "IIFEs", + "default": false + } + ] + }, { "patternId": "max-params", "level": "Warning", From e875dedf4b5e52128d7f4bcee4f83a5d816df956 Mon Sep 17 00:00:00 2001 From: Flo Edelmann Date: Fri, 14 Sep 2018 22:48:29 +0200 Subject: [PATCH 08/16] Add no-misleading-character-class rule See https://github.com/eslint/eslint/pull/10511 --- .../no-misleading-character-class.md | 17 +++++++++++++++++ src/main/resources/docs/patterns.json | 5 +++++ 2 files changed, 22 insertions(+) create mode 100644 src/main/resources/docs/description/no-misleading-character-class.md diff --git a/src/main/resources/docs/description/no-misleading-character-class.md b/src/main/resources/docs/description/no-misleading-character-class.md new file mode 100644 index 0000000..682d9f6 --- /dev/null +++ b/src/main/resources/docs/description/no-misleading-character-class.md @@ -0,0 +1,17 @@ +This rule reports the regular expressions which include multiple code point characters in character class syntax. + +``` +//Bad: +/^[Á]$/u +/^[❇️]$/u +/^[πŸ‘ΆπŸ»]$/u +/^[πŸ‡―πŸ‡΅]$/u +/^[πŸ‘¨β€πŸ‘©β€πŸ‘¦]$/u +/^[πŸ‘]$/ + +//Good: +/^[abc]$/ +/^[πŸ‘]$/u +``` + +[Source](http://eslint.org/docs/rules/no-misleading-character-class) diff --git a/src/main/resources/docs/patterns.json b/src/main/resources/docs/patterns.json index 9069585..ab82da3 100644 --- a/src/main/resources/docs/patterns.json +++ b/src/main/resources/docs/patterns.json @@ -1348,6 +1348,11 @@ "level": "Warning", "category": "ErrorProne" }, + { + "patternId": "no-misleading-character-class", + "level": "Warning", + "category": "ErrorProne" + }, { "patternId": "no-mixed-operators", "level": "Warning", From 3ee7e3621978d1eb44ba74c5c8fae90e79fe15f9 Mon Sep 17 00:00:00 2001 From: Flo Edelmann Date: Fri, 14 Sep 2018 22:50:33 +0200 Subject: [PATCH 09/16] Add no-async-promise-executor rule See https://github.com/eslint/eslint/pull/10661 --- .../description/no-async-promise-executor.md | 31 +++++++++++++++++++ src/main/resources/docs/patterns.json | 5 +++ 2 files changed, 36 insertions(+) create mode 100644 src/main/resources/docs/description/no-async-promise-executor.md diff --git a/src/main/resources/docs/description/no-async-promise-executor.md b/src/main/resources/docs/description/no-async-promise-executor.md new file mode 100644 index 0000000..e9c55c8 --- /dev/null +++ b/src/main/resources/docs/description/no-async-promise-executor.md @@ -0,0 +1,31 @@ +This rule aims to disallow async Promise executor functions. + +``` +//Bad: +const result = new Promise(async (resolve, reject) => { + readFile('foo.txt', function(err, result) { + if (err) { + reject(err); + } else { + resolve(result); + } + }); +}); +const result = new Promise(async (resolve, reject) => { + resolve(await foo); +}); + +//Good: +const result = new Promise((resolve, reject) => { + readFile('foo.txt', function(err, result) { + if (err) { + reject(err); + } else { + resolve(result); + } + }); +}); +const result = Promise.resolve(foo); +``` + +[Source](http://eslint.org/docs/rules/no-async-promise-executor) diff --git a/src/main/resources/docs/patterns.json b/src/main/resources/docs/patterns.json index ab82da3..3752816 100644 --- a/src/main/resources/docs/patterns.json +++ b/src/main/resources/docs/patterns.json @@ -1473,6 +1473,11 @@ "level": "Info", "category": "CodeStyle" }, + { + "patternId": "no-async-promise-executor", + "level": "Error", + "category": "ErrorProne" + }, { "patternId": "no-comma-dangle", "level": "Info", From ff67264ff6cb80b0a8b28f9686d7dab2701dd34a Mon Sep 17 00:00:00 2001 From: Flo Edelmann Date: Sat, 15 Sep 2018 13:24:04 +0200 Subject: [PATCH 10/16] Update eslint to version 5.6.0 --- src/main/resources/docs/patterns.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/docs/patterns.json b/src/main/resources/docs/patterns.json index 3752816..cddf078 100644 --- a/src/main/resources/docs/patterns.json +++ b/src/main/resources/docs/patterns.json @@ -1,6 +1,6 @@ { "name": "eslint", - "version": "5.5.0", + "version": "5.6.0", "patterns": [ { "patternId": "comma-dangle", From c7e40a44fb96ca2addfdf96cdd54bcd638aa6a32 Mon Sep 17 00:00:00 2001 From: Flo Edelmann Date: Sat, 15 Sep 2018 15:08:26 +0200 Subject: [PATCH 11/16] Fix test for indent rule See https://github.com/eslint/eslint/pull/10054 --- src/main/resources/docs/tests/indent.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/resources/docs/tests/indent.js b/src/main/resources/docs/tests/indent.js index a7734cd..7d2eb80 100644 --- a/src/main/resources/docs/tests/indent.js +++ b/src/main/resources/docs/tests/indent.js @@ -3,14 +3,14 @@ if (a) { -//ok + //ok b=c; //#Info: indent b=c; //#Info: indent -function foo(d) { +function foo(d) { //#Info: indent - e=f; + e=f; } } From fcfff4277c233a0fb4346fd8a40466eab705cf48 Mon Sep 17 00:00:00 2001 From: Flo Edelmann Date: Sat, 15 Sep 2018 15:11:52 +0200 Subject: [PATCH 12/16] Fix test for no-invalid-regexp rule See https://github.com/eslint/eslint/pull/10062 --- src/main/resources/docs/tests/no-invalid-regexp.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/resources/docs/tests/no-invalid-regexp.js b/src/main/resources/docs/tests/no-invalid-regexp.js index 34aa4f3..ae22846 100644 --- a/src/main/resources/docs/tests/no-invalid-regexp.js +++ b/src/main/resources/docs/tests/no-invalid-regexp.js @@ -4,7 +4,6 @@ RegExp('['); //#Err: no-invalid-regexp RegExp('.', 'z'); -//#Err: no-invalid-regexp new RegExp('\\'); From b0888a2126630470165007c698d150989f6566d8 Mon Sep 17 00:00:00 2001 From: Flo Edelmann Date: Sat, 15 Sep 2018 15:13:01 +0200 Subject: [PATCH 13/16] Fix test for valid-jsdoc rule See https://github.com/eslint/eslint/pull/9831 --- src/main/resources/docs/tests/valid-jsdoc.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/docs/tests/valid-jsdoc.js b/src/main/resources/docs/tests/valid-jsdoc.js index 1873e63..795149e 100644 --- a/src/main/resources/docs/tests/valid-jsdoc.js +++ b/src/main/resources/docs/tests/valid-jsdoc.js @@ -1,5 +1,5 @@ //#Patterns: valid-jsdoc -//#Issue: {"severity": "Info", "line": 5, "patternId": "valid-jsdoc"} +//#Issue: {"severity": "Info", "line": 7, "patternId": "valid-jsdoc"} //#Issue: {"severity": "Info", "line": 14, "patternId": "valid-jsdoc"} /** //error Missing JSDoc parameter description for 'num1'. @@ -17,4 +17,4 @@ function foo(num1) { */ function foo() { // ... -} \ No newline at end of file +} From d21aab0d7c822853839c2f8e90dc2425f032c4ea Mon Sep 17 00:00:00 2001 From: Flo Edelmann Date: Sat, 15 Sep 2018 15:13:15 +0200 Subject: [PATCH 14/16] Remove test for deprecated no-catch-shadow rule --- .../resources/docs/tests/no-catch-shadow.js | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 src/main/resources/docs/tests/no-catch-shadow.js diff --git a/src/main/resources/docs/tests/no-catch-shadow.js b/src/main/resources/docs/tests/no-catch-shadow.js deleted file mode 100644 index af1f0ee..0000000 --- a/src/main/resources/docs/tests/no-catch-shadow.js +++ /dev/null @@ -1,17 +0,0 @@ -//#Patterns: no-catch-shadow - - - -var err = "x"; -try { - throw "problem"; -//#Warn: no-catch-shadow -} catch (err) { -} - -var err = "x"; -try { - throw "problem"; -} catch (e) { - -} From 274b539658f687b4deb88348ee6bcb599fd799ce Mon Sep 17 00:00:00 2001 From: Flo Edelmann Date: Fri, 12 Oct 2018 22:29:47 +0200 Subject: [PATCH 15/16] Update ESLint to version 5.7.0 --- src/main/resources/docs/patterns.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/docs/patterns.json b/src/main/resources/docs/patterns.json index cddf078..2dd31c9 100644 --- a/src/main/resources/docs/patterns.json +++ b/src/main/resources/docs/patterns.json @@ -1,6 +1,6 @@ { "name": "eslint", - "version": "5.6.0", + "version": "5.7.0", "patterns": [ { "patternId": "comma-dangle", From 102ded17e765e65578b9eb34f135582ed0a52c17 Mon Sep 17 00:00:00 2001 From: Flo Edelmann Date: Fri, 12 Oct 2018 22:30:12 +0200 Subject: [PATCH 16/16] Re-enable no-invalid-regexp rule test --- src/main/resources/docs/tests/no-invalid-regexp.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/resources/docs/tests/no-invalid-regexp.js b/src/main/resources/docs/tests/no-invalid-regexp.js index ae22846..34aa4f3 100644 --- a/src/main/resources/docs/tests/no-invalid-regexp.js +++ b/src/main/resources/docs/tests/no-invalid-regexp.js @@ -4,6 +4,7 @@ RegExp('['); //#Err: no-invalid-regexp RegExp('.', 'z'); +//#Err: no-invalid-regexp new RegExp('\\');