Skip to content

Commit b911318

Browse files
committed
Add custom data-test definition for eslint-plugin-test-selectors
Now our JSX should not yell at us that we aren't using `data-test-id`, because we are using `data-testid`. Update test output, because some rules began applying in a different order. Release version 2.0.8.
1 parent 05144e9 commit b911318

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

demo/test/snapshots/lint-output.js.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ Generated by [AVA](https://ava.li).
2626
21:1 warning JSDoc type missing brace valid-jsdoc␊
2727
23:0 warning Expected @param names to be "params". Got "a, b" jsdoc/check-param-names␊
2828
23:0 warning Missing JSDoc @param "a" description jsdoc/require-param-description␊
29-
24:0 warning Missing JSDoc @param "b" type jsdoc/require-param-type␊
3029
24:0 warning Missing JSDoc @param "b" description jsdoc/require-param-description␊
30+
24:0 warning Missing JSDoc @param "b" type jsdoc/require-param-type␊
3131
25:0 warning Missing JSDoc @returns description jsdoc/require-returns-description␊
3232
25:0 warning Missing JSDoc @returns type jsdoc/require-returns-type␊
3333
30:5 warning 'myPromise' is never reassigned. Use 'const' instead prefer-const␊
@@ -39,8 +39,8 @@ Generated by [AVA](https://ava.li).
3939
36:5 error 'forgotToReturn' is not defined no-undef␊
4040
36:21 error Missing semicolon semi␊
4141
38:3 error Missing semicolon semi␊
42-
40:5 error 'variable' is assigned a value but never used no-unused-vars␊
4342
40:5 warning 'variable' is never reassigned. Use 'const' instead prefer-const␊
43+
40:5 error 'variable' is assigned a value but never used no-unused-vars␊
4444
40:16 warning This conditional operation returns the same value whether the condition is "true" or "false" sonarjs/no-all-duplicated-branches␊
4545
40:17 error Unexpected constant condition no-constant-condition␊
4646
40:25 error Unnecessary use of boolean literals in conditional expression no-unneeded-ternary␊
@@ -51,14 +51,14 @@ Generated by [AVA](https://ava.li).
5151
42:62 error 'params' is not defined no-undef␊
5252
43:3 warning This function expects 1 argument, but 2 were provided sonarjs/no-extra-arguments␊
5353
44:28 error Module path/to/legacyModule is deprecated. Use module x instead deprecate/import␊
54-
46:3 error 'deprecatedFunction' is not defined no-undef␊
5554
46:3 error Function deprecatedFunction is deprecated. Use function x from package y instead deprecate/function␊
55+
46:3 error 'deprecatedFunction' is not defined no-undef␊
5656
47:3 error Member expression $.each is deprecated. Use native forEach instead deprecate/member-expression␊
5757
47:3 error '$' is not defined no-undef␊
5858
48:3 error Unexpected 'debugger' statement no-debugger␊
5959
6060
/Users/clif/sandbox/frontier/common/eslint-config-tree/index.js␊
61-
49:0 warning Invalid JSDoc tag name "note" jsdoc/check-tag-names␊
61+
52:0 warning Invalid JSDoc tag name "note" jsdoc/check-tag-names␊
6262
6363
example.json␊
6464
4:6 error Property keys must be doublequoted json/undefined␊
-8 Bytes
Binary file not shown.

index.js

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// We use `data-testid` instead of `data-test-id`, in order to match React Native and Testing Library https://testing-library.com/docs/dom-testing-library/api-queries#bytestid
2+
const dataTestId = 'data-testid';
3+
14
module.exports = {
25

36
// NOTE: See .eslintrc.js for example `extends` and `plugins` sections, which have to be done individually by each repository because of Code Climate not supporting everything we use.
@@ -173,13 +176,13 @@ module.exports = {
173176
'sonarjs/prefer-single-boolean-return': 'warn',
174177
'sonarjs/prefer-while': 'warn',
175178

176-
'test-selectors/anchor': ['warn', 'always', { 'ignoreDisabled': false, 'ignoreReadonly': false }],
177-
'test-selectors/button': ['warn', 'always', { 'ignoreDisabled': false, 'ignoreReadonly': false }],
178-
'test-selectors/input': ['warn', 'always', { 'ignoreDisabled': false, 'ignoreReadonly': false }],
179-
'test-selectors/onChange': ['warn', 'always', { 'ignoreDisabled': false, 'ignoreReadonly': false }],
180-
'test-selectors/onClick': ['warn', 'always', { 'ignoreDisabled': false, 'ignoreReadonly': false }],
181-
'test-selectors/onKeyDown': ['warn', 'always', { 'ignoreDisabled': false, 'ignoreReadonly': false }],
182-
'test-selectors/onKeyUp': ['warn', 'always', { 'ignoreDisabled': false, 'ignoreReadonly': false }]
179+
'test-selectors/anchor': ['warn', 'always', { 'ignoreDisabled': false, 'ignoreReadonly': false, "testAttribute": dataTestId }],
180+
'test-selectors/button': ['warn', 'always', { 'ignoreDisabled': false, 'ignoreReadonly': false, "testAttribute": dataTestId }],
181+
'test-selectors/input': ['warn', 'always', { 'ignoreDisabled': false, 'ignoreReadonly': false, "testAttribute": dataTestId }],
182+
'test-selectors/onChange': ['warn', 'always', { 'ignoreDisabled': false, 'ignoreReadonly': false, "testAttribute": dataTestId }],
183+
'test-selectors/onClick': ['warn', 'always', { 'ignoreDisabled': false, 'ignoreReadonly': false, "testAttribute": dataTestId }],
184+
'test-selectors/onKeyDown': ['warn', 'always', { 'ignoreDisabled': false, 'ignoreReadonly': false, "testAttribute": dataTestId }],
185+
'test-selectors/onKeyUp': ['warn', 'always', { 'ignoreDisabled': false, 'ignoreReadonly': false, "testAttribute": dataTestId }]
183186

184187
// See eslint-config-tree/.eslintrc.js for example deprecation rules.
185188
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "eslint-config-tree",
3-
"version": "2.0.7",
3+
"version": "2.0.8",
44
"description": "Shared Tree configuration that contains overrides and enhancements on top of the base frontier configuration.",
55
"main": "index.js",
66
"repository": {

0 commit comments

Comments
 (0)