Skip to content

Commit 5eed973

Browse files
authored
chore(lint): disable @typescript-eslint/no-unused-vars rule for tests and mocks (#12301)
1 parent 5160ae0 commit 5eed973

File tree

10 files changed

+24
-19
lines changed

10 files changed

+24
-19
lines changed

.eslintrc.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ module.exports = {
100100
'packages/expect/src/matchers.ts',
101101
'packages/expect/src/print.ts',
102102
'packages/expect/src/toThrowMatchers.ts',
103-
'packages/expect/src/types.ts',
104103
'packages/expect/src/utils.ts',
105104
'packages/jest-core/src/ReporterDispatcher.ts',
106105
'packages/jest-core/src/TestScheduler.ts',
@@ -259,11 +258,13 @@ module.exports = {
259258
'website/**',
260259
'**/__mocks__/**',
261260
'**/__tests__/**',
261+
'**/__typetests__/**',
262262
'**/__performance_tests__/**',
263263
'packages/diff-sequences/perf/index.js',
264264
'packages/pretty-format/perf/test.js',
265265
],
266266
rules: {
267+
'@typescript-eslint/no-unused-vars': 'off',
267268
'import/no-unresolved': 'off',
268269
'no-console': 'off',
269270
'no-unused-vars': 'off',

e2e/coverage-remapping/covered.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
/* eslint-disable local/ban-types-eventually, @typescript-eslint/no-unused-vars */
8+
/* eslint-disable local/ban-types-eventually */
99

1010
export = function difference(a: number, b: number): number {
1111
const branch1: boolean = true ? 1 : 0;

e2e/stack-trace-source-maps-with-coverage/lib.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*/
7-
// @ts-expect-error
8-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
7+
98
interface NotUsedButTakesUpLines {
109
a: number;
1110
b: string;

e2e/stack-trace-source-maps/__tests__/fails.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*/
7-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
7+
88
interface NotUsedButTakesUpLines {
99
a: number;
1010
b: string;

packages/expect/__typetests__/expect.test.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8+
import {expectError} from 'tsd-lite';
89
import type * as expect from 'expect';
910

10-
export type M = expect.Matchers<void, unknown>;
11-
export type N = expect.Matchers<void>;
12-
// @ts-expect-error: Generic type 'Matchers<R, T>' requires between 1 and 2 type arguments.
13-
export type E = expect.Matchers;
11+
type M = expect.Matchers<void, unknown>;
12+
type N = expect.Matchers<void>;
13+
14+
expectError(() => {
15+
type E = expect.Matchers;
16+
});

packages/expect/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@
2626
},
2727
"devDependencies": {
2828
"@jest/test-utils": "^27.4.6",
29+
"@tsd/typescript": "~4.1.5",
2930
"chalk": "^4.0.0",
3031
"fast-check": "^2.0.0",
31-
"immutable": "^4.0.0"
32+
"immutable": "^4.0.0",
33+
"tsd-lite": "^0.5.1"
3234
},
3335
"engines": {
3436
"node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0"

packages/jest-matcher-utils/src/__tests__/Replaceable.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ describe('Replaceable', () => {
3939

4040
test('init with other type should throw error', () => {
4141
expect(() => {
42-
//eslint-disable-next-line @typescript-eslint/no-unused-vars
4342
const replaceable = new Replaceable(new Date());
4443
}).toThrow('Type date is not support in Replaceable!');
4544
});

packages/jest-snapshot/src/__tests__/utils.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,7 @@ test('escaping', () => {
178178
'exports[`key`] = `"\'\\\\`;\n',
179179
);
180180

181-
// @ts-expect-error
182-
const exports = {}; // eslint-disable-line @typescript-eslint/no-unused-vars
181+
const exports = {};
183182
// eslint-disable-next-line no-eval
184183
const readData = eval('var exports = {}; ' + writtenData + ' exports');
185184
expect(readData).toEqual({key: data});

packages/jest-types/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
},
2929
"devDependencies": {
3030
"@tsd/typescript": "~4.1.5",
31-
"tsd-lite": "^0.5.0"
31+
"tsd-lite": "^0.5.1"
3232
},
3333
"publishConfig": {
3434
"access": "public"

yarn.lock

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2803,7 +2803,7 @@ __metadata:
28032803
"@types/node": "*"
28042804
"@types/yargs": ^16.0.0
28052805
chalk: ^4.0.0
2806-
tsd-lite: ^0.5.0
2806+
tsd-lite: ^0.5.1
28072807
languageName: unknown
28082808
linkType: soft
28092809

@@ -9883,12 +9883,14 @@ __metadata:
98839883
dependencies:
98849884
"@jest/test-utils": ^27.4.6
98859885
"@jest/types": ^27.4.2
9886+
"@tsd/typescript": ~4.1.5
98869887
chalk: ^4.0.0
98879888
fast-check: ^2.0.0
98889889
immutable: ^4.0.0
98899890
jest-get-type: ^27.4.0
98909891
jest-matcher-utils: ^27.4.6
98919892
jest-message-util: ^27.4.6
9893+
tsd-lite: ^0.5.1
98929894
languageName: unknown
98939895
linkType: soft
98949896

@@ -20663,12 +20665,12 @@ [email protected]:
2066320665
languageName: node
2066420666
linkType: hard
2066520667

20666-
"tsd-lite@npm:^0.5.0":
20667-
version: 0.5.0
20668-
resolution: "tsd-lite@npm:0.5.0"
20668+
"tsd-lite@npm:^0.5.0, tsd-lite@npm:^0.5.1":
20669+
version: 0.5.1
20670+
resolution: "tsd-lite@npm:0.5.1"
2066920671
peerDependencies:
2067020672
"@tsd/typescript": ^3.8.3 || ^4.0.7
20671-
checksum: 6590ca24f2ac07e961ec3786a94269c26bfa93b09c3d397f5f3c3b09fedee515dbe96aa09de4c24ce3a42a3bbe47543f0a30aa06770b34b4a6eb8b61e92dce21
20673+
checksum: 875cf890f3cc10c0974a4588568ee9e5202b047480cd261dbe1e7487fb25b56df6217b2a3e95b5cc1a88d27e0e1f13299b3048b908afe2da782369e381ad083c
2067220674
languageName: node
2067320675
linkType: hard
2067420676

0 commit comments

Comments
 (0)