eslint-plugin-cypress 3.0.1 → 3.0.2

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/.eslintrc.json CHANGED
@@ -21,6 +21,7 @@
21
21
  "pattern": "https://github.com/cypress-io/eslint-plugin-cypress/blob/master/docs/rules/{{name}}.md"
22
22
  }
23
23
  ],
24
+ "eslint-plugin/require-meta-docs-description": "error",
24
25
  "n/no-extraneous-require": [
25
26
  "error",
26
27
  {
@@ -34,6 +35,6 @@
34
35
  "mocha/no-setup-in-describe": "off"
35
36
  },
36
37
  "parserOptions": {
37
- "ecmaVersion": 2018
38
+ "ecmaVersion": 2020
38
39
  }
39
40
  }
@@ -1,6 +1,6 @@
1
1
  # Prevent using async/await in Cypress test cases (no-async-tests)
2
2
 
3
- Cypress commands that return a promise may cause side effects in before/beforeEach hooks, possibly causing unexpected behavior.
3
+ Cypress commands that return a promise may cause side effects in before/beforeEach hooks, possibly causing unexpected behavior.
4
4
 
5
5
  ## Rule Details
6
6
 
@@ -47,6 +47,5 @@ If there are genuine use-cases for using `async/await` in your before then you m
47
47
 
48
48
  ## Further Reading
49
49
 
