cypress-io / eslint-plugin-cypress

An ESLint plugin for projects that use Cypress

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

Aryndel opened this issue · comments

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);

Also I'm getting similar on

cy.clearLocalStorage('app').should((localStorage) => {
      expect(localStorage.getItem('app')).to.be.null;
});

I found the commit related to this issue. 49c6eb3