Skip to content

Commit 756c688

Browse files
committed
refactor(prefer-presence-queries): use custom rule creator
1 parent fca6a2a commit 756c688

File tree

2 files changed

+563
-102
lines changed

2 files changed

+563
-102
lines changed

lib/rules/prefer-presence-queries.ts

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
import { ESLintUtils, TSESTree } from '@typescript-eslint/experimental-utils';
1+
import { TSESTree } from '@typescript-eslint/experimental-utils';
22
import {
3-
getDocsUrl,
3+
ABSENCE_MATCHERS,
44
ALL_QUERIES_METHODS,
55
PRESENCE_MATCHERS,
6-
ABSENCE_MATCHERS,
76
} from '../utils';
87
import {
98
findClosestCallNode,
10-
isMemberExpression,
119
isIdentifier,
10+
isMemberExpression,
1211
} from '../node-utils';
12+
import { createTestingLibraryRule } from '../create-testing-library-rule';
1313

1414
export const RULE_NAME = 'prefer-presence-queries';
15-
export type MessageIds = 'presenceQuery' | 'absenceQuery' | 'expectQueryBy';
15+
export type MessageIds = 'presenceQuery' | 'absenceQuery';
1616
type Options = [];
1717

1818
const QUERIES_REGEXP = new RegExp(
@@ -23,7 +23,7 @@ function isThrowingQuery(node: TSESTree.Identifier) {
2323
return node.name.startsWith('get');
2424
}
2525

26-
export default ESLintUtils.RuleCreator(getDocsUrl)<Options, MessageIds>({
26+
export default createTestingLibraryRule<Options, MessageIds>({
2727
name: RULE_NAME,
2828
meta: {
2929
docs: {
@@ -37,8 +37,6 @@ export default ESLintUtils.RuleCreator(getDocsUrl)<Options, MessageIds>({
3737
'Use `getBy*` queries rather than `queryBy*` for checking element is present',
3838
absenceQuery:
3939
'Use `queryBy*` queries rather than `getBy*` for checking element is NOT present',
40-
expectQueryBy:
41-
'Use `getBy*` only when checking elements are present, otherwise use `queryBy*`',
4240
},
4341
schema: [],
4442
type: 'suggestion',

0 commit comments

Comments
 (0)