Skip to content

Commit 9b70ddc

Browse files
committed
fix pr/247
1 parent 1fbedac commit 9b70ddc

File tree

4 files changed

+8
-13
lines changed

4 files changed

+8
-13
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff 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

docs/rules/no-xpath.md

+3-7
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,24 @@
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

89
Examples of **incorrect** code for this rule:
910

1011
```js
11-
1212
cy.xpath('//div[@class=\"container\"]').click()
1313
```
1414

1515
Examples of **correct** code for this rule:
1616

17-
1817
```js
19-
2018
cy.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

2925
See [the Cypress Best Practices guide](https://docs.cypress.io/guides/references/best-practices.html#Selecting-Elements).

lib/rules/no-xpath.js

+4-4
Original file line numberDiff line numberDiff 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) {

tests/lib/rules/no-xpath.js

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ const rule = require("../../../lib/rules/no-xpath"),
1414
const ruleTester = new RuleTester();
1515
ruleTester.run("no-xpath", rule, {
1616
valid: [
17-
{ code: 'cy.wait("@someRequest")' },
1817
{ code: 'cy.get("button").click({force: true})' },
1918
],
2019

0 commit comments

Comments
 (0)