Open microbae opened 1 year ago
@microbae Can you elaborate a bit more on why you think this is a false positive and what you think the correct behavior should be?
Hi! There are still some cases in which this eslint rule is causing an error even when the code looks exactly the same as some examples in the cypress documentation.
cy.get('.map-container').scrollIntoView().should('be.visible');
This is causing an error and it's something that is widely used and showed in the cypress docs
@riboher as i understand it from here: https://docs.cypress.io/guides/core-concepts/retry-ability#Actions-should-be-at-the-end-of-chains-not-the-middle
That command should be broken up where you end chains after an action.
cy.get('.map-container').scrollIntoView();
cy.get('.map-container').should('be.visible');
I think the blur command should be broken up too.
cy.get('[name="comment"]').focus().type('Nice Product!')
cy.get('[name="comment"]').blur()
So it seems like the cypress docs need to be updated.
Transferred this issue to the cypress-documentation repo so the documentation examples can be updated.
I experienced the same issue with cy.focused().blur()
and I don't think this should be split up.
Same for me, I have an eslint error on the following line:
cy.focused().should('have.id', 'name');
I don't think I can split this.
For
cy.focused().should('have.id', 'name');
the docs explicitly say this is safe, but it does flag on cypress/unsafe-to-chain-command
in eslint-plugin-cypress
2.14.0
https://docs.cypress.io/api/commands/focused#Syntax
cy.focused() is a query, and it is safe to chain further commands.
I've made a PR here: https://github.com/cypress-io/eslint-plugin-cypress/pull/142
unsafe-to-chain-command
Is it intended that the 'unsafe-to-chain-command' rule hits, if you use quite normal stuff like the ones given in the official Cypress documentation? I think the rule should do much more than just checking if the action is included in the unsafeToChainActions array. There are too many false positives here..
Example: