cypress-example-kitchensink
cypress-example-kitchensink copied to clipboard
Several advanced examples fail cypress/unsafe-to-chain-command lint rule
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('[email protected]').should('have.value', '[email protected]')
// .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('[email protected]', { delay: 100 })
.should('have.value', '[email protected]')
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
- [email protected]
- [email protected] (current
latest)
Next steps
- [ ] Correct the examples
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.
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.
- I have proposed a fix for a related issue in https://github.com/cypress-io/cypress-example-kitchensink/pull/662. For the waiting issue I propose to ignore the rule.
@mschile
unsafe-to-chain is currently disabled in this repo pending update of the examples to conform to linting rules.
The latest new release from Aug 8, 2023 [email protected] causes additional 8 problems to be flagged if the rule is enabled:
✖ 59 problems (59 errors, 0 warnings)
instead of the previous
✖ 51 problems (51 errors, 0 warnings)
It would be good for the examples to be updated so that they can be used as a reference for what is correct. Perhaps this fix could be scheduled some time soon?
- See also https://github.com/cypress-io/eslint-plugin-cypress/issues/140
Updating to [email protected] (current latest) causes now 59 "unsafe to chain" errors when checking with
"rules": {
"cypress/unsafe-to-chain-command": "error"
}
The rule is currently disabled and waiting for the examples to be corrected so they conform to the chaining rules as described in the https://docs.cypress.io/api/table-of-contents documentation.
https://github.com/cypress-io/cypress-example-kitchensink/blob/a3327d9af69f78cc3f7d52e7477c5f067f07c8f3/.eslintrc#L17-L18
Unfortunately I'm unable to provide a PR to resolve this issue, which remains unaddressed.
Steps to reproduce
Comment out
https://github.com/cypress-io/cypress-example-kitchensink/blob/b49f532c383335ee8d5d8c1fa403b50e4cef496a/.eslintrc#L18
and then execute
npm run lint
shows
✖ 57 problems (57 errors, 0 warnings)
+1
@MikeMcC399 I'd be fine with an update to the example recipes to reflect our new conventions. We just never revisited this.
@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.
- Thanks to @rubysolo for addressing this issue in #802 !
:tada: This issue has been resolved in version 2.0.3 :tada:
The release is available on:
Your semantic-release bot :package::rocket: