Skip to content

Commit 388fd8c

Browse files
SimenBcpojer
authored andcommitted
Upgrade eslint (jestjs#3897)
1 parent 5e28dda commit 388fd8c

File tree

22 files changed

+297
-438
lines changed

22 files changed

+297
-438
lines changed

.eslintignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
**/coverage/**
22
**/node_modules/**
33
bin/
4-
docs/
54
flow-typed/**
65
packages/*/build/**
76
packages/*/build-es5/**

.eslintrc-docs.json

-12
This file was deleted.

.eslintrc.js

+38-9
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,58 @@
77
*/
88

99
module.exports = {
10-
'extends': [
10+
extends: [
1111
'./packages/eslint-config-fb-strict/index.js',
12-
'plugin:import/errors'
12+
'plugin:import/errors',
1313
],
14-
'parser': 'babel-eslint',
15-
'rules': {
14+
parser: 'babel-eslint',
15+
rules: {
1616
'computed-property-spacing': 0,
1717
'flowtype/boolean-style': 2,
1818
'flowtype/no-primitive-constructor-types': 2,
1919
'flowtype/require-valid-file-annotation': 2,
2020
'max-len': 0,
2121
'no-multiple-empty-lines': 1,
2222
'import/no-duplicates': 2,
23-
'import/no-unresolved': [2, { 'ignore': ['^types/'] }],
23+
'import/no-unresolved': [2, { ignore: ['^types/'] }],
2424
// This has to be disabled until all type and module imports are combined
2525
// https://github.com/benmosher/eslint-plugin-import/issues/645
2626
'import/order': 0,
2727
// These has to be disabled until the whole code base is converted to ESM
2828
'import/default': 0,
2929
'import/named': 0,
3030
},
31-
'plugins': [
32-
'markdown',
33-
'import'
34-
]
31+
plugins: ['markdown', 'import'],
32+
overrides: [
33+
// to make it more suitable for running on code examples in docs/ folder
34+
{
35+
files: ['*.md'],
36+
rules: {
37+
'react/react-in-jsx-scope': 0,
38+
'react/jsx-no-undef': 0,
39+
'jest/no-focused-tests': 0,
40+
'jest/valid-expect': 0,
41+
'jest/no-identical-title': 0,
42+
'no-undef': 0,
43+
'no-unused-vars': 0,
44+
'consistent-return': 0,
45+
'import/no-unresolved': 0,
46+
'sort-keys': 0
47+
},
48+
},
49+
{
50+
files: ['examples/**/*'],
51+
rules: {
52+
'babel/func-params-comma-dangle': 0,
53+
'import/order': 0,
54+
'import/no-unresolved': [2, { 'ignore': ['^react-native$'] }]
55+
},
56+
},
57+
{
58+
files: ['scripts/**/*', 'integration_tests/**/*'],
59+
rules: {
60+
'babel/func-params-comma-dangle': 0,
61+
},
62+
},
63+
],
3564
};

blog/2016-07-27-jest-14.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ By building a test renderer that targets no specific platform we are finally abl
5454

5555
You can start using Jest with react-native by running `npm install --save-dev jest-react-native` and by adding the preset to your Jest configuration:
5656

57-
```javascript
57+
```json
5858
"jest": {
5959
"preset": "jest-react-native"
6060
}

docs/en/MockFunctions.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ invokes a callback for each item in a supplied array.
2525

2626
```javascript
2727
function forEach(items, callback) {
28-
for (var index = 0; index < items.length; index++) {
28+
for (let index = 0; index < items.length; index++) {
2929
callback(items[index]);
3030
}
3131
}

examples/.eslintrc

-7
This file was deleted.

integration_tests/.eslintrc

-5
This file was deleted.

integration_tests/__tests__/iterator-to-null-test.js

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* LICENSE file in the root directory of this source tree. An additional grant
66
* of patent rights can be found in the PATENTS file in the same directory.
77
*/
8+
/* eslint-disable no-extend-native */
89

910
'use strict';
1011

package.json

+6-7
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020
"codecov": "^1.0.1",
2121
"cross-spawn": "^5.1.0",
2222
"enzyme": "^2.8.2",
23-
"eslint": "^3.17.1",
23+
"eslint": "^4.1.0",
2424
"eslint-plugin-babel": "^4.1.1",
25-
"eslint-plugin-flowtype": "^2.30.3",
26-
"eslint-plugin-import": "^2.2.0",
27-
"eslint-plugin-markdown": "^1.0.0-beta.4",
28-
"eslint-plugin-react": "^6.7.1",
25+
"eslint-plugin-flowtype": "^2.34.0",
26+
"eslint-plugin-import": "^2.6.0",
27+
"eslint-plugin-markdown": "^1.0.0-beta.6",
28+
"eslint-plugin-react": "^7.1.0",
2929
"flow-bin": "^0.48.0",
3030
"glob": "^7.1.1",
3131
"graceful-fs": "^4.1.11",
@@ -57,8 +57,7 @@
5757
"clean-all": "rm -rf ./node_modules && rm -rf ./packages/*/node_modules && rm -rf ./integration_tests/*/*/node_modules && yarn run build-clean",
5858
"jest": "node ./packages/jest-cli/bin/jest.js",
5959
"jest-coverage": "yarn run jest --silent -- --coverage",
60-
"lint": "yarn run lint-prettier --silent && eslint . --cache && yarn run lint-docs --silent",
61-
"lint-docs": "eslint --config ./.eslintrc-docs.json --no-ignore --ext md ./docs/*.md",
60+
"lint": "yarn run lint-prettier --silent && eslint . --cache --ext js,md",
6261
"lint-es5-build": "eslint --no-eslintrc --no-ignore --env=browser packages/*/build-es5",
6362
"lint-prettier": "node scripts/prettier.js lint",
6463
"prettier": "node scripts/prettier.js write",

packages/babel-plugin-jest-hoist/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ $ babel --plugins jest-hoist script.js
2929
### Via Node API
3030

3131
```javascript
32-
require("babel-core").transform("code", {
33-
plugins: ["jest-hoist"]
32+
require('babel-core').transform('code', {
33+
plugins: ['jest-hoist'],
3434
});
3535
```

packages/babel-preset-jest/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ $ babel script.js --presets jest
2929
### Via Node API
3030

3131
```javascript
32-
require("babel-core").transform("code", {
33-
presets: ["jest"]
32+
require('babel-core').transform('code', {
33+
presets: ['jest'],
3434
});
3535
```

packages/eslint-config-fb-strict/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ module.exports = Object.assign({}, fbjsConfig, {
6363
'semi': [2, 'always'],
6464
'sort-keys': [2],
6565
'space-before-blocks': [2],
66-
'space-before-function-paren': [2, 'never'],
66+
'space-before-function-paren': [2, {anonymous: 'never', asyncArrow: 'always', named: 'never'}],
6767
'space-in-parens': [2, 'never'],
6868
}),
6969
});

packages/eslint-plugin-jest/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ This plugin exports a recommended configuration that enforces good testing pract
6161

6262
To enable this configuration use the `extends` property in your `.eslintrc` config file:
6363

64-
```js
64+
```json
6565
{
6666
"extends": ["plugin:jest/recommended"]
6767
}

packages/eslint-plugin-jest/docs/rules/no-disabled-tests.md

+15-15
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,24 @@ This rule looks for every `describe.skip`, `it.skip`, `test.skip`, `xdescribe`,
1010
The following patterns are considered warnings:
1111

1212
```js
13-
describe.skip("foo", function () {});
14-
it.skip("foo", function () {});
15-
describe["skip"]("bar", function () {});
16-
it["skip"]("bar", function () {});
17-
test.skip("foo", function () {});
18-
test["skip"]("bar", function () {});
19-
xdescribe("foo", function () {});
20-
xit("foo", function () {});
21-
xtest("bar", function () {});
13+
describe.skip('foo', () => {});
14+
it.skip('foo', () => {});
15+
describe['skip']('bar', () => {});
16+
it['skip']('bar', () => {});
17+
test.skip('foo', () => {});
18+
test['skip']('bar', () => {});
19+
xdescribe('foo', () => {});
20+
xit('foo', () => {});
21+
xtest('bar', () => {});
2222
```
2323

2424
These patterns would not be considered warnings:
2525

2626
```js
27-
describe("foo", function () {});
28-
it("foo", function () {});
29-
describe.only("bar", function () {});
30-
it.only("bar", function () {});
31-
test("foo", function () {});
32-
test.only("bar", function () {});
27+
describe('foo', () => {});
28+
it('foo', () => {});
29+
describe.only('bar', () => {});
30+
it.only('bar', () => {});
31+
test('foo', () => {});
32+
test.only('bar', () => {});
3333
```

packages/eslint-plugin-jest/docs/rules/no-focused-tests.md

+16-16
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,31 @@ This rule looks for every `describe.only`, `it.only`, `test.only`, `fdescribe`,
1212
Of course there are some edge-cases which can’t be detected by this rule e.g.:
1313

1414
```js
15-
var describeOnly = describe.only;
15+
const describeOnly = describe.only;
1616
describeOnly.apply(describe);
1717
```
1818

1919
The following patterns are considered warnings:
2020

2121
```js
22-
describe.only("foo", function () {});
23-
it.only("foo", function () {});
24-
describe["only"]("bar", function () {});
25-
it["only"]("bar", function () {});
26-
test.only("foo", function () {});
27-
test["only"]("bar", function () {});
28-
fdescribe("foo", function () {});
29-
fit("foo", function () {});
30-
ftest("bar", function () {});
22+
describe.only('foo', () => {});
23+
it.only('foo', () => {});
24+
describe['only']('bar', () => {});
25+
it['only']('bar', () => {});
26+
test.only('foo', () => {});
27+
test['only']('bar', () => {});
28+
fdescribe('foo', () => {});
29+
fit('foo', () => {});
30+
ftest('bar', () => {});
3131
```
3232

3333
These patterns would not be considered warnings:
3434

3535
```js
36-
describe("foo", function () {});
37-
it("foo", function () {});
38-
describe.skip("bar", function () {});
39-
it.skip("bar", function () {});
40-
test("foo", function () {});
41-
test.skip("bar", function () {});
36+
describe('foo', () => {});
37+
it('foo', () => {});
38+
describe.skip('bar', () => {});
39+
it.skip('bar', () => {});
40+
test('foo', () => {});
41+
test.skip('bar', () => {});
4242
```

packages/eslint-plugin-jest/docs/rules/no-identical-title.md

+13-13
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ This rule looks at the title of every test and test suites. It will report when
99
The following patterns are considered warnings:
1010

1111
```js
12-
describe('foo', function () {
13-
it('should do bar', function() {});
14-
it('should do bar', function() {}); // Has the same title as the previous test
12+
describe('foo', () => {
13+
it('should do bar', () => {});
14+
it('should do bar', () => {}); // Has the same title as the previous test
1515

16-
describe('baz', function() {
16+
describe('baz', () => {
1717
// ...
1818
});
1919

20-
describe('baz', function() { // Has the same title as a previous test suite
20+
describe('baz', () => { // Has the same title as a previous test suite
2121
// ...
2222
});
2323
});
@@ -26,20 +26,20 @@ describe('foo', function () {
2626
These patterns would not be considered warnings:
2727

2828
```js
29-
describe('foo', function () {
30-
it('should do foo', function() {});
31-
it('should do bar', function() {});
29+
describe('foo', () => {
30+
it('should do foo', () => {});
31+
it('should do bar', () => {});
3232

3333
// Has the same name as a parent test suite, which is fine
34-
describe('foo', function() {
34+
describe('foo', () => {
3535
// Has the same name as a test in a parent test suite, which is fine
36-
it('should do foo', function() {});
37-
it('should work', function() {});
36+
it('should do foo', () => {});
37+
it('should work', () => {});
3838
});
3939

40-
describe('baz', function() { // Has the same title as a previous test suite
40+
describe('baz', () => { // Has the same title as a previous test suite
4141
// Has the same name as a test in a sibling test suite, which is fine
42-
it('should work', function() {});
42+
it('should work', () => {});
4343
});
4444
});
4545
```

packages/eslint-plugin-jest/docs/rules/valid-expect.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ expect('something');
1515
or when a matcher function was not called, e.g.:
1616

1717
```js
18-
expect(true).toBeDefined
18+
expect(true).toBeDefined;
1919
```
2020

2121
This rule is enabled by default.

packages/jest-mock/README.md

+11-11
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ values for its mocks member and its return values.
2525

2626
Inspects the argument and returns its schema in the following recursive format:
2727

28-
```js
28+
```
2929
{
3030
type: ...
3131
members : {}
@@ -40,18 +40,18 @@ prototype should always be `object`. For instance, a simple class might be
4040
defined like this:
4141

4242
```js
43-
{
43+
const classDef = {
4444
type: 'function',
4545
members: {
4646
staticMethod: {type: 'function'},
4747
prototype: {
4848
type: 'object',
4949
members: {
50-
instanceMethod: {type: 'function'}
51-
}
52-
}
53-
}
54-
}
50+
instanceMethod: {type: 'function'},
51+
},
52+
},
53+
},
54+
};
5555
```
5656

5757
Metadata may also contain references to other objects defined within the
@@ -61,13 +61,13 @@ same metadata object. The metadata for the referent must be marked with
6161
For instance, this metadata blob:
6262

6363
```js
64-
{
64+
const refID = {
6565
type: 'object',
6666
refID: 1,
6767
members: {
68-
self: {ref: 1}
69-
}
70-
}
68+
self: {ref: 1},
69+
},
70+
};
7171
```
7272

7373
defines an object with a slot named `self` that refers back to the object.

0 commit comments

Comments
 (0)