Skip to content

Commit

Permalink
refactor: reformat everything with prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
G-Rath committed Sep 27, 2024
1 parent 5e57587 commit 5971cca
Show file tree
Hide file tree
Showing 32 changed files with 654 additions and 863 deletions.
1,179 changes: 485 additions & 694 deletions .all-contributorsrc

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export type TestingLibrarySettings = {

export type TestingLibraryContext<
TOptions extends readonly unknown[],
TMessageIds extends string
TMessageIds extends string,
> = Readonly<
TSESLint.RuleContext<TMessageIds, TOptions> & {
settings: TestingLibrarySettings;
Expand All @@ -45,7 +45,7 @@ export type TestingLibraryContext<
export type EnhancedRuleCreate<
TOptions extends readonly unknown[],
TMessageIds extends string,
TRuleListener extends TSESLint.RuleListener = TSESLint.RuleListener
TRuleListener extends TSESLint.RuleListener = TSESLint.RuleListener,
> = (
context: TestingLibraryContext<TOptions, TMessageIds>,
optionsWithDefault: Readonly<TOptions>,
Expand Down Expand Up @@ -156,7 +156,7 @@ export type DetectionOptions = {
export function detectTestingLibraryUtils<
TOptions extends readonly unknown[],
TMessageIds extends string,
TRuleListener extends TSESLint.RuleListener = TSESLint.RuleListener
TRuleListener extends TSESLint.RuleListener = TSESLint.RuleListener,
>(
ruleCreate: EnhancedRuleCreate<TOptions, TMessageIds, TRuleListener>,
{ skipRuleReportingCheck = false }: Partial<DetectionOptions> = {}
Expand Down
2 changes: 1 addition & 1 deletion lib/create-testing-library-rule/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
export function createTestingLibraryRule<
TOptions extends readonly unknown[],
TMessageIds extends string,
TRuleListener extends TSESLint.RuleListener = TSESLint.RuleListener
TRuleListener extends TSESLint.RuleListener = TSESLint.RuleListener,
>({
create,
detectionOptions = {},
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/await-async-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type EventModules = (typeof EVENTS_SIMULATORS)[number];
export type Options = [
{
eventModule: EventModules | EventModules[];
}
},
];

export default createTestingLibraryRule<Options, MessageIds>({
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/consistent-data-testid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export type Options = [
testIdAttribute?: string[] | string;
testIdPattern: string;
customMessage?: string;
}
},
];

const FILENAME_PLACEHOLDER = '{fileName}';
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-render-in-lifecycle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export type MessageIds = 'noRenderInSetup';
type Options = [
{
allowTestingFrameworkSetupHook?: string;
}
},
];

export function findClosestBeforeHook(
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/prefer-explicit-assert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type Options = [
{
assertion?: string;
includeFindQueries?: boolean;
}
},
];

const isAtTopLevel = (node: TSESTree.Node) =>
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/prefer-presence-queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export type Options = [
{
presence?: boolean;
absence?: boolean;
}
},
];

export default createTestingLibraryRule<Options, MessageIds>({
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/prefer-query-matchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export type Options = [
query: 'get' | 'query';
matcher: string;
}[];
}
},
];

export default createTestingLibraryRule<Options, MessageIds>({
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export type TestingLibraryRuleMetaDocs<TOptions extends readonly unknown[]> =
};
export type TestingLibraryRuleMeta<
TMessageIds extends string,
TOptions extends readonly unknown[]
TOptions extends readonly unknown[],
> = Omit<TSESLint.RuleMetaData<TMessageIds>, 'docs'> & {
docs: TestingLibraryRuleMetaDocs<TOptions>;
};
Expand Down
2 changes: 1 addition & 1 deletion tests/create-testing-library-rule.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ ruleTester.run(RULE_NAME, rule, {
messageId: 'renderError',
},
],
} as const)
}) as const
),
{
code: `
Expand Down
44 changes: 22 additions & 22 deletions tests/lib/rules/await-async-events.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ ruleTester.run(RULE_NAME, rule, {
await fireEvent.${eventMethod}(getByLabelText('username'))
})
`,
} as const)
}) as const
),
...FIRE_EVENT_ASYNC_FUNCTIONS.map(
(eventMethod) =>
Expand All @@ -452,7 +452,7 @@ ruleTester.run(RULE_NAME, rule, {
fireEvent.${eventMethod}(getByLabelText('username'))
`,
} as const)
}) as const
),
...FIRE_EVENT_ASYNC_FUNCTIONS.map(
(eventMethod) =>
Expand Down Expand Up @@ -485,7 +485,7 @@ ruleTester.run(RULE_NAME, rule, {
test('should handle external function', run)
`,
} as const)
}) as const
),
...FIRE_EVENT_ASYNC_FUNCTIONS.map(
(eventMethod) =>
Expand All @@ -512,7 +512,7 @@ ruleTester.run(RULE_NAME, rule, {
await testingLibraryFireEvent.${eventMethod}(getByLabelText('username'))
})
`,
} as const)
}) as const
),
...FIRE_EVENT_ASYNC_FUNCTIONS.map(
(eventMethod) =>
Expand All @@ -539,7 +539,7 @@ ruleTester.run(RULE_NAME, rule, {
await testingLibrary.fireEvent.${eventMethod}(getByLabelText('username'))
})
`,
} as const)
}) as const
),
...FIRE_EVENT_ASYNC_FUNCTIONS.map(
(eventMethod) =>
Expand Down Expand Up @@ -573,7 +573,7 @@ ruleTester.run(RULE_NAME, rule, {
await fireEvent.${eventMethod}(getByLabelText('username'))
})
`,
} as const)
}) as const
),
...FIRE_EVENT_ASYNC_FUNCTIONS.map(
(eventMethod) =>
Expand Down Expand Up @@ -602,7 +602,7 @@ ruleTester.run(RULE_NAME, rule, {
await fireEvent.${eventMethod}(getByLabelText('username'))
})
`,
} as const)
}) as const
),
...FIRE_EVENT_ASYNC_FUNCTIONS.map(
(eventMethod) =>
Expand Down Expand Up @@ -635,7 +635,7 @@ ruleTester.run(RULE_NAME, rule, {
await fireEvent.${eventMethod}(getByLabelText('username'))
})
`,
} as const)
}) as const
),
...FIRE_EVENT_ASYNC_FUNCTIONS.map(
(eventMethod) =>
Expand Down Expand Up @@ -668,7 +668,7 @@ ruleTester.run(RULE_NAME, rule, {
await fireEvent.${eventMethod}(getByLabelText('username'))
})
`,
} as const)
}) as const
),

