Skip to content

Commit eb17456

Browse files
authored
docs(consistent-data-testid): add clarification about rule creation (#248)
* feat: new setting for customizing file name pattern to report * test: add custom rule tester for testing library * refactor: use common rule tester config * refactor(no-dom-import): use createTestingLibraryRule * feat(detection-helpers): check imports with require * test(no-dom-import): include test cases for custom module setting * test(no-dom-import): include test cases for custom module setting * chore: fix merge * refactor(no-dom-import): extract detection helpers for import nodes * test: increase coverage * refactor: rename setting for filename pattern * refactor: add new detection option to skip reporting checks * refactor(consistent-data-testid): use createTestingLibraryRule * revert: refactor consistent-data-testid * revert: detection options * docs(consistent-data-testid): add clarification about rule creation
1 parent 5a6644f commit eb17456

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/rules/consistent-data-testid.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { getDocsUrl } from '../utils';
2-
import { ESLintUtils, TSESTree } from '@typescript-eslint/experimental-utils';
2+
import { ESLintUtils } from '@typescript-eslint/experimental-utils';
33
import { isJSXAttribute, isLiteral } from '../node-utils';
44

55
export const RULE_NAME = 'consistent-data-testid';
@@ -13,6 +13,11 @@ type Options = [
1313

1414
const FILENAME_PLACEHOLDER = '{fileName}';
1515

16+
/**
17+
* This rule is not created with `createTestingLibraryRule` since:
18+
* - it doesn't need any detection helper
19+
* - it doesn't apply to testing files but component files
20+
*/
1621
export default ESLintUtils.RuleCreator(getDocsUrl)<Options, MessageIds>({
1722
name: RULE_NAME,
1823
meta: {
@@ -89,7 +94,7 @@ export default ESLintUtils.RuleCreator(getDocsUrl)<Options, MessageIds>({
8994
}
9095

9196
return {
92-
[`JSXIdentifier`]: (node: TSESTree.JSXIdentifier) => {
97+
JSXIdentifier: (node) => {
9398
if (
9499
!isJSXAttribute(node.parent) ||
95100
!isLiteral(node.parent.value) ||

0 commit comments

Comments
 (0)