From d4bd838bf1f992052e27b4aca401c8327a74dee0 Mon Sep 17 00:00:00 2001 From: Damien Cassou Date: Mon, 4 Jul 2022 10:17:21 +0200 Subject: [PATCH 1/3] Fix regexp in expect-helpers.js The previous regexp didn't accept space characters in the expressions starting with `expect` expression. This would fail for example: cy.then(($a) => {expect($a) .to.have.attr("href")}) ^ space here --- lib/helpers/expect-helpers.js | 2 +- tests/lib/rules/no-single-expect-in-then-or-should.js | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/helpers/expect-helpers.js b/lib/helpers/expect-helpers.js index 364fc69a..faeea5d3 100644 --- a/lib/helpers/expect-helpers.js +++ b/lib/helpers/expect-helpers.js @@ -34,7 +34,7 @@ function getInitialReceiver (node) { } } -const expectRegexp = /^expect\([^)]*\)\.(not\.)?(?:to\.)?(.*)$/s +const expectRegexp = /^expect\([^)]*\)\s*\.\s*(not\s*\.)?\s*(?:to\s*\.)?\s*(.*)$/s /** * Convert `expectNode`, a call to `expect()` with some chainers into diff --git a/tests/lib/rules/no-single-expect-in-then-or-should.js b/tests/lib/rules/no-single-expect-in-then-or-should.js index 5a907af4..b93c4ce9 100644 --- a/tests/lib/rules/no-single-expect-in-then-or-should.js +++ b/tests/lib/rules/no-single-expect-in-then-or-should.js @@ -61,5 +61,10 @@ ruleTester.run('no-single-expect-in-then-or-should', rule, { errors: [thenError], output: 'cy.should("match", "checked")', }, + { + code: 'cy.then(($a) => {expect($a) .to.have.attr("href")})', + errors: [thenError], + output: 'cy.should("have.attr", "href")', + }, ], }) From 4d9c204d35106773302a6fecd3a173be5201057b Mon Sep 17 00:00:00 2001 From: Damien Cassou Date: Mon, 4 Jul 2022 10:18:27 +0200 Subject: [PATCH 2/3] Fix function documentation in no-single-expect-in-then-or-should --- lib/rules/no-single-expect-in-then-or-should.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/rules/no-single-expect-in-then-or-should.js b/lib/rules/no-single-expect-in-then-or-should.js index 0bd1ad36..1ecb0582 100644 --- a/lib/rules/no-single-expect-in-then-or-should.js +++ b/lib/rules/no-single-expect-in-then-or-should.js @@ -34,8 +34,8 @@ module.exports = { //---------------------------------------------------------------------- /** - * Use `fixer` to rewrite `node` (a call to `then()` or `should()` - * with a lonely `expect()` call as body). + * Use `fixer` to rewrite `thenOrShouldCallNode` (a call to + * `then()` or `should()` with a lonely `expect()` call as body). */ function fixCall (fixer, thenOrShouldCallNode, expectNode) { // shouldString is, e.g., .should("equal", 2) From c550f0ee5d861df44c93cef05488f3abd2b850a6 Mon Sep 17 00:00:00 2001 From: Damien Cassou Date: Mon, 4 Jul 2022 10:24:15 +0200 Subject: [PATCH 3/3] Release 3.1.1 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 16cea08f..ad35aa5d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@finsit/eslint-plugin-cypress", - "version": "3.1.0", + "version": "3.1.1", "lockfileVersion": 2, "requires": true, "packages": { diff --git a/package.json b/package.json index ed2dbbd0..b27ed4f9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@finsit/eslint-plugin-cypress", - "version": "3.1.0", + "version": "3.1.1", "description": "An ESLint plugin for projects using Cypress", "main": "index.js", "author": "Chris Breiding (chris@cypress.io)",