...FIRE_EVENT_ASYNC_FUNCTIONS.map(
Expand Down Expand Up @@ -699,7 +699,7 @@ ruleTester.run(RULE_NAME, rule, {
const promise = await fireEvent.${eventMethod}(getByLabelText('username'))
})
`,
} as const)
}) as const
),
...FIRE_EVENT_ASYNC_FUNCTIONS.map(
(eventMethod) =>
Expand Down Expand Up @@ -735,7 +735,7 @@ ruleTester.run(RULE_NAME, rule, {
await triggerEvent()
})
`,
} as const)
}) as const
),
...FIRE_EVENT_ASYNC_FUNCTIONS.map(
(eventMethod) =>
Expand Down Expand Up @@ -769,7 +769,7 @@ ruleTester.run(RULE_NAME, rule, {
triggerEvent()
`,
} as const)
}) as const
),
]),
...USER_EVENT_ASYNC_FRAMEWORKS.flatMap((testingFramework) => [
Expand Down Expand Up @@ -798,7 +798,7 @@ ruleTester.run(RULE_NAME, rule, {
await userEvent.${eventMethod}(getByLabelText('username'))
})
`,
} as const)
}) as const
),
...USER_EVENT_ASYNC_FUNCTIONS.map(
(eventMethod) =>
Expand All @@ -823,7 +823,7 @@ ruleTester.run(RULE_NAME, rule, {
userEvent.${eventMethod}(getByLabelText('username'))
`,
} as const)
}) as const
),
...USER_EVENT_ASYNC_FUNCTIONS.map(
(eventMethod) =>
Expand All @@ -850,7 +850,7 @@ ruleTester.run(RULE_NAME, rule, {
await testingLibraryUserEvent.${eventMethod}(getByLabelText('username'))
})
`,
} as const)
}) as const
),
...USER_EVENT_ASYNC_FUNCTIONS.map(
(eventMethod) =>
Expand Down Expand Up @@ -884,7 +884,7 @@ ruleTester.run(RULE_NAME, rule, {
await userEvent.${eventMethod}(getByLabelText('username'))
})
`,
} as const)
}) as const
),
...USER_EVENT_ASYNC_FUNCTIONS.map(
(eventMethod) =>
Expand Down Expand Up @@ -914,7 +914,7 @@ ruleTester.run(RULE_NAME, rule, {
const promise = await userEvent.${eventMethod}(getByLabelText('username'))
})
`,
} as const)
}) as const
),
...USER_EVENT_ASYNC_FUNCTIONS.map(
(eventMethod) =>
Expand Down Expand Up @@ -950,7 +950,7 @@ ruleTester.run(RULE_NAME, rule, {
await triggerEvent()
})
`,
} as const)
}) as const
),
...USER_EVENT_ASYNC_FUNCTIONS.map(
(eventMethod) =>
Expand Down Expand Up @@ -984,7 +984,7 @@ ruleTester.run(RULE_NAME, rule, {
triggerEvent()
`,
} as const)
}) as const
),
...USER_EVENT_ASYNC_FUNCTIONS.map(
(eventMethod) =>
Expand All @@ -1010,7 +1010,7 @@ ruleTester.run(RULE_NAME, rule, {
condition ? null : (null, true && await userEvent.${eventMethod}(getByLabelText('username')));
});
`,
} as const)
}) as const
),
...USER_EVENT_ASYNC_FUNCTIONS.map(
(eventMethod) =>
Expand All @@ -1036,7 +1036,7 @@ ruleTester.run(RULE_NAME, rule, {
await (await userEvent.${eventMethod}(getByLabelText('username')) && userEvent.${eventMethod}(getByLabelText('username')));
});
`,
} as const)
}) as const
),
...USER_EVENT_ASYNC_FUNCTIONS.map(
(eventMethod) =>
Expand Down Expand Up @@ -1070,7 +1070,7 @@ ruleTester.run(RULE_NAME, rule, {
await (await userEvent.${eventMethod}(getByLabelText('username')), null);
});
`,
} as const)
}) as const
),
]),
{
Expand Down
20 changes: 10 additions & 10 deletions tests/lib/rules/await-async-queries.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ function createTestCase(
? {
code: createTestCode({ code: test, isAsync, testingFramework }),
errors: [],
}
}
: {
code: createTestCode({ code: test.code, isAsync, testingFramework }),
errors: test.errors,
};
};
});
}

Expand Down Expand Up @@ -361,7 +361,7 @@ ruleTester.run(RULE_NAME, rule, {
});
`,
errors: [{ messageId: 'awaitAsyncQuery', line: 6, column: 21 }],
} as const)
}) as const
)
),
...ALL_ASYNC_COMBINATIONS_TO_TEST.map(
Expand All @@ -382,7 +382,7 @@ ruleTester.run(RULE_NAME, rule, {
data: { name: query },
},
],
} as const)
}) as const
),
...ALL_ASYNC_COMBINATIONS_TO_TEST.map(
(query) =>
Expand All @@ -403,7 +403,7 @@ ruleTester.run(RULE_NAME, rule, {
data: { name: query },
},
],
} as const)
}) as const
),
...ALL_ASYNC_COMBINATIONS_TO_TEST.map(
(query) =>
Expand All @@ -425,7 +425,7 @@ ruleTester.run(RULE_NAME, rule, {
data: { name: query },
},
],
} as const)
}) as const
),

