Skip to content

Commit

Permalink
refactor: remove mechanism to match files to be reported (#297)
Browse files Browse the repository at this point in the history
  • Loading branch information
Belco90 authored Mar 23, 2021
1 parent 461809f commit 69d5bbe
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 297 deletions.
20 changes: 1 addition & 19 deletions lib/detect-testing-library-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import {

export type TestingLibrarySettings = {
'testing-library/utils-module'?: string;
'testing-library/filename-pattern'?: string;
'testing-library/custom-renders'?: string[];
};

Expand Down Expand Up @@ -56,7 +55,6 @@ type GetCustomModuleImportNodeFn = () => ImportModuleNode | null;
type GetTestingLibraryImportNameFn = () => string | undefined;
type GetCustomModuleImportNameFn = () => string | undefined;
type IsTestingLibraryImportedFn = () => boolean;
type IsValidFilenameFn = () => boolean;
type IsGetQueryVariantFn = (node: TSESTree.Identifier) => boolean;
type IsQueryQueryVariantFn = (node: TSESTree.Identifier) => boolean;
type IsFindQueryVariantFn = (node: TSESTree.Identifier) => boolean;
Expand Down Expand Up @@ -90,7 +88,6 @@ export interface DetectionHelpers {
getTestingLibraryImportName: GetTestingLibraryImportNameFn;
getCustomModuleImportName: GetCustomModuleImportNameFn;
isTestingLibraryImported: IsTestingLibraryImportedFn;
isValidFilename: IsValidFilenameFn;
isGetQueryVariant: IsGetQueryVariantFn;
isQueryQueryVariant: IsQueryQueryVariantFn;
isFindQueryVariant: IsFindQueryVariantFn;
Expand All @@ -110,8 +107,6 @@ export interface DetectionHelpers {
isNodeComingFromTestingLibrary: IsNodeComingFromTestingLibraryFn;
}

const DEFAULT_FILENAME_PATTERN = '^.*\\.(test|spec)\\.[jt]sx?$';

const FIRE_EVENT_NAME = 'fireEvent';
const RENDER_NAME = 'render';

Expand All @@ -132,9 +127,6 @@ export function detectTestingLibraryUtils<

// Init options based on shared ESLint settings
const customModule = context.settings['testing-library/utils-module'];
const filenamePattern =
context.settings['testing-library/filename-pattern'] ??
DEFAULT_FILENAME_PATTERN;
const customRenders = context.settings['testing-library/custom-renders'];

/**
Expand Down Expand Up @@ -243,15 +235,6 @@ export function detectTestingLibraryUtils<
);
};

/**
* Determines whether filename is valid or not for current file
* being analyzed based on "testing-library/filename-pattern" setting.
*/
const isValidFilename: IsValidFilenameFn = () => {
const fileName = context.getFilename();
return !!fileName.match(filenamePattern);
};

/**
* Determines whether a given node is `get*` query variant or not.
*/
Expand Down Expand Up @@ -536,7 +519,7 @@ export function detectTestingLibraryUtils<
* Determines if file inspected meets all conditions to be reported by rules or not.
*/
const canReportErrors: CanReportErrorsFn = () => {
return isTestingLibraryImported() && isValidFilename();
return isTestingLibraryImported();
};

/**
Expand Down Expand Up @@ -566,7 +549,6 @@ export function detectTestingLibraryUtils<
getTestingLibraryImportName,
getCustomModuleImportName,
isTestingLibraryImported,
isValidFilename,
isGetQueryVariant,
isQueryQueryVariant,
isFindQueryVariant,
Expand Down
Loading

0 comments on commit 69d5bbe

Please sign in to comment.