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

Several advanced examples fail cypress/unsafe-to-chain-command lint rule #661

Closed
1 task
MikeMcC399 opened this issue May 2, 2023 · 11 comments · Fixed by #802
Closed
1 task

Several advanced examples fail cypress/unsafe-to-chain-command lint rule #661

MikeMcC399 opened this issue May 2, 2023 · 11 comments · Fixed by #802
Labels
released triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team.

Comments

@MikeMcC399
Copy link
Contributor

MikeMcC399 commented May 2, 2023

If the eslint rule cypress/unsafe-to-chain-command from eslint-plugin-cypress: Rules is enabled, then the following 6 examples in cypress/e2e/2-advanced-examples fail linting with the message:

"error It is unsafe to chain further commands that rely on the subject after this command. It is best to split the chain, chaining again from cy. in a next command line cypress/unsafe-to-chain-command"

"✖ 57 problems (51 errors, 0 warnings)"

Here is a portion of actions.cy.js which fails linting:

    cy.get('.action-email')
      .type('fake@email.com').should('have.value', 'fake@email.com')

      // .type() with special character sequences
      .type('{leftarrow}{rightarrow}{uparrow}{downarrow}')
      .type('{del}{selectall}{backspace}')

      // .type() with key modifiers
      .type('{alt}{option}') //these are equivalent
      .type('{ctrl}{control}') //these are equivalent
      .type('{meta}{command}{cmd}') //these are equivalent
      .type('{shift}')

      // Delay each keypress by 0.1 sec
      .type('slow.typing@email.com', { delay: 100 })
      .should('have.value', 'slow.typing@email.com') 

Expectation

Since the rule cypress/unsafe-to-chain-command is part of plugin:cypress/recommended rules according to eslint-plugin-cypress: Rules I would expect standard examples to pass this lint test.

Steps to reproduce

Add "cypress/unsafe-to-chain-command": "error" to rules of .eslintrc, similar to the following

  "rules": {
    "cypress/unsafe-to-chain-command": "error"
  }

Execute:

npm run lint

Reproducible example on https://github.com/MikeMcC399/cypress-example-kitchensink/tree/test/unsafe-to-chain

Environment

Next steps

  • Correct the examples
@mschile
Copy link
Contributor

mschile commented May 2, 2023

Hi @MikeMcC399 👋, thanks for logging this issue. I took a cursory look at the reported errors and the rule appears to be correct so we should do #2 and update the examples.

@mschile mschile added the triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team. label May 2, 2023
@mschile mschile removed their assignment May 2, 2023
@MikeMcC399
Copy link
Contributor Author

Hi @mschile

Thank you very much for qualifying this issue!

I can't provide a solution for this issue, so I would be happy for the core team to make the changes in the examples.

@MikeMcC399

This comment was marked as resolved.

MikeMcC399 added a commit to MikeMcC399/cypress-example-kitchensink that referenced this issue May 8, 2023
Co-authored-by: Matt Schile <mschile@gmail.com>
@MikeMcC399

This comment was marked as outdated.

@MikeMcC399

This comment was marked as outdated.

@MikeMcC399
Copy link
Contributor Author

Unfortunately I'm unable to provide a PR to resolve this issue, which remains unaddressed.

Steps to reproduce

Comment out

"cypress/unsafe-to-chain-command": "off",

and then execute

npm run lint

shows

✖ 57 problems (57 errors, 0 warnings)

@enchorb
Copy link

enchorb commented Jan 30, 2024

+1

@jennifer-shehane
Copy link
Member

@MikeMcC399 I'd be fine with an update to the example recipes to reflect our new conventions. We just never revisited this.

@MikeMcC399
Copy link
Contributor Author

@jennifer-shehane

@MikeMcC399 I'd be fine with an update to the example recipes to reflect our new conventions. We just never revisited this.

This issue is still open because as I said previously I don't have the skills for this and nobody else has picked it up.

rubysolo pushed a commit to rubysolo/cypress-example-kitchensink that referenced this issue Mar 11, 2024
rubysolo added a commit to rubysolo/cypress-example-kitchensink that referenced this issue Mar 11, 2024
rubysolo added a commit to rubysolo/cypress-example-kitchensink that referenced this issue Mar 11, 2024
@MikeMcC399
Copy link
Contributor Author

jennifer-shehane pushed a commit that referenced this issue Mar 12, 2024
@cypress-app-bot
Copy link
Collaborator

🎉 This issue has been resolved in version 2.0.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants