Skip to content

Commit a130fc3

Browse files
authored
chore: bump to typescript-eslint@3 and eslint@7 (#10437)
1 parent a91ce8f commit a130fc3

File tree

13 files changed

+400
-375
lines changed

13 files changed

+400
-375
lines changed

.eslintrc.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ module.exports = {
2121
plugins: ['@typescript-eslint/eslint-plugin'],
2222
rules: {
2323
'@typescript-eslint/array-type': ['error', {default: 'generic'}],
24-
'@typescript-eslint/ban-types': 'error',
24+
'@typescript-eslint/ban-types': [
25+
'error',
26+
// TODO: remove these overrides: https://github.com/facebook/jest/issues/10177
27+
{types: {Function: false, object: false, '{}': false}},
28+
],
2529
'@typescript-eslint/no-unused-vars': [
2630
'error',
2731
{argsIgnorePattern: '^_'},

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
"@types/jest": "24.0.2",
2020
"@types/node": "~10.14.0",
2121
"@types/which": "^1.3.2",
22-
"@typescript-eslint/eslint-plugin": "^2.30.0",
23-
"@typescript-eslint/parser": "^2.30.0",
22+
"@typescript-eslint/eslint-plugin": "^3.9.1",
23+
"@typescript-eslint/parser": "^3.9.1",
2424
"ansi-regex": "^5.0.0",
2525
"ansi-styles": "^4.2.0",
2626
"babel-eslint": "^10.0.3",
@@ -32,11 +32,11 @@
3232
"codecov": "^3.0.0",
3333
"debug": "^4.0.1",
3434
"dedent": "^0.7.0",
35-
"eslint": "^6.2.2",
35+
"eslint": "^7.7.0",
3636
"eslint-config-prettier": "^6.1.0",
3737
"eslint-plugin-babel": "^5.1.0",
3838
"eslint-plugin-eslint-comments": "^3.1.2",
39-
"eslint-plugin-flowtype": "^4.2.0",
39+
"eslint-plugin-flowtype": "^5.2.0",
4040
"eslint-plugin-import": "^2.6.0",
4141
"eslint-plugin-jest": "^23.0.2",
4242
"eslint-plugin-jsx-a11y": "^6.0.2",

packages/babel-plugin-jest-hoist/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ const extractJestObjExprIfHoistable = <T extends Node>(
241241
return functionLooksHoistable ? jestObjExpr : null;
242242
};
243243

244-
/* eslint-disable sort-keys,@typescript-eslint/explicit-module-boundary-types */
244+
/* eslint-disable sort-keys */
245245
export default (): PluginObj<{
246246
declareJestObjGetterIdentifier: () => Identifier;
247247
jestObjGetterIdentifier?: Identifier;
@@ -302,4 +302,4 @@ export default (): PluginObj<{
302302
});
303303
},
304304
});
305-
/* eslint-enable sort-keys,@typescript-eslint/explicit-module-boundary-types */
305+
/* eslint-enable */

packages/expect/src/__tests__/matchers.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1790,6 +1790,7 @@ describe('.toHaveProperty()', () => {
17901790
get b() {
17911791
return 'b';
17921792
}
1793+
// eslint-disable-next-line accessor-pairs
17931794
set setter(val) {
17941795
this.val = val;
17951796
}

packages/expect/src/toThrowMatchers.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ export const createMatcher = (
7676
matcherName: string,
7777
fromPromise?: boolean,
7878
): RawMatcherFn =>
79-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
8079
function (
8180
this: MatcherState,
8281
received: Function,

packages/expect/src/utils.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,13 @@ export const getPath = (
9494

9595
// Strip properties from object that are not present in the subset. Useful for
9696
// printing the diff for toMatchObject() without adding unrelated noise.
97-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
97+
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
9898
export const getObjectSubset = (
9999
object: any,
100100
subset: any,
101101
seenReferences: WeakMap<object, boolean> = new WeakMap(),
102102
): any => {
103+
/* eslint-enable */
103104
if (Array.isArray(object)) {
104105
if (Array.isArray(subset) && subset.length === object.length) {
105106
// The map method returns correct subclass of subset.
@@ -138,10 +139,11 @@ const IteratorSymbol = Symbol.iterator;
138139
const hasIterator = (object: any) =>
139140
!!(object != null && object[IteratorSymbol]);
140141

141-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
142+
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
142143
export const iterableEquality = (
143144
a: any,
144145
b: any,
146+
/* eslint-enable */
145147
aStack: Array<any> = [],
146148
bStack: Array<any> = [],
147149
): boolean | undefined => {
@@ -265,10 +267,9 @@ const isObjectWithKeys = (a: any) =>
265267
!(a instanceof Array) &&
266268
!(a instanceof Date);
267269

268-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
269270
export const subsetEquality = (
270-
object: any,
271-
subset: any,
271+
object: unknown,
272+
subset: unknown,
272273
): boolean | undefined => {
273274
// subsetEquality needs to keep track of the references
274275
// it has already visited to avoid infinite loops in case
@@ -357,8 +358,7 @@ export const isError = (value: unknown): value is Error => {
357358
}
358359
};
359360

360-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
361-
export function emptyObject(obj: any): boolean {
361+
export function emptyObject(obj: unknown): boolean {
362362
return obj && typeof obj === 'object' ? !Object.keys(obj).length : false;
363363
}
364364

packages/jest-circus/src/testCaseReportHandler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {makeSingleTestResult, parseSingleTestResult} from './utils';
1212
const testCaseReportHandler = (
1313
testPath: string,
1414
sendMessageToJest: TestFileEvent,
15-
) => (event: Circus.Event) => {
15+
) => (event: Circus.Event): void => {
1616
switch (event.name) {
1717
case 'test_done': {
1818
const testResult = makeSingleTestResult(event.test);

packages/jest-jasmine2/src/isError.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
import prettyFormat = require('pretty-format');
99

10-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
1110
export default function isError(
11+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
1212
potentialError: any,
1313
): {isError: boolean; message: string | null} {
1414
// duck-type Error, see #2549

packages/jest-snapshot/src/index.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import {
3838
printReceived,
3939
printSnapshotAndReceived,
4040
} from './printSnapshot';
41-
import type {Context, MatchSnapshotConfig} from './types';
41+
import type {Context, ExpectationResult, MatchSnapshotConfig} from './types';
4242
import * as utils from './utils';
4343

4444
const DID_NOT_THROW = 'Received function did not throw'; // same as toThrow
@@ -156,10 +156,10 @@ const cleanup = (
156156

157157
const toMatchSnapshot = function (
158158
this: Context,
159-
received: any,
159+
received: unknown,
160160
propertiesOrHint?: object | Config.Path,
161161
hint?: Config.Path,
162-
) {
162+
): ExpectationResult {
163163
const matcherName = 'toMatchSnapshot';
164164
let properties;
165165

@@ -214,10 +214,10 @@ const toMatchSnapshot = function (
214214

215215
const toMatchInlineSnapshot = function (
216216
this: Context,
217-
received: any,
217+
received: unknown,
218218
propertiesOrSnapshot?: object | string,
219219
inlineSnapshot?: string,
220-
) {
220+
): ExpectationResult {
221221
const matcherName = 'toMatchInlineSnapshot';
222222
let properties;
223223

@@ -414,10 +414,10 @@ const _toMatchSnapshot = (config: MatchSnapshotConfig) => {
414414

415415
const toThrowErrorMatchingSnapshot = function (
416416
this: Context,
417-
received: any,
417+
received: unknown,
418418
hint: string | undefined, // because error TS1016 for hint?: string
419419
fromPromise: boolean,
420-
) {
420+
): ExpectationResult {
421421
const matcherName = 'toThrowErrorMatchingSnapshot';
422422

423423
// Future breaking change: Snapshot hint must be a string
@@ -437,10 +437,10 @@ const toThrowErrorMatchingSnapshot = function (
437437

438438
const toThrowErrorMatchingInlineSnapshot = function (
439439
this: Context,
440-
received: any,
440+
received: unknown,
441441
inlineSnapshot?: string,
442442
fromPromise?: boolean,
443-
) {
443+
): ExpectationResult {
444444
const matcherName = 'toThrowErrorMatchingInlineSnapshot';
445445

446446
if (inlineSnapshot !== undefined && typeof inlineSnapshot !== 'string') {

packages/jest-snapshot/src/types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,9 @@ export type MatchSnapshotConfig = {
2323
};
2424

2525
export type SnapshotData = Record<string, string>;
26+
27+
// copied from `expect` - should be shared
28+
export type ExpectationResult = {
29+
pass: boolean;
30+
message: () => string;
31+
};

0 commit comments

Comments
 (0)