Skip to content

Commit

Permalink
chore: bump to typescript-eslint@3 and eslint@7 (#10437)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Aug 23, 2020
1 parent a91ce8f commit a130fc3
Show file tree
Hide file tree
Showing 13 changed files with 400 additions and 375 deletions.
6 changes: 5 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ module.exports = {
plugins: ['@typescript-eslint/eslint-plugin'],
rules: {
'@typescript-eslint/array-type': ['error', {default: 'generic'}],
'@typescript-eslint/ban-types': 'error',
'@typescript-eslint/ban-types': [
'error',
// TODO: remove these overrides: https://github.com/facebook/jest/issues/10177
{types: {Function: false, object: false, '{}': false}},
],
'@typescript-eslint/no-unused-vars': [
'error',
{argsIgnorePattern: '^_'},
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"@types/jest": "24.0.2",
"@types/node": "~10.14.0",
"@types/which": "^1.3.2",
"@typescript-eslint/eslint-plugin": "^2.30.0",
"@typescript-eslint/parser": "^2.30.0",
"@typescript-eslint/eslint-plugin": "^3.9.1",
"@typescript-eslint/parser": "^3.9.1",
"ansi-regex": "^5.0.0",
"ansi-styles": "^4.2.0",
"babel-eslint": "^10.0.3",
Expand All @@ -32,11 +32,11 @@
"codecov": "^3.0.0",
"debug": "^4.0.1",
"dedent": "^0.7.0",
"eslint": "^6.2.2",
"eslint": "^7.7.0",
"eslint-config-prettier": "^6.1.0",
"eslint-plugin-babel": "^5.1.0",
"eslint-plugin-eslint-comments": "^3.1.2",
"eslint-plugin-flowtype": "^4.2.0",
"eslint-plugin-flowtype": "^5.2.0",
"eslint-plugin-import": "^2.6.0",
"eslint-plugin-jest": "^23.0.2",
"eslint-plugin-jsx-a11y": "^6.0.2",
Expand Down
4 changes: 2 additions & 2 deletions packages/babel-plugin-jest-hoist/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ const extractJestObjExprIfHoistable = <T extends Node>(
return functionLooksHoistable ? jestObjExpr : null;
};

/* eslint-disable sort-keys,@typescript-eslint/explicit-module-boundary-types */
/* eslint-disable sort-keys */
export default (): PluginObj<{
declareJestObjGetterIdentifier: () => Identifier;
jestObjGetterIdentifier?: Identifier;
Expand Down Expand Up @@ -302,4 +302,4 @@ export default (): PluginObj<{
});
},
});
/* eslint-enable sort-keys,@typescript-eslint/explicit-module-boundary-types */
/* eslint-enable */
1 change: 1 addition & 0 deletions packages/expect/src/__tests__/matchers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1790,6 +1790,7 @@ describe('.toHaveProperty()', () => {
get b() {
return 'b';
}
// eslint-disable-next-line accessor-pairs
set setter(val) {
this.val = val;
}
Expand Down
1 change: 0 additions & 1 deletion packages/expect/src/toThrowMatchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ export const createMatcher = (
matcherName: string,
fromPromise?: boolean,
): RawMatcherFn =>
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
function (
this: MatcherState,
received: Function,
Expand Down
14 changes: 7 additions & 7 deletions packages/expect/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,13 @@ export const getPath = (

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

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
export const iterableEquality = (
a: any,
b: any,
/* eslint-enable */
aStack: Array<any> = [],
bStack: Array<any> = [],
): boolean | undefined => {
Expand Down Expand Up @@ -265,10 +267,9 @@ const isObjectWithKeys = (a: any) =>
!(a instanceof Array) &&
!(a instanceof Date);

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

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

Expand Down
2 changes: 1 addition & 1 deletion packages/jest-circus/src/testCaseReportHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {makeSingleTestResult, parseSingleTestResult} from './utils';
const testCaseReportHandler = (
testPath: string,
sendMessageToJest: TestFileEvent,
) => (event: Circus.Event) => {
) => (event: Circus.Event): void => {
switch (event.name) {
case 'test_done': {
const testResult = makeSingleTestResult(event.test);
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-jasmine2/src/isError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

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

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export default function isError(
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
potentialError: any,
): {isError: boolean; message: string | null} {
// duck-type Error, see #2549
Expand Down
18 changes: 9 additions & 9 deletions packages/jest-snapshot/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import {
printReceived,
printSnapshotAndReceived,
} from './printSnapshot';
import type {Context, MatchSnapshotConfig} from './types';
import type {Context, ExpectationResult, MatchSnapshotConfig} from './types';
import * as utils from './utils';

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

const toMatchSnapshot = function (
this: Context,
received: any,
received: unknown,
propertiesOrHint?: object | Config.Path,
hint?: Config.Path,
) {
): ExpectationResult {
const matcherName = 'toMatchSnapshot';
let properties;

Expand Down Expand Up @@ -214,10 +214,10 @@ const toMatchSnapshot = function (

const toMatchInlineSnapshot = function (
this: Context,
received: any,
received: unknown,
propertiesOrSnapshot?: object | string,
inlineSnapshot?: string,
) {
): ExpectationResult {
const matcherName = 'toMatchInlineSnapshot';
let properties;

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

const toThrowErrorMatchingSnapshot = function (
this: Context,
received: any,
received: unknown,
hint: string | undefined, // because error TS1016 for hint?: string
fromPromise: boolean,
) {
): ExpectationResult {
const matcherName = 'toThrowErrorMatchingSnapshot';

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

const toThrowErrorMatchingInlineSnapshot = function (
this: Context,
received: any,
received: unknown,
inlineSnapshot?: string,
fromPromise?: boolean,
) {
): ExpectationResult {
const matcherName = 'toThrowErrorMatchingInlineSnapshot';

if (inlineSnapshot !== undefined && typeof inlineSnapshot !== 'string') {
Expand Down
6 changes: 6 additions & 0 deletions packages/jest-snapshot/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,9 @@ export type MatchSnapshotConfig = {
};

export type SnapshotData = Record<string, string>;

// copied from `expect` - should be shared
export type ExpectationResult = {
pass: boolean;
message: () => string;
};
1 change: 1 addition & 0 deletions packages/jest-validate/src/exampleConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const config: ValidationOptions = {
condition: () => true,
deprecate: () => false,
deprecatedConfig: {
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
key: () => {},
},
error: () => {},
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"devDependencies": {
"@types/merge-stream": "^1.1.2",
"@types/supports-color": "^5.3.0",
"get-stream": "^5.1.0",
"get-stream": "^6.0.0",
"worker-farm": "^1.6.0"
},
"engines": {
Expand Down

0 comments on commit a130fc3

Please sign in to comment.