Skip to content

Commit 24e0472

Browse files
authored
chore(lint): enable recommended configs (#12902)
1 parent 1bf9f36 commit 24e0472

File tree

60 files changed

+145
-67
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+145
-67
lines changed

.eslintrc.cjs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8+
/* eslint-disable sort-keys */
9+
810
const fs = require('fs');
911
const path = require('path');
1012
const {sync: readPkg} = require('read-pkg');
@@ -27,6 +29,7 @@ module.exports = {
2729
'jest/globals': true,
2830
},
2931
extends: [
32+
'eslint:recommended',
3033
'plugin:markdown/recommended',
3134
'plugin:import/errors',
3235
'plugin:eslint-comments/recommended',
@@ -38,6 +41,7 @@ module.exports = {
3841
overrides: [
3942
{
4043
extends: [
44+
'plugin:@typescript-eslint/recommended',
4145
'plugin:@typescript-eslint/eslint-recommended',
4246
'plugin:import/typescript',
4347
],
@@ -52,10 +56,14 @@ module.exports = {
5256
{argsIgnorePattern: '^_'},
5357
],
5458
'@typescript-eslint/prefer-ts-expect-error': 'error',
59+
'@typescript-eslint/no-var-requires': 'off',
5560
// TS verifies these
5661
'consistent-return': 'off',
5762
'no-dupe-class-members': 'off',
5863
'no-unused-vars': 'off',
64+
// TODO: enable at some point
65+
'@typescript-eslint/no-explicit-any': 'off',
66+
'@typescript-eslint/no-non-null-assertion': 'off',
5967
},
6068
},
6169
{
@@ -144,6 +152,9 @@ module.exports = {
144152
files: ['**/*.md/**'],
145153
rules: {
146154
'@typescript-eslint/no-unused-vars': 'off',
155+
'@typescript-eslint/no-empty-function': 'off',
156+
'@typescript-eslint/no-namespace': 'off',
157+
'@typescript-eslint/no-empty-interface': 'off',
147158
'arrow-body-style': 'off',
148159
'consistent-return': 'off',
149160
'import/export': 'off',
@@ -201,6 +212,13 @@ module.exports = {
201212
],
202213
},
203214
},
215+
{
216+
files: ['**/__tests__/**', '**/__mocks__/**'],
217+
rules: {
218+
'@typescript-eslint/ban-ts-comment': 'off',
219+
'@typescript-eslint/no-empty-function': 'off',
220+
},
221+
},
204222
{
205223
files: [
206224
'**/__tests__/**',
@@ -247,6 +265,12 @@ module.exports = {
247265
'import/no-extraneous-dependencies': 'off',
248266
},
249267
},
268+
{
269+
files: ['**/__typetests__/**'],
270+
rules: {
271+
'@typescript-eslint/no-empty-function': 'off',
272+
},
273+
},
250274
{
251275
files: [
252276
'**/__typetests__/**',

e2e/__tests__/multiProjectRunner.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ test('can pass projects or global config', () => {
4949
getHasteName(filename) {
5050
return filename
5151
.substr(filename.lastIndexOf(path.sep) + 1)
52-
.replace(/\.js$/, '');
52+
.replace(/\\.js$/, '');
5353
},
5454
};
5555
`,
@@ -446,7 +446,7 @@ test('Does transform files with the corresponding project transformer', () => {
446446
'project1/jest.config.js': `
447447
module.exports = {
448448
rootDir: './',
449-
transform: {'file\.js': './transformer.js'},
449+
transform: {'file\\.js': './transformer.js'},
450450
};`,
451451
'project1/transformer.js': `
452452
module.exports = {
@@ -461,7 +461,7 @@ test('Does transform files with the corresponding project transformer', () => {
461461
'project2/jest.config.js': `
462462
module.exports = {
463463
rootDir: './',
464-
transform: {'file\.js': './transformer.js'},
464+
transform: {'file\\.js': './transformer.js'},
465465
};`,
466466
'project2/transformer.js': `
467467
module.exports = {

e2e/__tests__/runProgrammatically.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ const dir = resolve(__dirname, '..', 'run-programmatically');
1212

1313
test('run Jest programmatically cjs', () => {
1414
const {stdout} = run('node cjs.js --version', dir);
15-
expect(stdout).toMatch(/\d{2}\.\d{1,2}\.\d{1,2}[\-\S]*-dev$/);
15+
expect(stdout).toMatch(/\d{2}\.\d{1,2}\.\d{1,2}[-\S]*-dev$/);
1616
});
1717

1818
test('run Jest programmatically esm', () => {
1919
const {stdout} = run('node index.js --version', dir);
20-
expect(stdout).toMatch(/\d{2}\.\d{1,2}\.\d{1,2}[\-\S]*-dev$/);
20+
expect(stdout).toMatch(/\d{2}\.\d{1,2}\.\d{1,2}[-\S]*-dev$/);
2121
});

e2e/__tests__/version.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ test('works with jest.config.js', () => {
2222
});
2323

2424
const {exitCode, stdout, stderr} = runJest(DIR, ['--version']);
25-
expect(stdout).toMatch(/\d{2}\.\d{1,2}\.\d{1,2}[\-\S]*-dev$/);
25+
expect(stdout).toMatch(/\d{2}\.\d{1,2}\.\d{1,2}[-\S]*-dev$/);
2626
// Only version gets printed and nothing else
2727
expect(stdout.split(/\n/)).toHaveLength(1);
2828
expect(stderr).toBe('');

e2e/coverage-provider-v8/empty-sourcemap/types.ts

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

8+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
89
export interface obj {}

e2e/snapshot-escape/__tests__/snapshotEscapeRegex.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
'use strict';
88

9-
const regex = /\dd\ \s+ \w \\\[ \. blahzz.* [xyz]+/;
9+
const regex = /\dd \s+ \w \\\[ \. blahzz.* [xyz]+/;
1010

1111
test('escape regex', () => expect(regex).toMatchSnapshot());
1212

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ export default function jestHoist(): PluginObj<{
305305
},
306306
// in `post` to make sure we come after an import transform and can unshift above the `require`s
307307
post({path: program}) {
308+
// eslint-disable-next-line @typescript-eslint/no-this-alias
308309
const self = this;
309310

310311
visitBlock(program);

packages/expect/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export class JestAssertionError extends Error {
6464
matcherResult?: Omit<SyncExpectationResult, 'message'> & {message: string};
6565
}
6666

67+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint
6768
const isPromise = <T extends any>(obj: any): obj is PromiseLike<T> =>
6869
!!obj &&
6970
(typeof obj === 'object' || typeof obj === 'function') &&

packages/jest-circus/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ const test: Global.It = (() => {
155155
test.todo,
156156
);
157157
}
158+
// eslint-disable-next-line @typescript-eslint/no-empty-function
158159
return _addTest(testName, 'todo', false, () => {}, test.todo);
159160
};
160161

packages/jest-circus/src/legacy-code-todo-rewrite/jestAdapterInit.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export const initialize = async ({
6363
}
6464
getRunnerState().maxConcurrency = globalConfig.maxConcurrency;
6565

66-
// @ts-expect-error
66+
// @ts-expect-error: missing `concurrent` which is added later
6767
const globalsObject: Global.TestFrameworkGlobals = {
6868
...globals,
6969
fdescribe: globals.describe.only,

0 commit comments

Comments
 (0)