Skip to content

Commit 44f4fab

Browse files
committed
refactor: fix type-check
1 parent 98b5a77 commit 44f4fab

File tree

3 files changed

+33
-24
lines changed

3 files changed

+33
-24
lines changed

tests/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ it('should export configs that refer to actual rules', () => {
6161
'flat/marko',
6262
]);
6363
const allConfigRules = Object.values(allConfigs)
64-
.map((config) => Object.keys(config.rules))
64+
.map((config) => Object.keys(config.rules ?? {}))
6565
.reduce((previousValue, currentValue) => [
6666
...previousValue,
6767
...currentValue,

tests/lib/rules/no-wait-for-side-effects.test.ts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import rule, { RULE_NAME } from '../../../lib/rules/no-wait-for-side-effects';
1+
import { InvalidTestCase } from '@typescript-eslint/rule-tester';
2+
3+
import rule, {
4+
RULE_NAME,
5+
type MessageIds,
6+
} from '../../../lib/rules/no-wait-for-side-effects';
27
import { createRuleTester } from '../test-utils';
38

49
const ruleTester = createRuleTester();
@@ -118,7 +123,7 @@ ruleTester.run(RULE_NAME, rule, {
118123
code: `
119124
import { waitFor } from '${testingFramework}';
120125
import { notUserEvent } from 'somewhere-else';
121-
126+
122127
waitFor(() => {
123128
await notUserEvent.click(button)
124129
})
@@ -736,7 +741,7 @@ ruleTester.run(RULE_NAME, rule, {
736741
expect(b).toEqual('b')
737742
}).then(() => {
738743
userEvent.click(button) // Side effects are allowed inside .then()
739-
expect(b).toEqual('b')
744+
expect(b).toEqual('b')
740745
})
741746
`,
742747
errors: [{ line: 4, column: 11, messageId: 'noSideEffectsWaitFor' }],
@@ -808,9 +813,10 @@ ruleTester.run(RULE_NAME, rule, {
808813
} as const,
809814
]),
810815

811-
...SUPPORTED_TESTING_FRAMEWORKS.flatMap((testingFramework) => [
812-
{
813-
code: `
816+
...SUPPORTED_TESTING_FRAMEWORKS.flatMap<InvalidTestCase<MessageIds, []>>(
817+
(testingFramework) => [
818+
{
819+
code: `
814820
import { waitFor } from '${testingFramework}';
815821
import userEvent from '@testing-library/user-event'
816822
@@ -820,8 +826,9 @@ ruleTester.run(RULE_NAME, rule, {
820826
});
821827
});
822828
`,
823-
errors: [{ line: 7, column: 13, messageId: 'noSideEffectsWaitFor' }],
824-
},
825-
]),
829+
errors: [{ line: 7, column: 13, messageId: 'noSideEffectsWaitFor' }],
830+
},
831+
]
832+
),
826833
],
827834
});

tests/lib/rules/prefer-find-by.test.ts

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -714,8 +714,9 @@ ruleTester.run(RULE_NAME, rule, {
714714
)}('Count is: 0', { timeout: 100, interval: 200 })
715715
`,
716716
})),
717-
...ASYNC_QUERIES_COMBINATIONS.map((queryMethod) => ({
718-
code: `
717+
...ASYNC_QUERIES_COMBINATIONS.map<InvalidTestCase<MessageIds, []>>(
718+
(queryMethod) => ({
719+
code: `
719720
import {waitFor} from '${testingFramework}';
720721
it('tests', async () => {
721722
await waitFor(async () => {
@@ -724,24 +725,25 @@ ruleTester.run(RULE_NAME, rule, {
724725
})
725726
})
726727
`,
727-
errors: [
728-
{
729-
messageId: 'preferFindBy',
730-
data: {
731-
queryVariant: getFindByQueryVariant(queryMethod),
732-
queryMethod: queryMethod.split('By')[1],
733-
prevQuery: queryMethod,
734-
waitForMethodName: 'waitFor',
728+
errors: [
729+
{
730+
messageId: 'preferFindBy',
731+
data: {
732+
queryVariant: getFindByQueryVariant(queryMethod),
733+
queryMethod: queryMethod.split('By')[1],
734+
prevQuery: queryMethod,
735+
waitForMethodName: 'waitFor',
736+
},
735737
},
736-
},
737-
],
738-
output: `
738+
],
739+
output: `
739740
import {waitFor} from '${testingFramework}';
740741
it('tests', async () => {
741742
const button = await screen.${queryMethod}("button", { name: "Submit" })
742743
expect(button).toBeInTheDocument()
743744
})
744745
`,
745-
})),
746+
})
747+
),
746748
]),
747749
});

0 commit comments

Comments
 (0)