Skip to content

Commit fd94623

Browse files
committed
chore: update prettier
1 parent 516a424 commit fd94623

16 files changed

+93
-129
lines changed

src/processors/__tests__/snapshot-processor.test.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,9 @@ describe('snapshot-processor', () => {
2222
it('should only return messages about snapshot specific rules', () => {
2323
const { postprocess } = snapshotProcessor;
2424
const result = postprocess([
25-
[
26-
'no-console',
27-
'global-require',
28-
'jest/no-large-snapshots',
29-
].map(ruleId => ({ ruleId })),
25+
['no-console', 'global-require', 'jest/no-large-snapshots'].map(
26+
ruleId => ({ ruleId }),
27+
),
3028
]);
3129

3230
expect(result).toEqual([{ ruleId: 'jest/no-large-snapshots' }]);

src/rules/__tests__/no-deprecated-functions.test.ts

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -153,34 +153,23 @@ describe('the rule', () => {
153153
});
154154

155155
describe.each<JestVersion>([
156-
14,
157-
15,
158-
16,
159-
17,
160-
18,
161-
19,
162-
20,
163-
21,
164-
22,
165-
23,
166-
24,
167-
25,
168-
26,
169-
27,
156+
14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
170157
])('when using jest version %i', jestVersion => {
171158
beforeEach(async () =>
172159
process.chdir(await setupFakeProjectDirectory(jestVersion)),
173160
);
174161

175162
const allowedFunctions: string[] = [];
176-
const deprecations = ([
177-
[15, 'jest.resetModuleRegistry', 'jest.resetModules'],
178-
[17, 'jest.addMatchers', 'expect.extend'],
179-
[21, 'require.requireMock', 'jest.requireMock'],
180-
[21, 'require.requireActual', 'jest.requireActual'],
181-
[22, 'jest.runTimersToTime', 'jest.advanceTimersByTime'],
182-
[26, 'jest.genMockFromModule', 'jest.createMockFromModule'],
183-
] as const).filter(deprecation => {
163+
const deprecations = (
164+
[
165+
[15, 'jest.resetModuleRegistry', 'jest.resetModules'],
166+
[17, 'jest.addMatchers', 'expect.extend'],
167+
[21, 'require.requireMock', 'jest.requireMock'],
168+
[21, 'require.requireActual', 'jest.requireActual'],
169+
[22, 'jest.runTimersToTime', 'jest.advanceTimersByTime'],
170+
[26, 'jest.genMockFromModule', 'jest.createMockFromModule'],
171+
] as const
172+
).filter(deprecation => {
184173
if (deprecation[0] > jestVersion) {
185174
allowedFunctions.push(deprecation[1]);
186175

src/rules/__tests__/no-export.test.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ ruleTester.run('no-export', rule, {
2323
],
2424
invalid: [
2525
{
26-
code:
27-
'export const myThing = "invalid"; test("a test", () => { expect(1).toBe(1);});',
26+
code: 'export const myThing = "invalid"; test("a test", () => { expect(1).toBe(1);});',
2827
parserOptions: { sourceType: 'module' },
2928
errors: [{ endColumn: 34, column: 1, messageId: 'unexpectedExport' }],
3029
},
@@ -62,24 +61,20 @@ ruleTester.run('no-export', rule, {
6261
errors: [{ endColumn: 34, column: 1, messageId: 'unexpectedExport' }],
6362
},
6463
{
65-
code:
66-
'export default function() {}; test("a test", () => { expect(1).toBe(1);});',
64+
code: 'export default function() {}; test("a test", () => { expect(1).toBe(1);});',
6765
parserOptions: { sourceType: 'module' },
6866
errors: [{ endColumn: 29, column: 1, messageId: 'unexpectedExport' }],
6967
},
7068
{
71-
code:
72-
'module.exports["invalid"] = function() {}; test("a test", () => { expect(1).toBe(1);});',
69+
code: 'module.exports["invalid"] = function() {}; test("a test", () => { expect(1).toBe(1);});',
7370
errors: [{ endColumn: 26, column: 1, messageId: 'unexpectedExport' }],
7471
},
7572
{
76-
code:
77-
'module.exports = function() {}; ; test("a test", () => { expect(1).toBe(1);});',
73+
code: 'module.exports = function() {}; ; test("a test", () => { expect(1).toBe(1);});',
7874
errors: [{ endColumn: 15, column: 1, messageId: 'unexpectedExport' }],
7975
},
8076
{
81-
code:
82-
'module.export.invalid = function() {}; ; test("a test", () => { expect(1).toBe(1);});',
77+
code: 'module.export.invalid = function() {}; ; test("a test", () => { expect(1).toBe(1);});',
8378
errors: [{ endColumn: 22, column: 1, messageId: 'unexpectedExport' }],
8479
},
8580
],

src/rules/__tests__/no-interpolation-in-snapshots.test.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ ruleTester.run('no-interpolation-in-snapshots', rule, {
5757
],
5858
},
5959
{
60-
code:
61-
'expect(something).not.toMatchInlineSnapshot({}, `${interpolated}`);',
60+
code: 'expect(something).not.toMatchInlineSnapshot({}, `${interpolated}`);',
6261
errors: [
6362
{
6463
endColumn: 66,
@@ -68,8 +67,7 @@ ruleTester.run('no-interpolation-in-snapshots', rule, {
6867
],
6968
},
7069
{
71-
code:
72-
'expect(something).toThrowErrorMatchingInlineSnapshot(`${interpolated}`);',
70+
code: 'expect(something).toThrowErrorMatchingInlineSnapshot(`${interpolated}`);',
7371
errors: [
7472
{
7573
endColumn: 71,
@@ -79,8 +77,7 @@ ruleTester.run('no-interpolation-in-snapshots', rule, {
7977
],
8078
},
8179
{
82-
code:
83-
'expect(something).not.toThrowErrorMatchingInlineSnapshot(`${interpolated}`);',
80+
code: 'expect(something).not.toThrowErrorMatchingInlineSnapshot(`${interpolated}`);',
8481
errors: [
8582
{
8683
endColumn: 75,

src/rules/__tests__/no-standalone-expect.test.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,11 @@ ruleTester.run('no-standalone-expect', rule, {
128128
errors: [{ endColumn: 35, column: 26, messageId: 'unexpectedExpect' }],
129129
},
130130
{
131-
code:
132-
'describe("a test", () => { const func = () => { expect(1).toBe(1); }; expect(1).toBe(1); });',
131+
code: 'describe("a test", () => { const func = () => { expect(1).toBe(1); }; expect(1).toBe(1); });',
133132
errors: [{ endColumn: 80, column: 71, messageId: 'unexpectedExpect' }],
134133
},
135134
{
136-
code:
137-
'describe("a test", () => { it(() => { expect(1).toBe(1); }); expect(1).toBe(1); });',
135+
code: 'describe("a test", () => { it(() => { expect(1).toBe(1); }); expect(1).toBe(1); });',
138136
errors: [{ endColumn: 72, column: 63, messageId: 'unexpectedExpect' }],
139137
},
140138
{
@@ -150,13 +148,11 @@ ruleTester.run('no-standalone-expect', rule, {
150148
errors: [{ endColumn: 11, column: 2, messageId: 'unexpectedExpect' }],
151149
},
152150
{
153-
code:
154-
'it.each([1, true])("trues", value => { expect(value).toBe(true); }); expect(1).toBe(1);',
151+
code: 'it.each([1, true])("trues", value => { expect(value).toBe(true); }); expect(1).toBe(1);',
155152
errors: [{ endColumn: 79, column: 70, messageId: 'unexpectedExpect' }],
156153
},
157154
{
158-
code:
159-
'describe.each([1, true])("trues", value => { expect(value).toBe(true); });',
155+
code: 'describe.each([1, true])("trues", value => { expect(value).toBe(true); });',
160156
errors: [{ endColumn: 59, column: 46, messageId: 'unexpectedExpect' }],
161157
},
162158
],

src/rules/__tests__/prefer-spy-on.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,7 @@ ruleTester.run('prefer-spy-on', rule, {
8787
],
8888
},
8989
{
90-
code:
91-
"obj.a.b = jest.fn(() => ({})).mockReturnValue('default').mockReturnValueOnce('first call'); test();",
90+
code: "obj.a.b = jest.fn(() => ({})).mockReturnValue('default').mockReturnValueOnce('first call'); test();",
9291
output:
9392
"jest.spyOn(obj.a, 'b').mockImplementation(() => ({})).mockReturnValue('default').mockReturnValueOnce('first call'); test();",
9493
errors: [

src/rules/__tests__/valid-expect.test.ts

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ ruleTester.run('valid-expect', rule, {
2525
'test("valid-expect", function () { return Promise.resolve(expect(Promise.resolve(2)).resolves.not.toBeDefined()); });',
2626
'test("valid-expect", function () { return Promise.resolve(expect(Promise.resolve(2)).rejects.not.toBeDefined()); });',
2727
{
28-
code:
29-
'test("valid-expect", () => expect(Promise.resolve(2)).resolves.toBeDefined());',
28+
code: 'test("valid-expect", () => expect(Promise.resolve(2)).resolves.toBeDefined());',
3029
options: [{ alwaysAwait: true }],
3130
},
3231
'test("valid-expect", () => expect(Promise.resolve(2)).resolves.toBeDefined());',
@@ -457,8 +456,7 @@ ruleTester.run('valid-expect', rule, {
457456

458457
// expect().resolves
459458
{
460-
code:
461-
'test("valid-expect", () => { expect(Promise.resolve(2)).resolves.toBeDefined(); });',
459+
code: 'test("valid-expect", () => { expect(Promise.resolve(2)).resolves.toBeDefined(); });',
462460
errors: [
463461
{
464462
column: 30,
@@ -470,8 +468,7 @@ ruleTester.run('valid-expect', rule, {
470468
},
471469
// expect().resolves.not
472470
{
473-
code:
474-
'test("valid-expect", () => { expect(Promise.resolve(2)).resolves.not.toBeDefined(); });',
471+
code: 'test("valid-expect", () => { expect(Promise.resolve(2)).resolves.not.toBeDefined(); });',
475472
errors: [
476473
{
477474
column: 30,
@@ -483,8 +480,7 @@ ruleTester.run('valid-expect', rule, {
483480
},
484481
// expect().rejects
485482
{
486-
code:
487-
'test("valid-expect", () => { expect(Promise.resolve(2)).rejects.toBeDefined(); });',
483+
code: 'test("valid-expect", () => { expect(Promise.resolve(2)).rejects.toBeDefined(); });',
488484
errors: [
489485
{
490486
column: 30,
@@ -496,8 +492,7 @@ ruleTester.run('valid-expect', rule, {
496492
},
497493
// expect().rejects.not
498494
{
499-
code:
500-
'test("valid-expect", () => { expect(Promise.resolve(2)).rejects.not.toBeDefined(); });',
495+
code: 'test("valid-expect", () => { expect(Promise.resolve(2)).rejects.not.toBeDefined(); });',
501496
errors: [
502497
{
503498
column: 30,
@@ -509,8 +504,7 @@ ruleTester.run('valid-expect', rule, {
509504
},
510505
// usages in async function
511506
{
512-
code:
513-
'test("valid-expect", async () => { expect(Promise.resolve(2)).resolves.toBeDefined(); });',
507+
code: 'test("valid-expect", async () => { expect(Promise.resolve(2)).resolves.toBeDefined(); });',
514508
errors: [
515509
{
516510
column: 36,
@@ -521,8 +515,7 @@ ruleTester.run('valid-expect', rule, {
521515
],
522516
},
523517
{
524-
code:
525-
'test("valid-expect", async () => { expect(Promise.resolve(2)).resolves.not.toBeDefined(); });',
518+
code: 'test("valid-expect", async () => { expect(Promise.resolve(2)).resolves.not.toBeDefined(); });',
526519
errors: [
527520
{
528521
column: 36,

src/rules/consistent-test-it.ts

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,21 @@ import {
1111
isTestCaseCall,
1212
} from './utils';
1313

14-
const buildFixer = (
15-
callee: TSESTree.LeftHandSideExpression,
16-
nodeName: string,
17-
preferredTestKeyword: TestCaseName.test | TestCaseName.it,
18-
) => (fixer: TSESLint.RuleFixer) => [
19-
fixer.replaceText(
20-
callee.type === AST_NODE_TYPES.MemberExpression ? callee.object : callee,
21-
getPreferredNodeName(nodeName, preferredTestKeyword),
22-
),
23-
];
14+
const buildFixer =
15+
(
16+
callee: TSESTree.LeftHandSideExpression,
17+
nodeName: string,
18+
preferredTestKeyword: TestCaseName.test | TestCaseName.it,
19+
) =>
20+
(fixer: TSESLint.RuleFixer) =>
21+
[
22+
fixer.replaceText(
23+
callee.type === AST_NODE_TYPES.MemberExpression
24+
? callee.object
25+
: callee,
26+
getPreferredNodeName(nodeName, preferredTestKeyword),
27+
),
28+
];
2429

2530
export default createRule<
2631
[

src/rules/expect-expect.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,8 @@ export default createRule<
8181

8282
if (node.type === AST_NODE_TYPES.FunctionDeclaration) {
8383
const declaredVariables = context.getDeclaredVariables(node);
84-
const testCallExpressions = getTestCallExpressionsFromDeclaredVariables(
85-
declaredVariables,
86-
);
84+
const testCallExpressions =
85+
getTestCallExpressionsFromDeclaredVariables(declaredVariables);
8786

8887
checkCallExpressionUsed(testCallExpressions);
8988
}

src/rules/no-conditional-expect.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,8 @@ export default createRule({
4343
return {
4444
FunctionDeclaration(node) {
4545
const declaredVariables = context.getDeclaredVariables(node);
46-
const testCallExpressions = getTestCallExpressionsFromDeclaredVariables(
47-
declaredVariables,
48-
);
46+
const testCallExpressions =
47+
getTestCallExpressionsFromDeclaredVariables(declaredVariables);
4948

5049
if (testCallExpressions.length > 0) {
5150
inTestCase = true;

0 commit comments

Comments
 (0)