Skip to content
This repository has been archived by the owner on Feb 21, 2020. It is now read-only.

Commit

Permalink
Merge pull request #103 from FloEdelmann/eslint-5.5.0
Browse files Browse the repository at this point in the history
Update eslint to version 5.7.0
  • Loading branch information
rtfpessoa committed Oct 14, 2018
2 parents a0f3485 + 375359a commit f38d4b9
Show file tree
Hide file tree
Showing 12 changed files with 209 additions and 54 deletions.
13 changes: 13 additions & 0 deletions 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)
3 changes: 3 additions & 0 deletions 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)
31 changes: 31 additions & 0 deletions 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)
26 changes: 0 additions & 26 deletions src/main/resources/docs/description/no-catch-shadow.md

This file was deleted.

@@ -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)
24 changes: 24 additions & 0 deletions 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)
39 changes: 39 additions & 0 deletions 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)
17 changes: 17 additions & 0 deletions 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)
66 changes: 60 additions & 6 deletions src/main/resources/docs/patterns.json
@@ -1,6 +1,6 @@
{
"name": "eslint",
"version": "4.15.0",
"version": "5.7.0",
"patterns": [
{
"patternId": "comma-dangle",
Expand Down Expand Up @@ -522,11 +522,6 @@
}
]
},
{
"patternId": "no-catch-shadow",
"level": "Warning",
"category": "ErrorProne"
},
{
"patternId": "no-delete-var",
"level": "Warning",
Expand Down Expand Up @@ -988,11 +983,21 @@
}
]
},
{
"patternId": "require-atomic-updates",
"level": "Error",
"category": "ErrorProne"
},
{
"patternId": "require-jsdoc",
"level": "Info",
"category": "CodeStyle"
},
{
"patternId": "require-unicode-regexp",
"level": "Warning",
"category": "ErrorProne"
},
{
"patternId": "semi-spacing",
"level": "Info",
Expand Down Expand Up @@ -1159,6 +1164,11 @@
"level": "Info",
"category": "CodeStyle"
},
{
"patternId": "prefer-object-spread",
"level": "Info",
"category": "CodeStyle"
},
{
"patternId": "prefer-spread",
"level": "Info",
Expand Down Expand Up @@ -1259,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",
Expand All @@ -1274,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",
Expand Down Expand Up @@ -1304,6 +1348,11 @@
"level": "Warning",
"category": "ErrorProne"
},
{
"patternId": "no-misleading-character-class",
"level": "Warning",
"category": "ErrorProne"
},
{
"patternId": "no-mixed-operators",
"level": "Warning",
Expand Down Expand Up @@ -1424,6 +1473,11 @@
"level": "Info",
"category": "CodeStyle"
},
{
"patternId": "no-async-promise-executor",
"level": "Error",
"category": "ErrorProne"
},
{
"patternId": "no-comma-dangle",
"level": "Info",
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/docs/tests/indent.js
Expand Up @@ -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;
}
}
17 changes: 0 additions & 17 deletions src/main/resources/docs/tests/no-catch-shadow.js

This file was deleted.

4 changes: 2 additions & 2 deletions 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'.
Expand All @@ -17,4 +17,4 @@ function foo(num1) {
*/
function foo() {
// ...
}
}

0 comments on commit f38d4b9

Please sign in to comment.