File tree Expand file tree Collapse file tree 4 files changed +8
-13
lines changed
Expand file tree Collapse file tree 4 files changed +8
-13
lines changed Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ These rules enforce some of the [best practices recommended for using Cypress](h
5454| [ no-force] ( docs/rules/no-force.md ) | disallow using ` force: true ` with action commands | |
5555| [ no-pause] ( docs/rules/no-pause.md ) | disallow using ` cy.pause() ` calls | |
5656| [ no-unnecessary-waiting] ( docs/rules/no-unnecessary-waiting.md ) | disallow waiting for arbitrary time periods | ✅ |
57- | [ no-xpath] ( docs/rules/no-xpath.md ) | disallow usage of xpath in selector | |
57+ | [ no-xpath] ( docs/rules/no-xpath.md ) | disallow using ` cy. xpath() ` calls | |
5858| [ require-data-selectors] ( docs/rules/require-data-selectors.md ) | require ` data-* ` attribute selectors | |
5959| [ unsafe-to-chain-command] ( docs/rules/unsafe-to-chain-command.md ) | disallow actions within chains | ✅ |
6060
Original file line number Diff line number Diff line change 22
33<!-- end auto-generated rule header -->
44
5- This rule disallow the usage of cypress- xpath for selecting elements.
5+ This rule disallows the usage of ` cy. xpath() ` for selecting elements.
66
7+ ## Rule Details
78
89Examples of ** incorrect** code for this rule:
910
1011``` js
11-
1212cy .xpath (' //div[@class=\" container\" ]' ).click ()
1313```
1414
1515Examples of ** correct** code for this rule:
1616
17-
1817``` js
19-
2018cy .get (' [data-cy="container"]' ).click ();
2119```
2220
23-
2421## Further Reading
2522
26- Both ` @cypress/xpath ` and ` cypress-xpath ` packages have been deprecated since Oct 13, 2022.
27-
23+ Both ` @cypress/xpath ` and ` cypress-xpath ` are deprecated.
2824
2925See [ the Cypress Best Practices guide] ( https://docs.cypress.io/guides/references/best-practices.html#Selecting-Elements ) .
Original file line number Diff line number Diff line change @@ -4,15 +4,15 @@ module.exports = {
44 meta : {
55 type : 'suggestion' ,
66 docs : {
7- description : " disallow using cy.xpath() calls" ,
7+ description : ' disallow using ` cy.xpath()` calls' ,
88 recommended : false ,
9- url : " https://github.com/cypress-io/eslint-plugin-cypress/blob/master/docs/rules/no-xpath.md"
9+ url : ' https://github.com/cypress-io/eslint-plugin-cypress/blob/master/docs/rules/no-xpath.md'
1010 } ,
1111 fixable : null , // Or `code` or `whitespace`
1212 schema : [ ] , // Add a schema if the rule has options
1313 messages : {
14- unexpected : 'avoid using cypress xpath' ,
15- } ,
14+ unexpected : 'Avoid using cy. xpath command ' ,
15+ } ,
1616 } ,
1717
1818 create ( context ) {
Original file line number Diff line number Diff line change @@ -14,7 +14,6 @@ const rule = require("../../../lib/rules/no-xpath"),
1414const ruleTester = new RuleTester ( ) ;
1515ruleTester . run ( "no-xpath" , rule , {
1616 valid : [
17- { code : 'cy.wait("@someRequest")' } ,
1817 { code : 'cy.get("button").click({force: true})' } ,
1918 ] ,
2019
You can’t perform that action at this time.
0 commit comments