eslint-plugin-cypress
Advanced tools
Comparing version 3.0.1 to 3.0.2
@@ -24,2 +24,3 @@ { | ||
], | ||
"eslint-plugin/require-meta-docs-description": "error", | ||
"n/no-extraneous-require": [ | ||
@@ -38,4 +39,4 @@ "error", | ||
"parserOptions": { | ||
"ecmaVersion": 2018 | ||
"ecmaVersion": 2020 | ||
} | ||
} |
# Prevent using async/await in Cypress test cases (no-async-tests) | ||
Cypress commands that return a promise may cause side effects in before/beforeEach hooks, possibly causing unexpected behavior. | ||
Cypress commands that return a promise may cause side effects in before/beforeEach hooks, possibly causing unexpected behavior. | ||
@@ -50,4 +50,3 @@ ## Rule Details | ||
- [Commands Are Asynchronous](https://docs.cypress.io/guides/core-concepts/introduction-to-cypress.html#Commands-Are-Asynchronous) | ||
- [Commands Are Promises](https://docs.cypress.io/guides/core-concepts/introduction-to-cypress.html#Commands-Are-Promises) | ||
- [Commands Are Not Promises](https://docs.cypress.io/guides/core-concepts/introduction-to-cypress.html#Commands-Are-Not-Promises) | ||
- [Mixing Async and Sync code](https://on.cypress.io/guides/core-concepts/introduction-to-cypress#Mixing-Async-and-Sync-code) | ||
- [Commands Are Asynchronous](https://on.cypress.io/guides/core-concepts/introduction-to-cypress.html#Commands-Are-Asynchronous) |
@@ -50,4 +50,3 @@ # Prevent using async/await in Cypress test cases (no-async-tests) | ||
- [Commands Are Asynchronous](https://docs.cypress.io/guides/core-concepts/introduction-to-cypress.html#Commands-Are-Asynchronous) | ||
- [Commands Are Promises](https://docs.cypress.io/guides/core-concepts/introduction-to-cypress.html#Commands-Are-Promises) | ||
- [Commands Are Not Promises](https://docs.cypress.io/guides/core-concepts/introduction-to-cypress.html#Commands-Are-Not-Promises) | ||
- [Mixing Async and Sync code](https://on.cypress.io/guides/core-concepts/introduction-to-cypress#Mixing-Async-and-Sync-code) | ||
- [Commands Are Asynchronous](https://on.cypress.io/guides/core-concepts/introduction-to-cypress.html#Commands-Are-Asynchronous) |
@@ -21,3 +21,3 @@ 'use strict' | ||
docs: { | ||
description: 'Assert on the page state before taking a screenshot, so the screenshot is consistent', | ||
description: 'require screenshots to be preceded by an assertion', | ||
category: 'Possible Errors', | ||
@@ -24,0 +24,0 @@ recommended: false, |
@@ -22,3 +22,3 @@ 'use strict' | ||
docs: { | ||
description: 'Prevent assigning return values of cy calls', | ||
description: 'disallow assigning return values of `cy` calls', | ||
category: 'Possible Errors', | ||
@@ -25,0 +25,0 @@ recommended: true, |
@@ -7,3 +7,3 @@ 'use strict' | ||
docs: { | ||
description: 'Prevent using async/await in Cypress before methods', | ||
description: 'disallow using `async`/`await` in Cypress `before` methods', | ||
category: 'Possible Errors', | ||
@@ -32,2 +32,3 @@ recommended: true, | ||
} | ||
const sourceCode = context.sourceCode ?? context.getSourceCode() | ||
@@ -37,3 +38,5 @@ return { | ||
if (node.name === 'cy' || node.name === 'Cypress') { | ||
const ancestors = context.getAncestors() | ||
const ancestors = sourceCode.getAncestors | ||
? sourceCode.getAncestors(node) | ||
: context.getAncestors() | ||
const asyncTestBlocks = ancestors | ||
@@ -40,0 +43,0 @@ .filter((n) => n.type === 'CallExpression') |
@@ -7,3 +7,3 @@ 'use strict' | ||
docs: { | ||
description: 'Prevent using async/await in Cypress test cases', | ||
description: 'disallow using `async`/`await` in Cypress test cases', | ||
category: 'Possible Errors', | ||
@@ -32,2 +32,3 @@ recommended: true, | ||
} | ||
const sourceCode = context.sourceCode ?? context.getSourceCode() | ||
@@ -37,3 +38,5 @@ return { | ||
if (node.name === 'cy' || node.name === 'Cypress') { | ||
const ancestors = context.getAncestors() | ||
const ancestors = sourceCode.getAncestors | ||
? sourceCode.getAncestors(node) | ||
: context.getAncestors() | ||
const asyncTestBlocks = ancestors | ||
@@ -40,0 +43,0 @@ .filter((n) => n.type === 'CallExpression') |
@@ -11,3 +11,3 @@ 'use strict' | ||
docs: { | ||
description: 'Disallow using of \'force: true\' option for click and type calls', | ||
description: 'disallow using `force: true` with action commands', | ||
category: 'Possible Errors', | ||
@@ -14,0 +14,0 @@ recommended: false, |
@@ -11,3 +11,3 @@ 'use strict' | ||
docs: { | ||
description: 'Disallow using of \'cy.pause\' calls', | ||
description: 'disallow using `cy.pause()` calls', | ||
category: 'Possible Errors', | ||
@@ -14,0 +14,0 @@ recommended: false, |
@@ -7,3 +7,3 @@ 'use strict' | ||
docs: { | ||
description: 'Prevent waiting for arbitrary time periods', | ||
description: 'disallow waiting for arbitrary time periods', | ||
category: 'Possible Errors', | ||
@@ -19,6 +19,10 @@ recommended: true, | ||
create (context) { | ||
const sourceCode = context.sourceCode ?? context.getSourceCode() | ||
return { | ||
CallExpression (node) { | ||
if (isCallingCyWait(node)) { | ||
const scope = context.getScope() | ||
const scope = sourceCode.getScope | ||
? sourceCode.getScope(node) | ||
: context.getScope() | ||
@@ -25,0 +29,0 @@ if (isIdentifierNumberConstArgument(node, scope) || isNumberArgument(node)) { |
@@ -7,3 +7,3 @@ 'use strict' | ||
docs: { | ||
description: 'Use data-* attributes to provide context to your selectors and insulate them from CSS or JS changes', | ||
description: 'require `data-*` attribute selectors', | ||
category: 'Possible Errors', | ||
@@ -10,0 +10,0 @@ recommended: false, |
@@ -6,3 +6,3 @@ 'use strict' | ||
const NAME = basename(__dirname) | ||
const DESCRIPTION = 'Actions should be in the end of chains, not in the middle' | ||
const DESCRIPTION = 'disallow actions within chains' | ||
@@ -9,0 +9,0 @@ /** |
{ | ||
"name": "eslint-plugin-cypress", | ||
"version": "3.0.1", | ||
"version": "3.0.2", | ||
"description": "An ESLint plugin for projects using Cypress", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
55682
1004