Skip to content

fix(no-unnecessary-act): report everything that's reported in non-strict #423

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 21, 2021

Conversation

zaicevas
Copy link
Contributor

@zaicevas zaicevas commented Jul 20, 2021

Closes #416

Everything that is reported with isStrict disabled should also be reported with isStrict enabled. That's what this PR fixes.

With regards to tests - went with the quickest approach. Shamelessly copy-pasted test cases and enabled isStrict 😄 If we have a better way to deal with this duplication - let me know.

Belco90
Belco90 previously approved these changes Jul 20, 2021
Copy link
Member

@Belco90 Belco90 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy duplicating those tests to enable isStrict mode.

@MichaelDeBoey
Copy link
Member

MichaelDeBoey commented Jul 20, 2021

What about instead of duplicating them, we create a helper function that takes rules and add the strict: true option, like I did in consistent-data-testid?
This way, we don't have to duplicate all the testcases.

type ValidTestCase = TSESLint.ValidTestCase<Options>;
type InvalidTestCase = TSESLint.InvalidTestCase<MessageIds, Options>;
type TestCase = InvalidTestCase | ValidTestCase;
const disableAggressiveReporting = <T extends TestCase>(array: T[]): T[] =>
array.map((testCase) => ({
...testCase,
settings: {
'testing-library/utils-module': 'off',
'testing-library/custom-renders': 'off',
'testing-library/custom-queries': 'off',
},
}));

ruleTester.run(RULE_NAME, rule, {
valid: [...validTestCases, ...disableAggressiveReporting(validTestCases)],
invalid: [
...invalidTestCases,
...disableAggressiveReporting(invalidTestCases),
],
});

@Belco90 Belco90 requested a review from MichaelDeBoey July 21, 2021 08:08
@Belco90 Belco90 merged commit 840763d into testing-library:main Jul 21, 2021
@github-actions
Copy link

🎉 This PR is included in version 4.10.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: isStrict option in no-unnecessary-act only reports strict violations
3 participants