// unresolved async queries are not valid (aggressive reporting)
Expand All @@ -440,7 +440,7 @@ ruleTester.run(RULE_NAME, rule, {
})
`,
errors: [{ messageId: 'awaitAsyncQuery', line: 5, column: 27 }],
} as const)
}) as const
),

// unhandled promise from async query function wrapper is invalid
Expand All @@ -463,7 +463,7 @@ ruleTester.run(RULE_NAME, rule, {
})
`,
errors: [{ messageId: 'asyncQueryWrapper', line: 9, column: 27 }],
} as const)
}) as const
),
// unhandled promise from async query arrow function wrapper is invalid
...ALL_ASYNC_COMBINATIONS_TO_TEST.map(
Expand All @@ -485,7 +485,7 @@ ruleTester.run(RULE_NAME, rule, {
})
`,
errors: [{ messageId: 'asyncQueryWrapper', line: 9, column: 27 }],
} as const)
}) as const
),
// unhandled promise implicitly returned from async query arrow function wrapper is invalid
...ALL_ASYNC_COMBINATIONS_TO_TEST.map(
Expand All @@ -503,7 +503,7 @@ ruleTester.run(RULE_NAME, rule, {
})
`,
errors: [{ messageId: 'asyncQueryWrapper', line: 5, column: 27 }],
} as const)
}) as const
),

// unhandled promise from custom query matching custom-queries setting is invalid
Expand Down
Loading

0 comments on commit 5971cca

Please sign in to comment.