Skip to content

Commit

Permalink
chore(lint): disable @typescript-eslint/no-unused-vars rule for tests…
Browse files Browse the repository at this point in the history
… and mocks (#12301)
  • Loading branch information
mrazauskas authored Feb 5, 2022
1 parent 5160ae0 commit 5eed973
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 19 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ module.exports = {
'packages/expect/src/matchers.ts',
'packages/expect/src/print.ts',
'packages/expect/src/toThrowMatchers.ts',
'packages/expect/src/types.ts',
'packages/expect/src/utils.ts',
'packages/jest-core/src/ReporterDispatcher.ts',
'packages/jest-core/src/TestScheduler.ts',
Expand Down Expand Up @@ -259,11 +258,13 @@ module.exports = {
'website/**',
'**/__mocks__/**',
'**/__tests__/**',
'**/__typetests__/**',
'**/__performance_tests__/**',
'packages/diff-sequences/perf/index.js',
'packages/pretty-format/perf/test.js',
],
rules: {
'@typescript-eslint/no-unused-vars': 'off',
'import/no-unresolved': 'off',
'no-console': 'off',
'no-unused-vars': 'off',
Expand Down
2 changes: 1 addition & 1 deletion e2e/coverage-remapping/covered.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

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

export = function difference(a: number, b: number): number {
const branch1: boolean = true ? 1 : 0;
Expand Down
3 changes: 1 addition & 2 deletions e2e/stack-trace-source-maps-with-coverage/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// @ts-expect-error
// eslint-disable-next-line @typescript-eslint/no-unused-vars

interface NotUsedButTakesUpLines {
a: number;
b: string;
Expand Down
2 changes: 1 addition & 1 deletion e2e/stack-trace-source-maps/__tests__/fails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars

interface NotUsedButTakesUpLines {
a: number;
b: string;
Expand Down
11 changes: 7 additions & 4 deletions packages/expect/__typetests__/expect.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
* LICENSE file in the root directory of this source tree.
*/

import {expectError} from 'tsd-lite';
import type * as expect from 'expect';

export type M = expect.Matchers<void, unknown>;
export type N = expect.Matchers<void>;
// @ts-expect-error: Generic type 'Matchers<R, T>' requires between 1 and 2 type arguments.
export type E = expect.Matchers;
type M = expect.Matchers<void, unknown>;
type N = expect.Matchers<void>;

expectError(() => {
type E = expect.Matchers;
});
4 changes: 3 additions & 1 deletion packages/expect/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@
},
"devDependencies": {
"@jest/test-utils": "^27.4.6",
"@tsd/typescript": "~4.1.5",
"chalk": "^4.0.0",
"fast-check": "^2.0.0",
"immutable": "^4.0.0"
"immutable": "^4.0.0",
"tsd-lite": "^0.5.1"
},
"engines": {
"node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ describe('Replaceable', () => {

test('init with other type should throw error', () => {
expect(() => {
//eslint-disable-next-line @typescript-eslint/no-unused-vars
const replaceable = new Replaceable(new Date());
}).toThrow('Type date is not support in Replaceable!');
});
Expand Down
3 changes: 1 addition & 2 deletions packages/jest-snapshot/src/__tests__/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,7 @@ test('escaping', () => {
'exports[`key`] = `"\'\\\\`;\n',
);

// @ts-expect-error
const exports = {}; // eslint-disable-line @typescript-eslint/no-unused-vars
const exports = {};
// eslint-disable-next-line no-eval
const readData = eval('var exports = {}; ' + writtenData + ' exports');
expect(readData).toEqual({key: data});
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
},
"devDependencies": {
"@tsd/typescript": "~4.1.5",
"tsd-lite": "^0.5.0"
"tsd-lite": "^0.5.1"
},
"publishConfig": {
"access": "public"
Expand Down
12 changes: 7 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2803,7 +2803,7 @@ __metadata:
"@types/node": "*"
"@types/yargs": ^16.0.0
chalk: ^4.0.0
tsd-lite: ^0.5.0
tsd-lite: ^0.5.1
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -9883,12 +9883,14 @@ __metadata:
dependencies:
"@jest/test-utils": ^27.4.6
"@jest/types": ^27.4.2
"@tsd/typescript": ~4.1.5
chalk: ^4.0.0
fast-check: ^2.0.0
immutable: ^4.0.0
jest-get-type: ^27.4.0
jest-matcher-utils: ^27.4.6
jest-message-util: ^27.4.6
tsd-lite: ^0.5.1
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -20663,12 +20665,12 @@ [email protected]:
languageName: node
linkType: hard

"tsd-lite@npm:^0.5.0":
version: 0.5.0
resolution: "tsd-lite@npm:0.5.0"
"tsd-lite@npm:^0.5.0, tsd-lite@npm:^0.5.1":
version: 0.5.1
resolution: "tsd-lite@npm:0.5.1"
peerDependencies:
"@tsd/typescript": ^3.8.3 || ^4.0.7
checksum: 6590ca24f2ac07e961ec3786a94269c26bfa93b09c3d397f5f3c3b09fedee515dbe96aa09de4c24ce3a42a3bbe47543f0a30aa06770b34b4a6eb8b61e92dce21
checksum: 875cf890f3cc10c0974a4588568ee9e5202b047480cd261dbe1e7487fb25b56df6217b2a3e95b5cc1a88d27e0e1f13299b3048b908afe2da782369e381ad083c
languageName: node
linkType: hard

Expand Down

0 comments on commit 5eed973

Please sign in to comment.