Skip to content

cypress/unsafe-to-chain-command produces false positives on custom commands containing the name of an unsafe stock command #145

@Aryndel

Description

@Aryndel

Due to the rule code for the cypress/unsafe-to-chain-command rule simply performing a substring check for its regex test, it displays false positives for any Cypress custom commands that just happen to include the same word as a stock command the rule looks for.

For example, our repo has a custom command called checkImageMatching. Since the rule looks for the check command, it flags any commands chained from this custom command as violating the rule (for the record, the custom command just compares two image files and doesn't even query the DOM, so this isn't a concern at all).

Example code that triggers the rule inappropriately:

cy.checkImageMatching( './cypress/e2e/aya-logo-full-transparent.jpg', ${Cypress.config(
'downloadsFolder'
)}/Testjwlvh Testowszfnnb_7-1-2022 CHOCChildHealtCenteMissiViejo-1_1.jpg ).should('eq', 0);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions