Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug with testAttribute error messages #7

Closed
mahammedzkhan opened this issue Jul 24, 2020 · 1 comment
Closed

Bug with testAttribute error messages #7

mahammedzkhan opened this issue Jul 24, 2020 · 1 comment

Comments

@mahammedzkhan
Copy link

mahammedzkhan commented Jul 24, 2020

I've added this plugin to our projects with the following settings:

rules: [
"test-selectors/onChange": [
      "warn",
      "always",
      {
        "testAttribute": "data-testid"
      }
    ],
]

Is it possible to set the testAttribute for all rules? Because I don't think there's a scenario where you use a different testAttribute for onChange and for button.

@davidcalhoun
Copy link
Owner

Hello @mahammedzkhan - it looks like you just enabled that custom test selector for the onChange handler rule. There's currently no way to turn on that custom selector for all rules unfortunately. If you want to enable that custom attribute for all rules, your ESLint config will look something like this:

{
    "rules": {
        "test-selectors/anchor": ["warn", "always", { "testAttribute": "data-testid" }],
        "test-selectors/button": ["warn", "always", { "testAttribute": "data-testid" }],
        "test-selectors/input": ["warn", "always", { "testAttribute": "data-testid" }],
        "test-selectors/onChange": ["warn", "always", { "testAttribute": "data-testid" }],
        "test-selectors/onClick": ["warn", "always", { "testAttribute": "data-testid" }],
        "test-selectors/onKeyDown": ["warn", "always", { "testAttribute": "data-testid" }],
        "test-selectors/onKeyUp": ["warn", "always", { "testAttribute": "data-testid" }]
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants