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

feat: invalid-react-selector in /react ruleset #43

Open
codejedi365 opened this issue Nov 14, 2021 · 0 comments
Open

feat: invalid-react-selector in /react ruleset #43

codejedi365 opened this issue Nov 14, 2021 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@codejedi365
Copy link
Collaborator

codejedi365 commented Nov 14, 2021

Feature Request

Create a rule that throws an error when using ReactSelector() on a selector string which will result in a null as part of the /react ruleset.

Problem & Goal

testcafe-react-selectors has a known limitation where selecting root components start at the root React component to look down the component tree. This means invalid selectors that reference html outside of the base react component like body prior to the react component name will return null even if the React component name exists.

Throw an error stating this selector will likely return null and should only start with the react component. Alternatives should be provided as well to identify other valid selector methods.

Expected behavior

// page.test.js -- invalid code
import { ReactSelector } from "testcafe-react-selectors";

test("my react component", async (t) => {
  const myComponent = ReactSelector("body MyComponent");
  await t.expect(myComponent.exists).ok();
});
eslint ./page.test.js

Should throw an error on line 5, highlighting ReactSelector() providing a message that this will likely return null.

@codejedi365 codejedi365 added the enhancement New feature or request label Nov 14, 2021
@codejedi365 codejedi365 self-assigned this Nov 14, 2021
@codejedi365 codejedi365 changed the title feat: invalid-react-selector in /react rules feat: invalid-react-selector in /react ruleset Nov 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant