Skip to content

Move rules settings to ESLint shared config: part 2 - check imports #239

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 7 commits into from
Oct 25, 2020
Prev Previous commit
Next Next commit
docs: add jsdoc to detection helpers
Belco90 committed Oct 25, 2020
commit e9d7bc3132f3294efffae6086d8864bff69511da
16 changes: 16 additions & 0 deletions lib/detect-testing-library-utils.ts
Original file line number Diff line number Diff line change
@@ -48,13 +48,29 @@ export function detectTestingLibraryUtils<

// Helpers for Testing Library detection.
const helpers: DetectionHelpers = {
/**
* Gets if Testing Library is considered as imported or not.
*
* By default, it is ALWAYS considered as imported. This is what we call
* "aggressive reporting" so we don't miss TL utils reexported from
* custom modules.
*
* However, there is a setting to customize the module where TL utils can
* be imported from: "testing-library/module". If this setting is enabled,
* then this method will return `true` ONLY IF a testing-library package
* or custom module are imported.
*/
getIsTestingLibraryImported() {
if (!customModule) {
return true;
}

return isImportingTestingLibraryModule || isImportingCustomModule;
},

/**
* Wraps all conditions that must be met to report rules.
*/
canReportErrors() {
return this.getIsTestingLibraryImported();
Copy link
Collaborator

Choose a reason for hiding this comment

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

it's been a long time since I've seen a this 😄

},