50
- - [Commands Are Asynchronous](https://docs.cypress.io/guides/core-concepts/introduction-to-cypress.html#Commands-Are-Asynchronous)
51
- - [Commands Are Promises](https://docs.cypress.io/guides/core-concepts/introduction-to-cypress.html#Commands-Are-Promises)
52
- - [Commands Are Not Promises](https://docs.cypress.io/guides/core-concepts/introduction-to-cypress.html#Commands-Are-Not-Promises)
50
+ - [Mixing Async and Sync code](https://on.cypress.io/guides/core-concepts/introduction-to-cypress#Mixing-Async-and-Sync-code)
51
+ - [Commands Are Asynchronous](https://on.cypress.io/guides/core-concepts/introduction-to-cypress.html#Commands-Are-Asynchronous)
@@ -47,6 +47,5 @@ If there are genuine use-cases for using `async/await` in your test cases then y
47
47
 
48
48
  ## Further Reading
49
49
 
50
- - [Commands Are Asynchronous](https://docs.cypress.io/guides/core-concepts/introduction-to-cypress.html#Commands-Are-Asynchronous)
51
- - [Commands Are Promises](https://docs.cypress.io/guides/core-concepts/introduction-to-cypress.html#Commands-Are-Promises)
52
- - [Commands Are Not Promises](https://docs.cypress.io/guides/core-concepts/introduction-to-cypress.html#Commands-Are-Not-Promises)
50
+ - [Mixing Async and Sync code](https://on.cypress.io/guides/core-concepts/introduction-to-cypress#Mixing-Async-and-Sync-code)
51
+ - [Commands Are Asynchronous](https://on.cypress.io/guides/core-concepts/introduction-to-cypress.html#Commands-Are-Asynchronous)
@@ -18,7 +18,7 @@ module.exports = {
18
18
  meta: {
19
19
  type: 'problem',
20
20
  docs: {
21
- description: 'Assert on the page state before taking a screenshot, so the screenshot is consistent',
21
+ description: 'require screenshots to be preceded by an assertion',
22
22
  category: 'Possible Errors',
23
23
  recommended: false,
24
24
  url: 'https://github.com/cypress-io/eslint-plugin-cypress/blob/master/docs/rules/assertion-before-screenshot.md',
@@ -19,7 +19,7 @@ module.exports = {
19
19
  meta: {
20
20
  type: 'problem',
21
21
  docs: {
22
- description: 'Prevent assigning return values of cy calls',
22
+ description: 'disallow assigning return values of `cy` calls',
23
23
  category: 'Possible Errors',
24
24
  recommended: true,
25
25
  url: 'https://github.com/cypress-io/eslint-plugin-cypress/blob/master/docs/rules/no-assigning-return-values.md',
@@ -4,7 +4,7 @@ module.exports = {
4
4
  meta: {
5
5
  type: 'problem',
6
6
  docs: {
7
- description: 'Prevent using async/await in Cypress before methods',
7
+ description: 'disallow using `async`/`await` in Cypress `before` methods',
8
8
  category: 'Possible Errors',
9
9
  recommended: true,
10
10
  url: 'https://github.com/cypress-io/eslint-plugin-cypress/blob/master/docs/rules/no-async-before.md',
@@ -28,11 +28,14 @@ module.exports = {
28
28
  && node.arguments.length >= 2
29
29
  && node.arguments[1].async === true
30
30
  }
31
+ const sourceCode = context.sourceCode ?? context.getSourceCode()
31
32
 
32
33
  return {
33
34
  Identifier (node) {
34
35
  if (node.name === 'cy' || node.name === 'Cypress') {
35
- const ancestors = context.getAncestors()
36
+ const ancestors = sourceCode.getAncestors
37
+ ? sourceCode.getAncestors(node)
38
+ : context.getAncestors()
36
39
  const asyncTestBlocks = ancestors
37
40
  .filter((n) => n.type === 'CallExpression')
38
41
  .filter(isBeforeBlock)
@@ -4,7 +4,7 @@ module.exports = {
4
4
  meta: {
5
5
  type: 'problem',
6
6
  docs: {
7
- description: 'Prevent using async/await in Cypress test cases',
7
+ description: 'disallow using `async`/`await` in Cypress test cases',
8
8
  category: 'Possible Errors',
9
9
  recommended: true,
10
10
  url: 'https://github.com/cypress-io/eslint-plugin-cypress/blob/master/docs/rules/no-async-tests.md',
@@ -28,11 +28,14 @@ module.exports = {
28
28
  && node.arguments.length >= 2
29
29
  && node.arguments[1].async === true
30
30
  }
31
+ const sourceCode = context.sourceCode ?? context.getSourceCode()
31
32
 
32
33
  return {
33
34
  Identifier (node) {
34
35
  if (node.name === 'cy' || node.name === 'Cypress') {
35
- const ancestors = context.getAncestors()
36
+ const ancestors = sourceCode.getAncestors
37
+ ? sourceCode.getAncestors(node)
38
+ : context.getAncestors()
36
39
  const asyncTestBlocks = ancestors
37
40
  .filter((n) => n.type === 'CallExpression')
38
41
  .filter(isTestBlock)
@@ -8,7 +8,7 @@ module.exports = {
8
8
  meta: {
9
9
  type: 'suggestion',
10
10
  docs: {
11
- description: 'Disallow using of \'force: true\' option for click and type calls',
11
+ description: 'disallow using `force: true` with action commands',
12
12
  category: 'Possible Errors',
13
13
  recommended: false,
14
14
  url: 'https://github.com/cypress-io/eslint-plugin-cypress/blob/master/docs/rules/no-force.md',
@@ -8,7 +8,7 @@ module.exports = {
8
8
  meta: {
9
9
  type: 'suggestion',
10
10
  docs: {
11
- description: 'Disallow using of \'cy.pause\' calls',
11
+ description: 'disallow using `cy.pause()` calls',
12
12
  category: 'Possible Errors',
13
13
  recommended: false,
14
14
  url: 'https://github.com/cypress-io/eslint-plugin-cypress/blob/master/docs/rules/no-pause.md',
@@ -4,7 +4,7 @@ module.exports = {
4
4
  meta: {
5
5
  type: 'problem',
6
6
  docs: {
7
- description: 'Prevent waiting for arbitrary time periods',
7
+ description: 'disallow waiting for arbitrary time periods',
8
8
  category: 'Possible Errors',
9
9
  recommended: true,
10
10
  url: 'https://github.com/cypress-io/eslint-plugin-cypress/blob/master/docs/rules/no-unnecessary-waiting.md',
@@ -15,10 +15,14 @@ module.exports = {
15
15
  },
16
16
  },
17
17
  create (context) {
18
+ const sourceCode = context.sourceCode ?? context.getSourceCode()
19
+
18
20
  return {
19
21
  CallExpression (node) {
20
22
  if (isCallingCyWait(node)) {
21
- const scope = context.getScope()
23
+ const scope = sourceCode.getScope
24
+ ? sourceCode.getScope(node)
25
+ : context.getScope()
22
26
 
23
27
  if (isIdentifierNumberConstArgument(node, scope) || isNumberArgument(node)) {
24
28
  context.report({ node, messageId: 'unexpected' })
@@ -4,7 +4,7 @@ module.exports = {
4
4
  meta: {
5
5
  type: 'suggestion',
6
6
  docs: {
7
- description: 'Use data-* attributes to provide context to your selectors and insulate them from CSS or JS changes',
7
+ description: 'require `data-*` attribute selectors',
8
8
  category: 'Possible Errors',
9
9
  recommended: false,
10
10
  url: 'https://github.com/cypress-io/eslint-plugin-cypress/blob/master/docs/rules/require-data-selectors.md',
@@ -3,7 +3,7 @@
3
3
  const { basename } = require('path')
4
4
 
5
5
  const NAME = basename(__dirname)
6
- const DESCRIPTION = 'Actions should be in the end of chains, not in the middle'
6
+ const DESCRIPTION = 'disallow actions within chains'
7
7
 
8
8
  /**
9
9
  * Commands listed in the documentation with text: 'It is unsafe to chain further commands that rely on the subject after xxx.'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-cypress",
3
- "version": "3.0.1",
3
+ "version": "3.0.2",
4
4
  "description": "An ESLint plugin for projects using Cypress",
5
5
  "main": "index.js",
6
6
  "author": "Cypress-io",