eslint-plugin-cypress 3.1.1 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRIBUTING.md +45 -11
- package/FLAT-CONFIG.md +146 -0
- package/README.md +5 -2
- package/circle.yml +21 -1
- package/eslint.config.mjs +29 -0
- package/jest.config-legacy.js +6 -0
- package/lib/flat.js +66 -0
- package/package.json +13 -6
- package/tests/config.js +6 -6
- package/tests/lib/rules/assertion-before-screenshot.js +18 -19
- package/tests/lib/rules/no-assigning-return-values.js +19 -20
- package/tests/lib/rules/no-async-before.js +8 -10
- package/tests/lib/rules/no-async-tests.js +8 -10
- package/tests/lib/rules/no-force.js +24 -34
- package/tests/lib/rules/no-pause.js +9 -23
- package/tests/lib/rules/no-unnecessary-waiting.js +31 -55
- package/tests/lib/rules/require-data-selectors.js +14 -15
- package/tests/lib/rules/unsafe-to-chain-command.js +8 -30
- package/tests-legacy/config.js +26 -0
- package/tests-legacy/lib/rules/assertion-before-screenshot.js +35 -0
- package/tests-legacy/lib/rules/no-assigning-return-values.js +38 -0
- package/tests-legacy/lib/rules/no-async-before.js +25 -0
- package/tests-legacy/lib/rules/no-async-tests.js +25 -0
- package/tests-legacy/lib/rules/no-force.js +49 -0
- package/tests-legacy/lib/rules/no-pause.js +37 -0
- package/tests-legacy/lib/rules/no-unnecessary-waiting.js +71 -0
- package/tests-legacy/lib/rules/require-data-selectors.js +31 -0
- package/tests-legacy/lib/rules/unsafe-to-chain-command.js +56 -0
- package/.eslintrc.js +0 -30
- /package/{index.js → legacy.js} +0 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const rule = require('../../../lib/rules/require-data-selectors')
|
|
4
|
+
const RuleTester = require('eslint').RuleTester
|
|
5
|
+
|
|
6
|
+
const ruleTester = new RuleTester()
|
|
7
|
+
|
|
8
|
+
const errors = [{ messageId: 'unexpected' }]
|
|
9
|
+
const parserOptions = { ecmaVersion: 6 }
|
|
10
|
+
|
|
11
|
+
ruleTester.run('require-data-selectors', rule, {
|
|
12
|
+
valid: [
|
|
13
|
+
{ code: 'cy.get(\'[data-cy=submit]\').click()', parserOptions },
|
|
14
|
+
{ code: 'cy.get(\'[data-QA=submit]\')', parserOptions },
|
|
15
|
+
{ code: 'cy.clock(5000)', parserOptions },
|
|
16
|
+
{ code: 'cy.scrollTo(0, 10)', parserOptions },
|
|
17
|
+
{ code: 'cy.tick(500)', parserOptions },
|
|
18
|
+
{ code: 'cy.get(\`[data-cy=${1}]\`)', parserOptions }, // eslint-disable-line no-useless-escape
|
|
19
|
+
{ code: 'cy.get("@my-alias")', parserOptions, errors },
|
|
20
|
+
{ code: 'cy.get(`@my-alias`)', parserOptions, errors },
|
|
21
|
+
],
|
|
22
|
+
|
|
23
|
+
invalid: [
|
|
24
|
+
{ code: 'cy.get(\'[daedta-cy=submit]\').click()', parserOptions, errors },
|
|
25
|
+
{ code: 'cy.get(\'[d-cy=submit]\')', parserOptions, errors },
|
|
26
|
+
{ code: 'cy.get(".btn-large").click()', parserOptions, errors },
|
|
27
|
+
{ code: 'cy.get(".btn-.large").click()', parserOptions, errors },
|
|
28
|
+
{ code: 'cy.get(".a")', parserOptions, errors },
|
|
29
|
+
{ code: 'cy.get(\`[daedta-cy=${1}]\`)', parserOptions, errors }, // eslint-disable-line no-useless-escape
|
|
30
|
+
],
|
|
31
|
+
})
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const rule = require('../../../lib/rules/unsafe-to-chain-command')
|
|
4
|
+
const RuleTester = require('eslint').RuleTester
|
|
5
|
+
|
|
6
|
+
const ruleTester = new RuleTester()
|
|
7
|
+
|
|
8
|
+
const errors = [{ messageId: 'unexpected' }]
|
|
9
|
+
const parserOptions = { ecmaVersion: 6 }
|
|
10
|
+
|
|
11
|
+
ruleTester.run('action-ends-chain', rule, {
|
|
12
|
+
valid: [
|
|
13
|
+
{
|
|
14
|
+
code: 'cy.get("new-todo").type("todo A{enter}"); cy.get("new-todo").type("todo B{enter}"); cy.get("new-todo").should("have.class", "active");',
|
|
15
|
+
parserOptions,
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
code: 'cy.focused().should("be.visible");',
|
|
19
|
+
parserOptions,
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
code: 'cy.submitBtn().click();',
|
|
23
|
+
parserOptions,
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
|
|
27
|
+
invalid: [
|
|
28
|
+
{
|
|
29
|
+
code: 'cy.get("new-todo").type("todo A{enter}").should("have.class", "active");',
|
|
30
|
+
parserOptions,
|
|
31
|
+
errors,
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
code: 'cy.get("new-todo").type("todo A{enter}").type("todo B{enter}");',
|
|
35
|
+
parserOptions,
|
|
36
|
+
errors,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
code: 'cy.get("new-todo").focus().should("have.class", "active");',
|
|
40
|
+
parserOptions,
|
|
41
|
+
errors,
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
code: 'cy.get("new-todo").customType("todo A{enter}").customClick();',
|
|
45
|
+
options: [{ methods: ['customType', 'customClick'] }],
|
|
46
|
+
parserOptions,
|
|
47
|
+
errors,
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
code: 'cy.get("new-todo").customPress("Enter").customScroll();',
|
|
51
|
+
options: [{ methods: [/customPress/, /customScroll/] }],
|
|
52
|
+
parserOptions,
|
|
53
|
+
errors,
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
})
|
package/.eslintrc.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
"env": {
|
|
3
|
-
"node": true,
|
|
4
|
-
"es6": true
|
|
5
|
-
},
|
|
6
|
-
"plugins": [
|
|
7
|
-
"eslint-plugin",
|
|
8
|
-
"n",
|
|
9
|
-
"mocha"
|
|
10
|
-
],
|
|
11
|
-
"extends": [
|
|
12
|
-
"eslint:recommended",
|
|
13
|
-
"plugin:eslint-plugin/recommended",
|
|
14
|
-
"plugin:n/recommended",
|
|
15
|
-
"plugin:mocha/recommended"
|
|
16
|
-
],
|
|
17
|
-
"rules": {
|
|
18
|
-
"eslint-plugin/require-meta-docs-url":
|
|
19
|
-
["error", { "pattern": "https://github.com/cypress-io/eslint-plugin-cypress/blob/master/docs/rules/{{name}}.md" }],
|
|
20
|
-
"eslint-plugin/require-meta-docs-description": "error",
|
|
21
|
-
"n/no-extraneous-require":
|
|
22
|
-
["error", { "allowModules": ["jest-config"] }],
|
|
23
|
-
"no-redeclare": "off",
|
|
24
|
-
"mocha/no-mocha-arrows": "off",
|
|
25
|
-
"mocha/no-setup-in-describe": "off"
|
|
26
|
-
},
|
|
27
|
-
"parserOptions": {
|
|
28
|
-
"ecmaVersion": 2020
|
|
29
|
-
}
|
|
30
|
-
}
|
/package/{index.js → legacy.js}
RENAMED
|
File without changes
|