Skip to content

Commit

Permalink
docs(consistent-data-testid): add clarification about rule creation (#…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
Belco90 authored Nov 3, 2020
1 parent 5a6644f commit eb17456
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/rules/consistent-data-testid.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getDocsUrl } from '../utils';
import { ESLintUtils, TSESTree } from '@typescript-eslint/experimental-utils';
import { ESLintUtils } from '@typescript-eslint/experimental-utils';
import { isJSXAttribute, isLiteral } from '../node-utils';

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

const FILENAME_PLACEHOLDER = '{fileName}';

/**
* This rule is not created with `createTestingLibraryRule` since:
* - it doesn't need any detection helper
* - it doesn't apply to testing files but component files
*/
export default ESLintUtils.RuleCreator(getDocsUrl)<Options, MessageIds>({
name: RULE_NAME,
meta: {
Expand Down Expand Up @@ -89,7 +94,7 @@ export default ESLintUtils.RuleCreator(getDocsUrl)<Options, MessageIds>({
}

return {
[`JSXIdentifier`]: (node: TSESTree.JSXIdentifier) => {
JSXIdentifier: (node) => {
if (
!isJSXAttribute(node.parent) ||
!isLiteral(node.parent.value) ||
Expand Down

0 comments on commit eb17456

Please sign in to comment.