Skip to content

Commit

Permalink
chore: upgrade to TS-ESLint@6 (jestjs#14483)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB authored Sep 19, 2023
1 parent ea685a5 commit c985cb4
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 61 deletions.
5 changes: 4 additions & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ module.exports = {
{
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:import/typescript',
],
files: ['*.ts', '*.tsx'],
Expand All @@ -64,6 +63,10 @@ module.exports = {
// TODO: enable at some point
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',

// TODO: part of "stylistic" rules, remove explicit activation when that lands
'@typescript-eslint/no-empty-function': 'error',
'@typescript-eslint/no-empty-interface': 'error',
},
},
{
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
"@types/node": "^16.10.0",
"@types/which": "^3.0.0",
"@types/ws": "8.5.1",
"@typescript-eslint/eslint-plugin": "^5.14.0",
"@typescript-eslint/parser": "^5.14.0",
"@typescript-eslint/eslint-plugin": "^6.6.0",
"@typescript-eslint/parser": "^6.6.0",
"ansi-regex": "^5.0.1",
"ansi-styles": "^5.0.0",
"babel-jest": "workspace:^",
Expand Down
5 changes: 2 additions & 3 deletions packages/jest-console/src/BufferedConsole.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default class BufferedConsole extends Console {
constructor() {
super({
write: (message: string) => {
BufferedConsole.write(this._buffer, 'log', message, null);
BufferedConsole.write(this._buffer, 'log', message);

return true;
},
Expand All @@ -41,9 +41,8 @@ export default class BufferedConsole extends Console {
buffer: ConsoleBuffer,
type: LogType,
message: LogMessage,
level?: number | null,
stackLevel = 2,
): ConsoleBuffer {
const stackLevel = level == null ? 2 : level;
const rawStack = new ErrorWithStack(undefined, BufferedConsole.write).stack;

invariant(rawStack != null, 'always have a stack trace');
Expand Down
4 changes: 2 additions & 2 deletions packages/jest-mock/src/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1495,7 +1495,7 @@ describe('moduleMocker', () => {
});

const spy = moduleMocker.spyOn(obj, 'method');
obj['method'].call(null);
obj.method.call(null);

expect(haveBeenCalled).toBe(true);
expect(spy).toHaveBeenCalled();
Expand Down Expand Up @@ -2326,7 +2326,7 @@ describe('moduleMocker', () => {

moduleMocker.replaceProperty(obj, 'property', 'def');

expect(obj['property']).toBe('def');
expect(obj.property).toBe('def');
});

it('should work for property from prototype chain', () => {
Expand Down
20 changes: 17 additions & 3 deletions scripts/lintTs.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/

/* eslint-disable sort-keys */

import * as os from 'os';
import * as path from 'path';
import * as url from 'url';
Expand Down Expand Up @@ -83,21 +85,22 @@ try {
fix,
fixTypes: ['problem', 'suggestion', 'layout'],
overrideConfig: {
extends: [
'plugin:@typescript-eslint/recommended-requiring-type-checking',
],
extends: ['plugin:@typescript-eslint/recommended-type-checked'],
overrides: [
{
files: ['**/__tests__/**'],
plugins: ['jest'],
rules: {
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'jest/unbound-method': 'error',
},
},
],
parser: '@typescript-eslint/parser',
parserOptions: {
EXPERIMENTAL_useProjectService: true,
project: ['./tsconfig.json', `${packageDir}/tsconfig.json`],
tsconfigRootDir: monorepoRoot,
},
Expand All @@ -115,6 +118,17 @@ try {
'@typescript-eslint/return-await': 'error',
'@typescript-eslint/strict-boolean-expressions': 'error',
'@typescript-eslint/switch-exhaustiveness-check': 'error',

// TODO: enable these
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-redundant-type-constituents': 'off',
'@typescript-eslint/no-duplicate-type-constituents': 'off',
'@typescript-eslint/no-base-to-string': 'off',

// disable the ones we disable in main config
'@typescript-eslint/no-invalid-void-type': 'off',
'@typescript-eslint/no-dynamic-delete': 'off',
'@typescript-eslint/no-var-requires': 'off',
},
},
});
Expand Down
166 changes: 116 additions & 50 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2631,7 +2631,7 @@ __metadata:
languageName: node
linkType: hard

"@eslint-community/eslint-utils@npm:^4.1.2, @eslint-community/eslint-utils@npm:^4.2.0":
"@eslint-community/eslint-utils@npm:^4.1.2, @eslint-community/eslint-utils@npm:^4.2.0, @eslint-community/eslint-utils@npm:^4.4.0":
version: 4.4.0
resolution: "@eslint-community/eslint-utils@npm:4.4.0"
dependencies:
Expand All @@ -2642,7 +2642,7 @@ __metadata:
languageName: node
linkType: hard

"@eslint-community/regexpp@npm:^4.4.0, @eslint-community/regexpp@npm:^4.6.1":
"@eslint-community/regexpp@npm:^4.5.1, @eslint-community/regexpp@npm:^4.6.1":
version: 4.8.1
resolution: "@eslint-community/regexpp@npm:4.8.1"
checksum: 82d62c845ef42b810f268cfdc84d803a2da01735fb52e902fd34bdc09f92464a094fd8e4802839874b000b2f73f67c972859e813ba705233515d3e954f234bf2
Expand Down Expand Up @@ -2941,8 +2941,8 @@ __metadata:
"@types/node": ^16.10.0
"@types/which": ^3.0.0
"@types/ws": 8.5.1
"@typescript-eslint/eslint-plugin": ^5.14.0
"@typescript-eslint/parser": ^5.14.0
"@typescript-eslint/eslint-plugin": ^6.6.0
"@typescript-eslint/parser": ^6.6.0
ansi-regex: ^5.0.1
ansi-styles: ^5.0.0
babel-jest: "workspace:^"
Expand Down Expand Up @@ -5012,10 +5012,10 @@ __metadata:
languageName: node
linkType: hard

"@types/json-schema@npm:*, @types/json-schema@npm:^7.0.4, @types/json-schema@npm:^7.0.5, @types/json-schema@npm:^7.0.8, @types/json-schema@npm:^7.0.9":
version: 7.0.12
resolution: "@types/json-schema@npm:7.0.12"
checksum: 00239e97234eeb5ceefb0c1875d98ade6e922bfec39dd365ec6bd360b5c2f825e612ac4f6e5f1d13601b8b30f378f15e6faa805a3a732f4a1bbe61915163d293
"@types/json-schema@npm:*, @types/json-schema@npm:^7.0.12, @types/json-schema@npm:^7.0.4, @types/json-schema@npm:^7.0.5, @types/json-schema@npm:^7.0.8, @types/json-schema@npm:^7.0.9":
version: 7.0.13
resolution: "@types/json-schema@npm:7.0.13"
checksum: 345df21a678fa72fb389f35f33de77833d09d4a142bb2bcb27c18690efa4cf70fc2876e43843cefb3fbdb9fcb12cd3e970a90936df30f53bbee899865ff605ab
languageName: node
linkType: hard

Expand Down Expand Up @@ -5300,10 +5300,10 @@ __metadata:
languageName: node
linkType: hard

"@types/semver@npm:^7.1.0, @types/semver@npm:^7.3.12":
version: 7.5.1
resolution: "@types/semver@npm:7.5.1"
checksum: 2fffe938c7ac168711f245a16e1856a3578d77161ca17e29a05c3e02c7be3e9c5beefa29a3350f6c1bd982fb70aa28cc52e4845eb7d36246bcdc0377170d584d
"@types/semver@npm:^7.1.0, @types/semver@npm:^7.3.12, @types/semver@npm:^7.5.0":
version: 7.5.2
resolution: "@types/semver@npm:7.5.2"
checksum: 743aa8a2b58e20b329c19bd2459152cb049d12fafab7279b90ac11e0f268c97efbcb606ea0c681cca03f79015381b40d9b1244349b354270bec3f939ed49f6e9
languageName: node
linkType: hard

Expand Down Expand Up @@ -5465,44 +5465,46 @@ __metadata:
languageName: node
linkType: hard

"@typescript-eslint/eslint-plugin@npm:^5.14.0":
version: 5.62.0
resolution: "@typescript-eslint/eslint-plugin@npm:5.62.0"
"@typescript-eslint/eslint-plugin@npm:^6.6.0":
version: 6.7.2
resolution: "@typescript-eslint/eslint-plugin@npm:6.7.2"
dependencies:
"@eslint-community/regexpp": ^4.4.0
"@typescript-eslint/scope-manager": 5.62.0
"@typescript-eslint/type-utils": 5.62.0
"@typescript-eslint/utils": 5.62.0
"@eslint-community/regexpp": ^4.5.1
"@typescript-eslint/scope-manager": 6.7.2
"@typescript-eslint/type-utils": 6.7.2
"@typescript-eslint/utils": 6.7.2
"@typescript-eslint/visitor-keys": 6.7.2
debug: ^4.3.4
graphemer: ^1.4.0
ignore: ^5.2.0
natural-compare-lite: ^1.4.0
semver: ^7.3.7
tsutils: ^3.21.0
ignore: ^5.2.4
natural-compare: ^1.4.0
semver: ^7.5.4
ts-api-utils: ^1.0.1
peerDependencies:
"@typescript-eslint/parser": ^5.0.0
eslint: ^6.0.0 || ^7.0.0 || ^8.0.0
"@typescript-eslint/parser": ^6.0.0 || ^6.0.0-alpha
eslint: ^7.0.0 || ^8.0.0
peerDependenciesMeta:
typescript:
optional: true
checksum: fc104b389c768f9fa7d45a48c86d5c1ad522c1d0512943e782a56b1e3096b2cbcc1eea3fcc590647bf0658eef61aac35120a9c6daf979bf629ad2956deb516a1
checksum: 4d6f612619282a20518cd6581bce16cd7c50ac4e49f5eeca2ab916a923049379aa382817568c929216381fb2c1bfbc1c4e6fde16ac8bfdd63862a9126f0ab797
languageName: node
linkType: hard

"@typescript-eslint/parser@npm:^5.14.0":
version: 5.62.0
resolution: "@typescript-eslint/parser@npm:5.62.0"
"@typescript-eslint/parser@npm:^6.6.0":
version: 6.7.2
resolution: "@typescript-eslint/parser@npm:6.7.2"
dependencies:
"@typescript-eslint/scope-manager": 5.62.0
"@typescript-eslint/types": 5.62.0
"@typescript-eslint/typescript-estree": 5.62.0
"@typescript-eslint/scope-manager": 6.7.2
"@typescript-eslint/types": 6.7.2
"@typescript-eslint/typescript-estree": 6.7.2
"@typescript-eslint/visitor-keys": 6.7.2
debug: ^4.3.4
peerDependencies:
eslint: ^6.0.0 || ^7.0.0 || ^8.0.0
eslint: ^7.0.0 || ^8.0.0
peerDependenciesMeta:
typescript:
optional: true
checksum: d168f4c7f21a7a63f47002e2d319bcbb6173597af5c60c1cf2de046b46c76b4930a093619e69faf2d30214c29ab27b54dcf1efc7046a6a6bd6f37f59a990e752
checksum: 9e93d3eb432ed5457a852e25a31782d07518f728966cd477620175ae64db9be04f5d8e605f3561dbfe9a365f209a83b2a3788efb9b3cf33669c8bca17f1bcf6f
languageName: node
linkType: hard

Expand All @@ -5516,20 +5518,30 @@ __metadata:
languageName: node
linkType: hard

"@typescript-eslint/type-utils@npm:5.62.0":
version: 5.62.0
resolution: "@typescript-eslint/type-utils@npm:5.62.0"
"@typescript-eslint/scope-manager@npm:6.7.2":
version: 6.7.2
resolution: "@typescript-eslint/scope-manager@npm:6.7.2"
dependencies:
"@typescript-eslint/typescript-estree": 5.62.0
"@typescript-eslint/utils": 5.62.0
"@typescript-eslint/types": 6.7.2
"@typescript-eslint/visitor-keys": 6.7.2
checksum: e35fa23ecb16252c3ad00b5f1ec05d9b8d33ee30d4c57543892f900443ed77926be9bd2836f06463c31b483f5f0f79070273bc51c4a606f55ac3cd1d9c9cd542
languageName: node
linkType: hard

"@typescript-eslint/type-utils@npm:6.7.2":
version: 6.7.2
resolution: "@typescript-eslint/type-utils@npm:6.7.2"
dependencies:
"@typescript-eslint/typescript-estree": 6.7.2
"@typescript-eslint/utils": 6.7.2
debug: ^4.3.4
tsutils: ^3.21.0
ts-api-utils: ^1.0.1
peerDependencies:
eslint: "*"
eslint: ^7.0.0 || ^8.0.0
peerDependenciesMeta:
typescript:
optional: true
checksum: fc41eece5f315dfda14320be0da78d3a971d650ea41300be7196934b9715f3fe1120a80207551eb71d39568275dbbcf359bde540d1ca1439d8be15e9885d2739
checksum: 67743f8e4b77d0ab3d82907eda0411ffd221357b60ac9cbd29683d5b8c77127369ebfafcf0bfc30a1f1828927ccd5635fab5b2eaf2b2f1d12a9361549cab3e62
languageName: node
linkType: hard

Expand All @@ -5540,6 +5552,13 @@ __metadata:
languageName: node
linkType: hard

"@typescript-eslint/types@npm:6.7.2":
version: 6.7.2
resolution: "@typescript-eslint/types@npm:6.7.2"
checksum: 5a7c4cd456f721649757d2edb4cae71d1405c1c2c35672031f012b27007b9d49b7118297eec746dc3351370e6aa414e5d2c493fb658c7b910154b7998c0278e1
languageName: node
linkType: hard

"@typescript-eslint/typescript-estree@npm:5.62.0":
version: 5.62.0
resolution: "@typescript-eslint/typescript-estree@npm:5.62.0"
Expand All @@ -5558,7 +5577,42 @@ __metadata:
languageName: node
linkType: hard

"@typescript-eslint/utils@npm:5.62.0, @typescript-eslint/utils@npm:^5.10.0":
"@typescript-eslint/typescript-estree@npm:6.7.2":
version: 6.7.2
resolution: "@typescript-eslint/typescript-estree@npm:6.7.2"
dependencies:
"@typescript-eslint/types": 6.7.2
"@typescript-eslint/visitor-keys": 6.7.2
debug: ^4.3.4
globby: ^11.1.0
is-glob: ^4.0.3
semver: ^7.5.4
ts-api-utils: ^1.0.1
peerDependenciesMeta:
typescript:
optional: true
checksum: c30b9803567c37527e2806badd98f3083ae125db9a430d8a28647b153e446e6a4b830833f229cca27d5aa0ff5497c149aaa524aa3a6dbf932b557c60d0bfd4f9
languageName: node
linkType: hard

"@typescript-eslint/utils@npm:6.7.2":
version: 6.7.2
resolution: "@typescript-eslint/utils@npm:6.7.2"
dependencies:
"@eslint-community/eslint-utils": ^4.4.0
"@types/json-schema": ^7.0.12
"@types/semver": ^7.5.0
"@typescript-eslint/scope-manager": 6.7.2
"@typescript-eslint/types": 6.7.2
"@typescript-eslint/typescript-estree": 6.7.2
semver: ^7.5.4
peerDependencies:
eslint: ^7.0.0 || ^8.0.0
checksum: 97f950562dba2bda63ffe64672f643ef940123cf74007bc878afcf31c75f905c99934a3ad77da3d5a4fe7807d5d69c791b20c429712ad5a5525e331ebc313756
languageName: node
linkType: hard

"@typescript-eslint/utils@npm:^5.10.0":
version: 5.62.0
resolution: "@typescript-eslint/utils@npm:5.62.0"
dependencies:
Expand Down Expand Up @@ -5586,6 +5640,16 @@ __metadata:
languageName: node
linkType: hard

"@typescript-eslint/visitor-keys@npm:6.7.2":
version: 6.7.2
resolution: "@typescript-eslint/visitor-keys@npm:6.7.2"
dependencies:
"@typescript-eslint/types": 6.7.2
eslint-visitor-keys: ^3.4.1
checksum: b4915fbc0f3d44c81b92b7151830b698e8b6ed2dee8587bb65540c888c7a84300d3fd6b0c159e2131c7c6df1bebe49fb0d21c347ecdbf7f3e4aec05acebbb0bc
languageName: node
linkType: hard

"@webassemblyjs/ast@npm:1.11.6, @webassemblyjs/ast@npm:^1.11.5":
version: 1.11.6
resolution: "@webassemblyjs/ast@npm:1.11.6"
Expand Down Expand Up @@ -15460,13 +15524,6 @@ __metadata:
languageName: node
linkType: hard

"natural-compare-lite@npm:^1.4.0":
version: 1.4.0
resolution: "natural-compare-lite@npm:1.4.0"
checksum: 5222ac3986a2b78dd6069ac62cbb52a7bf8ffc90d972ab76dfe7b01892485d229530ed20d0c62e79a6b363a663b273db3bde195a1358ce9e5f779d4453887225
languageName: node
linkType: hard

"natural-compare@npm:^1.4.0":
version: 1.4.0
resolution: "natural-compare@npm:1.4.0"
Expand Down Expand Up @@ -19958,6 +20015,15 @@ __metadata:
languageName: node
linkType: hard

"ts-api-utils@npm:^1.0.1":
version: 1.0.3
resolution: "ts-api-utils@npm:1.0.3"
peerDependencies:
typescript: ">=4.2.0"
checksum: 441cc4489d65fd515ae6b0f4eb8690057add6f3b6a63a36073753547fb6ce0c9ea0e0530220a0b282b0eec535f52c4dfc315d35f8a4c9a91c0def0707a714ca6
languageName: node
linkType: hard

"ts-node@npm:^10.5.0":
version: 10.9.1
resolution: "ts-node@npm:10.9.1"
Expand Down

0 comments on commit c985cb4

Please sign in to comment.