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: no-implied-descendent in /react ruleset #49

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

feat: no-implied-descendent in /react ruleset #49

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

Comments

@codejedi365
Copy link
Collaborator

Feature Request

Create a rule that errors when a ReactSelector() parameter uses an html entity as a descendent selector without specifying it as a direct descendent with >.

Problem & Goal

testcafe-react-selectors warns about using ReactSelector() with a parameter of a 'ReactComponent div' when the div will only match direct children of the ReactComponent and not all the children of the subcomponent.

// Example html
<TodoApp className="todo-app">
    <TodoInput />
    <TodoList>
        <TodoItem priority="High" key="HighPriority">Item 1</TodoItem>
        <TodoItem priority="Low" key="LowPriority">Item 2</TodoItem>
    </TodoList>

    <div className="items-count">Items count: <span>{this.state.itemCount}</span></div>
</TodoApp>
// Extraction code
import { ReactSelector } from 'testcafe-react-selectors';

const TodoList         = ReactSelector('TodoApp TodoList');
const itemsCountStatus = ReactSelector('TodoApp div');

// itemsCountStatus == Selector('.todo-app > div')

The goal here is to enforce an explicit use of the immediate descendent css selector > to ensure the limitation of the library is not overlooked.

Expected behavior

@codejedi365 codejedi365 added the enhancement New feature or request label Nov 14, 2021
@codejedi365 codejedi365 self-assigned this 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