From 213217fe9c7d52f6faacbff7c1f1eeb3f46c4771 Mon Sep 17 00:00:00 2001 From: Mark Skelton Date: Sat, 14 Jan 2023 17:47:38 -0600 Subject: [PATCH 01/28] Better scope for no-skipped-tests --- src/rules/no-skipped-test.ts | 6 +- test/spec/no-skipped-test.spec.ts | 235 ++++++++++++++++++++++++------ 2 files changed, 197 insertions(+), 44 deletions(-) diff --git a/src/rules/no-skipped-test.ts b/src/rules/no-skipped-test.ts index b3db30a..a37601a 100644 --- a/src/rules/no-skipped-test.ts +++ b/src/rules/no-skipped-test.ts @@ -17,13 +17,15 @@ export default { callee.type === 'MemberExpression' && isPropertyAccessor(callee, 'skip') ) { + const isHook = isTest(node) || isDescribeCall(node); + context.report({ messageId: 'noSkippedTest', suggest: [ { messageId: 'removeSkippedTestAnnotation', fix: (fixer) => { - return isTest(node) || isDescribeCall(node) + return isHook ? fixer.removeRange([ callee.property.range![0] - 1, callee.range![1], @@ -32,7 +34,7 @@ export default { }, }, ], - node, + node: isHook ? callee.property : node, }); } }, diff --git a/test/spec/no-skipped-test.spec.ts b/test/spec/no-skipped-test.spec.ts index b9ec5ee..d18b0e3 100644 --- a/test/spec/no-skipped-test.spec.ts +++ b/test/spec/no-skipped-test.spec.ts @@ -1,51 +1,202 @@ import { runRuleTester } from '../utils/rule-tester'; import rule from '../../src/rules/no-skipped-test'; -const invalid = (code: string, output: string) => ({ - code, - errors: [ - { - messageId: 'noSkippedTest', - suggestions: [{ messageId: 'removeSkippedTestAnnotation', output }], - }, - ], -}); +const messageId = 'removeSkippedTestAnnotation'; runRuleTester('no-skipped-test', rule, { invalid: [ - invalid( - 'test.skip("skip this test", async ({ page }) => {});', - 'test("skip this test", async ({ page }) => {});' - ), - invalid( - 'test["skip"]("skip this test", async ({ page }) => {});', - 'test("skip this test", async ({ page }) => {});' - ), - invalid( - 'test[`skip`]("skip this test", async ({ page }) => {});', - 'test("skip this test", async ({ page }) => {});' - ), - invalid( - 'test.describe.skip("skip this describe", () => {});', - 'test.describe("skip this describe", () => {});' - ), - invalid( - 'test.describe["skip"]("skip this describe", () => {});', - 'test.describe("skip this describe", () => {});' - ), - invalid( - 'test.describe[`skip`]("skip this describe", () => {});', - 'test.describe("skip this describe", () => {});' - ), - invalid('test.skip(browserName === "firefox");', ''), - invalid('test.skip(browserName === "firefox", "Still working on it");', ''), - invalid( - 'test.describe.parallel("run in parallel", () => { test.skip(); expect(true).toBe(true); })', - 'test.describe.parallel("run in parallel", () => { expect(true).toBe(true); })' - ), - invalid('test.skip()', ''), - invalid('test["skip"]()', ''), - invalid('test[`skip`]()', ''), + { + code: 'test.skip("skip this test", async ({ page }) => {});', + errors: [ + { + messageId: 'noSkippedTest', + suggestions: [ + { + messageId, + output: 'test("skip this test", async ({ page }) => {});', + }, + ], + line: 1, + column: 6, + endLine: 1, + endColumn: 10, + }, + ], + }, + { + code: 'test["skip"]("skip this test", async ({ page }) => {});', + errors: [ + { + messageId: 'noSkippedTest', + suggestions: [ + { + messageId, + output: 'test("skip this test", async ({ page }) => {});', + }, + ], + line: 1, + column: 6, + endLine: 1, + endColumn: 12, + }, + ], + }, + { + code: 'test[`skip`]("skip this test", async ({ page }) => {});', + errors: [ + { + messageId: 'noSkippedTest', + suggestions: [ + { + messageId, + output: 'test("skip this test", async ({ page }) => {});', + }, + ], + line: 1, + column: 6, + endLine: 1, + endColumn: 12, + }, + ], + }, + { + code: 'test.describe.skip("skip this describe", () => {});', + errors: [ + { + messageId: 'noSkippedTest', + suggestions: [ + { + messageId, + output: 'test.describe("skip this describe", () => {});', + }, + ], + line: 1, + column: 15, + endLine: 1, + endColumn: 19, + }, + ], + }, + { + code: 'test.describe["skip"]("skip this describe", () => {});', + errors: [ + { + messageId: 'noSkippedTest', + suggestions: [ + { + messageId, + output: 'test.describe("skip this describe", () => {});', + }, + ], + line: 1, + column: 15, + endLine: 1, + endColumn: 21, + }, + ], + }, + { + code: 'test.describe[`skip`]("skip this describe", () => {});', + errors: [ + { + messageId: 'noSkippedTest', + suggestions: [ + { + messageId, + output: 'test.describe("skip this describe", () => {});', + }, + ], + line: 1, + column: 15, + endLine: 1, + endColumn: 21, + }, + ], + }, + { + code: 'test.skip(browserName === "firefox");', + errors: [ + { + messageId: 'noSkippedTest', + suggestions: [{ messageId, output: '' }], + line: 1, + column: 1, + endLine: 1, + endColumn: 37, + }, + ], + }, + { + code: 'test.skip(browserName === "firefox", "Still working on it");', + errors: [ + { + messageId: 'noSkippedTest', + suggestions: [{ messageId, output: '' }], + line: 1, + column: 1, + endLine: 1, + endColumn: 60, + }, + ], + }, + { + code: 'test.describe.parallel("run in parallel", () => { test.skip(); expect(true).toBe(true); })', + errors: [ + { + messageId: 'noSkippedTest', + suggestions: [ + { + messageId, + output: + 'test.describe.parallel("run in parallel", () => { expect(true).toBe(true); })', + }, + ], + line: 1, + column: 51, + endLine: 1, + endColumn: 62, + }, + ], + }, + { + code: 'test.skip()', + errors: [ + { + messageId: 'noSkippedTest', + suggestions: [{ messageId, output: '' }], + line: 1, + column: 1, + endLine: 1, + endColumn: 12, + }, + ], + }, + { + code: 'test["skip"]()', + errors: [ + { + messageId: 'noSkippedTest', + suggestions: [{ messageId, output: '' }], + line: 1, + column: 1, + endLine: 1, + endColumn: 15, + }, + ], + }, + { + code: 'test[`skip`]()', + errors: [ + { + messageId: 'noSkippedTest', + suggestions: [{ messageId, output: '' }], + line: 1, + column: 1, + endLine: 1, + endColumn: 15, + }, + ], + }, ], valid: [ 'test.describe("describe tests", () => {});', From 5a16fdee7de516b344e82d25cd455686492e8959 Mon Sep 17 00:00:00 2001 From: Mark Skelton Date: Sat, 14 Jan 2023 18:03:25 -0600 Subject: [PATCH 02/28] Add examples folder for testing --- examples/.eslintrc | 7 + examples/index.js | 0 examples/package-lock.json | 1818 ++++++++++++++++++++++++++++++++++++ examples/package.json | 9 + package.json | 3 + 5 files changed, 1837 insertions(+) create mode 100644 examples/.eslintrc create mode 100644 examples/index.js create mode 100644 examples/package-lock.json create mode 100644 examples/package.json diff --git a/examples/.eslintrc b/examples/.eslintrc new file mode 100644 index 0000000..503bfe7 --- /dev/null +++ b/examples/.eslintrc @@ -0,0 +1,7 @@ +{ + "extends": ["plugin:playwright/playwright-test"], + "parserOptions": { + "sourceType": "module", + "ecmaVersion": 2018 + } +} diff --git a/examples/index.js b/examples/index.js new file mode 100644 index 0000000..e69de29 diff --git a/examples/package-lock.json b/examples/package-lock.json new file mode 100644 index 0000000..a6e9098 --- /dev/null +++ b/examples/package-lock.json @@ -0,0 +1,1818 @@ +{ + "name": "examples", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "examples", + "dependencies": { + "@playwright/test": "^1.29.2", + "eslint": "^8.31.0", + "eslint-plugin-playwright": "file:../" + } + }, + "..": { + "version": "0.11.2", + "license": "MIT", + "devDependencies": { + "@types/dedent": "^0.7.0", + "@types/eslint": "^8.4.5", + "@types/estree": "^1.0.0", + "dedent": "^0.7.0", + "eslint": "^8.4.1", + "jest": "^28.1.3", + "prettier": "^2.7.1", + "ts-jest": "^28.0.7", + "typescript": "^4.7.4" + }, + "peerDependencies": { + "eslint": ">=7", + "eslint-plugin-jest": ">=24" + }, + "peerDependenciesMeta": { + "eslint-plugin-jest": { + "optional": true + } + } + }, + "node_modules/@eslint/eslintrc": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.4.1.tgz", + "integrity": "sha512-XXrH9Uarn0stsyldqDYq8r++mROmWRI1xKMXa640Bb//SY1+ECYX6VzT6Lcx5frD0V30XieqJ0oX9I2Xj5aoMA==", + "dependencies": { + "ajv": "^6.12.4", + "debug": "^4.3.2", + "espree": "^9.4.0", + "globals": "^13.19.0", + "ignore": "^5.2.0", + "import-fresh": "^3.2.1", + "js-yaml": "^4.1.0", + "minimatch": "^3.1.2", + "strip-json-comments": "^3.1.1" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@humanwhocodes/config-array": { + "version": "0.11.8", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.8.tgz", + "integrity": "sha512-UybHIJzJnR5Qc/MsD9Kr+RpO2h+/P1GhOwdiLPXK5TWk5sgTdu88bTD9UP+CKbPPh5Rni1u0GjAdYQLemG8g+g==", + "dependencies": { + "@humanwhocodes/object-schema": "^1.2.1", + "debug": "^4.1.1", + "minimatch": "^3.0.5" + }, + "engines": { + "node": ">=10.10.0" + } + }, + "node_modules/@humanwhocodes/module-importer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", + "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", + "engines": { + "node": ">=12.22" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, + "node_modules/@humanwhocodes/object-schema": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", + "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==" + }, + "node_modules/@nodelib/fs.scandir": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", + "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", + "dependencies": { + "@nodelib/fs.stat": "2.0.5", + "run-parallel": "^1.1.9" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.stat": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", + "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.walk": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", + "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", + "dependencies": { + "@nodelib/fs.scandir": "2.1.5", + "fastq": "^1.6.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@playwright/test": { + "version": "1.29.2", + "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.29.2.tgz", + "integrity": "sha512-+3/GPwOgcoF0xLz/opTnahel1/y42PdcgZ4hs+BZGIUjtmEFSXGg+nFoaH3NSmuc7a6GSFwXDJ5L7VXpqzigNg==", + "dependencies": { + "@types/node": "*", + "playwright-core": "1.29.2" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=14" + } + }, + "node_modules/@types/node": { + "version": "18.11.18", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.18.tgz", + "integrity": "sha512-DHQpWGjyQKSHj3ebjFI/wRKcqQcdR+MoFBygntYOZytCqNfkd2ZC4ARDJ2DQqhjH5p85Nnd3jhUJIXrszFX/JA==" + }, + "node_modules/acorn": { + "version": "8.8.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.1.tgz", + "integrity": "sha512-7zFpHzhnqYKrkYdUjF1HI1bzd0VygEGX8lFk4k5zVMqHEoES+P+7TKI+EvLO9WVMJ8eekdO0aDEK044xTXwPPA==", + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-jsx": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", + "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", + "peerDependencies": { + "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, + "node_modules/ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "dependencies": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" + }, + "node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "engines": { + "node": ">=6" + } + }, + "node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" + }, + "node_modules/cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/deep-is": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", + "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==" + }, + "node_modules/doctrine": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", + "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", + "dependencies": { + "esutils": "^2.0.2" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint": { + "version": "8.31.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.31.0.tgz", + "integrity": "sha512-0tQQEVdmPZ1UtUKXjX7EMm9BlgJ08G90IhWh0PKDCb3ZLsgAOHI8fYSIzYVZej92zsgq+ft0FGsxhJ3xo2tbuA==", + "dependencies": { + "@eslint/eslintrc": "^1.4.1", + "@humanwhocodes/config-array": "^0.11.8", + "@humanwhocodes/module-importer": "^1.0.1", + "@nodelib/fs.walk": "^1.2.8", + "ajv": "^6.10.0", + "chalk": "^4.0.0", + "cross-spawn": "^7.0.2", + "debug": "^4.3.2", + "doctrine": "^3.0.0", + "escape-string-regexp": "^4.0.0", + "eslint-scope": "^7.1.1", + "eslint-utils": "^3.0.0", + "eslint-visitor-keys": "^3.3.0", + "espree": "^9.4.0", + "esquery": "^1.4.0", + "esutils": "^2.0.2", + "fast-deep-equal": "^3.1.3", + "file-entry-cache": "^6.0.1", + "find-up": "^5.0.0", + "glob-parent": "^6.0.2", + "globals": "^13.19.0", + "grapheme-splitter": "^1.0.4", + "ignore": "^5.2.0", + "import-fresh": "^3.0.0", + "imurmurhash": "^0.1.4", + "is-glob": "^4.0.0", + "is-path-inside": "^3.0.3", + "js-sdsl": "^4.1.4", + "js-yaml": "^4.1.0", + "json-stable-stringify-without-jsonify": "^1.0.1", + "levn": "^0.4.1", + "lodash.merge": "^4.6.2", + "minimatch": "^3.1.2", + "natural-compare": "^1.4.0", + "optionator": "^0.9.1", + "regexpp": "^3.2.0", + "strip-ansi": "^6.0.1", + "strip-json-comments": "^3.1.0", + "text-table": "^0.2.0" + }, + "bin": { + "eslint": "bin/eslint.js" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint-plugin-playwright": { + "resolved": "..", + "link": true + }, + "node_modules/eslint-scope": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.1.1.tgz", + "integrity": "sha512-QKQM/UXpIiHcLqJ5AOyIW7XZmzjkzQXYE54n1++wb0u9V/abW3l9uQnxX8Z5Xd18xyKIMTUAyQ0k1e8pz6LUrw==", + "dependencies": { + "esrecurse": "^4.3.0", + "estraverse": "^5.2.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + } + }, + "node_modules/eslint-utils": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-3.0.0.tgz", + "integrity": "sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==", + "dependencies": { + "eslint-visitor-keys": "^2.0.0" + }, + "engines": { + "node": "^10.0.0 || ^12.0.0 || >= 14.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/mysticatea" + }, + "peerDependencies": { + "eslint": ">=5" + } + }, + "node_modules/eslint-utils/node_modules/eslint-visitor-keys": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz", + "integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==", + "engines": { + "node": ">=10" + } + }, + "node_modules/eslint-visitor-keys": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz", + "integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==", + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + } + }, + "node_modules/espree": { + "version": "9.4.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.4.1.tgz", + "integrity": "sha512-XwctdmTO6SIvCzd9810yyNzIrOrqNYV9Koizx4C/mRhf9uq0o4yHoCEU/670pOxOL/MSraektvSAji79kX90Vg==", + "dependencies": { + "acorn": "^8.8.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^3.3.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/esquery": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.4.0.tgz", + "integrity": "sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w==", + "dependencies": { + "estraverse": "^5.1.0" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/esrecurse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", + "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", + "dependencies": { + "estraverse": "^5.2.0" + }, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "engines": { + "node": ">=4.0" + } + }, + "node_modules/esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" + }, + "node_modules/fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==" + }, + "node_modules/fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==" + }, + "node_modules/fastq": { + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.15.0.tgz", + "integrity": "sha512-wBrocU2LCXXa+lWBt8RoIRD89Fi8OdABODa/kEnyeyjS5aZO5/GNvI5sEINADqP/h8M29UHTHUb53sUu5Ihqdw==", + "dependencies": { + "reusify": "^1.0.4" + } + }, + "node_modules/file-entry-cache": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", + "integrity": "sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==", + "dependencies": { + "flat-cache": "^3.0.4" + }, + "engines": { + "node": "^10.12.0 || >=12.0.0" + } + }, + "node_modules/find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dependencies": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/flat-cache": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.0.4.tgz", + "integrity": "sha512-dm9s5Pw7Jc0GvMYbshN6zchCA9RgQlzzEZX3vylR9IqFfS8XciblUXOKfW6SiuJ0e13eDYZoZV5wdrev7P3Nwg==", + "dependencies": { + "flatted": "^3.1.0", + "rimraf": "^3.0.2" + }, + "engines": { + "node": "^10.12.0 || >=12.0.0" + } + }, + "node_modules/flatted": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.7.tgz", + "integrity": "sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ==" + }, + "node_modules/fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==" + }, + "node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/glob-parent": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", + "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", + "dependencies": { + "is-glob": "^4.0.3" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/globals": { + "version": "13.19.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.19.0.tgz", + "integrity": "sha512-dkQ957uSRWHw7CFXLUtUHQI3g3aWApYhfNR2O6jn/907riyTYKVBmxYVROkBcY614FSSeSJh7Xm7SrUWCxvJMQ==", + "dependencies": { + "type-fest": "^0.20.2" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/grapheme-splitter": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz", + "integrity": "sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==" + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/ignore": { + "version": "5.2.4", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.4.tgz", + "integrity": "sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==", + "engines": { + "node": ">= 4" + } + }, + "node_modules/import-fresh": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", + "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", + "dependencies": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", + "engines": { + "node": ">=0.8.19" + } + }, + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-path-inside": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", + "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==" + }, + "node_modules/js-sdsl": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/js-sdsl/-/js-sdsl-4.2.0.tgz", + "integrity": "sha512-dyBIzQBDkCqCu+0upx25Y2jGdbTGxE9fshMsCdK0ViOongpV+n5tXRcZY9v7CaVQ79AGS9KA1KHtojxiM7aXSQ==", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/js-sdsl" + } + }, + "node_modules/js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==" + }, + "node_modules/json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==" + }, + "node_modules/levn": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", + "dependencies": { + "prelude-ls": "^1.2.1", + "type-check": "~0.4.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dependencies": { + "p-locate": "^5.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/lodash.merge": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", + "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==" + }, + "node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "node_modules/natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==" + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/optionator": { + "version": "0.9.1", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz", + "integrity": "sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==", + "dependencies": { + "deep-is": "^0.1.3", + "fast-levenshtein": "^2.0.6", + "levn": "^0.4.1", + "prelude-ls": "^1.2.1", + "type-check": "^0.4.0", + "word-wrap": "^1.2.3" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dependencies": { + "p-limit": "^3.0.2" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dependencies": { + "callsites": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "engines": { + "node": ">=8" + } + }, + "node_modules/path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "engines": { + "node": ">=8" + } + }, + "node_modules/playwright-core": { + "version": "1.29.2", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.29.2.tgz", + "integrity": "sha512-94QXm4PMgFoHAhlCuoWyaBYKb92yOcGVHdQLoxQ7Wjlc7Flg4aC/jbFW7xMR52OfXMVkWicue4WXE7QEegbIRA==", + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=14" + } + }, + "node_modules/prelude-ls": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/punycode": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.2.0.tgz", + "integrity": "sha512-LN6QV1IJ9ZhxWTNdktaPClrNfp8xdSAYS0Zk2ddX7XsXZAxckMHPCBcHRo0cTcEIgYPRiGEkmji3Idkh2yFtYw==", + "engines": { + "node": ">=6" + } + }, + "node_modules/queue-microtask": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", + "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/regexpp": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.2.0.tgz", + "integrity": "sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/mysticatea" + } + }, + "node_modules/resolve-from": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", + "engines": { + "node": ">=4" + } + }, + "node_modules/reusify": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", + "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", + "engines": { + "iojs": ">=1.0.0", + "node": ">=0.10.0" + } + }, + "node_modules/rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "dependencies": { + "glob": "^7.1.3" + }, + "bin": { + "rimraf": "bin.js" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/run-parallel": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", + "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "queue-microtask": "^1.2.2" + } + }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/text-table": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", + "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==" + }, + "node_modules/type-check": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", + "dependencies": { + "prelude-ls": "^1.2.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/type-fest": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", + "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dependencies": { + "punycode": "^2.1.0" + } + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/word-wrap": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", + "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" + }, + "node_modules/yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + } + }, + "dependencies": { + "@eslint/eslintrc": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.4.1.tgz", + "integrity": "sha512-XXrH9Uarn0stsyldqDYq8r++mROmWRI1xKMXa640Bb//SY1+ECYX6VzT6Lcx5frD0V30XieqJ0oX9I2Xj5aoMA==", + "requires": { + "ajv": "^6.12.4", + "debug": "^4.3.2", + "espree": "^9.4.0", + "globals": "^13.19.0", + "ignore": "^5.2.0", + "import-fresh": "^3.2.1", + "js-yaml": "^4.1.0", + "minimatch": "^3.1.2", + "strip-json-comments": "^3.1.1" + } + }, + "@humanwhocodes/config-array": { + "version": "0.11.8", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.8.tgz", + "integrity": "sha512-UybHIJzJnR5Qc/MsD9Kr+RpO2h+/P1GhOwdiLPXK5TWk5sgTdu88bTD9UP+CKbPPh5Rni1u0GjAdYQLemG8g+g==", + "requires": { + "@humanwhocodes/object-schema": "^1.2.1", + "debug": "^4.1.1", + "minimatch": "^3.0.5" + } + }, + "@humanwhocodes/module-importer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", + "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==" + }, + "@humanwhocodes/object-schema": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", + "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==" + }, + "@nodelib/fs.scandir": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", + "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", + "requires": { + "@nodelib/fs.stat": "2.0.5", + "run-parallel": "^1.1.9" + } + }, + "@nodelib/fs.stat": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", + "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==" + }, + "@nodelib/fs.walk": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", + "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", + "requires": { + "@nodelib/fs.scandir": "2.1.5", + "fastq": "^1.6.0" + } + }, + "@playwright/test": { + "version": "1.29.2", + "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.29.2.tgz", + "integrity": "sha512-+3/GPwOgcoF0xLz/opTnahel1/y42PdcgZ4hs+BZGIUjtmEFSXGg+nFoaH3NSmuc7a6GSFwXDJ5L7VXpqzigNg==", + "requires": { + "@types/node": "*", + "playwright-core": "1.29.2" + } + }, + "@types/node": { + "version": "18.11.18", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.18.tgz", + "integrity": "sha512-DHQpWGjyQKSHj3ebjFI/wRKcqQcdR+MoFBygntYOZytCqNfkd2ZC4ARDJ2DQqhjH5p85Nnd3jhUJIXrszFX/JA==" + }, + "acorn": { + "version": "8.8.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.1.tgz", + "integrity": "sha512-7zFpHzhnqYKrkYdUjF1HI1bzd0VygEGX8lFk4k5zVMqHEoES+P+7TKI+EvLO9WVMJ8eekdO0aDEK044xTXwPPA==" + }, + "acorn-jsx": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", + "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", + "requires": {} + }, + "ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "requires": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + } + }, + "ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==" + }, + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "requires": { + "color-convert": "^2.0.1" + } + }, + "argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" + }, + "balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==" + }, + "chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" + }, + "cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "requires": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + } + }, + "debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "requires": { + "ms": "2.1.2" + } + }, + "deep-is": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", + "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==" + }, + "doctrine": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", + "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", + "requires": { + "esutils": "^2.0.2" + } + }, + "escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==" + }, + "eslint": { + "version": "8.31.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.31.0.tgz", + "integrity": "sha512-0tQQEVdmPZ1UtUKXjX7EMm9BlgJ08G90IhWh0PKDCb3ZLsgAOHI8fYSIzYVZej92zsgq+ft0FGsxhJ3xo2tbuA==", + "requires": { + "@eslint/eslintrc": "^1.4.1", + "@humanwhocodes/config-array": "^0.11.8", + "@humanwhocodes/module-importer": "^1.0.1", + "@nodelib/fs.walk": "^1.2.8", + "ajv": "^6.10.0", + "chalk": "^4.0.0", + "cross-spawn": "^7.0.2", + "debug": "^4.3.2", + "doctrine": "^3.0.0", + "escape-string-regexp": "^4.0.0", + "eslint-scope": "^7.1.1", + "eslint-utils": "^3.0.0", + "eslint-visitor-keys": "^3.3.0", + "espree": "^9.4.0", + "esquery": "^1.4.0", + "esutils": "^2.0.2", + "fast-deep-equal": "^3.1.3", + "file-entry-cache": "^6.0.1", + "find-up": "^5.0.0", + "glob-parent": "^6.0.2", + "globals": "^13.19.0", + "grapheme-splitter": "^1.0.4", + "ignore": "^5.2.0", + "import-fresh": "^3.0.0", + "imurmurhash": "^0.1.4", + "is-glob": "^4.0.0", + "is-path-inside": "^3.0.3", + "js-sdsl": "^4.1.4", + "js-yaml": "^4.1.0", + "json-stable-stringify-without-jsonify": "^1.0.1", + "levn": "^0.4.1", + "lodash.merge": "^4.6.2", + "minimatch": "^3.1.2", + "natural-compare": "^1.4.0", + "optionator": "^0.9.1", + "regexpp": "^3.2.0", + "strip-ansi": "^6.0.1", + "strip-json-comments": "^3.1.0", + "text-table": "^0.2.0" + } + }, + "eslint-plugin-playwright": { + "version": "file:..", + "requires": { + "@types/dedent": "^0.7.0", + "@types/eslint": "^8.4.5", + "@types/estree": "^1.0.0", + "dedent": "^0.7.0", + "eslint": "^8.4.1", + "jest": "^28.1.3", + "prettier": "^2.7.1", + "ts-jest": "^28.0.7", + "typescript": "^4.7.4" + } + }, + "eslint-scope": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.1.1.tgz", + "integrity": "sha512-QKQM/UXpIiHcLqJ5AOyIW7XZmzjkzQXYE54n1++wb0u9V/abW3l9uQnxX8Z5Xd18xyKIMTUAyQ0k1e8pz6LUrw==", + "requires": { + "esrecurse": "^4.3.0", + "estraverse": "^5.2.0" + } + }, + "eslint-utils": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-3.0.0.tgz", + "integrity": "sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==", + "requires": { + "eslint-visitor-keys": "^2.0.0" + }, + "dependencies": { + "eslint-visitor-keys": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz", + "integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==" + } + } + }, + "eslint-visitor-keys": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz", + "integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==" + }, + "espree": { + "version": "9.4.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.4.1.tgz", + "integrity": "sha512-XwctdmTO6SIvCzd9810yyNzIrOrqNYV9Koizx4C/mRhf9uq0o4yHoCEU/670pOxOL/MSraektvSAji79kX90Vg==", + "requires": { + "acorn": "^8.8.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^3.3.0" + } + }, + "esquery": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.4.0.tgz", + "integrity": "sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w==", + "requires": { + "estraverse": "^5.1.0" + } + }, + "esrecurse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", + "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", + "requires": { + "estraverse": "^5.2.0" + } + }, + "estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==" + }, + "esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==" + }, + "fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" + }, + "fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==" + }, + "fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==" + }, + "fastq": { + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.15.0.tgz", + "integrity": "sha512-wBrocU2LCXXa+lWBt8RoIRD89Fi8OdABODa/kEnyeyjS5aZO5/GNvI5sEINADqP/h8M29UHTHUb53sUu5Ihqdw==", + "requires": { + "reusify": "^1.0.4" + } + }, + "file-entry-cache": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", + "integrity": "sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==", + "requires": { + "flat-cache": "^3.0.4" + } + }, + "find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "requires": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + } + }, + "flat-cache": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.0.4.tgz", + "integrity": "sha512-dm9s5Pw7Jc0GvMYbshN6zchCA9RgQlzzEZX3vylR9IqFfS8XciblUXOKfW6SiuJ0e13eDYZoZV5wdrev7P3Nwg==", + "requires": { + "flatted": "^3.1.0", + "rimraf": "^3.0.2" + } + }, + "flatted": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.7.tgz", + "integrity": "sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ==" + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==" + }, + "glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "glob-parent": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", + "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", + "requires": { + "is-glob": "^4.0.3" + } + }, + "globals": { + "version": "13.19.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.19.0.tgz", + "integrity": "sha512-dkQ957uSRWHw7CFXLUtUHQI3g3aWApYhfNR2O6jn/907riyTYKVBmxYVROkBcY614FSSeSJh7Xm7SrUWCxvJMQ==", + "requires": { + "type-fest": "^0.20.2" + } + }, + "grapheme-splitter": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz", + "integrity": "sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==" + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==" + }, + "ignore": { + "version": "5.2.4", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.4.tgz", + "integrity": "sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==" + }, + "import-fresh": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", + "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", + "requires": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + } + }, + "imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==" + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==" + }, + "is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "requires": { + "is-extglob": "^2.1.1" + } + }, + "is-path-inside": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", + "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==" + }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==" + }, + "js-sdsl": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/js-sdsl/-/js-sdsl-4.2.0.tgz", + "integrity": "sha512-dyBIzQBDkCqCu+0upx25Y2jGdbTGxE9fshMsCdK0ViOongpV+n5tXRcZY9v7CaVQ79AGS9KA1KHtojxiM7aXSQ==" + }, + "js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "requires": { + "argparse": "^2.0.1" + } + }, + "json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==" + }, + "json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==" + }, + "levn": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", + "requires": { + "prelude-ls": "^1.2.1", + "type-check": "~0.4.0" + } + }, + "locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "requires": { + "p-locate": "^5.0.0" + } + }, + "lodash.merge": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", + "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==" + }, + "minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==" + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "requires": { + "wrappy": "1" + } + }, + "optionator": { + "version": "0.9.1", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz", + "integrity": "sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==", + "requires": { + "deep-is": "^0.1.3", + "fast-levenshtein": "^2.0.6", + "levn": "^0.4.1", + "prelude-ls": "^1.2.1", + "type-check": "^0.4.0", + "word-wrap": "^1.2.3" + } + }, + "p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "requires": { + "yocto-queue": "^0.1.0" + } + }, + "p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "requires": { + "p-limit": "^3.0.2" + } + }, + "parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "requires": { + "callsites": "^3.0.0" + } + }, + "path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==" + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==" + }, + "path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==" + }, + "playwright-core": { + "version": "1.29.2", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.29.2.tgz", + "integrity": "sha512-94QXm4PMgFoHAhlCuoWyaBYKb92yOcGVHdQLoxQ7Wjlc7Flg4aC/jbFW7xMR52OfXMVkWicue4WXE7QEegbIRA==" + }, + "prelude-ls": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==" + }, + "punycode": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.2.0.tgz", + "integrity": "sha512-LN6QV1IJ9ZhxWTNdktaPClrNfp8xdSAYS0Zk2ddX7XsXZAxckMHPCBcHRo0cTcEIgYPRiGEkmji3Idkh2yFtYw==" + }, + "queue-microtask": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", + "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==" + }, + "regexpp": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.2.0.tgz", + "integrity": "sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==" + }, + "resolve-from": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==" + }, + "reusify": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", + "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==" + }, + "rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "requires": { + "glob": "^7.1.3" + } + }, + "run-parallel": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", + "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", + "requires": { + "queue-microtask": "^1.2.2" + } + }, + "shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "requires": { + "shebang-regex": "^3.0.0" + } + }, + "shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==" + }, + "strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "requires": { + "ansi-regex": "^5.0.1" + } + }, + "strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==" + }, + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "requires": { + "has-flag": "^4.0.0" + } + }, + "text-table": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", + "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==" + }, + "type-check": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", + "requires": { + "prelude-ls": "^1.2.1" + } + }, + "type-fest": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", + "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==" + }, + "uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "requires": { + "punycode": "^2.1.0" + } + }, + "which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "requires": { + "isexe": "^2.0.0" + } + }, + "word-wrap": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", + "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==" + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" + }, + "yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==" + } + } +} diff --git a/examples/package.json b/examples/package.json new file mode 100644 index 0000000..2dfc42f --- /dev/null +++ b/examples/package.json @@ -0,0 +1,9 @@ +{ + "name": "examples", + "type": "module", + "dependencies": { + "@playwright/test": "^1.29.2", + "eslint": "^8.31.0", + "eslint-plugin-playwright": "file:../" + } +} diff --git a/package.json b/package.json index 3095738..1dc00ea 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,9 @@ "main": "lib/index.js", "repository": "https://github.com/playwright-community/eslint-plugin-playwright", "author": "Max Schmitt ", + "contributors": [ + "Mark Skelton " + ], "license": "MIT", "files": [ "lib", From 484f243e1611bff78fea27d30a8b87aed9705a6b Mon Sep 17 00:00:00 2001 From: Mark Skelton Date: Sat, 14 Jan 2023 18:19:26 -0600 Subject: [PATCH 03/28] Better scope for no-useless-not --- src/rules/no-useless-not.ts | 5 +- test/spec/no-skipped-test.spec.ts | 12 ---- test/spec/no-useless-not.spec.ts | 104 +++++++++++++++++++++++++++--- 3 files changed, 99 insertions(+), 22 deletions(-) diff --git a/src/rules/no-useless-not.ts b/src/rules/no-useless-not.ts index 9ea6290..ad8b528 100644 --- a/src/rules/no-useless-not.ts +++ b/src/rules/no-useless-not.ts @@ -37,8 +37,11 @@ export default { replaceAccessorFixer(fixer, expectCall.matcher, newMatcher), ], messageId: 'noUselessNot', - node: node, data: { old: expectCall.matcherName, new: newMatcher }, + loc: { + start: notModifier.loc!.start, + end: expectCall.matcher.loc!.end, + }, }); } }, diff --git a/test/spec/no-skipped-test.spec.ts b/test/spec/no-skipped-test.spec.ts index d18b0e3..21083fa 100644 --- a/test/spec/no-skipped-test.spec.ts +++ b/test/spec/no-skipped-test.spec.ts @@ -18,7 +18,6 @@ runRuleTester('no-skipped-test', rule, { ], line: 1, column: 6, - endLine: 1, endColumn: 10, }, ], @@ -36,7 +35,6 @@ runRuleTester('no-skipped-test', rule, { ], line: 1, column: 6, - endLine: 1, endColumn: 12, }, ], @@ -54,7 +52,6 @@ runRuleTester('no-skipped-test', rule, { ], line: 1, column: 6, - endLine: 1, endColumn: 12, }, ], @@ -72,7 +69,6 @@ runRuleTester('no-skipped-test', rule, { ], line: 1, column: 15, - endLine: 1, endColumn: 19, }, ], @@ -90,7 +86,6 @@ runRuleTester('no-skipped-test', rule, { ], line: 1, column: 15, - endLine: 1, endColumn: 21, }, ], @@ -108,7 +103,6 @@ runRuleTester('no-skipped-test', rule, { ], line: 1, column: 15, - endLine: 1, endColumn: 21, }, ], @@ -121,7 +115,6 @@ runRuleTester('no-skipped-test', rule, { suggestions: [{ messageId, output: '' }], line: 1, column: 1, - endLine: 1, endColumn: 37, }, ], @@ -134,7 +127,6 @@ runRuleTester('no-skipped-test', rule, { suggestions: [{ messageId, output: '' }], line: 1, column: 1, - endLine: 1, endColumn: 60, }, ], @@ -153,7 +145,6 @@ runRuleTester('no-skipped-test', rule, { ], line: 1, column: 51, - endLine: 1, endColumn: 62, }, ], @@ -166,7 +157,6 @@ runRuleTester('no-skipped-test', rule, { suggestions: [{ messageId, output: '' }], line: 1, column: 1, - endLine: 1, endColumn: 12, }, ], @@ -179,7 +169,6 @@ runRuleTester('no-skipped-test', rule, { suggestions: [{ messageId, output: '' }], line: 1, column: 1, - endLine: 1, endColumn: 15, }, ], @@ -192,7 +181,6 @@ runRuleTester('no-skipped-test', rule, { suggestions: [{ messageId, output: '' }], line: 1, column: 1, - endLine: 1, endColumn: 15, }, ], diff --git a/test/spec/no-useless-not.spec.ts b/test/spec/no-useless-not.spec.ts index 5430d61..ff682e0 100644 --- a/test/spec/no-useless-not.spec.ts +++ b/test/spec/no-useless-not.spec.ts @@ -8,41 +8,127 @@ const invalid = (oldMatcher: string, newMatcher: string) => ({ { messageId: 'noUselessNot', data: { old: oldMatcher, new: newMatcher }, + line: 1, + column: 17, + endColumn: 21 + oldMatcher.length, }, ], }); runRuleTester('no-useless-not', rule, { invalid: [ - invalid('toBeVisible', 'toBeHidden'), - invalid('toBeHidden', 'toBeVisible'), - invalid('toBeEnabled', 'toBeDisabled'), - invalid('toBeDisabled', 'toBeEnabled'), + { + code: 'expect(locator).not.toBeVisible()', + output: 'expect(locator).toBeHidden()', + errors: [ + { + messageId: 'noUselessNot', + data: { old: 'toBeVisible', new: 'toBeHidden' }, + line: 1, + column: 17, + endColumn: 32, + }, + ], + }, + { + code: 'expect(locator).not.toBeHidden()', + output: 'expect(locator).toBeVisible()', + errors: [ + { + messageId: 'noUselessNot', + data: { new: 'toBeVisible', old: 'toBeHidden' }, + line: 1, + column: 17, + endColumn: 31, + }, + ], + }, + { + code: 'expect(locator).not.toBeEnabled()', + output: 'expect(locator).toBeDisabled()', + errors: [ + { + messageId: 'noUselessNot', + data: { old: 'toBeEnabled', new: 'toBeDisabled' }, + line: 1, + column: 17, + endColumn: 32, + }, + ], + }, + { + code: 'expect(locator).not.toBeDisabled()', + output: 'expect(locator).toBeEnabled()', + errors: [ + { + messageId: 'noUselessNot', + data: { old: 'toBeDisabled', new: 'toBeEnabled' }, + line: 1, + column: 17, + endColumn: 33, + }, + ], + }, { code: 'expect(locator)["not"]["toBeHidden"]()', output: 'expect(locator)["toBeVisible"]()', - errors: [{ messageId: 'noUselessNot' }], + errors: [ + { + messageId: 'noUselessNot', + line: 1, + column: 17, + endColumn: 36, + }, + ], }, { code: 'expect(locator)[`not`][`toBeHidden`]()', output: 'expect(locator)[`toBeVisible`]()', - errors: [{ messageId: 'noUselessNot' }], + errors: [ + { + messageId: 'noUselessNot', + line: 1, + column: 17, + endColumn: 36, + }, + ], }, { code: 'expect.soft(locator).not.toBeVisible()', output: 'expect.soft(locator).toBeHidden()', - errors: [{ messageId: 'noUselessNot' }], + errors: [ + { + messageId: 'noUselessNot', + line: 1, + column: 22, + endColumn: 37, + }, + ], }, { code: 'expect.poll(() => locator)[`not`][`toBeHidden`]()', output: 'expect.poll(() => locator)[`toBeVisible`]()', - errors: [{ messageId: 'noUselessNot' }], + errors: [ + { + messageId: 'noUselessNot', + line: 1, + column: 28, + endColumn: 47, + }, + ], }, // Incomplete call expression { code: 'expect(locator).not.toBeHidden', output: 'expect(locator).toBeVisible', - errors: [{ messageId: 'noUselessNot' }], + errors: [ + { + messageId: 'noUselessNot', + line: 1, + column: 17, + endColumn: 31, + }, + ], }, ], valid: [ From 89a16b0ed997301fbe606c8a86dcf84b758ab6de Mon Sep 17 00:00:00 2001 From: Mark Skelton Date: Sat, 14 Jan 2023 19:31:17 -0600 Subject: [PATCH 04/28] max-nested-describe --- src/rules/max-nested-describe.ts | 2 +- test/spec/max-nested-describe.spec.ts | 343 +++++++++++++------------- 2 files changed, 178 insertions(+), 167 deletions(-) diff --git a/src/rules/max-nested-describe.ts b/src/rules/max-nested-describe.ts index e91a731..53fbbcd 100644 --- a/src/rules/max-nested-describe.ts +++ b/src/rules/max-nested-describe.ts @@ -19,7 +19,7 @@ export default { if (describeCallbackStack.length > max) { context.report({ - node: node.parent, + node: node.parent.callee, messageId: 'exceededMaxDepth', data: { depth: describeCallbackStack.length.toString(), diff --git a/test/spec/max-nested-describe.spec.ts b/test/spec/max-nested-describe.spec.ts index 0d651fe..f5e517e 100644 --- a/test/spec/max-nested-describe.spec.ts +++ b/test/spec/max-nested-describe.spec.ts @@ -1,138 +1,147 @@ -import { runRuleTester, Errors } from '../utils/rule-tester'; +import { runRuleTester } from '../utils/rule-tester'; import rule from '../../src/rules/max-nested-describe'; -const invalid = ( - code: string, - options: unknown[] = [], - errors: Errors = [{ messageId: 'exceededMaxDepth' }] -) => ({ code, options, errors }); - -const valid = (code: string, options: unknown[] = []) => ({ code, options }); +const messageId = 'exceededMaxDepth'; runRuleTester('max-nested-describe', rule, { invalid: [ - invalid(` - test.describe('foo', function() { - test.describe('bar', function () { - test.describe('baz', function () { - test.describe('qux', function () { - test.describe('quxx', function () { - test.describe('over limit', function () { - test('should get something', () => { - expect(getSomething()).toBe('Something'); + { + code: ` + test.describe('foo', function() { + test.describe('bar', function () { + test.describe('baz', function () { + test.describe('qux', function () { + test.describe('quxx', function () { + test.describe('over limit', function () { + test('should get something', () => { + expect(getSomething()).toBe('Something'); + }); + }); }); }); }); }); }); - }); - }); - `), - invalid(` - describe('foo', function() { - describe('bar', function () { - describe('baz', function () { - describe('qux', function () { - describe('quxx', function () { - describe('over limit', function () { - test('should get something', () => { - expect(getSomething()).toBe('Something'); + `, + errors: [{ messageId, line: 7, column: 19, endLine: 7, endColumn: 32 }], + }, + { + code: ` + describe('foo', function() { + describe('bar', function () { + describe('baz', function () { + describe('qux', function () { + describe('quxx', function () { + describe('over limit', function () { + test('should get something', () => { + expect(getSomething()).toBe('Something'); + }); + }); }); }); }); }); }); - }); - }); - `), - invalid( - ` - test.describe('foo', () => { - test.describe('bar', () => { - test["describe"]('baz', () => { - test.describe('baz1', () => { - test.describe('baz2', () => { - test[\`describe\`]('baz3', () => { - test('should get something', () => { - expect(getSomething()).toBe('Something'); + `, + errors: [{ messageId, line: 7, column: 19, endLine: 7, endColumn: 27 }], + }, + { + code: ` + test.describe('foo', () => { + test.describe('bar', () => { + test["describe"]('baz', () => { + test.describe('baz1', () => { + test.describe('baz2', () => { + test[\`describe\`]('baz3', () => { + test('should get something', () => { + expect(getSomething()).toBe('Something'); + }); + }); + + test.describe('baz4', () => { + it('should get something', () => { + expect(getSomething()).toBe('Something'); + }); + }); + }); }); }); - test.describe('baz4', () => { - it('should get something', () => { + test.describe('qux', function () { + test('should get something', () => { expect(getSomething()).toBe('Something'); }); }); - }); - }); - }); - - test.describe('qux', function () { - test('should get something', () => { - expect(getSomething()).toBe('Something'); + }) }); - }); - }) - }); - `, - [{ max: 5 }], - [{ messageId: 'exceededMaxDepth' }, { messageId: 'exceededMaxDepth' }] - ), - invalid(` - test.describe.only('foo', function() { - test.describe('bar', function() { - test.describe('baz', function() { - test.describe('qux', function() { - test.describe('quux', function() { - test.describe('quuz', function() { + `, + options: [{ max: 5 }], + errors: [ + { messageId, line: 7, column: 19, endLine: 7, endColumn: 35 }, + { messageId, line: 13, column: 19, endLine: 13, endColumn: 32 }, + ], + }, + { + code: ` + test.describe.only('foo', function() { + test.describe('bar', function() { + test.describe('baz', function() { + test.describe('qux', function() { + test.describe('quux', function() { + test.describe.only('quuz', function() { }); + }); + }); }); }); }); - }); - }); - }); - `), - invalid(` - test.describe.serial.only('foo', function() { - test.describe('bar', function() { - test.describe('baz', function() { - test.describe('qux', function() { - test.describe('quux', function() { - test.describe('quuz', function() { + `, + errors: [{ messageId, line: 7, column: 19, endLine: 7, endColumn: 37 }], + }, + { + code: ` + test.describe.serial.only('foo', function() { + test.describe('bar', function() { + test.describe('baz', function() { + test.describe('qux', function() { + test.describe('quux', function() { + test.describe('quuz', function() { }); + }); + }); }); }); }); - }); - }); - }); - `), - invalid( - ` - test.describe('qux', () => { - test('should get something', () => { - expect(getSomething()).toBe('Something'); - }); - }); - `, - [{ max: 0 }] - ), - invalid( - ` - test.describe('foo', () => { - test.describe('bar', () => { - test.describe('baz', () => { - test("test1", () => { - expect(true).toBe(true); + `, + errors: [{ messageId, line: 7, column: 19, endLine: 7, endColumn: 32 }], + }, + { + code: ` + test.describe('qux', () => { + test('should get something', () => { + expect(getSomething()).toBe('Something'); }); - test("test2", () => { - expect(true).toBe(true); + }); + `, + errors: [{ messageId, line: 2, column: 9, endLine: 2, endColumn: 22 }], + options: [{ max: 0 }], + }, + { + code: ` + test.describe('foo', () => { + test.describe('bar', () => { + test.describe('baz', () => { + test("test1", () => { + expect(true).toBe(true); + }); + test("test2", () => { + expect(true).toBe(true); + }); + }); }); }); - }); - }); - `, - [{ max: 2 }] - ), + `, + errors: [{ messageId, line: 4, column: 13, endLine: 4, endColumn: 26 }], + options: [{ max: 2 }], + }, ], valid: [ 'test.describe("describe tests", () => {});', @@ -140,83 +149,85 @@ runRuleTester('max-nested-describe', rule, { 'test.describe.serial.only("describe serial focus tests", () => {});', 'test.describe.serial.skip("describe serial focus tests", () => {});', 'test.describe.parallel.fixme("describe serial focus tests", () => {});', - valid( - ` - test('foo', function () { - expect(true).toBe(true); - }); - test('bar', () => { - expect(true).toBe(true); - }); - `, - [{ max: 0 }] - ), - valid(` - test.describe('foo', function() { - test.describe('bar', function () { - test.describe('baz', function () { - test.describe('qux', function () { - test.describe('quxx', function () { - test('should get something', () => { - expect(getSomething()).toBe('Something'); + { + code: ` + test('foo', function () { + expect(true).toBe(true); + }); + test('bar', () => { + expect(true).toBe(true); + }); + `, + options: [{ max: 0 }], + }, + { + code: ` + test.describe('foo', function() { + test.describe('bar', function () { + test.describe('baz', function () { + test.describe('qux', function () { + test.describe('quxx', function () { + test('should get something', () => { + expect(getSomething()).toBe('Something'); + }); }); }); }); }); }); - }); - `), - valid( - ` - test.describe('foo', () => { - test.describe('bar', () => { - test.describe('baz', () => { - test.describe('qux', () => { - test('foo', () => { - expect(someCall().property).toBe(true); - }); - test('bar', () => { - expect(universe.answer).toBe(42); + `, + }, + { + code: ` + test.describe('foo', () => { + test.describe('bar', () => { + test.describe('baz', () => { + test.describe('qux', () => { + test('foo', () => { + expect(someCall().property).toBe(true); + }); + test('bar', () => { + expect(universe.answer).toBe(42); + }); }); - }); - test.describe('quxx', () => { - test('baz', () => { - expect(2 + 2).toEqual(4); + test.describe('quxx', () => { + test('baz', () => { + expect(2 + 2).toEqual(4); + }); }); }); }); }); - }); - `, - [{ max: 4 }] - ), - valid( - ` - test.describe('foo', () => { - test.describe.only('bar', () => { - test.describe.skip('baz', () => { - test('something', async () => { - expect('something').toBe('something'); + `, + options: [{ max: 4 }], + }, + { + code: ` + test.describe('foo', () => { + test.describe.only('bar', () => { + test.describe.skip('baz', () => { + test('something', async () => { + expect('something').toBe('something'); + }); }); }); }); - }); - `, - [{ max: 3 }] - ), - valid( - ` - describe('foo', () => { - describe.only('bar', () => { - describe.skip('baz', () => { - test('something', async () => { - expect('something').toBe('something'); + `, + options: [{ max: 3 }], + }, + { + code: ` + describe('foo', () => { + describe.only('bar', () => { + describe.skip('baz', () => { + test('something', async () => { + expect('something').toBe('something'); + }); }); }); }); - }); - `, - [{ max: 3 }] - ), + `, + options: [{ max: 3 }], + }, ], }); From 93649d6e3721d08f7eb5e4e5795a674d80febe2f Mon Sep 17 00:00:00 2001 From: Mark Skelton Date: Sat, 14 Jan 2023 20:07:40 -0600 Subject: [PATCH 05/28] missing-playwright-await --- src/rules/missing-playwright-await.ts | 4 +- test/spec/missing-playwright-await.spec.ts | 284 +++++++++++++-------- 2 files changed, 183 insertions(+), 105 deletions(-) diff --git a/src/rules/missing-playwright-await.ts b/src/rules/missing-playwright-await.ts index 3316914..ba2a148 100644 --- a/src/rules/missing-playwright-await.ts +++ b/src/rules/missing-playwright-await.ts @@ -78,7 +78,7 @@ function getCallType( return { messageId: 'expectPoll' }; } - // expect with awitable matcher + // expect with awaitable matcher const [lastMatcher] = getMatchers(node).slice(-1); const matcherName = getStringValue(lastMatcher); @@ -116,7 +116,7 @@ export default { fix: (fixer) => fixer.insertTextBefore(node, 'await '), messageId: result.messageId, data: result.data, - node: reportNode, + node: node.callee, }); } }, diff --git a/test/spec/missing-playwright-await.spec.ts b/test/spec/missing-playwright-await.spec.ts index 90f6034..fa0180c 100644 --- a/test/spec/missing-playwright-await.spec.ts +++ b/test/spec/missing-playwright-await.spec.ts @@ -1,127 +1,205 @@ -import { runRuleTester, wrapInTest } from '../utils/rule-tester'; +import { runRuleTester, wrapInTest as test } from '../utils/rule-tester'; import rule from '../../src/rules/missing-playwright-await'; -const invalid = ( - messageId: string, - code: string, - output: string, - options: unknown[] = [] -) => ({ - code: wrapInTest(code), - errors: [{ messageId }], - options, - output: wrapInTest(output), -}); - -const valid = (code: string, options: unknown[] = []) => ({ - code: wrapInTest(code), - options, -}); - -const options = [{ customMatchers: ['toBeCustomThing'] }]; - runRuleTester('missing-playwright-await', rule, { invalid: [ - invalid( - 'expect', - 'expect(page).toBeChecked()', - 'await expect(page).toBeChecked()' - ), - invalid( - 'expect', - 'expect(page).not.toBeEnabled()', - 'await expect(page).not.toBeEnabled()' - ), - + { + code: test('expect(page).toBeChecked()'), + output: test('await expect(page).toBeChecked()'), + errors: [ + { + messageId: 'expect', + line: 1, + column: 28, + endLine: 1, + endColumn: 34, + }, + ], + }, + { + code: test('expect(page).not.toBeEnabled()'), + output: test('await expect(page).not.toBeEnabled()'), + errors: [ + { + messageId: 'expect', + line: 1, + column: 28, + endLine: 1, + endColumn: 34, + }, + ], + }, // Custom matchers - invalid( - 'expect', - 'expect(page).toBeCustomThing(false)', - 'await expect(page).toBeCustomThing(false)', - options - ), - invalid( - 'expect', - 'expect(page)["not"][`toBeCustomThing`](true)', - 'await expect(page)["not"][`toBeCustomThing`](true)', - options - ), - + { + code: test('expect(page).toBeCustomThing(false)'), + output: test('await expect(page).toBeCustomThing(false)'), + errors: [ + { + messageId: 'expect', + line: 1, + column: 28, + endLine: 1, + endColumn: 34, + }, + ], + options: [{ customMatchers: ['toBeCustomThing'] }], + }, + { + code: test('expect(page)["not"][`toBeCustomThing`](true)'), + output: test('await expect(page)["not"][`toBeCustomThing`](true)'), + errors: [ + { + messageId: 'expect', + line: 1, + column: 28, + endLine: 1, + endColumn: 34, + }, + ], + options: [{ customMatchers: ['toBeCustomThing'] }], + }, // expect.soft - invalid( - 'expect', - 'expect.soft(page).toBeChecked()', - 'await expect.soft(page).toBeChecked()' - ), - invalid( - 'expect', - 'expect["soft"](page)["toBeChecked"]()', - 'await expect["soft"](page)["toBeChecked"]()' - ), - invalid( - 'expect', - 'expect[`soft`](page)[`toBeChecked`]()', - 'await expect[`soft`](page)[`toBeChecked`]()' - ), - + { + code: test('expect.soft(page).toBeChecked()'), + output: test('await expect.soft(page).toBeChecked()'), + errors: [ + { + messageId: 'expect', + line: 1, + column: 28, + endLine: 1, + endColumn: 39, + }, + ], + }, + { + code: test('expect["soft"](page)["toBeChecked"]()'), + output: test('await expect["soft"](page)["toBeChecked"]()'), + errors: [ + { + messageId: 'expect', + line: 1, + column: 28, + endLine: 1, + endColumn: 42, + }, + ], + }, + { + code: test('expect[`soft`](page)[`toBeChecked`]()'), + output: test('await expect[`soft`](page)[`toBeChecked`]()'), + errors: [ + { + messageId: 'expect', + line: 1, + column: 28, + endLine: 1, + endColumn: 42, + }, + ], + }, // expect.poll - invalid( - 'expectPoll', - 'expect.poll(() => foo).toBe(true)', - 'await expect.poll(() => foo).toBe(true)' - ), - invalid( - 'expectPoll', - 'expect["poll"](() => foo)["toContain"]("bar")', - 'await expect["poll"](() => foo)["toContain"]("bar")' - ), - invalid( - 'expectPoll', - 'expect[`poll`](() => foo)[`toBeTruthy`]()', - 'await expect[`poll`](() => foo)[`toBeTruthy`]()' - ), - + { + code: test('expect.poll(() => foo).toBe(true)'), + output: test('await expect.poll(() => foo).toBe(true)'), + errors: [ + { + messageId: 'expectPoll', + line: 1, + column: 28, + endLine: 1, + endColumn: 39, + }, + ], + }, + { + code: test('expect["poll"](() => foo)["toContain"]("bar")'), + output: test('await expect["poll"](() => foo)["toContain"]("bar")'), + errors: [ + { + messageId: 'expectPoll', + line: 1, + column: 28, + endLine: 1, + endColumn: 42, + }, + ], + }, + { + code: test('expect[`poll`](() => foo)[`toBeTruthy`]()'), + output: test('await expect[`poll`](() => foo)[`toBeTruthy`]()'), + errors: [ + { + messageId: 'expectPoll', + line: 1, + column: 28, + endLine: 1, + endColumn: 42, + }, + ], + }, // test.step - invalid( - 'testStep', - "test.step('foo', async () => {})", - "await test.step('foo', async () => {})" - ), - invalid( - 'testStep', - "test['step']('foo', async () => {})", - "await test['step']('foo', async () => {})" - ), + { + code: test("test.step('foo', async () => {})"), + output: test("await test.step('foo', async () => {})"), + errors: [ + { + messageId: 'testStep', + line: 1, + column: 28, + endLine: 1, + endColumn: 37, + }, + ], + }, + { + code: test("test['step']('foo', async () => {})"), + output: test("await test['step']('foo', async () => {})"), + errors: [ + { + messageId: 'testStep', + line: 1, + column: 28, + endLine: 1, + endColumn: 40, + }, + ], + }, ], valid: [ - valid('await expect(page).toBeEditable'), - valid('await expect(page).toEqualTitle("text")'), - valid('await expect(page).not.toHaveText("text")'), + { code: test('await expect(page).toBeEditable') }, + { code: test('await expect(page).toEqualTitle("text")') }, + { code: test('await expect(page).not.toHaveText("text")') }, // Doesn't require an await when returning - valid('return expect(page).toHaveText("text")'), + { code: test('return expect(page).toHaveText("text")') }, { - code: 'const a = () => expect(page).toHaveText("text")', - options, + code: test('const a = () => expect(page).toHaveText("text")'), + options: [{ customMatchers: ['toBeCustomThing'] }], }, // Custom matchers - valid('await expect(page).toBeCustomThing(true)', options), - valid('await expect(page).toBeCustomThing(true)', options), - valid('await expect(page).toBeCustomThing(true)', options), - valid('await expect(page).toBeCustomThing(true)'), - valid('expect(page).toBeCustomThing(true)'), + { + code: test('await expect(page).toBeCustomThing(true)'), + options: [{ customMatchers: ['toBeCustomThing'] }], + }, + { code: test('await expect(page).toBeCustomThing(true)') }, + { code: test('expect(page).toBeCustomThing(true)') }, + { + code: test('await expect(page).toBeAsync(true)'), + options: [{ customMatchers: ['toBeAsync'] }], + }, // expect.soft - valid('await expect.soft(page).toHaveText("text")'), - valid('await expect.soft(page).not.toHaveText("text")'), + { code: test('await expect.soft(page).toHaveText("text")') }, + { code: test('await expect.soft(page).not.toHaveText("text")') }, // expect.poll - valid('await expect.poll(() => foo).toBe("text")'), - valid('await expect["poll"](() => foo).toContain("text")'), - valid('await expect[`poll`](() => foo).toBeTruthy()'), + { code: test('await expect.poll(() => foo).toBe("text")') }, + { code: test('await expect["poll"](() => foo).toContain("text")') }, + { code: test('await expect[`poll`](() => foo).toBeTruthy()') }, // test.step - valid("await test.step('foo', async () => {})"), + { code: test("await test.step('foo', async () => {})") }, ], }); From b324d3a0594b70488da7f0f65ff14028c3890fb7 Mon Sep 17 00:00:00 2001 From: Mark Skelton Date: Sat, 14 Jan 2023 20:59:37 -0600 Subject: [PATCH 06/28] no-focused-test --- src/rules/no-focused-test.ts | 2 +- test/spec/no-focused-test.spec.ts | 182 +++++++++++++++++++++++------- 2 files changed, 140 insertions(+), 44 deletions(-) diff --git a/src/rules/no-focused-test.ts b/src/rules/no-focused-test.ts index c45d734..89f729c 100644 --- a/src/rules/no-focused-test.ts +++ b/src/rules/no-focused-test.ts @@ -25,7 +25,7 @@ export default { ]), }, ], - node, + node: node.callee.property, }); } }, diff --git a/test/spec/no-focused-test.spec.ts b/test/spec/no-focused-test.spec.ts index 7cfd84e..5610c9f 100644 --- a/test/spec/no-focused-test.spec.ts +++ b/test/spec/no-focused-test.spec.ts @@ -1,55 +1,151 @@ import { runRuleTester } from '../utils/rule-tester'; import rule from '../../src/rules/no-focused-test'; -const invalid = (code: string, output: string) => ({ - code, - errors: [ - { - messageId: 'noFocusedTest', - suggestions: [{ messageId: 'suggestRemoveOnly', output }], - }, - ], -}); +const messageId = 'noFocusedTest'; runRuleTester('no-focused-test', rule, { invalid: [ - invalid( - 'test.describe.only("skip this describe", () => {});', - 'test.describe("skip this describe", () => {});' - ), - invalid( - 'test.describe["only"]("skip this describe", () => {});', - 'test.describe("skip this describe", () => {});' - ), - invalid( - 'test["describe"][`only`]("skip this describe", () => {});', - 'test["describe"]("skip this describe", () => {});' - ), - invalid( - 'test.describe.parallel.only("skip this describe", () => {});', - 'test.describe.parallel("skip this describe", () => {});' - ), - invalid( - 'test.describe.serial.only("skip this describe", () => {});', - 'test.describe.serial("skip this describe", () => {});' - ), - invalid( - 'test.only("skip this test", async ({ page }) => {});', - 'test("skip this test", async ({ page }) => {});' - ), - invalid( - 'test["only"]("skip this test", async ({ page }) => {});', - 'test("skip this test", async ({ page }) => {});' - ), - invalid( - 'test[`only`]("skip this test", async ({ page }) => {});', - 'test("skip this test", async ({ page }) => {});' - ), + { + code: 'test.describe.only("skip this describe", () => {});', + errors: [ + { + messageId, + suggestions: [ + { + messageId: 'suggestRemoveOnly', + output: 'test.describe("skip this describe", () => {});', + }, + ], + line: 1, + column: 15, + endColumn: 19, + }, + ], + }, + { + code: 'test.describe["only"]("skip this describe", () => {});', + errors: [ + { + messageId, + suggestions: [ + { + messageId: 'suggestRemoveOnly', + output: 'test.describe("skip this describe", () => {});', + }, + ], + line: 1, + column: 15, + endColumn: 21, + }, + ], + }, + { + code: 'test["describe"][`only`]("skip this describe", () => {});', + errors: [ + { + messageId, + suggestions: [ + { + messageId: 'suggestRemoveOnly', + output: 'test["describe"]("skip this describe", () => {});', + }, + ], + line: 1, + column: 18, + endColumn: 24, + }, + ], + }, + { + code: 'test.describe.parallel.only("skip this describe", () => {});', + errors: [ + { + messageId, + suggestions: [ + { + messageId: 'suggestRemoveOnly', + output: 'test.describe.parallel("skip this describe", () => {});', + }, + ], + line: 1, + column: 24, + endColumn: 28, + }, + ], + }, + { + code: 'test.describe.serial.only("skip this describe", () => {});', + errors: [ + { + messageId, + suggestions: [ + { + messageId: 'suggestRemoveOnly', + output: 'test.describe.serial("skip this describe", () => {});', + }, + ], + line: 1, + column: 22, + endColumn: 26, + }, + ], + }, + { + code: 'test.only("skip this test", async ({code: page }) => {});', + errors: [ + { + messageId, + suggestions: [ + { + messageId: 'suggestRemoveOnly', + output: 'test("skip this test", async ({code: page }) => {});', + }, + ], + line: 1, + column: 6, + endColumn: 10, + }, + ], + }, + { + code: 'test["only"]("skip this test", async ({code: page }) => {});', + errors: [ + { + messageId, + suggestions: [ + { + messageId: 'suggestRemoveOnly', + output: 'test("skip this test", async ({code: page }) => {});', + }, + ], + line: 1, + column: 6, + endColumn: 12, + }, + ], + }, + { + code: 'test[`only`]("skip this test", async ({code: page }) => {});', + errors: [ + { + messageId, + suggestions: [ + { + messageId: 'suggestRemoveOnly', + output: 'test("skip this test", async ({code: page }) => {});', + }, + ], + line: 1, + column: 6, + endColumn: 12, + }, + ], + }, ], valid: [ 'test.describe("describe tests", () => {});', 'test.describe.skip("describe tests", () => {});', - 'test("one", async ({ page }) => {});', + 'test("one", async ({code: page }) => {});', 'test.fixme(isMobile, "Settings page does not work in mobile yet");', 'test["fixme"](isMobile, "Settings page does not work in mobile yet");', 'test[`fixme`](isMobile, "Settings page does not work in mobile yet");', @@ -57,7 +153,7 @@ runRuleTester('no-focused-test', rule, { 'test["slow"]();', 'test[`slow`]();', 'const only = true;', - 'function only() { return null };', + 'function only() {code: return null };', 'this.only();', ], }); From f34f23d54f06a04c7379d8f8e886c8e20adb7a2c Mon Sep 17 00:00:00 2001 From: Mark Skelton Date: Sat, 14 Jan 2023 21:18:12 -0600 Subject: [PATCH 07/28] no-force-option --- src/rules/no-force-option.ts | 11 ++- test/spec/no-force-option.spec.ts | 135 ++++++++++++++++++++---------- 2 files changed, 98 insertions(+), 48 deletions(-) diff --git a/src/rules/no-force-option.ts b/src/rules/no-force-option.ts index 10f0c9f..cc8558c 100644 --- a/src/rules/no-force-option.ts +++ b/src/rules/no-force-option.ts @@ -7,7 +7,7 @@ function isForceOptionEnabled(node: ESTree.CallExpression) { return ( arg?.type === 'ObjectExpression' && - arg.properties.some( + arg.properties.find( (property) => property.type === 'Property' && getStringValue(property.key) === 'force' && @@ -37,10 +37,13 @@ export default { MemberExpression(node) { if ( methodsWithForceOption.has(getStringValue(node.property)) && - node.parent.type === 'CallExpression' && - isForceOptionEnabled(node.parent) + node.parent.type === 'CallExpression' ) { - context.report({ messageId: 'noForceOption', node }); + const reportNode = isForceOptionEnabled(node.parent); + + if (reportNode) { + context.report({ messageId: 'noForceOption', node: reportNode }); + } } }, }; diff --git a/test/spec/no-force-option.spec.ts b/test/spec/no-force-option.spec.ts index 1cf54e9..b412ca7 100644 --- a/test/spec/no-force-option.spec.ts +++ b/test/spec/no-force-option.spec.ts @@ -1,55 +1,102 @@ -import { runRuleTester, wrapInTest } from '../utils/rule-tester'; +import { runRuleTester, wrapInTest as test } from '../utils/rule-tester'; import rule from '../../src/rules/no-force-option'; -const invalid = (code: string) => ({ - code: wrapInTest(code), - errors: [{ messageId: 'noForceOption' }], -}); - -const valid = wrapInTest; +const messageId = 'noForceOption'; runRuleTester('no-force-option', rule, { invalid: [ - invalid('await page.locator("check").check({ force: true })'), - invalid('await page.locator("check").uncheck({ ["force"]: true })'), - invalid('await page.locator("button").click({ [`force`]: true })'), - invalid( - 'const button = page["locator"]("button"); await button.click({ force: true })' - ), - invalid( - 'await page[`locator`]("button").locator("btn").click({ force: true })' - ), - invalid('await page.locator("button").dblclick({ force: true })'), - invalid('await page.locator("input").dragTo({ force: true })'), - invalid('await page.locator("input").fill("test", { force: true })'), - invalid('await page[`locator`]("input").fill("test", { ["force"]: true })'), - invalid('await page["locator"]("input").fill("test", { [`force`]: true })'), - invalid('await page.locator("elm").hover({ force: true })'), - invalid( - 'await page.locator("select").selectOption({ label: "Blue" }, { force: true })' - ), - invalid('await page.locator("select").selectText({ force: true })'), - invalid('await page.locator("checkbox").setChecked(true, { force: true })'), - invalid('await page.locator("button").tap({ force: true })'), + { + code: test('await page.locator("check").check({ force: true })'), + errors: [{ messageId, line: 1, column: 64, endColumn: 75 }], + }, + { + code: test('await page.locator("check").uncheck({ ["force"]: true })'), + errors: [{ messageId, line: 1, column: 66, endColumn: 81 }], + }, + { + code: test('await page.locator("button").click({ [`force`]: true })'), + errors: [{ messageId, line: 1, column: 65, endColumn: 80 }], + }, + { + code: test(` + const button = page["locator"]("button") + await button.click({ force: true }) + `), + errors: [{ messageId, line: 3, column: 30, endLine: 3, endColumn: 41 }], + }, + { + code: test( + 'await page[`locator`]("button").locator("btn").click({ force: true })' + ), + errors: [{ messageId, line: 1, column: 83, endColumn: 94 }], + }, + { + code: test('await page.locator("button").dblclick({ force: true })'), + errors: [{ messageId, line: 1, column: 68, endColumn: 79 }], + }, + { + code: test('await page.locator("input").dragTo({ force: true })'), + errors: [{ messageId, line: 1, column: 65, endColumn: 76 }], + }, + { + code: test('await page.locator("input").fill("test", { force: true })'), + errors: [{ messageId, line: 1, column: 71, endColumn: 82 }], + }, + { + code: test( + 'await page[`locator`]("input").fill("test", { ["force"]: true })' + ), + errors: [{ messageId, line: 1, column: 74, endColumn: 89 }], + }, + { + code: test( + 'await page["locator"]("input").fill("test", { [`force`]: true })' + ), + errors: [{ messageId, line: 1, column: 74, endColumn: 89 }], + }, + { + code: test('await page.locator("elm").hover({ force: true })'), + errors: [{ messageId, line: 1, column: 62, endColumn: 73 }], + }, + { + code: test( + 'await page.locator("select").selectOption({ label: "Blue" }, { force: true })' + ), + errors: [{ messageId, line: 1, column: 91, endColumn: 102 }], + }, + { + code: test('await page.locator("select").selectText({ force: true })'), + errors: [{ messageId, line: 1, column: 70, endColumn: 81 }], + }, + { + code: test( + 'await page.locator("checkbox").setChecked(true, { force: true })' + ), + errors: [{ messageId, line: 1, column: 78, endColumn: 89 }], + }, + { + code: test('await page.locator("button").tap({ force: true })'), + errors: [{ messageId, line: 1, column: 63, endColumn: 74 }], + }, ], valid: [ - valid("await page.locator('check').check()"), - valid("await page.locator('check').uncheck()"), - valid("await page.locator('button').click()"), - valid("await page.locator('button').locator('btn').click()"), - valid( + test("await page.locator('check').check()"), + test("await page.locator('check').uncheck()"), + test("await page.locator('button').click()"), + test("await page.locator('button').locator('btn').click()"), + test( "await page.locator('button').click({ delay: 500, noWaitAfter: true })" ), - valid("await page.locator('button').dblclick()"), - valid("await page.locator('input').dragTo()"), - valid("await page.locator('input').fill('something', { timeout: 1000 })"), - valid("await page.locator('elm').hover()"), - valid("await page.locator('select').selectOption({ label: 'Blue' })"), - valid("await page.locator('select').selectText()"), - valid("await page.locator('checkbox').setChecked(true)"), - valid("await page.locator('button').tap()"), - valid('doSomething({ force: true })'), - valid('await doSomething({ ["force"]: true })'), - valid('await doSomething({ [`force`]: true })'), + test("await page.locator('button').dblclick()"), + test("await page.locator('input').dragTo()"), + test("await page.locator('input').fill('something', { timeout: 1000 })"), + test("await page.locator('elm').hover()"), + test("await page.locator('select').selectOption({ label: 'Blue' })"), + test("await page.locator('select').selectText()"), + test("await page.locator('checkbox').setChecked(true)"), + test("await page.locator('button').tap()"), + test('doSomething({ force: true })'), + test('await doSomething({ ["force"]: true })'), + test('await doSomething({ [`force`]: true })'), ], }); From 3a67a699307fcd91150c85c44b71106121c00914 Mon Sep 17 00:00:00 2001 From: Mark Skelton Date: Sat, 14 Jan 2023 21:21:34 -0600 Subject: [PATCH 08/28] no-page-pause --- test/spec/no-page-pause.spec.ts | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/test/spec/no-page-pause.spec.ts b/test/spec/no-page-pause.spec.ts index 599b6c1..ed64f88 100644 --- a/test/spec/no-page-pause.spec.ts +++ b/test/spec/no-page-pause.spec.ts @@ -1,23 +1,27 @@ -import { runRuleTester, wrapInTest } from '../utils/rule-tester'; +import { runRuleTester, wrapInTest as test } from '../utils/rule-tester'; import rule from '../../src/rules/no-page-pause'; -const invalid = (code: string) => ({ - code: wrapInTest(code), - errors: [{ messageId: 'noPagePause' }], -}); - -const valid = wrapInTest; +const messageId = 'noPagePause'; runRuleTester('no-page-pause', rule, { invalid: [ - invalid('await page.pause()'), - invalid('await page["pause"]()'), - invalid('await page[`pause`]()'), + { + code: test('await page.pause()'), + errors: [{ messageId, line: 1, column: 34, endColumn: 46 }], + }, + { + code: test('await page["pause"]()'), + errors: [{ messageId, line: 1, column: 34, endColumn: 49 }], + }, + { + code: test('await page[`pause`]()'), + errors: [{ messageId, line: 1, column: 34, endColumn: 49 }], + }, ], valid: [ - valid('await page.click()'), - valid('await page["hover"]()'), - valid('await page[`check`]()'), - valid('await expect(page).toBePaused()'), + test('await page.click()'), + test('await page["hover"]()'), + test('await page[`check`]()'), + test('await expect(page).toBePaused()'), ], }); From 8aa5782a58b59f257f7f474c50b885fb3762610b Mon Sep 17 00:00:00 2001 From: Mark Skelton Date: Sat, 14 Jan 2023 21:49:13 -0600 Subject: [PATCH 09/28] no-restricted-matchers --- src/rules/no-restricted-matchers.ts | 45 ++++++++++++++++-------- test/spec/no-restricted-matchers.spec.ts | 28 +++++++++------ 2 files changed, 48 insertions(+), 25 deletions(-) diff --git a/src/rules/no-restricted-matchers.ts b/src/rules/no-restricted-matchers.ts index 034112b..3cc1532 100644 --- a/src/rules/no-restricted-matchers.ts +++ b/src/rules/no-restricted-matchers.ts @@ -2,12 +2,6 @@ import { Rule } from 'eslint'; import { getStringValue } from '../utils/ast'; import { parseExpectCall } from '../utils/parseExpectCall'; -// To properly test matcher chains, we ensure the entire chain is surrounded by -// periods so that the `includes` matcher doesn't match substrings. For example, -// `not` should only match `expect().not.something()` but it should not match -// `expect().nothing()`. -const wrap = (chain: string) => `.${chain}.`; - export default { create(context) { const restrictedChains = (context.options?.[0] ?? {}) as { @@ -19,19 +13,42 @@ export default { const expectCall = parseExpectCall(node); if (!expectCall) return; - // Stringify the expect call chain to compare to the list of restricted - // matcher chains. - const chain = expectCall.members.map(getStringValue).join('.'); - Object.entries(restrictedChains) - .filter(([restriction]) => wrap(chain).includes(wrap(restriction))) - .forEach(([restriction, message]) => { + .map(([restriction, message]) => { + const chain = expectCall.members; + const restrictionLinks = restriction.split('.').length; + + // Find in the full chain, where the restriction chain starts + const startIndex = chain.findIndex((_, i) => { + // Construct the partial chain to compare against the restriction + // chain string. + const partial = chain + .slice(i, i + restrictionLinks) + .map(getStringValue) + .join('.'); + + return partial === restriction; + }); + + return { + // If the restriction chain was found, return the portion of the + // chain that matches the restriction chain. + chain: + startIndex !== -1 + ? chain.slice(startIndex, startIndex + restrictionLinks) + : [], + restriction, + message, + }; + }) + .filter(({ chain }) => chain.length) + .forEach(({ chain, restriction, message }) => { context.report({ messageId: message ? 'restrictedWithMessage' : 'restricted', data: { message: message ?? '', restriction }, loc: { - start: expectCall.members[0].loc!.start, - end: expectCall.members[expectCall.members.length - 1].loc!.end, + start: chain[0].loc!.start, + end: chain[chain.length - 1].loc!.end, }, }); }); diff --git a/test/spec/no-restricted-matchers.spec.ts b/test/spec/no-restricted-matchers.spec.ts index a6a920f..fb0b923 100644 --- a/test/spec/no-restricted-matchers.spec.ts +++ b/test/spec/no-restricted-matchers.spec.ts @@ -54,8 +54,9 @@ runRuleTester('no-restricted-matchers', rule, { { messageId: 'restricted', data: { message: '', restriction: 'toBe' }, - column: 11, line: 1, + column: 11, + endColumn: 15, }, ], }, @@ -66,8 +67,9 @@ runRuleTester('no-restricted-matchers', rule, { { messageId: 'restricted', data: { message: '', restriction: 'toBe' }, - column: 16, line: 1, + column: 16, + endColumn: 20, }, ], }, @@ -78,8 +80,9 @@ runRuleTester('no-restricted-matchers', rule, { { messageId: 'restricted', data: { message: '', restriction: 'toBe' }, - column: 25, line: 1, + column: 25, + endColumn: 31, }, ], }, @@ -90,8 +93,9 @@ runRuleTester('no-restricted-matchers', rule, { { messageId: 'restricted', data: { message: '', restriction: 'not' }, - column: 11, line: 1, + column: 11, + endColumn: 14, }, ], }, @@ -102,9 +106,9 @@ runRuleTester('no-restricted-matchers', rule, { { messageId: 'restricted', data: { message: '', restriction: 'not.toBeTruthy' }, - endColumn: 25, - column: 11, line: 1, + column: 11, + endColumn: 25, }, ], }, @@ -115,8 +119,9 @@ runRuleTester('no-restricted-matchers', rule, { { messageId: 'restricted', data: { message: '', restriction: 'not' }, - column: 19, line: 1, + column: 19, + endColumn: 24, }, ], }, @@ -127,9 +132,9 @@ runRuleTester('no-restricted-matchers', rule, { { messageId: 'restricted', data: { message: '', restriction: 'not.toBeTruthy' }, - endColumn: 39, - column: 25, line: 1, + column: 25, + endColumn: 39, }, ], }, @@ -143,8 +148,9 @@ runRuleTester('no-restricted-matchers', rule, { message: 'Prefer `toStrictEqual` instead', restriction: 'toBe', }, - column: 11, line: 1, + column: 11, + endColumn: 15, }, ], }, @@ -158,8 +164,8 @@ runRuleTester('no-restricted-matchers', rule, { message: 'Use not.toContainText instead', restriction: 'not.toHaveText', }, - endColumn: 27, column: 13, + endColumn: 27, }, ], }, From 0a449d3a187de245426a063375bd2296516b27b8 Mon Sep 17 00:00:00 2001 From: Mark Skelton Date: Sat, 14 Jan 2023 21:49:38 -0600 Subject: [PATCH 10/28] Update ecma version --- examples/.eslintrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/.eslintrc b/examples/.eslintrc index 503bfe7..e39a0ce 100644 --- a/examples/.eslintrc +++ b/examples/.eslintrc @@ -2,6 +2,6 @@ "extends": ["plugin:playwright/playwright-test"], "parserOptions": { "sourceType": "module", - "ecmaVersion": 2018 + "ecmaVersion": 2022 } } From 49a2eb9a498fb0355e660c301d19288b12aeaf04 Mon Sep 17 00:00:00 2001 From: Mark Skelton Date: Sat, 14 Jan 2023 22:52:14 -0600 Subject: [PATCH 11/28] no-wait-for-timeout --- test/spec/no-wait-for-timeout.spec.ts | 176 ++++++++++++++++++++------ 1 file changed, 140 insertions(+), 36 deletions(-) diff --git a/test/spec/no-wait-for-timeout.spec.ts b/test/spec/no-wait-for-timeout.spec.ts index b3bc9bf..85ad28d 100644 --- a/test/spec/no-wait-for-timeout.spec.ts +++ b/test/spec/no-wait-for-timeout.spec.ts @@ -1,45 +1,149 @@ import { runRuleTester } from '../utils/rule-tester'; import rule from '../../src/rules/no-wait-for-timeout'; -const invalid = (code: string, output: string) => ({ - code, - errors: [ - { - messageId: 'noWaitForTimeout', - suggestions: [{ messageId: 'removeWaitForTimeout', output }], - }, - ], -}); +const messageId = 'noWaitForTimeout'; runRuleTester('no-wait-for-timeout', rule, { invalid: [ - invalid( - 'async function fn() { await page.waitForTimeout(1000) }', - 'async function fn() { }' - ), - invalid( - 'async function fn() { await page["waitForTimeout"](1000) }', - 'async function fn() { }' - ), - invalid( - 'async function fn() { await page[`waitForTimeout`](1000) }', - 'async function fn() { }' - ), - invalid( - 'async function fn() { return page.waitForTimeout(1000); }', - 'async function fn() { }' - ), - invalid( - 'async function fn() { page.waitForTimeout(1000); }', - 'async function fn() { }' - ), - invalid( - '(async function() { await page.waitForTimeout(500); })();', - '(async function() { })();' - ), - invalid('page.waitForTimeout(2000)', ''), - invalid('page["waitForTimeout"](2000)', ''), - invalid('page[`waitForTimeout`](2000)', ''), + { + code: 'async function fn() { await page.waitForTimeout(1000) }', + errors: [ + { + messageId, + suggestions: [ + { + messageId: 'removeWaitForTimeout', + output: 'async function fn() { }', + }, + ], + line: 1, + column: 29, + endLine: 1, + endColumn: 54, + }, + ], + }, + { + code: 'async function fn() { await page["waitForTimeout"](1000) }', + errors: [ + { + messageId, + suggestions: [ + { + messageId: 'removeWaitForTimeout', + output: 'async function fn() { }', + }, + ], + line: 1, + column: 29, + endColumn: 57, + }, + ], + }, + { + code: 'async function fn() { await page[`waitForTimeout`](1000) }', + errors: [ + { + messageId, + suggestions: [ + { + messageId: 'removeWaitForTimeout', + output: 'async function fn() { }', + }, + ], + line: 1, + column: 29, + endColumn: 57, + }, + ], + }, + { + code: 'async function fn() { return page.waitForTimeout(1000); }', + errors: [ + { + messageId, + suggestions: [ + { + messageId: 'removeWaitForTimeout', + output: 'async function fn() { }', + }, + ], + line: 1, + column: 30, + endColumn: 55, + }, + ], + }, + { + code: 'async function fn() { page.waitForTimeout(1000); }', + errors: [ + { + messageId, + suggestions: [ + { + messageId: 'removeWaitForTimeout', + output: 'async function fn() { }', + }, + ], + line: 1, + column: 23, + endColumn: 48, + }, + ], + }, + { + code: '(async function() { await page.waitForTimeout(500); })();', + errors: [ + { + messageId, + suggestions: [ + { + messageId: 'removeWaitForTimeout', + output: '(async function() { })();', + }, + ], + line: 1, + column: 27, + endColumn: 51, + }, + ], + }, + { + code: 'page.waitForTimeout(2000)', + errors: [ + { + messageId, + suggestions: [{ messageId: 'removeWaitForTimeout', output: '' }], + line: 1, + column: 1, + endColumn: 26, + }, + ], + }, + { + code: 'page["waitForTimeout"](2000)', + errors: [ + { + messageId, + suggestions: [{ messageId: 'removeWaitForTimeout', output: '' }], + line: 1, + column: 1, + endColumn: 29, + }, + ], + }, + { + code: 'page[`waitForTimeout`](2000)', + errors: [ + { + messageId, + suggestions: [{ messageId: 'removeWaitForTimeout', output: '' }], + line: 1, + column: 1, + endColumn: 29, + }, + ], + }, ], valid: [ 'function waitForTimeout() {}', From 693ee8f8e7bab1d46675079f585eb1334b5aa114 Mon Sep 17 00:00:00 2001 From: Mark Skelton Date: Sat, 14 Jan 2023 23:10:54 -0600 Subject: [PATCH 12/28] prefer-lowercase-title --- test/spec/prefer-lowercase-title.spec.ts | 344 +++++++++++++++++------ 1 file changed, 254 insertions(+), 90 deletions(-) diff --git a/test/spec/prefer-lowercase-title.spec.ts b/test/spec/prefer-lowercase-title.spec.ts index 37d0d56..06fd603 100644 --- a/test/spec/prefer-lowercase-title.spec.ts +++ b/test/spec/prefer-lowercase-title.spec.ts @@ -2,11 +2,7 @@ import * as dedent from 'dedent'; import rule from '../../src/rules/prefer-lowercase-title'; import { runRuleTester } from '../utils/rule-tester'; -const invalid = (code: string, output: string, method: string) => ({ - code, - output, - errors: [{ messageId: 'unexpectedLowercase', data: { method } }], -}); +const messageId = 'unexpectedLowercase'; runRuleTester('prefer-lowercase-title', rule, { valid: [ @@ -47,83 +43,227 @@ runRuleTester('prefer-lowercase-title', rule, { "test.describe['serial'].only('foo', () => {})", ], invalid: [ - invalid("test('Foo', () => {})", "test('foo', () => {})", 'test'), - invalid('test(`Foo bar`, () => {})', 'test(`foo bar`, () => {})', 'test'), - invalid( - "test.skip('Foo Bar', () => {})", - "test.skip('foo Bar', () => {})", - 'test' - ), - invalid( - 'test.skip(`Foo`, () => {})', - 'test.skip(`foo`, () => {})', - 'test' - ), - invalid( - "test['fixme']('Foo', () => {})", - "test['fixme']('foo', () => {})", - 'test' - ), - invalid( - 'test[`only`](`Foo`, () => {})', - 'test[`only`](`foo`, () => {})', - 'test' - ), - invalid( - "test.describe('Foo bar', () => {})", - "test.describe('foo bar', () => {})", - 'test.describe' - ), - invalid( - 'test[`describe`](`Foo Bar`, () => {})', - 'test[`describe`](`foo Bar`, () => {})', - 'test.describe' - ), - invalid( - "test.describe.skip('Foo', () => {})", - "test.describe.skip('foo', () => {})", - 'test.describe' - ), - invalid( - 'test.describe.fixme(`Foo`, () => {})', - 'test.describe.fixme(`foo`, () => {})', - 'test.describe' - ), - invalid( - 'test[`describe`]["only"]("Foo", () => {})', - 'test[`describe`]["only"]("foo", () => {})', - 'test.describe' - ), - invalid( - "test.describe.parallel.skip('Foo', () => {})", - "test.describe.parallel.skip('foo', () => {})", - 'test.describe' - ), - invalid( - 'test.describe.parallel.fixme(`Foo`, () => {})', - 'test.describe.parallel.fixme(`foo`, () => {})', - 'test.describe' - ), - invalid( - 'test.describe.parallel.only("Foo", () => {})', - 'test.describe.parallel.only("foo", () => {})', - 'test.describe' - ), - invalid( - "test.describe.serial.skip('Foo', () => {})", - "test.describe.serial.skip('foo', () => {})", - 'test.describe' - ), - invalid( - 'test.describe.serial.fixme(`Foo`, () => {})', - 'test.describe.serial.fixme(`foo`, () => {})', - 'test.describe' - ), - invalid( - 'test.describe.serial.only("Foo", () => {})', - 'test.describe.serial.only("foo", () => {})', - 'test.describe' - ), + { + code: "test('Foo', () => {})", + output: "test('foo', () => {})", + errors: [ + { + messageId, + data: { method: 'test' }, + line: 1, + column: 6, + endColumn: 11, + }, + ], + }, + { + code: 'test(`Foo bar`, () => {})', + output: 'test(`foo bar`, () => {})', + errors: [ + { + messageId, + data: { method: 'test' }, + line: 1, + column: 6, + endColumn: 15, + }, + ], + }, + { + code: "test.skip('Foo Bar', () => {})", + output: "test.skip('foo Bar', () => {})", + errors: [ + { + messageId, + data: { method: 'test' }, + line: 1, + column: 11, + endColumn: 20, + }, + ], + }, + { + code: 'test.skip(`Foo`, () => {})', + output: 'test.skip(`foo`, () => {})', + errors: [ + { + messageId, + data: { method: 'test' }, + line: 1, + column: 11, + endColumn: 16, + }, + ], + }, + { + code: "test['fixme']('Foo', () => {})", + output: "test['fixme']('foo', () => {})", + errors: [ + { + messageId, + data: { method: 'test' }, + line: 1, + column: 15, + endColumn: 20, + }, + ], + }, + { + code: 'test[`only`](`Foo`, () => {})', + output: 'test[`only`](`foo`, () => {})', + errors: [ + { + messageId, + data: { method: 'test' }, + line: 1, + column: 14, + endColumn: 19, + }, + ], + }, + { + code: "test.describe('Foo bar', () => {})", + output: "test.describe('foo bar', () => {})", + errors: [ + { + messageId, + data: { method: 'test.describe' }, + line: 1, + column: 15, + endColumn: 24, + }, + ], + }, + { + code: 'test[`describe`](`Foo Bar`, () => {})', + output: 'test[`describe`](`foo Bar`, () => {})', + errors: [ + { + messageId, + data: { method: 'test.describe' }, + line: 1, + column: 18, + endColumn: 27, + }, + ], + }, + { + code: "test.describe.skip('Foo', () => {})", + output: "test.describe.skip('foo', () => {})", + errors: [ + { + messageId, + data: { method: 'test.describe' }, + line: 1, + column: 20, + endColumn: 25, + }, + ], + }, + { + code: "test.describe.fixme('Foo', () => {})", + output: "test.describe.fixme('foo', () => {})", + errors: [ + { + messageId, + data: { method: 'test.describe' }, + line: 1, + column: 21, + endColumn: 26, + }, + ], + }, + { + code: 'test[`describe`]["only"]("Foo", () => {})', + output: 'test[`describe`]["only"]("foo", () => {})', + errors: [ + { + messageId, + data: { method: 'test.describe' }, + line: 1, + column: 26, + endColumn: 31, + }, + ], + }, + { + code: "test.describe.parallel.skip('Foo', () => {})", + output: "test.describe.parallel.skip('foo', () => {})", + errors: [ + { + messageId, + data: { method: 'test.describe' }, + line: 1, + column: 29, + endColumn: 34, + }, + ], + }, + { + code: 'test.describe.parallel.fixme(`Foo`, () => {})', + output: 'test.describe.parallel.fixme(`foo`, () => {})', + errors: [ + { + messageId, + data: { method: 'test.describe' }, + line: 1, + column: 30, + endColumn: 35, + }, + ], + }, + { + code: 'test.describe.parallel.only("Foo", () => {})', + output: 'test.describe.parallel.only("foo", () => {})', + errors: [ + { + messageId, + data: { method: 'test.describe' }, + line: 1, + column: 29, + endColumn: 34, + }, + ], + }, + { + code: "test.describe.serial.skip('Foo', () => {})", + output: "test.describe.serial.skip('foo', () => {})", + errors: [ + { + messageId, + data: { method: 'test.describe' }, + line: 1, + column: 27, + endColumn: 32, + }, + ], + }, + { + code: 'test.describe.serial.fixme(`Foo`, () => {})', + output: 'test.describe.serial.fixme(`foo`, () => {})', + errors: [ + { + messageId, + data: { method: 'test.describe' }, + line: 1, + column: 28, + endColumn: 33, + }, + ], + }, + { + code: 'test.describe.serial.only("Foo", () => {})', + output: 'test.describe.serial.only("foo", () => {})', + errors: [ + { + messageId, + data: { method: 'test.describe' }, + line: 1, + column: 27, + endColumn: 32, + }, + ], + }, ], }); @@ -147,7 +287,15 @@ runRuleTester('prefer-lowercase-title with ignore=test.describe', rule, { code: "test('Foo', () => {})", output: "test('foo', () => {})", options: [{ ignore: ['test.describe'] }], - errors: [{ messageId: 'unexpectedLowercase', data: { method: 'test' } }], + errors: [ + { + messageId, + data: { method: 'test' }, + line: 1, + column: 6, + endColumn: 11, + }, + ], }, ], }); @@ -174,8 +322,11 @@ runRuleTester('prefer-lowercase-title with ignore=test', rule, { options: [{ ignore: ['test'] }], errors: [ { - messageId: 'unexpectedLowercase', + messageId, data: { method: 'test.describe' }, + line: 1, + column: 15, + endColumn: 20, }, ], }, @@ -202,7 +353,15 @@ runRuleTester('prefer-lowercase-title with allowedPrefixes', rule, { code: 'test(`POST /live`, () => {})', output: 'test(`pOST /live`, () => {})', options: [{ allowedPrefixes: ['GET'] }], - errors: [{ messageId: 'unexpectedLowercase', data: { method: 'test' } }], + errors: [ + { + messageId, + data: { method: 'test' }, + line: 1, + column: 6, + endColumn: 18, + }, + ], }, ], }); @@ -231,8 +390,11 @@ runRuleTester('prefer-lowercase-title with ignoreTopLevelDescribe', rule, { options: [{ ignoreTopLevelDescribe: true }], errors: [ { - messageId: 'unexpectedLowercase', + messageId, data: { method: 'test' }, + line: 1, + column: 6, + endColumn: 14, }, ], }, @@ -254,16 +416,18 @@ runRuleTester('prefer-lowercase-title with ignoreTopLevelDescribe', rule, { options: [{ ignoreTopLevelDescribe: true }], errors: [ { - messageId: 'unexpectedLowercase', + messageId, data: { method: 'test.describe' }, - column: 17, line: 2, + column: 17, + endColumn: 27, }, { - messageId: 'unexpectedLowercase', + messageId, data: { method: 'test' }, - column: 10, line: 3, + column: 10, + endColumn: 23, }, ], }, From 3898539677e4646bf72188730893d91ec19704b3 Mon Sep 17 00:00:00 2001 From: Mark Skelton Date: Sat, 14 Jan 2023 23:11:43 -0600 Subject: [PATCH 13/28] prefer-strict-equal --- test/spec/prefer-strict-equal.spec.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test/spec/prefer-strict-equal.spec.ts b/test/spec/prefer-strict-equal.spec.ts index 45c0d91..2331904 100644 --- a/test/spec/prefer-strict-equal.spec.ts +++ b/test/spec/prefer-strict-equal.spec.ts @@ -13,14 +13,15 @@ runRuleTester('prefer-strict-equal', rule, { errors: [ { messageId: 'useToStrictEqual', - column: 19, - line: 1, suggestions: [ { messageId: 'suggestReplaceWithStrictEqual', output: 'expect(something).toStrictEqual(somethingElse);', }, ], + line: 1, + column: 19, + endColumn: 26, }, ], }, @@ -29,14 +30,15 @@ runRuleTester('prefer-strict-equal', rule, { errors: [ { messageId: 'useToStrictEqual', - column: 19, - line: 1, suggestions: [ { messageId: 'suggestReplaceWithStrictEqual', output: 'expect(something)["toStrictEqual"](somethingElse);', }, ], + line: 1, + column: 19, + endColumn: 28, }, ], }, From ca839135c9ffafe948833b5302f967d5a99e14a3 Mon Sep 17 00:00:00 2001 From: Mark Skelton Date: Sat, 14 Jan 2023 23:21:38 -0600 Subject: [PATCH 14/28] prefer-to-be --- test/spec/prefer-to-be.spec.ts | 123 ++++++++++++++++++++++----------- 1 file changed, 82 insertions(+), 41 deletions(-) diff --git a/test/spec/prefer-to-be.spec.ts b/test/spec/prefer-to-be.spec.ts index 4949397..5cb5f4e 100644 --- a/test/spec/prefer-to-be.spec.ts +++ b/test/spec/prefer-to-be.spec.ts @@ -22,57 +22,57 @@ runRuleTester('prefer-to-be', rule, { { code: 'expect(value).toEqual("my string");', output: 'expect(value).toBe("my string");', - errors: [{ messageId: 'useToBe', column: 15, line: 1 }], + errors: [{ messageId: 'useToBe', column: 15, endColumn: 22, line: 1 }], }, { code: 'expect(value).toStrictEqual("my string");', output: 'expect(value).toBe("my string");', - errors: [{ messageId: 'useToBe', column: 15, line: 1 }], + errors: [{ messageId: 'useToBe', column: 15, endColumn: 28, line: 1 }], }, { code: 'expect(value).toStrictEqual(1);', output: 'expect(value).toBe(1);', - errors: [{ messageId: 'useToBe', column: 15, line: 1 }], + errors: [{ messageId: 'useToBe', column: 15, endColumn: 28, line: 1 }], }, { code: 'expect(value).toStrictEqual(-1);', output: 'expect(value).toBe(-1);', - errors: [{ messageId: 'useToBe', column: 15, line: 1 }], + errors: [{ messageId: 'useToBe', column: 15, endColumn: 28, line: 1 }], }, { code: 'expect(value).toEqual(`my string`);', output: 'expect(value).toBe(`my string`);', - errors: [{ messageId: 'useToBe', column: 15, line: 1 }], + errors: [{ messageId: 'useToBe', column: 15, endColumn: 22, line: 1 }], }, { code: 'expect(value)["toEqual"](`my string`);', output: 'expect(value)["toBe"](`my string`);', - errors: [{ messageId: 'useToBe', column: 15, line: 1 }], + errors: [{ messageId: 'useToBe', column: 15, endColumn: 24, line: 1 }], }, { code: 'expect(value).toStrictEqual(`my ${string}`);', output: 'expect(value).toBe(`my ${string}`);', - errors: [{ messageId: 'useToBe', column: 15, line: 1 }], + errors: [{ messageId: 'useToBe', column: 15, endColumn: 28, line: 1 }], }, { code: 'expect(loadMessage()).resolves.toStrictEqual("hello world");', output: 'expect(loadMessage()).resolves.toBe("hello world");', - errors: [{ messageId: 'useToBe', column: 32, line: 1 }], + errors: [{ messageId: 'useToBe', column: 32, endColumn: 45, line: 1 }], }, { code: 'expect(loadMessage()).resolves["toStrictEqual"]("hello world");', output: 'expect(loadMessage()).resolves["toBe"]("hello world");', - errors: [{ messageId: 'useToBe', column: 32, line: 1 }], + errors: [{ messageId: 'useToBe', column: 32, endColumn: 47, line: 1 }], }, { code: 'expect(loadMessage())["resolves"].toStrictEqual("hello world");', output: 'expect(loadMessage())["resolves"].toBe("hello world");', - errors: [{ messageId: 'useToBe', column: 35, line: 1 }], + errors: [{ messageId: 'useToBe', column: 35, endColumn: 48, line: 1 }], }, { code: 'expect(loadMessage()).resolves.toStrictEqual(false);', output: 'expect(loadMessage()).resolves.toBe(false);', - errors: [{ messageId: 'useToBe', column: 32, line: 1 }], + errors: [{ messageId: 'useToBe', column: 32, endColumn: 45, line: 1 }], }, ], }); @@ -88,7 +88,6 @@ runRuleTester('prefer-to-be: null', rule, { 'expect(value).toMatchSnapshot();', "expect(catchError()).toStrictEqual({ message: 'oh noes!' })", 'expect("something");', - // 'expect(null).not.toEqual();', 'expect(null).toBe();', 'expect(null).toMatchSnapshot();', @@ -100,42 +99,58 @@ runRuleTester('prefer-to-be: null', rule, { { code: 'expect(null).toBe(null);', output: 'expect(null).toBeNull();', - errors: [{ messageId: 'useToBeNull', column: 14, line: 1 }], + errors: [ + { messageId: 'useToBeNull', column: 14, endColumn: 18, line: 1 }, + ], }, { code: 'expect(null).toEqual(null);', output: 'expect(null).toBeNull();', - errors: [{ messageId: 'useToBeNull', column: 14, line: 1 }], + errors: [ + { messageId: 'useToBeNull', column: 14, endColumn: 21, line: 1 }, + ], }, { code: 'expect(null).toStrictEqual(null);', output: 'expect(null).toBeNull();', - errors: [{ messageId: 'useToBeNull', column: 14, line: 1 }], + errors: [ + { messageId: 'useToBeNull', column: 14, endColumn: 27, line: 1 }, + ], }, { code: 'expect("a string").not.toBe(null);', output: 'expect("a string").not.toBeNull();', - errors: [{ messageId: 'useToBeNull', column: 24, line: 1 }], + errors: [ + { messageId: 'useToBeNull', column: 24, endColumn: 28, line: 1 }, + ], }, { code: 'expect("a string").not["toBe"](null);', output: 'expect("a string").not["toBeNull"]();', - errors: [{ messageId: 'useToBeNull', column: 24, line: 1 }], + errors: [ + { messageId: 'useToBeNull', column: 24, endColumn: 30, line: 1 }, + ], }, { code: 'expect("a string")["not"]["toBe"](null);', output: 'expect("a string")["not"]["toBeNull"]();', - errors: [{ messageId: 'useToBeNull', column: 27, line: 1 }], + errors: [ + { messageId: 'useToBeNull', column: 27, endColumn: 33, line: 1 }, + ], }, { code: 'expect("a string").not.toEqual(null);', output: 'expect("a string").not.toBeNull();', - errors: [{ messageId: 'useToBeNull', column: 24, line: 1 }], + errors: [ + { messageId: 'useToBeNull', column: 24, endColumn: 31, line: 1 }, + ], }, { code: 'expect("a string").not.toStrictEqual(null);', output: 'expect("a string").not.toBeNull();', - errors: [{ messageId: 'useToBeNull', column: 24, line: 1 }], + errors: [ + { messageId: 'useToBeNull', column: 24, endColumn: 37, line: 1 }, + ], }, ], }); @@ -158,42 +173,58 @@ runRuleTester('prefer-to-be: undefined', rule, { { code: 'expect(undefined).toBe(undefined);', output: 'expect(undefined).toBeUndefined();', - errors: [{ messageId: 'useToBeUndefined', column: 19, line: 1 }], + errors: [ + { messageId: 'useToBeUndefined', column: 19, endColumn: 23, line: 1 }, + ], }, { code: 'expect(undefined).toEqual(undefined);', output: 'expect(undefined).toBeUndefined();', - errors: [{ messageId: 'useToBeUndefined', column: 19, line: 1 }], + errors: [ + { messageId: 'useToBeUndefined', column: 19, endColumn: 26, line: 1 }, + ], }, { code: 'expect(undefined).toStrictEqual(undefined);', output: 'expect(undefined).toBeUndefined();', - errors: [{ messageId: 'useToBeUndefined', column: 19, line: 1 }], + errors: [ + { messageId: 'useToBeUndefined', column: 19, endColumn: 32, line: 1 }, + ], }, { code: 'expect("a string").not.toBe(undefined);', output: 'expect("a string").toBeDefined();', - errors: [{ messageId: 'useToBeDefined', column: 24, line: 1 }], + errors: [ + { messageId: 'useToBeDefined', column: 24, endColumn: 28, line: 1 }, + ], }, { code: 'expect("a string").rejects.not.toBe(undefined);', output: 'expect("a string").rejects.toBeDefined();', - errors: [{ messageId: 'useToBeDefined', column: 32, line: 1 }], + errors: [ + { messageId: 'useToBeDefined', column: 32, endColumn: 36, line: 1 }, + ], }, { code: 'expect("a string").rejects.not["toBe"](undefined);', output: 'expect("a string").rejects["toBeDefined"]();', - errors: [{ messageId: 'useToBeDefined', column: 32, line: 1 }], + errors: [ + { messageId: 'useToBeDefined', column: 32, endColumn: 38, line: 1 }, + ], }, { code: 'expect("a string").not.toEqual(undefined);', output: 'expect("a string").toBeDefined();', - errors: [{ messageId: 'useToBeDefined', column: 24, line: 1 }], + errors: [ + { messageId: 'useToBeDefined', column: 24, endColumn: 31, line: 1 }, + ], }, { code: 'expect("a string").not.toStrictEqual(undefined);', output: 'expect("a string").toBeDefined();', - errors: [{ messageId: 'useToBeDefined', column: 24, line: 1 }], + errors: [ + { messageId: 'useToBeDefined', column: 24, endColumn: 37, line: 1 }, + ], }, ], }); @@ -215,42 +246,42 @@ runRuleTester('prefer-to-be: NaN', rule, { { code: 'expect(NaN).toBe(NaN);', output: 'expect(NaN).toBeNaN();', - errors: [{ messageId: 'useToBeNaN', column: 13, line: 1 }], + errors: [{ messageId: 'useToBeNaN', column: 13, endColumn: 17, line: 1 }], }, { code: 'expect(NaN).toEqual(NaN);', output: 'expect(NaN).toBeNaN();', - errors: [{ messageId: 'useToBeNaN', column: 13, line: 1 }], + errors: [{ messageId: 'useToBeNaN', column: 13, endColumn: 20, line: 1 }], }, { code: 'expect(NaN).toStrictEqual(NaN);', output: 'expect(NaN).toBeNaN();', - errors: [{ messageId: 'useToBeNaN', column: 13, line: 1 }], + errors: [{ messageId: 'useToBeNaN', column: 13, endColumn: 26, line: 1 }], }, { code: 'expect("a string").not.toBe(NaN);', output: 'expect("a string").not.toBeNaN();', - errors: [{ messageId: 'useToBeNaN', column: 24, line: 1 }], + errors: [{ messageId: 'useToBeNaN', column: 24, endColumn: 28, line: 1 }], }, { code: 'expect("a string").rejects.not.toBe(NaN);', output: 'expect("a string").rejects.not.toBeNaN();', - errors: [{ messageId: 'useToBeNaN', column: 32, line: 1 }], + errors: [{ messageId: 'useToBeNaN', column: 32, endColumn: 36, line: 1 }], }, { code: 'expect("a string")["rejects"].not.toBe(NaN);', output: 'expect("a string")["rejects"].not.toBeNaN();', - errors: [{ messageId: 'useToBeNaN', column: 35, line: 1 }], + errors: [{ messageId: 'useToBeNaN', column: 35, endColumn: 39, line: 1 }], }, { code: 'expect("a string").not.toEqual(NaN);', output: 'expect("a string").not.toBeNaN();', - errors: [{ messageId: 'useToBeNaN', column: 24, line: 1 }], + errors: [{ messageId: 'useToBeNaN', column: 24, endColumn: 31, line: 1 }], }, { code: 'expect("a string").not.toStrictEqual(NaN);', output: 'expect("a string").not.toBeNaN();', - errors: [{ messageId: 'useToBeNaN', column: 24, line: 1 }], + errors: [{ messageId: 'useToBeNaN', column: 24, endColumn: 37, line: 1 }], }, ], }); @@ -272,27 +303,37 @@ runRuleTester('prefer-to-be: undefined vs defined', rule, { { code: 'expect(undefined).not.toBeDefined();', output: 'expect(undefined).toBeUndefined();', - errors: [{ messageId: 'useToBeUndefined', column: 23, line: 1 }], + errors: [ + { messageId: 'useToBeUndefined', column: 23, endColumn: 34, line: 1 }, + ], }, { code: 'expect(undefined).resolves.not.toBeDefined();', output: 'expect(undefined).resolves.toBeUndefined();', - errors: [{ messageId: 'useToBeUndefined', column: 32, line: 1 }], + errors: [ + { messageId: 'useToBeUndefined', column: 32, endColumn: 43, line: 1 }, + ], }, { code: 'expect(undefined).resolves.toBe(undefined);', output: 'expect(undefined).resolves.toBeUndefined();', - errors: [{ messageId: 'useToBeUndefined', column: 28, line: 1 }], + errors: [ + { messageId: 'useToBeUndefined', column: 28, endColumn: 32, line: 1 }, + ], }, { code: 'expect("a string").not.toBeUndefined();', output: 'expect("a string").toBeDefined();', - errors: [{ messageId: 'useToBeDefined', column: 24, line: 1 }], + errors: [ + { messageId: 'useToBeDefined', column: 24, endColumn: 37, line: 1 }, + ], }, { code: 'expect("a string").rejects.not.toBeUndefined();', output: 'expect("a string").rejects.toBeDefined();', - errors: [{ messageId: 'useToBeDefined', column: 32, line: 1 }], + errors: [ + { messageId: 'useToBeDefined', column: 32, endColumn: 45, line: 1 }, + ], }, ], }); From c449a009fc6032ce4d5f12f20819d98f9cdf6ef8 Mon Sep 17 00:00:00 2001 From: Mark Skelton Date: Sat, 14 Jan 2023 23:22:54 -0600 Subject: [PATCH 15/28] prefer-to-have-length --- test/spec/prefer-to-have-length.spec.ts | 28 ++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/test/spec/prefer-to-have-length.spec.ts b/test/spec/prefer-to-have-length.spec.ts index fcec52e..fad7176 100644 --- a/test/spec/prefer-to-have-length.spec.ts +++ b/test/spec/prefer-to-have-length.spec.ts @@ -16,37 +16,51 @@ runRuleTester('prefer-to-have-length', rule, { { code: 'expect(files.length).toBe(1)', output: 'expect(files).toHaveLength(1)', - errors: [{ messageId: 'useToHaveLength', column: 22, line: 1 }], + errors: [ + { messageId: 'useToHaveLength', column: 22, endColumn: 26, line: 1 }, + ], }, { code: 'expect(files.length).not.toBe(1)', output: 'expect(files).not.toHaveLength(1)', - errors: [{ messageId: 'useToHaveLength', column: 26, line: 1 }], + errors: [ + { messageId: 'useToHaveLength', column: 26, endColumn: 30, line: 1 }, + ], }, { code: 'expect.soft(files["length"]).not.toBe(1)', output: 'expect.soft(files).not.toHaveLength(1)', - errors: [{ messageId: 'useToHaveLength', column: 34, line: 1 }], + errors: [ + { messageId: 'useToHaveLength', column: 34, endColumn: 38, line: 1 }, + ], }, { code: 'expect(files["length"]).not["toBe"](1)', output: 'expect(files).not["toHaveLength"](1)', - errors: [{ messageId: 'useToHaveLength', column: 29, line: 1 }], + errors: [ + { messageId: 'useToHaveLength', column: 29, endColumn: 35, line: 1 }, + ], }, { code: 'expect(files.length)[`toEqual`](1)', output: 'expect(files)[`toHaveLength`](1)', - errors: [{ messageId: 'useToHaveLength', column: 22, line: 1 }], + errors: [ + { messageId: 'useToHaveLength', column: 22, endColumn: 31, line: 1 }, + ], }, { code: 'expect(files.length).toStrictEqual(1)', output: 'expect(files).toHaveLength(1)', - errors: [{ messageId: 'useToHaveLength', column: 22, line: 1 }], + errors: [ + { messageId: 'useToHaveLength', column: 22, endColumn: 35, line: 1 }, + ], }, { code: 'expect(files.length).not.toStrictEqual(1)', output: 'expect(files).not.toHaveLength(1)', - errors: [{ messageId: 'useToHaveLength', column: 26, line: 1 }], + errors: [ + { messageId: 'useToHaveLength', column: 26, endColumn: 39, line: 1 }, + ], }, ], }); From 74a24e41af12a028fb108cb465b0559e5b33c1dc Mon Sep 17 00:00:00 2001 From: Mark Skelton Date: Sat, 14 Jan 2023 23:32:44 -0600 Subject: [PATCH 16/28] require-top-level-describe --- src/rules/require-top-level-describe.ts | 6 +- test/spec/require-top-level-describe.spec.ts | 114 +++++++++++++++---- 2 files changed, 98 insertions(+), 22 deletions(-) diff --git a/src/rules/require-top-level-describe.ts b/src/rules/require-top-level-describe.ts index ef01ac2..98680dc 100644 --- a/src/rules/require-top-level-describe.ts +++ b/src/rules/require-top-level-describe.ts @@ -23,7 +23,7 @@ export default { if (topLevelDescribeCount > maxTopLevelDescribes) { context.report({ - node, + node: node.callee, messageId: 'tooManyDescribes', data: getAmountData(maxTopLevelDescribes), }); @@ -31,9 +31,9 @@ export default { } } else if (!describeCount) { if (isTest(node)) { - context.report({ node, messageId: 'unexpectedTest' }); + context.report({ node: node.callee, messageId: 'unexpectedTest' }); } else if (isTestHook(node)) { - context.report({ node, messageId: 'unexpectedHook' }); + context.report({ node: node.callee, messageId: 'unexpectedHook' }); } } }, diff --git a/test/spec/require-top-level-describe.spec.ts b/test/spec/require-top-level-describe.spec.ts index 9fbfd36..61ba1ac 100644 --- a/test/spec/require-top-level-describe.spec.ts +++ b/test/spec/require-top-level-describe.spec.ts @@ -47,32 +47,102 @@ runRuleTester('require-top-level-describe', rule, { ], invalid: [ // Top level hooks - invalid('test.beforeAll(() => {})', 'unexpectedHook'), - invalid('test.beforeEach(() => {})', 'unexpectedHook'), - invalid('test.afterAll(() => {})', 'unexpectedHook'), - invalid('test.afterEach(() => {})', 'unexpectedHook'), - invalid('test["afterEach"](() => {})', 'unexpectedHook'), - invalid('test[`afterEach`](() => {})', 'unexpectedHook'), + { + code: 'test.beforeAll(() => {})', + errors: [ + { messageId: 'unexpectedHook', line: 1, column: 1, endColumn: 15 }, + ], + }, + { + code: 'test.beforeEach(() => {})', + errors: [ + { messageId: 'unexpectedHook', line: 1, column: 1, endColumn: 16 }, + ], + }, + { + code: 'test.afterAll(() => {})', + errors: [ + { messageId: 'unexpectedHook', line: 1, column: 1, endColumn: 14 }, + ], + }, + { + code: 'test.afterEach(() => {})', + errors: [ + { messageId: 'unexpectedHook', line: 1, column: 1, endColumn: 15 }, + ], + }, + { + code: 'test["afterEach"](() => {})', + errors: [ + { messageId: 'unexpectedHook', line: 1, column: 1, endColumn: 18 }, + ], + }, + { + code: 'test[`afterEach`](() => {})', + errors: [ + { messageId: 'unexpectedHook', line: 1, column: 1, endColumn: 18 }, + ], + }, { code: dedent` test.describe("suite", () => {}); test.afterAll(() => {}) `, - errors: [{ messageId: 'unexpectedHook' }], + errors: [ + { + messageId: 'unexpectedHook', + line: 2, + column: 1, + endLine: 2, + endColumn: 14, + }, + ], }, // Top level tests - invalid('test("foo", () => {})', 'unexpectedTest'), - invalid('test.skip("foo", () => {})', 'unexpectedTest'), - invalid('test.fixme("foo", () => {})', 'unexpectedTest'), - invalid('test.only("foo", () => {})', 'unexpectedTest'), - invalid('test["only"]("foo", () => {})', 'unexpectedTest'), - invalid('test[`only`]("foo", () => {})', 'unexpectedTest'), + { + code: 'test("foo", () => {})', + errors: [ + { messageId: 'unexpectedTest', line: 1, column: 1, endColumn: 5 }, + ], + }, + { + code: 'test.skip("foo", () => {})', + errors: [ + { messageId: 'unexpectedTest', line: 1, column: 1, endColumn: 10 }, + ], + }, + { + code: 'test.fixme("foo", () => {})', + errors: [ + { messageId: 'unexpectedTest', line: 1, column: 1, endColumn: 11 }, + ], + }, + { + code: 'test.only("foo", () => {})', + errors: [ + { messageId: 'unexpectedTest', line: 1, column: 1, endColumn: 10 }, + ], + }, + { + code: 'test["only"]("foo", () => {})', + errors: [ + { messageId: 'unexpectedTest', line: 1, column: 1, endColumn: 13 }, + ], + }, + { + code: 'test[`only`]("foo", () => {})', + errors: [ + { messageId: 'unexpectedTest', line: 1, column: 1, endColumn: 13 }, + ], + }, { code: dedent` test("foo", () => {}) test.describe("suite", () => {}); `, - errors: [{ messageId: 'unexpectedTest' }], + errors: [ + { messageId: 'unexpectedTest', line: 1, column: 1, endColumn: 5 }, + ], }, { code: dedent` @@ -81,7 +151,9 @@ runRuleTester('require-top-level-describe', rule, { test("bar", () => {}) }); `, - errors: [{ messageId: 'unexpectedTest' }], + errors: [ + { messageId: 'unexpectedTest', line: 1, column: 1, endColumn: 5 }, + ], }, // Too many describes { @@ -91,7 +163,9 @@ runRuleTester('require-top-level-describe', rule, { test.describe.parallel('three', () => {}); `, options: [{ maxTopLevelDescribes: 2 }], - errors: [{ messageId: 'tooManyDescribes', line: 3 }], + errors: [ + { messageId: 'tooManyDescribes', line: 3, column: 1, endColumn: 23 }, + ], }, { code: dedent` @@ -113,7 +187,9 @@ runRuleTester('require-top-level-describe', rule, { }); `, options: [{ maxTopLevelDescribes: 2 }], - errors: [{ messageId: 'tooManyDescribes', line: 12 }], + errors: [ + { messageId: 'tooManyDescribes', line: 12, column: 1, endColumn: 26 }, + ], }, { code: dedent` @@ -123,8 +199,8 @@ runRuleTester('require-top-level-describe', rule, { `, options: [{ maxTopLevelDescribes: 1 }], errors: [ - { messageId: 'tooManyDescribes', line: 2 }, - { messageId: 'tooManyDescribes', line: 3 }, + { messageId: 'tooManyDescribes', line: 2, column: 1, endColumn: 25 }, + { messageId: 'tooManyDescribes', line: 3, column: 1, endColumn: 20 }, ], }, ], From 1b14ced36fb86b6ca10ccb9da68a6ca64fa67a51 Mon Sep 17 00:00:00 2001 From: Mark Skelton Date: Sun, 15 Jan 2023 07:37:05 -0600 Subject: [PATCH 17/28] valid-expect --- src/rules/valid-expect.ts | 5 +- test/spec/valid-expect.spec.ts | 214 +++++++++++++++++++++++++++------ test/utils/rule-tester.ts | 2 - 3 files changed, 181 insertions(+), 40 deletions(-) diff --git a/src/rules/valid-expect.ts b/src/rules/valid-expect.ts index b6b818f..1b56fb4 100644 --- a/src/rules/valid-expect.ts +++ b/src/rules/valid-expect.ts @@ -49,7 +49,10 @@ export default { if (!result.called) { context.report({ - node: result.node, + node: + result.node.type === 'MemberExpression' + ? result.node.property + : result.node, messageId: 'matcherNotCalled', }); } diff --git a/test/spec/valid-expect.spec.ts b/test/spec/valid-expect.spec.ts index 7247d91..6891e75 100644 --- a/test/spec/valid-expect.spec.ts +++ b/test/spec/valid-expect.spec.ts @@ -1,11 +1,6 @@ import { runRuleTester } from '../utils/rule-tester'; import rule from '../../src/rules/valid-expect'; -const invalid = (code: string, messageId: string) => ({ - code, - errors: [{ messageId }], -}); - runRuleTester('valid-expect', rule, { valid: [ 'expect("something").toBe("else")', @@ -40,63 +35,208 @@ runRuleTester('valid-expect', rule, { ], invalid: [ // Matcher not found - invalid('expect(foo)', 'matcherNotFound'), - invalid('expect(foo).not', 'matcherNotFound'), - invalid('expect.soft(foo)', 'matcherNotFound'), - invalid('expect.soft(foo).not', 'matcherNotFound'), - invalid('expect["soft"](foo)["not"]', 'matcherNotFound'), - invalid('expect.poll(foo)', 'matcherNotFound'), - invalid('expect.poll(foo).not', 'matcherNotFound'), - invalid('expect[`poll`](foo)[`not`]', 'matcherNotFound'), + { + code: 'expect(foo)', + errors: [ + { messageId: 'matcherNotFound', line: 1, column: 1, endColumn: 12 }, + ], + }, + { + code: 'expect(foo).not', + errors: [ + { messageId: 'matcherNotFound', line: 1, column: 1, endColumn: 12 }, + ], + }, + { + code: 'expect.soft(foo)', + errors: [ + { messageId: 'matcherNotFound', line: 1, column: 1, endColumn: 17 }, + ], + }, + { + code: 'expect.soft(foo).not', + errors: [ + { messageId: 'matcherNotFound', line: 1, column: 1, endColumn: 17 }, + ], + }, + { + code: 'expect["soft"](foo)["not"]', + errors: [ + { messageId: 'matcherNotFound', line: 1, column: 1, endColumn: 20 }, + ], + }, + { + code: 'expect.poll(foo)', + errors: [ + { messageId: 'matcherNotFound', line: 1, column: 1, endColumn: 17 }, + ], + }, + { + code: 'expect.poll(foo).not', + errors: [ + { messageId: 'matcherNotFound', line: 1, column: 1, endColumn: 17 }, + ], + }, + { + code: 'expect[`poll`](foo)[`not`]', + errors: [ + { messageId: 'matcherNotFound', line: 1, column: 1, endColumn: 20 }, + ], + }, // Matcher not called - invalid('expect(foo).toBe', 'matcherNotCalled'), - invalid('expect(foo).not.toBe', 'matcherNotCalled'), - invalid('expect(foo)["not"].toBe', 'matcherNotCalled'), - invalid('something(expect(foo).not.toBe)', 'matcherNotCalled'), - invalid('expect.soft(foo).toBe', 'matcherNotCalled'), - invalid('expect.soft(foo).not.toBe', 'matcherNotCalled'), - invalid('something(expect.soft(foo).not.toBe)', 'matcherNotCalled'), - invalid('expect.poll(() => foo).toBe', 'matcherNotCalled'), - invalid('expect.poll(() => foo).not.toBe', 'matcherNotCalled'), - invalid('something(expect.poll(() => foo).not.toBe)', 'matcherNotCalled'), - invalid('expect["poll"](() => foo)["not"][`toBe`]', 'matcherNotCalled'), - invalid( - 'something(expect["poll"](() => foo)["not"][`toBe`])', - 'matcherNotCalled' - ), + { + code: 'expect(foo).toBe', + errors: [ + { messageId: 'matcherNotCalled', line: 1, column: 13, endColumn: 17 }, + ], + }, + { + code: 'expect(foo).not.toBe', + errors: [ + { messageId: 'matcherNotCalled', line: 1, column: 17, endColumn: 21 }, + ], + }, + { + code: 'expect(foo)["not"].toBe', + errors: [ + { messageId: 'matcherNotCalled', line: 1, column: 20, endColumn: 24 }, + ], + }, + { + code: 'something(expect(foo).not.toBe)', + errors: [ + { messageId: 'matcherNotCalled', line: 1, column: 27, endColumn: 31 }, + ], + }, + { + code: 'expect.soft(foo).toEqual', + errors: [ + { messageId: 'matcherNotCalled', line: 1, column: 18, endColumn: 25 }, + ], + }, + { + code: 'expect.soft(foo).not.toEqual', + errors: [ + { messageId: 'matcherNotCalled', line: 1, column: 22, endColumn: 29 }, + ], + }, + { + code: 'something(expect.soft(foo).not.toEqual)', + errors: [ + { messageId: 'matcherNotCalled', line: 1, column: 32, endColumn: 39 }, + ], + }, + { + code: 'expect.poll(() => foo).toBe', + errors: [ + { messageId: 'matcherNotCalled', line: 1, column: 24, endColumn: 28 }, + ], + }, + { + code: 'expect.poll(() => foo).not.toBe', + errors: [ + { messageId: 'matcherNotCalled', line: 1, column: 28, endColumn: 32 }, + ], + }, + { + code: 'expect["poll"](() => foo)["not"][`toBe`]', + errors: [ + { messageId: 'matcherNotCalled', line: 1, column: 34, endColumn: 40 }, + ], + }, + { + code: 'something(expect["poll"](() => foo)["not"][`toBe`])', + errors: [ + { messageId: 'matcherNotCalled', line: 1, column: 44, endColumn: 50 }, + ], + }, // minArgs { - code: 'expect().toBe(true)', - errors: [{ messageId: 'notEnoughArgs', data: { amount: 1, s: '' } }], + code: 'expect().toContain(true)', + errors: [ + { + messageId: 'notEnoughArgs', + data: { amount: 1, s: '' }, + line: 1, + column: 1, + endColumn: 9, + }, + ], }, { code: 'expect(foo).toBe(true)', options: [{ minArgs: 2 }], - errors: [{ messageId: 'notEnoughArgs', data: { amount: 2, s: 's' } }], + errors: [ + { + messageId: 'notEnoughArgs', + data: { amount: 2, s: 's' }, + line: 1, + column: 1, + endColumn: 12, + }, + ], }, // maxArgs { code: 'expect(foo, "bar", "baz").toBe(true)', - errors: [{ messageId: 'tooManyArgs', data: { amount: 2, s: 's' } }], + errors: [ + { + messageId: 'tooManyArgs', + data: { amount: 2, s: 's' }, + line: 1, + column: 1, + endColumn: 26, + }, + ], }, { code: 'expect(foo, "bar").toBe(true)', options: [{ maxArgs: 1 }], - errors: [{ messageId: 'tooManyArgs', data: { amount: 1, s: '' } }], + errors: [ + { + messageId: 'tooManyArgs', + data: { amount: 1, s: '' }, + line: 1, + column: 1, + endColumn: 19, + }, + ], }, // Multiple errors { code: 'expect()', errors: [ - { messageId: 'matcherNotFound' }, - { messageId: 'notEnoughArgs', data: { amount: 1, s: '' } }, + { + messageId: 'matcherNotFound', + line: 1, + column: 1, + endColumn: 9, + }, + { + messageId: 'notEnoughArgs', + data: { amount: 1, s: '' }, + line: 1, + column: 1, + endColumn: 9, + }, ], }, { code: 'expect().toHaveText', errors: [ - { messageId: 'matcherNotCalled' }, - { messageId: 'notEnoughArgs', data: { amount: 1, s: '' } }, + { + messageId: 'notEnoughArgs', + data: { amount: 1, s: '' }, + line: 1, + column: 1, + endColumn: 9, + }, + { + messageId: 'matcherNotCalled', + line: 1, + column: 10, + endColumn: 20, + }, ], }, ], diff --git a/test/utils/rule-tester.ts b/test/utils/rule-tester.ts index 3dd16c2..f4b9869 100644 --- a/test/utils/rule-tester.ts +++ b/test/utils/rule-tester.ts @@ -21,5 +21,3 @@ export function runRuleTester(...args: Parameters) { export const wrapInTest = (input: string) => `test('test', async () => { ${input} })`; - -export type Errors = RuleTester.InvalidTestCase['errors']; From f16684ed8b1fe5e4b0c85faf2c477990fae6bc31 Mon Sep 17 00:00:00 2001 From: Mark Skelton Date: Sun, 15 Jan 2023 07:54:10 -0600 Subject: [PATCH 18/28] no-conditional-in-test --- test/spec/no-conditional-in-test.spec.ts | 291 +++++++++++++---------- 1 file changed, 170 insertions(+), 121 deletions(-) diff --git a/test/spec/no-conditional-in-test.spec.ts b/test/spec/no-conditional-in-test.spec.ts index ba7713d..aedc29a 100644 --- a/test/spec/no-conditional-in-test.spec.ts +++ b/test/spec/no-conditional-in-test.spec.ts @@ -1,138 +1,187 @@ -import { Errors, runRuleTester } from '../utils/rule-tester'; +import { runRuleTester } from '../utils/rule-tester'; import rule from '../../src/rules/no-conditional-in-test'; +import dedent = require('dedent'); -const invalid = ( - code: string, - errors: Errors = [{ messageId: 'conditionalInTest' }] -) => ({ code, errors }); +const messageId = 'conditionalInTest'; runRuleTester('no-conditional-in-test', rule, { invalid: [ - invalid('test("foo", () => { if (true) { expect(1).toBe(1); } });'), - invalid(` - test.describe("foo", () => { - test("bar", () => { - if (someCondition()) { - expect(1).toBe(1); - } else { - expect(2).toBe(2); + { + code: 'test("foo", () => { if (true) { expect(1).toBe(1); } });', + errors: [{ messageId, line: 1, column: 21, endLine: 1, endColumn: 53 }], + }, + { + code: dedent` + test.describe("foo", () => { + test("bar", () => { + if (someCondition()) { + expect(1).toBe(1); + } else { + expect(2).toBe(2); + } + }); + }); + `, + errors: [{ messageId, line: 3, column: 5, endLine: 7, endColumn: 6 }], + }, + { + code: dedent` + describe('foo', () => { + test('bar', () => { + if ('bar') {} + }) + }) + `, + errors: [{ messageId, line: 3, column: 5, endLine: 3, endColumn: 18 }], + }, + { + code: dedent` + describe('foo', () => { + test('bar', () => { + if ('bar') {} + }) + test('baz', () => { + if ('qux') {} + if ('quux') {} + }) + }) + `, + errors: [ + { messageId, line: 3, column: 5, endLine: 3, endColumn: 18 }, + { messageId, line: 6, column: 5, endLine: 6, endColumn: 18 }, + { messageId, line: 7, column: 5, endLine: 7, endColumn: 19 }, + ], + }, + { + code: dedent` + test("foo", function () { + switch(someCondition()) { + case 1: + expect(1).toBe(1); + break; + case 2: + expect(2).toBe(2); + break; } }); - }); - `), - invalid(` - describe('foo', () => { - test('bar', () => { + `, + errors: [{ messageId, line: 2, column: 3, endLine: 9, endColumn: 4 }], + }, + { + code: dedent` + test('foo', () => { if ('bar') {} }) - }) - `), - invalid( - ` - describe('foo', () => { - test('bar', () => { + `, + errors: [{ messageId, line: 2, column: 3, endLine: 2, endColumn: 16 }], + }, + { + code: dedent` + test('foo', () => { + bar ? expect(1).toBe(1) : expect(2).toBe(2); + }) + `, + errors: [{ messageId, line: 2, column: 3, endLine: 2, endColumn: 46 }], + }, + { + code: dedent` + test('foo', function () { + bar ? expect(1).toBe(1) : expect(2).toBe(2); + }) + `, + errors: [{ messageId, line: 2, column: 3, endLine: 2, endColumn: 46 }], + }, + { + code: dedent` + test('foo', function () { if ('bar') {} }) - test('baz', () => { - if ('qux') {} - if ('quux') {} + `, + errors: [{ messageId, line: 2, column: 3, endLine: 2, endColumn: 16 }], + }, + { + code: dedent` + test('foo', async function ({ page }) { + await asyncFunc(); + if ('bar') {} }) - }) - `, - [ - { messageId: 'conditionalInTest' }, - { messageId: 'conditionalInTest' }, - { messageId: 'conditionalInTest' }, - ] - ), - invalid(` - test("foo", function () { - switch(someCondition()) { - case 1: - expect(1).toBe(1); - break; - case 2: - expect(2).toBe(2); - break; - } - }); - `), - invalid(` - test('foo', () => { - if ('bar') {} - }) - `), - invalid(` - test('foo', () => { - bar ? expect(1).toBe(1) : expect(2).toBe(2); - }) - `), - invalid(` - test('foo', function () { - bar ? expect(1).toBe(1) : expect(2).toBe(2); - }) - `), - invalid(` - test('foo', function () { - if ('bar') {} - }) - `), - invalid(` - test('foo', async function ({ page }) { - await asyncFunc(); - if ('bar') {} - }) - `), - invalid(` - test.skip('foo', () => { - if ('bar') {} - }) - `), - invalid(` - test.skip('foo', async ({ page }) => { - await asyncFunc(); - if ('bar') {} - }) - `), - invalid(` - test.skip('foo', function () { - if ('bar') {} - }) - `), - invalid(` - test.only('foo', () => { - if ('bar') {} - }) - `), - invalid(` - test.fixme('foo', () => { - if ('bar') {} - }) - `), - invalid(` - test('foo', () => { - callExpression() - if ('bar') {} - }) - `), - invalid(` - testDetails.forEach((detail) => { - test(detail.name, () => { - if (detail.fail) { - test.fail(); - } else { - expect(true).toBe(true); - } + `, + errors: [{ messageId, line: 3, column: 3, endLine: 3, endColumn: 16 }], + }, + { + code: dedent` + test.skip('foo', () => { + if ('bar') {} }) - }); - `), - invalid(` - test('test', async ({ page }) => { - await test.step('step', async () => { - if (true) {} + `, + errors: [{ messageId, line: 2, column: 3, endLine: 2, endColumn: 16 }], + }, + { + code: dedent` + test.skip('foo', async ({ page }) => { + await asyncFunc(); + if ('bar') {} + }) + `, + errors: [{ messageId, line: 3, column: 3, endLine: 3, endColumn: 16 }], + }, + { + code: dedent` + test.skip('foo', function () { + if ('bar') {} + }) + `, + errors: [{ messageId, line: 2, column: 3, endLine: 2, endColumn: 16 }], + }, + { + code: dedent` + test.only('foo', () => { + if ('bar') {} + }) + `, + errors: [{ messageId, line: 2, column: 3, endLine: 2, endColumn: 16 }], + }, + { + code: dedent` + test.fixme('foo', () => { + if ('bar') {} + }) + `, + errors: [{ messageId, line: 2, column: 3, endLine: 2, endColumn: 16 }], + }, + { + code: dedent` + test('foo', () => { + callExpression() + if ('bar') {} + }) + `, + errors: [{ messageId, line: 3, column: 3, endLine: 3, endColumn: 16 }], + }, + { + code: dedent` + testDetails.forEach((detail) => { + test(detail.name, () => { + if (detail.fail) { + test.fail(); + } else { + expect(true).toBe(true); + } + }) }); - }); - `), + `, + errors: [{ messageId, line: 3, column: 5, endLine: 7, endColumn: 6 }], + }, + { + code: dedent` + test('test', async ({ page }) => { + await test.step('step', async () => { + if (true) {} + }); + }); + `, + errors: [{ messageId, line: 3, column: 5, endLine: 3, endColumn: 17 }], + }, ], valid: [ 'test("foo", () => { expect(1).toBe(1); });', From 5701facdeb3a14c779347631a5a941b851588c34 Mon Sep 17 00:00:00 2001 From: Mark Skelton Date: Sun, 15 Jan 2023 07:57:06 -0600 Subject: [PATCH 19/28] Update example eslintrc --- examples/.eslintrc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/examples/.eslintrc b/examples/.eslintrc index e39a0ce..38ea186 100644 --- a/examples/.eslintrc +++ b/examples/.eslintrc @@ -3,5 +3,19 @@ "parserOptions": { "sourceType": "module", "ecmaVersion": 2022 + }, + "rules": { + "playwright/prefer-lowercase-title": "warn", + "playwright/prefer-to-be": "warn", + "playwright/prefer-to-have-length": "warn", + "playwright/prefer-strict-equal": "warn", + "playwright/require-top-level-describe": "warn", + "playwright/no-restricted-matchers": [ + "error", + { + "toBeFalsy": "Use `toBe(false)` instead.", + "not": null + } + ] } } From a9f84ae47b6c6468086e561af57b43d6c8b161e4 Mon Sep 17 00:00:00 2001 From: Mark Skelton Date: Sun, 15 Jan 2023 08:11:17 -0600 Subject: [PATCH 20/28] no-eval --- src/rules/no-eval.ts | 2 +- test/spec/no-eval.spec.ts | 115 ++++++++++++++++++++++++-------------- 2 files changed, 74 insertions(+), 43 deletions(-) diff --git a/src/rules/no-eval.ts b/src/rules/no-eval.ts index 6ae655c..aa52ac4 100644 --- a/src/rules/no-eval.ts +++ b/src/rules/no-eval.ts @@ -10,7 +10,7 @@ export default { if (isEval || isPageMethod(node, '$$eval')) { context.report({ messageId: isEval ? 'noEval' : 'noEvalAll', - node, + node: node.callee, }); } }, diff --git a/test/spec/no-eval.spec.ts b/test/spec/no-eval.spec.ts index c98d68d..847a8db 100644 --- a/test/spec/no-eval.spec.ts +++ b/test/spec/no-eval.spec.ts @@ -1,60 +1,91 @@ -import { runRuleTester, wrapInTest } from '../utils/rule-tester'; +import { runRuleTester, test } from '../utils/rule-tester'; import rule from '../../src/rules/no-eval'; -const invalid = (code: string) => ({ - code: wrapInTest(code), - errors: [{ messageId: code.includes('$$eval') ? 'noEvalAll' : 'noEval' }], -}); - -const valid = wrapInTest; - runRuleTester('no-eval', rule, { + invalid: [ + { + code: test( + 'const searchValue = await page.$eval("#search", el => el.value);' + ), + errors: [{ messageId: 'noEval', line: 1, column: 54, endColumn: 64 }], + }, + { + code: test( + 'const searchValue = await this.page.$eval("#search", el => el.value);' + ), + errors: [{ messageId: 'noEval', line: 1, column: 54, endColumn: 69 }], + }, + { + code: test( + 'const searchValue = await page["$eval"]("#search", el => el.value);' + ), + errors: [{ messageId: 'noEval', line: 1, column: 54, endColumn: 67 }], + }, + { + code: test( + 'const searchValue = await page[`$eval`]("#search", el => el.value);' + ), + errors: [{ messageId: 'noEval', line: 1, column: 54, endColumn: 67 }], + }, + { + code: test('await page.$eval("#search", el => el.value);'), + errors: [{ messageId: 'noEval', line: 1, column: 34, endColumn: 44 }], + }, + { + code: test('await this.page.$eval("#search", el => el.value);'), + errors: [{ messageId: 'noEval', line: 1, column: 34, endColumn: 49 }], + }, + { + code: test('await page.$$eval("#search", el => el.value);'), + errors: [{ messageId: 'noEvalAll', line: 1, column: 34, endColumn: 45 }], + }, + { + code: test('await this.page.$$eval("#search", el => el.value);'), + errors: [{ messageId: 'noEvalAll', line: 1, column: 34, endColumn: 50 }], + }, + { + code: test('await page["$$eval"]("#search", el => el.value);'), + errors: [{ messageId: 'noEvalAll', line: 1, column: 34, endColumn: 48 }], + }, + { + code: test('await page[`$$eval`]("#search", el => el.value);'), + errors: [{ messageId: 'noEvalAll', line: 1, column: 34, endColumn: 48 }], + }, + { + code: test( + 'const html = await page.$eval(".main-container", (e, suffix) => e.outerHTML + suffix, "hello");' + ), + errors: [{ messageId: 'noEval', line: 1, column: 47, endColumn: 57 }], + }, + { + code: test( + 'const divCounts = await page.$$eval("div", (divs, min) => divs.length >= min, 10);' + ), + errors: [{ messageId: 'noEvalAll', line: 1, column: 52, endColumn: 63 }], + }, + ], valid: [ - valid('await page.locator(".tweet").evaluate(node => node.innerText)'), - valid('await this.page.locator(".tweet").evaluate(node => node.innerText)'), - valid('await page.locator(".tweet")["evaluate"](node => node.innerText)'), - valid('await page.locator(".tweet")[`evaluate`](node => node.innerText)'), - valid( + test('await page.locator(".tweet").evaluate(node => node.innerText)'), + test('await this.page.locator(".tweet").evaluate(node => node.innerText)'), + test('await page.locator(".tweet")["evaluate"](node => node.innerText)'), + test('await page.locator(".tweet")[`evaluate`](node => node.innerText)'), + test( 'await (await page.$(".tweet")).$eval(".like", node => node.innerText)' ), - valid( + test( 'await (await page.$(".tweet"))["$eval"](".like", node => node.innerText)' ), - valid( + test( 'await (await page.$(".tweet")).$$eval(".like", node => node.innerText)' ), - valid( + test( 'await (await page.$(".tweet"))[`$$eval`](".like", node => node.innerText)' ), - valid( + test( 'await page.locator("div").evaluateAll((divs, min) => divs.length >= min, 10);' ), - valid( + test( 'await this.page.locator("div").evaluateAll((divs, min) => divs.length >= min, 10);' ), ], - invalid: [ - invalid('const searchValue = await page.$eval("#search", el => el.value);'), - invalid( - 'const searchValue = await this.page.$eval("#search", el => el.value);' - ), - invalid( - 'const searchValue = await page["$eval"]("#search", el => el.value);' - ), - invalid( - 'const searchValue = await page[`$eval`]("#search", el => el.value);' - ), - invalid('await page.$eval("#search", el => el.value);'), - invalid('await this.page.$eval("#search", el => el.value);'), - invalid('await page.$$eval("#search", el => el.value);'), - invalid('await this.page.$$eval("#search", el => el.value);'), - invalid('await page["$$eval"]("#search", el => el.value);'), - invalid('await page[`$$eval`]("#search", el => el.value);'), - invalid( - 'const html = await page.$eval(".main-container", (e, suffix) => e.outerHTML + suffix, "hello");' - ), - invalid( - 'const divCounts = await page.$$eval("div", (divs, min) => divs.length >= min, 10);' - ), - ], }); From ed607bba9862c8eb31562a5e456f0bd7abeed3ab Mon Sep 17 00:00:00 2001 From: Mark Skelton Date: Sun, 15 Jan 2023 08:11:24 -0600 Subject: [PATCH 21/28] Cleanup --- test/spec/missing-playwright-await.spec.ts | 2 +- test/spec/no-element-handle.spec.ts | 8 ++++---- test/spec/no-force-option.spec.ts | 2 +- test/spec/no-page-pause.spec.ts | 2 +- test/utils/rule-tester.ts | 3 +-- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/test/spec/missing-playwright-await.spec.ts b/test/spec/missing-playwright-await.spec.ts index fa0180c..c8a45d0 100644 --- a/test/spec/missing-playwright-await.spec.ts +++ b/test/spec/missing-playwright-await.spec.ts @@ -1,4 +1,4 @@ -import { runRuleTester, wrapInTest as test } from '../utils/rule-tester'; +import { runRuleTester, test } from '../utils/rule-tester'; import rule from '../../src/rules/missing-playwright-await'; runRuleTester('missing-playwright-await', rule, { diff --git a/test/spec/no-element-handle.spec.ts b/test/spec/no-element-handle.spec.ts index 945017f..1b264d6 100644 --- a/test/spec/no-element-handle.spec.ts +++ b/test/spec/no-element-handle.spec.ts @@ -1,8 +1,8 @@ -import { runRuleTester, wrapInTest } from '../utils/rule-tester'; +import { runRuleTester, test } from '../utils/rule-tester'; import rule from '../../src/rules/no-element-handle'; const invalid = (code: string, output: string) => ({ - code: wrapInTest(code), + code: test(code), errors: [ { messageId: 'noElementHandle', @@ -11,14 +11,14 @@ const invalid = (code: string, output: string) => ({ messageId: code.includes('$$') ? 'replaceElementHandlesWithLocator' : 'replaceElementHandleWithLocator', - output: wrapInTest(output), + output: test(output), }, ], }, ], }); -const valid = wrapInTest; +const valid = test; runRuleTester('no-element-handle', rule, { invalid: [ diff --git a/test/spec/no-force-option.spec.ts b/test/spec/no-force-option.spec.ts index b412ca7..5f25613 100644 --- a/test/spec/no-force-option.spec.ts +++ b/test/spec/no-force-option.spec.ts @@ -1,4 +1,4 @@ -import { runRuleTester, wrapInTest as test } from '../utils/rule-tester'; +import { runRuleTester, test } from '../utils/rule-tester'; import rule from '../../src/rules/no-force-option'; const messageId = 'noForceOption'; diff --git a/test/spec/no-page-pause.spec.ts b/test/spec/no-page-pause.spec.ts index b824b38..521ea38 100644 --- a/test/spec/no-page-pause.spec.ts +++ b/test/spec/no-page-pause.spec.ts @@ -1,4 +1,4 @@ -import { runRuleTester, wrapInTest as test } from '../utils/rule-tester'; +import { runRuleTester, test } from '../utils/rule-tester'; import rule from '../../src/rules/no-page-pause'; const messageId = 'noPagePause'; diff --git a/test/utils/rule-tester.ts b/test/utils/rule-tester.ts index f4b9869..4fe9d25 100644 --- a/test/utils/rule-tester.ts +++ b/test/utils/rule-tester.ts @@ -19,5 +19,4 @@ export function runRuleTester(...args: Parameters) { return new RuleTester(config).run(...args); } -export const wrapInTest = (input: string) => - `test('test', async () => { ${input} })`; +export const test = (input: string) => `test('test', async () => { ${input} })`; From 252ec10fa78a2f3014af182f9b605c966a3dabd5 Mon Sep 17 00:00:00 2001 From: Mark Skelton Date: Sun, 15 Jan 2023 08:26:52 -0600 Subject: [PATCH 22/28] no-element-handle --- examples/index.js | 1 - src/rules/no-element-handle.ts | 2 +- test/spec/no-element-handle.spec.ts | 462 +++++++++++++++++++++------- 3 files changed, 354 insertions(+), 111 deletions(-) diff --git a/examples/index.js b/examples/index.js index 049e886..e69de29 100644 --- a/examples/index.js +++ b/examples/index.js @@ -1 +0,0 @@ -await this.page.pause(); diff --git a/src/rules/no-element-handle.ts b/src/rules/no-element-handle.ts index 0123c62..73bb2ac 100644 --- a/src/rules/no-element-handle.ts +++ b/src/rules/no-element-handle.ts @@ -43,7 +43,7 @@ export default { }, }, ], - node, + node: node.callee, }); } }, diff --git a/test/spec/no-element-handle.spec.ts b/test/spec/no-element-handle.spec.ts index 1b264d6..dd862ae 100644 --- a/test/spec/no-element-handle.spec.ts +++ b/test/spec/no-element-handle.spec.ts @@ -1,134 +1,378 @@ import { runRuleTester, test } from '../utils/rule-tester'; import rule from '../../src/rules/no-element-handle'; -const invalid = (code: string, output: string) => ({ - code: test(code), - errors: [ +runRuleTester('no-element-handle', rule, { + invalid: [ + // element handle as const { - messageId: 'noElementHandle', - suggestions: [ + code: test('const handle = await page.$("text=Submit");'), + errors: [ { - messageId: code.includes('$$') - ? 'replaceElementHandlesWithLocator' - : 'replaceElementHandleWithLocator', - output: test(output), + messageId: 'noElementHandle', + suggestions: [ + { + messageId: 'replaceElementHandleWithLocator', + output: test('const handle = page.locator("text=Submit");'), + }, + ], + line: 1, + column: 49, + endColumn: 55, + }, + ], + }, + { + code: test('const handle = await this.page.$("text=Submit");'), + errors: [ + { + messageId: 'noElementHandle', + suggestions: [ + { + messageId: 'replaceElementHandleWithLocator', + output: test('const handle = this.page.locator("text=Submit");'), + }, + ], + line: 1, + column: 49, + endColumn: 60, + }, + ], + }, + { + code: test('const handle = await page["$$"]("text=Submit");'), + errors: [ + { + messageId: 'noElementHandle', + suggestions: [ + { + messageId: 'replaceElementHandlesWithLocator', + output: test('const handle = page["locator"]("text=Submit");'), + }, + ], + line: 1, + column: 49, + endColumn: 59, + }, + ], + }, + { + code: test('const handle = await page[`$$`]("text=Submit");'), + errors: [ + { + messageId: 'noElementHandle', + suggestions: [ + { + messageId: 'replaceElementHandlesWithLocator', + output: test('const handle = page[`locator`]("text=Submit");'), + }, + ], + line: 1, + column: 49, + endColumn: 59, + }, + ], + }, + { + code: test('const handle = await this.page.$$("text=Submit");'), + errors: [ + { + messageId: 'noElementHandle', + suggestions: [ + { + messageId: 'replaceElementHandlesWithLocator', + output: test('const handle = this.page.locator("text=Submit");'), + }, + ], + line: 1, + column: 49, + endColumn: 61, }, ], }, - ], -}); - -const valid = test; - -runRuleTester('no-element-handle', rule, { - invalid: [ - // element handle as const - invalid( - 'const handle = await page.$("text=Submit");', - 'const handle = page.locator("text=Submit");' - ), - invalid( - 'const handle = await this.page.$("text=Submit");', - 'const handle = this.page.locator("text=Submit");' - ), - invalid( - 'const handle = await page["$$"]("text=Submit");', - 'const handle = page["locator"]("text=Submit");' - ), - invalid( - 'const handle = await page[`$$`]("text=Submit");', - 'const handle = page[`locator`]("text=Submit");' - ), - invalid( - 'const handle = await this.page.$$("text=Submit");', - 'const handle = this.page.locator("text=Submit");' - ), - // element handle as let - invalid( - 'let handle = await page.$("text=Submit");', - 'let handle = page.locator("text=Submit");' - ), - + { + code: test('let handle = await page.$("text=Submit");'), + errors: [ + { + messageId: 'noElementHandle', + suggestions: [ + { + messageId: 'replaceElementHandleWithLocator', + output: test('let handle = page.locator("text=Submit");'), + }, + ], + line: 1, + column: 47, + endColumn: 53, + }, + ], + }, // element handle as expression statement without await - invalid('page.$("div")', 'page.locator("div")'), - + { + code: test('page.$("div")'), + errors: [ + { + messageId: 'noElementHandle', + suggestions: [ + { + messageId: 'replaceElementHandleWithLocator', + output: test('page.locator("div")'), + }, + ], + line: 1, + column: 28, + endColumn: 34, + }, + ], + }, // element handles as expression statement without await - invalid('page.$$("div")', 'page.locator("div")'), - + { + code: test('page.$$("div")'), + errors: [ + { + messageId: 'noElementHandle', + suggestions: [ + { + messageId: 'replaceElementHandlesWithLocator', + output: test('page.locator("div")'), + }, + ], + line: 1, + column: 28, + endColumn: 35, + }, + ], + }, // element handle as expression statement - invalid('await page.$("div")', 'page.locator("div")'), - + { + code: test('await page.$("div")'), + errors: [ + { + messageId: 'noElementHandle', + suggestions: [ + { + messageId: 'replaceElementHandleWithLocator', + output: test('page.locator("div")'), + }, + ], + line: 1, + column: 34, + endColumn: 40, + }, + ], + }, // element handle click - invalid( - 'await (await page.$$("div")).click();', - 'await (page.locator("div")).click();' - ), - + { + code: test('await (await page.$$("div")).click();'), + errors: [ + { + messageId: 'noElementHandle', + suggestions: [ + { + messageId: 'replaceElementHandlesWithLocator', + output: test('await (page.locator("div")).click();'), + }, + ], + line: 1, + column: 41, + endColumn: 48, + }, + ], + }, // element handles as const - invalid( - 'const handles = await page.$$("a")', - 'const handles = page.locator("a")' - ), - invalid( - 'const handle = await page["$$"]("a");', - 'const handle = page["locator"]("a");' - ), - invalid( - 'const handle = await page[`$$`]("a");', - 'const handle = page[`locator`]("a");' - ), - + { + code: test('const handles = await page.$$("a")'), + errors: [ + { + messageId: 'noElementHandle', + suggestions: [ + { + messageId: 'replaceElementHandlesWithLocator', + output: test('const handles = page.locator("a")'), + }, + ], + line: 1, + column: 50, + endColumn: 57, + }, + ], + }, + { + code: test('const handle = await page["$$"]("a");'), + errors: [ + { + messageId: 'noElementHandle', + suggestions: [ + { + messageId: 'replaceElementHandlesWithLocator', + output: test('const handle = page["locator"]("a");'), + }, + ], + line: 1, + column: 49, + endColumn: 59, + }, + ], + }, + { + code: test('const handle = await page[`$$`]("a");'), + errors: [ + { + messageId: 'noElementHandle', + suggestions: [ + { + messageId: 'replaceElementHandlesWithLocator', + output: test('const handle = page[`locator`]("a");'), + }, + ], + line: 1, + column: 49, + endColumn: 59, + }, + ], + }, // element handles as let - invalid( - 'let handles = await page.$$("a")', - 'let handles = page.locator("a")' - ), - + { + code: test('let handles = await page.$$("a")'), + errors: [ + { + messageId: 'noElementHandle', + suggestions: [ + { + messageId: 'replaceElementHandlesWithLocator', + output: test('let handles = page.locator("a")'), + }, + ], + line: 1, + column: 48, + endColumn: 55, + }, + ], + }, // element handles as expression statement - invalid('await page.$$("a")', 'page.locator("a")'), - + { + code: test('await page.$$("a")'), + errors: [ + { + messageId: 'noElementHandle', + suggestions: [ + { + messageId: 'replaceElementHandlesWithLocator', + output: test('page.locator("a")'), + }, + ], + line: 1, + column: 34, + endColumn: 41, + }, + ], + }, // return element handle without awaiting it - invalid( - 'function getHandle() { return page.$("button"); }', - 'function getHandle() { return page.locator("button"); }' - ), - + { + code: test('function getHandle() { return page.$("button"); }'), + errors: [ + { + messageId: 'noElementHandle', + suggestions: [ + { + messageId: 'replaceElementHandleWithLocator', + output: test( + 'function getHandle() { return page.locator("button"); }' + ), + }, + ], + line: 1, + column: 58, + endColumn: 64, + }, + ], + }, // return element handles without awaiting it - invalid( - 'function getHandle() { return page.$$("button"); }', - 'function getHandle() { return page.locator("button"); }' - ), - + { + code: test('function getHandle() { return page.$$("button"); }'), + errors: [ + { + messageId: 'noElementHandle', + suggestions: [ + { + messageId: 'replaceElementHandlesWithLocator', + output: test( + 'function getHandle() { return page.locator("button"); }' + ), + }, + ], + line: 1, + column: 58, + endColumn: 65, + }, + ], + }, // missed return for the element handle - invalid( - 'function getHandle() { page.$("button"); }', - 'function getHandle() { page.locator("button"); }' - ), - + { + code: test('function getHandle() { page.$("button"); }'), + errors: [ + { + messageId: 'noElementHandle', + suggestions: [ + { + messageId: 'replaceElementHandleWithLocator', + output: test('function getHandle() { page.locator("button"); }'), + }, + ], + line: 1, + column: 51, + endColumn: 57, + }, + ], + }, // arrow function return element handle without awaiting it - invalid( - 'const getHandles = () => page.$("links");', - 'const getHandles = () => page.locator("links");' - ), - + { + code: test('const getHandles = () => page.$("links");'), + errors: [ + { + messageId: 'noElementHandle', + suggestions: [ + { + messageId: 'replaceElementHandleWithLocator', + output: test('const getHandles = () => page.locator("links");'), + }, + ], + line: 1, + column: 53, + endColumn: 59, + }, + ], + }, // arrow function return element handles without awaiting it - invalid( - 'const getHandles = () => page.$$("links");', - 'const getHandles = () => page.locator("links");' - ), + { + code: test('const getHandles = () => page.$$("links");'), + errors: [ + { + messageId: 'noElementHandle', + suggestions: [ + { + messageId: 'replaceElementHandlesWithLocator', + output: test('const getHandles = () => page.locator("links");'), + }, + ], + line: 1, + column: 53, + endColumn: 60, + }, + ], + }, ], valid: [ - valid('page.locator("a")'), - valid('this.page.locator("a")'), - valid('await page.locator("a").click();'), - valid('const $ = "text";'), - valid('$("a");'), - valid('this.$("a");'), - valid('this["$"]("a");'), - valid('this[`$`]("a");'), - valid('internalPage.$("a");'), - valid('this.page.$$$("div");'), - valid('page.$$$("div");'), + test('page.locator("a")'), + test('this.page.locator("a")'), + test('await page.locator("a").click();'), + test('const $ = "text";'), + test('$("a");'), + test('this.$("a");'), + test('this["$"]("a");'), + test('this[`$`]("a");'), + test('internalPage.$("a");'), + test('this.page.$$$("div");'), + test('page.$$$("div");'), ], }); From 47465703949ef5aebb93a7c36b1373c7d4a24783 Mon Sep 17 00:00:00 2001 From: Mark Skelton Date: Sun, 15 Jan 2023 08:31:20 -0600 Subject: [PATCH 23/28] Order --- test/spec/max-nested-describe.spec.ts | 174 ++++++++-------- test/spec/missing-playwright-await.spec.ts | 67 +++--- test/spec/no-conditional-in-test.spec.ts | 204 +++++++++---------- test/spec/no-element-handle.spec.ts | 26 +-- test/spec/no-eval.spec.ts | 48 ++--- test/spec/no-focused-test.spec.ts | 28 +-- test/spec/no-force-option.spec.ts | 40 ++-- test/spec/no-page-pause.spec.ts | 14 +- test/spec/no-skipped-test.spec.ts | 32 +-- test/spec/no-useless-not.spec.ts | 50 ++--- test/spec/no-wait-for-timeout.spec.ts | 16 +- test/spec/require-top-level-describe.spec.ts | 5 - test/utils/rule-tester.ts | 2 +- 13 files changed, 341 insertions(+), 365 deletions(-) diff --git a/test/spec/max-nested-describe.spec.ts b/test/spec/max-nested-describe.spec.ts index f5e517e..34680b1 100644 --- a/test/spec/max-nested-describe.spec.ts +++ b/test/spec/max-nested-describe.spec.ts @@ -4,6 +4,93 @@ import rule from '../../src/rules/max-nested-describe'; const messageId = 'exceededMaxDepth'; runRuleTester('max-nested-describe', rule, { + valid: [ + 'test.describe("describe tests", () => {});', + 'test.describe.only("describe focus tests", () => {});', + 'test.describe.serial.only("describe serial focus tests", () => {});', + 'test.describe.serial.skip("describe serial focus tests", () => {});', + 'test.describe.parallel.fixme("describe serial focus tests", () => {});', + { + code: ` + test('foo', function () { + expect(true).toBe(true); + }); + test('bar', () => { + expect(true).toBe(true); + }); + `, + options: [{ max: 0 }], + }, + { + code: ` + test.describe('foo', function() { + test.describe('bar', function () { + test.describe('baz', function () { + test.describe('qux', function () { + test.describe('quxx', function () { + test('should get something', () => { + expect(getSomething()).toBe('Something'); + }); + }); + }); + }); + }); + }); + `, + }, + { + code: ` + test.describe('foo', () => { + test.describe('bar', () => { + test.describe('baz', () => { + test.describe('qux', () => { + test('foo', () => { + expect(someCall().property).toBe(true); + }); + test('bar', () => { + expect(universe.answer).toBe(42); + }); + }); + test.describe('quxx', () => { + test('baz', () => { + expect(2 + 2).toEqual(4); + }); + }); + }); + }); + }); + `, + options: [{ max: 4 }], + }, + { + code: ` + test.describe('foo', () => { + test.describe.only('bar', () => { + test.describe.skip('baz', () => { + test('something', async () => { + expect('something').toBe('something'); + }); + }); + }); + }); + `, + options: [{ max: 3 }], + }, + { + code: ` + describe('foo', () => { + describe.only('bar', () => { + describe.skip('baz', () => { + test('something', async () => { + expect('something').toBe('something'); + }); + }); + }); + }); + `, + options: [{ max: 3 }], + }, + ], invalid: [ { code: ` @@ -143,91 +230,4 @@ runRuleTester('max-nested-describe', rule, { options: [{ max: 2 }], }, ], - valid: [ - 'test.describe("describe tests", () => {});', - 'test.describe.only("describe focus tests", () => {});', - 'test.describe.serial.only("describe serial focus tests", () => {});', - 'test.describe.serial.skip("describe serial focus tests", () => {});', - 'test.describe.parallel.fixme("describe serial focus tests", () => {});', - { - code: ` - test('foo', function () { - expect(true).toBe(true); - }); - test('bar', () => { - expect(true).toBe(true); - }); - `, - options: [{ max: 0 }], - }, - { - code: ` - test.describe('foo', function() { - test.describe('bar', function () { - test.describe('baz', function () { - test.describe('qux', function () { - test.describe('quxx', function () { - test('should get something', () => { - expect(getSomething()).toBe('Something'); - }); - }); - }); - }); - }); - }); - `, - }, - { - code: ` - test.describe('foo', () => { - test.describe('bar', () => { - test.describe('baz', () => { - test.describe('qux', () => { - test('foo', () => { - expect(someCall().property).toBe(true); - }); - test('bar', () => { - expect(universe.answer).toBe(42); - }); - }); - test.describe('quxx', () => { - test('baz', () => { - expect(2 + 2).toEqual(4); - }); - }); - }); - }); - }); - `, - options: [{ max: 4 }], - }, - { - code: ` - test.describe('foo', () => { - test.describe.only('bar', () => { - test.describe.skip('baz', () => { - test('something', async () => { - expect('something').toBe('something'); - }); - }); - }); - }); - `, - options: [{ max: 3 }], - }, - { - code: ` - describe('foo', () => { - describe.only('bar', () => { - describe.skip('baz', () => { - test('something', async () => { - expect('something').toBe('something'); - }); - }); - }); - }); - `, - options: [{ max: 3 }], - }, - ], }); diff --git a/test/spec/missing-playwright-await.spec.ts b/test/spec/missing-playwright-await.spec.ts index c8a45d0..abdd95f 100644 --- a/test/spec/missing-playwright-await.spec.ts +++ b/test/spec/missing-playwright-await.spec.ts @@ -2,6 +2,37 @@ import { runRuleTester, test } from '../utils/rule-tester'; import rule from '../../src/rules/missing-playwright-await'; runRuleTester('missing-playwright-await', rule, { + valid: [ + { code: test('await expect(page).toBeEditable') }, + { code: test('await expect(page).toEqualTitle("text")') }, + { code: test('await expect(page).not.toHaveText("text")') }, + // Doesn't require an await when returning + { code: test('return expect(page).toHaveText("text")') }, + { + code: test('const a = () => expect(page).toHaveText("text")'), + options: [{ customMatchers: ['toBeCustomThing'] }], + }, + // Custom matchers + { + code: test('await expect(page).toBeCustomThing(true)'), + options: [{ customMatchers: ['toBeCustomThing'] }], + }, + { code: test('await expect(page).toBeCustomThing(true)') }, + { code: test('expect(page).toBeCustomThing(true)') }, + { + code: test('await expect(page).toBeAsync(true)'), + options: [{ customMatchers: ['toBeAsync'] }], + }, + // expect.soft + { code: test('await expect.soft(page).toHaveText("text")') }, + { code: test('await expect.soft(page).not.toHaveText("text")') }, + // expect.poll + { code: test('await expect.poll(() => foo).toBe("text")') }, + { code: test('await expect["poll"](() => foo).toContain("text")') }, + { code: test('await expect[`poll`](() => foo).toBeTruthy()') }, + // test.step + { code: test("await test.step('foo', async () => {})") }, + ], invalid: [ { code: test('expect(page).toBeChecked()'), @@ -166,40 +197,4 @@ runRuleTester('missing-playwright-await', rule, { ], }, ], - valid: [ - { code: test('await expect(page).toBeEditable') }, - { code: test('await expect(page).toEqualTitle("text")') }, - { code: test('await expect(page).not.toHaveText("text")') }, - - // Doesn't require an await when returning - { code: test('return expect(page).toHaveText("text")') }, - { - code: test('const a = () => expect(page).toHaveText("text")'), - options: [{ customMatchers: ['toBeCustomThing'] }], - }, - - // Custom matchers - { - code: test('await expect(page).toBeCustomThing(true)'), - options: [{ customMatchers: ['toBeCustomThing'] }], - }, - { code: test('await expect(page).toBeCustomThing(true)') }, - { code: test('expect(page).toBeCustomThing(true)') }, - { - code: test('await expect(page).toBeAsync(true)'), - options: [{ customMatchers: ['toBeAsync'] }], - }, - - // expect.soft - { code: test('await expect.soft(page).toHaveText("text")') }, - { code: test('await expect.soft(page).not.toHaveText("text")') }, - - // expect.poll - { code: test('await expect.poll(() => foo).toBe("text")') }, - { code: test('await expect["poll"](() => foo).toContain("text")') }, - { code: test('await expect[`poll`](() => foo).toBeTruthy()') }, - - // test.step - { code: test("await test.step('foo', async () => {})") }, - ], }); diff --git a/test/spec/no-conditional-in-test.spec.ts b/test/spec/no-conditional-in-test.spec.ts index aedc29a..9774a30 100644 --- a/test/spec/no-conditional-in-test.spec.ts +++ b/test/spec/no-conditional-in-test.spec.ts @@ -5,6 +5,108 @@ import dedent = require('dedent'); const messageId = 'conditionalInTest'; runRuleTester('no-conditional-in-test', rule, { + valid: [ + 'test("foo", () => { expect(1).toBe(1); });', + 'test.fixme("some broken test", () => { expect(1).toBe(1); });', + 'test.describe("foo", () => { if(true) { test("bar", () => { expect(true).toBe(true); }); } });', + 'test.skip(process.env.APP_VERSION === "v1", "There are no settings in v1");', + 'test("some slow test", () => { test.slow(); })', + 'const foo = bar ? foo : baz;', + `test.describe('foo', () => { + test.afterEach(() => { + if ('bar') {} + }); + })`, + `test.describe('foo', () => { + test.beforeEach(() => { + if ('bar') {} + }); + })`, + `test.describe('foo', function () { + test.beforeEach(function () { + if ('bar') {} + }); + })`, + `test.describe.parallel('foo', function () { + test.beforeEach(function () { + if ('bar') {} + }); + })`, + `test.describe.parallel.only('foo', function () { + test.beforeEach(function () { + if ('bar') {} + }); + })`, + `test.describe.serial('foo', function () { + test.beforeEach(function () { + if ('bar') {} + }); + })`, + `test.describe.serial.only('foo', function () { + test.beforeEach(function () { + if ('bar') {} + }); + })`, + `const values = something.map((thing) => { + if (thing.isFoo) { + return thing.foo + } else { + return thing.bar; + } + }); + + test.describe('valid', () => { + test('still valid', () => { + expect(values).toStrictEqual(['foo']); + }); + });`, + `describe('valid', () => { + const values = something.map((thing) => { + if (thing.isFoo) { + return thing.foo + } else { + return thing.bar; + } + }); + + test.describe('still valid', () => { + test('really still valid', () => { + expect(values).toStrictEqual(['foo']); + }); + }); + });`, + // Conditionals are only disallowed at the root level. Nested conditionals + // are common and valid. + `test('nested', async ({ page }) => { + const [request] = await Promise.all([ + page.waitForRequest(request => request.url() === 'foo' && request.method() === 'GET'), + page.click('button'), + ]); + })`, + `test('nested', async ({ page }) => { + await page.waitForRequest(request => request.url() === 'foo' && request.method() === 'GET') + })`, + `test.fixme('nested', async ({ page }) => { + await page.waitForRequest(request => request.url() === 'foo' && request.method() === 'GET') + })`, + `test.only('nested', async ({ page }) => { + await page.waitForRequest(request => request.url() === 'foo' && request.method() === 'GET') + })`, + `test('nested', () => { + test.skip(true && false) + })`, + `test('nested', () => { + test.skip( + ({ baseURL }) => (baseURL || "").includes("localhost"), + "message", + ) + })`, + `test('test', async ({ page }) => { + await test.step('step', async () => { + await page.waitForRequest(request => request.url() === 'foo' && request.method() === 'GET') + }); + })`, + ], invalid: [ { code: 'test("foo", () => { if (true) { expect(1).toBe(1); } });', @@ -183,106 +285,4 @@ runRuleTester('no-conditional-in-test', rule, { errors: [{ messageId, line: 3, column: 5, endLine: 3, endColumn: 17 }], }, ], - valid: [ - 'test("foo", () => { expect(1).toBe(1); });', - 'test.fixme("some broken test", () => { expect(1).toBe(1); });', - 'test.describe("foo", () => { if(true) { test("bar", () => { expect(true).toBe(true); }); } });', - 'test.skip(process.env.APP_VERSION === "v1", "There are no settings in v1");', - 'test("some slow test", () => { test.slow(); })', - 'const foo = bar ? foo : baz;', - `test.describe('foo', () => { - test.afterEach(() => { - if ('bar') {} - }); - })`, - `test.describe('foo', () => { - test.beforeEach(() => { - if ('bar') {} - }); - })`, - `test.describe('foo', function () { - test.beforeEach(function () { - if ('bar') {} - }); - })`, - `test.describe.parallel('foo', function () { - test.beforeEach(function () { - if ('bar') {} - }); - })`, - `test.describe.parallel.only('foo', function () { - test.beforeEach(function () { - if ('bar') {} - }); - })`, - `test.describe.serial('foo', function () { - test.beforeEach(function () { - if ('bar') {} - }); - })`, - `test.describe.serial.only('foo', function () { - test.beforeEach(function () { - if ('bar') {} - }); - })`, - `const values = something.map((thing) => { - if (thing.isFoo) { - return thing.foo - } else { - return thing.bar; - } - }); - - test.describe('valid', () => { - test('still valid', () => { - expect(values).toStrictEqual(['foo']); - }); - });`, - `describe('valid', () => { - const values = something.map((thing) => { - if (thing.isFoo) { - return thing.foo - } else { - return thing.bar; - } - }); - - test.describe('still valid', () => { - test('really still valid', () => { - expect(values).toStrictEqual(['foo']); - }); - }); - });`, - // Conditionals are only disallowed at the root level. Nested conditionals - // are common and valid. - `test('nested', async ({ page }) => { - const [request] = await Promise.all([ - page.waitForRequest(request => request.url() === 'foo' && request.method() === 'GET'), - page.click('button'), - ]); - })`, - `test('nested', async ({ page }) => { - await page.waitForRequest(request => request.url() === 'foo' && request.method() === 'GET') - })`, - `test.fixme('nested', async ({ page }) => { - await page.waitForRequest(request => request.url() === 'foo' && request.method() === 'GET') - })`, - `test.only('nested', async ({ page }) => { - await page.waitForRequest(request => request.url() === 'foo' && request.method() === 'GET') - })`, - `test('nested', () => { - test.skip(true && false) - })`, - `test('nested', () => { - test.skip( - ({ baseURL }) => (baseURL || "").includes("localhost"), - "message", - ) - })`, - `test('test', async ({ page }) => { - await test.step('step', async () => { - await page.waitForRequest(request => request.url() === 'foo' && request.method() === 'GET') - }); - })`, - ], }); diff --git a/test/spec/no-element-handle.spec.ts b/test/spec/no-element-handle.spec.ts index dd862ae..16b32e3 100644 --- a/test/spec/no-element-handle.spec.ts +++ b/test/spec/no-element-handle.spec.ts @@ -2,6 +2,19 @@ import { runRuleTester, test } from '../utils/rule-tester'; import rule from '../../src/rules/no-element-handle'; runRuleTester('no-element-handle', rule, { + valid: [ + test('page.locator("a")'), + test('this.page.locator("a")'), + test('await page.locator("a").click();'), + test('const $ = "text";'), + test('$("a");'), + test('this.$("a");'), + test('this["$"]("a");'), + test('this[`$`]("a");'), + test('internalPage.$("a");'), + test('this.page.$$$("div");'), + test('page.$$$("div");'), + ], invalid: [ // element handle as const { @@ -362,17 +375,4 @@ runRuleTester('no-element-handle', rule, { ], }, ], - valid: [ - test('page.locator("a")'), - test('this.page.locator("a")'), - test('await page.locator("a").click();'), - test('const $ = "text";'), - test('$("a");'), - test('this.$("a");'), - test('this["$"]("a");'), - test('this[`$`]("a");'), - test('internalPage.$("a");'), - test('this.page.$$$("div");'), - test('page.$$$("div");'), - ], }); diff --git a/test/spec/no-eval.spec.ts b/test/spec/no-eval.spec.ts index 847a8db..79b3339 100644 --- a/test/spec/no-eval.spec.ts +++ b/test/spec/no-eval.spec.ts @@ -2,6 +2,30 @@ import { runRuleTester, test } from '../utils/rule-tester'; import rule from '../../src/rules/no-eval'; runRuleTester('no-eval', rule, { + valid: [ + test('await page.locator(".tweet").evaluate(node => node.innerText)'), + test('await this.page.locator(".tweet").evaluate(node => node.innerText)'), + test('await page.locator(".tweet")["evaluate"](node => node.innerText)'), + test('await page.locator(".tweet")[`evaluate`](node => node.innerText)'), + test( + 'await (await page.$(".tweet")).$eval(".like", node => node.innerText)' + ), + test( + 'await (await page.$(".tweet"))["$eval"](".like", node => node.innerText)' + ), + test( + 'await (await page.$(".tweet")).$$eval(".like", node => node.innerText)' + ), + test( + 'await (await page.$(".tweet"))[`$$eval`](".like", node => node.innerText)' + ), + test( + 'await page.locator("div").evaluateAll((divs, min) => divs.length >= min, 10);' + ), + test( + 'await this.page.locator("div").evaluateAll((divs, min) => divs.length >= min, 10);' + ), + ], invalid: [ { code: test( @@ -64,28 +88,4 @@ runRuleTester('no-eval', rule, { errors: [{ messageId: 'noEvalAll', line: 1, column: 52, endColumn: 63 }], }, ], - valid: [ - test('await page.locator(".tweet").evaluate(node => node.innerText)'), - test('await this.page.locator(".tweet").evaluate(node => node.innerText)'), - test('await page.locator(".tweet")["evaluate"](node => node.innerText)'), - test('await page.locator(".tweet")[`evaluate`](node => node.innerText)'), - test( - 'await (await page.$(".tweet")).$eval(".like", node => node.innerText)' - ), - test( - 'await (await page.$(".tweet"))["$eval"](".like", node => node.innerText)' - ), - test( - 'await (await page.$(".tweet")).$$eval(".like", node => node.innerText)' - ), - test( - 'await (await page.$(".tweet"))[`$$eval`](".like", node => node.innerText)' - ), - test( - 'await page.locator("div").evaluateAll((divs, min) => divs.length >= min, 10);' - ), - test( - 'await this.page.locator("div").evaluateAll((divs, min) => divs.length >= min, 10);' - ), - ], }); diff --git a/test/spec/no-focused-test.spec.ts b/test/spec/no-focused-test.spec.ts index 5610c9f..f0bf7cc 100644 --- a/test/spec/no-focused-test.spec.ts +++ b/test/spec/no-focused-test.spec.ts @@ -4,6 +4,20 @@ import rule from '../../src/rules/no-focused-test'; const messageId = 'noFocusedTest'; runRuleTester('no-focused-test', rule, { + valid: [ + 'test.describe("describe tests", () => {});', + 'test.describe.skip("describe tests", () => {});', + 'test("one", async ({code: page }) => {});', + 'test.fixme(isMobile, "Settings page does not work in mobile yet");', + 'test["fixme"](isMobile, "Settings page does not work in mobile yet");', + 'test[`fixme`](isMobile, "Settings page does not work in mobile yet");', + 'test.slow();', + 'test["slow"]();', + 'test[`slow`]();', + 'const only = true;', + 'function only() {code: return null };', + 'this.only();', + ], invalid: [ { code: 'test.describe.only("skip this describe", () => {});', @@ -142,18 +156,4 @@ runRuleTester('no-focused-test', rule, { ], }, ], - valid: [ - 'test.describe("describe tests", () => {});', - 'test.describe.skip("describe tests", () => {});', - 'test("one", async ({code: page }) => {});', - 'test.fixme(isMobile, "Settings page does not work in mobile yet");', - 'test["fixme"](isMobile, "Settings page does not work in mobile yet");', - 'test[`fixme`](isMobile, "Settings page does not work in mobile yet");', - 'test.slow();', - 'test["slow"]();', - 'test[`slow`]();', - 'const only = true;', - 'function only() {code: return null };', - 'this.only();', - ], }); diff --git a/test/spec/no-force-option.spec.ts b/test/spec/no-force-option.spec.ts index 5f25613..b15909c 100644 --- a/test/spec/no-force-option.spec.ts +++ b/test/spec/no-force-option.spec.ts @@ -4,6 +4,26 @@ import rule from '../../src/rules/no-force-option'; const messageId = 'noForceOption'; runRuleTester('no-force-option', rule, { + valid: [ + test("await page.locator('check').check()"), + test("await page.locator('check').uncheck()"), + test("await page.locator('button').click()"), + test("await page.locator('button').locator('btn').click()"), + test( + "await page.locator('button').click({ delay: 500, noWaitAfter: true })" + ), + test("await page.locator('button').dblclick()"), + test("await page.locator('input').dragTo()"), + test("await page.locator('input').fill('something', { timeout: 1000 })"), + test("await page.locator('elm').hover()"), + test("await page.locator('select').selectOption({ label: 'Blue' })"), + test("await page.locator('select').selectText()"), + test("await page.locator('checkbox').setChecked(true)"), + test("await page.locator('button').tap()"), + test('doSomething({ force: true })'), + test('await doSomething({ ["force"]: true })'), + test('await doSomething({ [`force`]: true })'), + ], invalid: [ { code: test('await page.locator("check").check({ force: true })'), @@ -79,24 +99,4 @@ runRuleTester('no-force-option', rule, { errors: [{ messageId, line: 1, column: 63, endColumn: 74 }], }, ], - valid: [ - test("await page.locator('check').check()"), - test("await page.locator('check').uncheck()"), - test("await page.locator('button').click()"), - test("await page.locator('button').locator('btn').click()"), - test( - "await page.locator('button').click({ delay: 500, noWaitAfter: true })" - ), - test("await page.locator('button').dblclick()"), - test("await page.locator('input').dragTo()"), - test("await page.locator('input').fill('something', { timeout: 1000 })"), - test("await page.locator('elm').hover()"), - test("await page.locator('select').selectOption({ label: 'Blue' })"), - test("await page.locator('select').selectText()"), - test("await page.locator('checkbox').setChecked(true)"), - test("await page.locator('button').tap()"), - test('doSomething({ force: true })'), - test('await doSomething({ ["force"]: true })'), - test('await doSomething({ [`force`]: true })'), - ], }); diff --git a/test/spec/no-page-pause.spec.ts b/test/spec/no-page-pause.spec.ts index 521ea38..d0928b5 100644 --- a/test/spec/no-page-pause.spec.ts +++ b/test/spec/no-page-pause.spec.ts @@ -4,6 +4,13 @@ import rule from '../../src/rules/no-page-pause'; const messageId = 'noPagePause'; runRuleTester('no-page-pause', rule, { + valid: [ + test('await page.click()'), + test('await this.page.click()'), + test('await page["hover"]()'), + test('await page[`check`]()'), + test('await expect(page).toBePaused()'), + ], invalid: [ { code: test('await page.pause()'), @@ -22,11 +29,4 @@ runRuleTester('no-page-pause', rule, { errors: [{ messageId, line: 1, column: 34, endColumn: 49 }], }, ], - valid: [ - test('await page.click()'), - test('await this.page.click()'), - test('await page["hover"]()'), - test('await page[`check`]()'), - test('await expect(page).toBePaused()'), - ], }); diff --git a/test/spec/no-skipped-test.spec.ts b/test/spec/no-skipped-test.spec.ts index 21083fa..7a560fd 100644 --- a/test/spec/no-skipped-test.spec.ts +++ b/test/spec/no-skipped-test.spec.ts @@ -4,6 +4,22 @@ import rule from '../../src/rules/no-skipped-test'; const messageId = 'removeSkippedTestAnnotation'; runRuleTester('no-skipped-test', rule, { + valid: [ + 'test.describe("describe tests", () => {});', + 'test.describe.only("describe focus tests", () => {});', + 'test.describ["only"]("describe focus tests", () => {});', + 'test.describ[`only`]("describe focus tests", () => {});', + 'test("one", async ({ page }) => {});', + 'test.only(isMobile, "Settings page does not work in mobile yet");', + 'test.slow();', + 'test["slow"]();', + 'test[`slow`]();', + 'const skip = true;', + 'function skip() { return null };', + 'this.skip();', + 'this["skip"]();', + 'this[`skip`]();', + ], invalid: [ { code: 'test.skip("skip this test", async ({ page }) => {});', @@ -186,20 +202,4 @@ runRuleTester('no-skipped-test', rule, { ], }, ], - valid: [ - 'test.describe("describe tests", () => {});', - 'test.describe.only("describe focus tests", () => {});', - 'test.describ["only"]("describe focus tests", () => {});', - 'test.describ[`only`]("describe focus tests", () => {});', - 'test("one", async ({ page }) => {});', - 'test.only(isMobile, "Settings page does not work in mobile yet");', - 'test.slow();', - 'test["slow"]();', - 'test[`slow`]();', - 'const skip = true;', - 'function skip() { return null };', - 'this.skip();', - 'this["skip"]();', - 'this[`skip`]();', - ], }); diff --git a/test/spec/no-useless-not.spec.ts b/test/spec/no-useless-not.spec.ts index ff682e0..3f15ef4 100644 --- a/test/spec/no-useless-not.spec.ts +++ b/test/spec/no-useless-not.spec.ts @@ -1,21 +1,25 @@ import { runRuleTester } from '../utils/rule-tester'; import rule from '../../src/rules/no-useless-not'; -const invalid = (oldMatcher: string, newMatcher: string) => ({ - code: `expect(locator).not.${oldMatcher}()`, - output: `expect(locator).${newMatcher}()`, - errors: [ - { - messageId: 'noUselessNot', - data: { old: oldMatcher, new: newMatcher }, - line: 1, - column: 17, - endColumn: 21 + oldMatcher.length, - }, - ], -}); - runRuleTester('no-useless-not', rule, { + valid: [ + 'expect(locator).toBeVisible()', + 'expect(locator).toBeHidden()', + 'expect(locator).toBeEnabled()', + 'expect(locator).toBeDisabled()', + 'expect.soft(locator).toBeEnabled()', + 'expect.poll(() => locator).toBeDisabled()', + 'expect(locator)[`toBeEnabled`]()', + 'expect(locator)["toBeDisabled"]()', + // Incomplete call expression + 'expect(locator).toBeVisible', + 'expect(locator).toBeEnabled', + // Doesn't impact non-complimentary matchers + "expect(locator).not.toHaveText('foo')", + 'expect(locator).not.toBeChecked()', + 'expect(locator).not.toBeChecked({ checked: false })', + 'expect(locator).not.toBeFocused()', + ], invalid: [ { code: 'expect(locator).not.toBeVisible()', @@ -131,22 +135,4 @@ runRuleTester('no-useless-not', rule, { ], }, ], - valid: [ - 'expect(locator).toBeVisible()', - 'expect(locator).toBeHidden()', - 'expect(locator).toBeEnabled()', - 'expect(locator).toBeDisabled()', - 'expect.soft(locator).toBeEnabled()', - 'expect.poll(() => locator).toBeDisabled()', - 'expect(locator)[`toBeEnabled`]()', - 'expect(locator)["toBeDisabled"]()', - // Incomplete call expression - 'expect(locator).toBeVisible', - 'expect(locator).toBeEnabled', - // Doesn't impact non-complimentary matchers - "expect(locator).not.toHaveText('foo')", - 'expect(locator).not.toBeChecked()', - 'expect(locator).not.toBeChecked({ checked: false })', - 'expect(locator).not.toBeFocused()', - ], }); diff --git a/test/spec/no-wait-for-timeout.spec.ts b/test/spec/no-wait-for-timeout.spec.ts index 1439ba9..98cca1b 100644 --- a/test/spec/no-wait-for-timeout.spec.ts +++ b/test/spec/no-wait-for-timeout.spec.ts @@ -4,6 +4,14 @@ import rule from '../../src/rules/no-wait-for-timeout'; const messageId = 'noWaitForTimeout'; runRuleTester('no-wait-for-timeout', rule, { + valid: [ + 'function waitForTimeout() {}', + 'async function fn() { await waitForTimeout(4343); }', + 'async function fn() { await this.foo.waitForTimeout(4343); }', + '(async function() { await page.waitForSelector("#foo"); })();', + 'page.waitForSelector("#foo");', + 'page["waitForSelector"]("#foo");', + ], invalid: [ { code: 'async function fn() { await page.waitForTimeout(1000) }', @@ -163,12 +171,4 @@ runRuleTester('no-wait-for-timeout', rule, { ], }, ], - valid: [ - 'function waitForTimeout() {}', - 'async function fn() { await waitForTimeout(4343); }', - 'async function fn() { await this.foo.waitForTimeout(4343); }', - '(async function() { await page.waitForSelector("#foo"); })();', - 'page.waitForSelector("#foo");', - 'page["waitForSelector"]("#foo");', - ], }); diff --git a/test/spec/require-top-level-describe.spec.ts b/test/spec/require-top-level-describe.spec.ts index 61ba1ac..2bf6b69 100644 --- a/test/spec/require-top-level-describe.spec.ts +++ b/test/spec/require-top-level-describe.spec.ts @@ -2,11 +2,6 @@ import rule from '../../src/rules/require-top-level-describe'; import * as dedent from 'dedent'; import { runRuleTester } from '../utils/rule-tester'; -const invalid = (code: string, messageId: string) => ({ - code, - errors: [{ messageId }], -}); - runRuleTester('require-top-level-describe', rule, { valid: [ 'foo()', diff --git a/test/utils/rule-tester.ts b/test/utils/rule-tester.ts index 4fe9d25..82c4f32 100644 --- a/test/utils/rule-tester.ts +++ b/test/utils/rule-tester.ts @@ -5,8 +5,8 @@ import { RuleTester } from 'eslint'; * import rule from '../../src/rules/missing-playwright-await'; * * runRuleTester('missing-playwright-await', rule, { - * valid: ['await expect(page.locator('checkbox')).toBeChecked()'], * invalid: ['expect(page.locator('checkbox')).toBeChecked()'], + * valid: ['await expect(page.locator('checkbox')).toBeChecked()'], * }); */ export function runRuleTester(...args: Parameters) { From e32e4a0d50e57c6ba3bdb1d8cfadea8bd5199c62 Mon Sep 17 00:00:00 2001 From: Mark Skelton Date: Sun, 15 Jan 2023 09:19:06 -0600 Subject: [PATCH 24/28] Use dedent --- test/spec/max-nested-describe.spec.ts | 41 ++++++++++++++------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/test/spec/max-nested-describe.spec.ts b/test/spec/max-nested-describe.spec.ts index 34680b1..56d99bb 100644 --- a/test/spec/max-nested-describe.spec.ts +++ b/test/spec/max-nested-describe.spec.ts @@ -1,5 +1,6 @@ import { runRuleTester } from '../utils/rule-tester'; import rule from '../../src/rules/max-nested-describe'; +import dedent = require('dedent'); const messageId = 'exceededMaxDepth'; @@ -11,7 +12,7 @@ runRuleTester('max-nested-describe', rule, { 'test.describe.serial.skip("describe serial focus tests", () => {});', 'test.describe.parallel.fixme("describe serial focus tests", () => {});', { - code: ` + code: dedent` test('foo', function () { expect(true).toBe(true); }); @@ -22,7 +23,7 @@ runRuleTester('max-nested-describe', rule, { options: [{ max: 0 }], }, { - code: ` + code: dedent` test.describe('foo', function() { test.describe('bar', function () { test.describe('baz', function () { @@ -39,7 +40,7 @@ runRuleTester('max-nested-describe', rule, { `, }, { - code: ` + code: dedent` test.describe('foo', () => { test.describe('bar', () => { test.describe('baz', () => { @@ -63,7 +64,7 @@ runRuleTester('max-nested-describe', rule, { options: [{ max: 4 }], }, { - code: ` + code: dedent` test.describe('foo', () => { test.describe.only('bar', () => { test.describe.skip('baz', () => { @@ -77,7 +78,7 @@ runRuleTester('max-nested-describe', rule, { options: [{ max: 3 }], }, { - code: ` + code: dedent` describe('foo', () => { describe.only('bar', () => { describe.skip('baz', () => { @@ -93,7 +94,7 @@ runRuleTester('max-nested-describe', rule, { ], invalid: [ { - code: ` + code: dedent` test.describe('foo', function() { test.describe('bar', function () { test.describe('baz', function () { @@ -110,10 +111,10 @@ runRuleTester('max-nested-describe', rule, { }); }); `, - errors: [{ messageId, line: 7, column: 19, endLine: 7, endColumn: 32 }], + errors: [{ messageId, line: 6, column: 11, endLine: 6, endColumn: 24 }], }, { - code: ` + code: dedent` describe('foo', function() { describe('bar', function () { describe('baz', function () { @@ -130,10 +131,10 @@ runRuleTester('max-nested-describe', rule, { }); }); `, - errors: [{ messageId, line: 7, column: 19, endLine: 7, endColumn: 27 }], + errors: [{ messageId, line: 6, column: 11, endLine: 6, endColumn: 19 }], }, { - code: ` + code: dedent` test.describe('foo', () => { test.describe('bar', () => { test["describe"]('baz', () => { @@ -164,12 +165,12 @@ runRuleTester('max-nested-describe', rule, { `, options: [{ max: 5 }], errors: [ - { messageId, line: 7, column: 19, endLine: 7, endColumn: 35 }, - { messageId, line: 13, column: 19, endLine: 13, endColumn: 32 }, + { messageId, line: 6, column: 11, endLine: 6, endColumn: 27 }, + { messageId, line: 12, column: 11, endLine: 12, endColumn: 24 }, ], }, { - code: ` + code: dedent` test.describe.only('foo', function() { test.describe('bar', function() { test.describe('baz', function() { @@ -182,10 +183,10 @@ runRuleTester('max-nested-describe', rule, { }); }); `, - errors: [{ messageId, line: 7, column: 19, endLine: 7, endColumn: 37 }], + errors: [{ messageId, line: 6, column: 11, endLine: 6, endColumn: 29 }], }, { - code: ` + code: dedent` test.describe.serial.only('foo', function() { test.describe('bar', function() { test.describe('baz', function() { @@ -198,21 +199,21 @@ runRuleTester('max-nested-describe', rule, { }); }); `, - errors: [{ messageId, line: 7, column: 19, endLine: 7, endColumn: 32 }], + errors: [{ messageId, line: 6, column: 11, endLine: 6, endColumn: 24 }], }, { - code: ` + code: dedent` test.describe('qux', () => { test('should get something', () => { expect(getSomething()).toBe('Something'); }); }); `, - errors: [{ messageId, line: 2, column: 9, endLine: 2, endColumn: 22 }], + errors: [{ messageId, line: 1, column: 1, endLine: 1, endColumn: 14 }], options: [{ max: 0 }], }, { - code: ` + code: dedent` test.describe('foo', () => { test.describe('bar', () => { test.describe('baz', () => { @@ -226,7 +227,7 @@ runRuleTester('max-nested-describe', rule, { }); }); `, - errors: [{ messageId, line: 4, column: 13, endLine: 4, endColumn: 26 }], + errors: [{ messageId, line: 3, column: 5, endLine: 3, endColumn: 18 }], options: [{ max: 2 }], }, ], From c851876e7fa7140049b7b4b675539b784e32a263 Mon Sep 17 00:00:00 2001 From: Mark Skelton Date: Sun, 15 Jan 2023 17:42:12 -0600 Subject: [PATCH 25/28] Update examples --- examples/.eslintrc | 2 +- examples/package.json | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/.eslintrc b/examples/.eslintrc index 38ea186..cf1fa8e 100644 --- a/examples/.eslintrc +++ b/examples/.eslintrc @@ -9,7 +9,7 @@ "playwright/prefer-to-be": "warn", "playwright/prefer-to-have-length": "warn", "playwright/prefer-strict-equal": "warn", - "playwright/require-top-level-describe": "warn", + "playwright/max-nested-describe": ["warn", { "max": 1 }], "playwright/no-restricted-matchers": [ "error", { diff --git a/examples/package.json b/examples/package.json index 2dfc42f..e6b03fe 100644 --- a/examples/package.json +++ b/examples/package.json @@ -1,6 +1,9 @@ { "name": "examples", "type": "module", + "scripts": { + "lint": "eslint ." + }, "dependencies": { "@playwright/test": "^1.29.2", "eslint": "^8.31.0", From 1385e7773368aa255ddd094b7496169c2b086da7 Mon Sep 17 00:00:00 2001 From: Mark Skelton Date: Mon, 16 Jan 2023 17:08:53 -0600 Subject: [PATCH 26/28] Docs --- README.md | 41 ++++++++++++++------------- docs/rules/require-soft-assertions.md | 26 +++++++++++++++++ src/index.ts | 2 ++ 3 files changed, 49 insertions(+), 20 deletions(-) create mode 100644 docs/rules/require-soft-assertions.md diff --git a/README.md b/README.md index 9320f57..cf0d47c 100644 --- a/README.md +++ b/README.md @@ -49,23 +49,24 @@ command line option.\ 💡: Some problems reported by this rule are manually fixable by editor [suggestions](https://eslint.org/docs/latest/developer-guide/working-with-rules#providing-suggestions). -| ✔ | 🔧 | 💡 | Rule | Description | -| :-: | :-: | :-: | ------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------- | -| ✔ | | | [max-nested-describe](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/max-nested-describe.md) | Enforces a maximum depth to nested describe calls | -| ✔ | 🔧 | | [missing-playwright-await](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/missing-playwright-await.md) | Enforce Playwright APIs to be awaited | -| ✔ | | | [no-conditional-in-test](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/no-conditional-in-test.md) | Disallow conditional logic in tests | -| ✔ | | 💡 | [no-element-handle](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/no-element-handle.md) | Disallow usage of element handles | -| ✔ | | | [no-eval](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/no-eval.md) | Disallow usage of `page.$eval` and `page.$$eval` | -| ✔ | | 💡 | [no-focused-test](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/no-focused-test.md) | Disallow usage of `.only` annotation | -| ✔ | | | [no-force-option](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/no-force-option.md) | Disallow usage of the `{ force: true }` option | -| ✔ | | | [no-page-pause](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/no-page-pause.md) | Disallow using `page.pause` | -| | | | [no-restricted-matchers](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/no-restricted-matchers.md) | Disallow specific matchers & modifiers | -| ✔ | | 💡 | [no-skipped-test](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/no-skipped-test.md) | Disallow usage of the `.skip` annotation | -| ✔ | 🔧 | | [no-useless-not](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/no-useless-not.md) | Disallow usage of `not` matchers when a specific matcher exists | -| ✔ | | 💡 | [no-wait-for-timeout](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/no-wait-for-timeout.md) | Disallow usage of `page.waitForTimeout` | -| | | 💡 | [prefer-strict-equal](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/prefer-strict-equal.md) | Suggest using `toStrictEqual()` | -| | 🔧 | | [prefer-lowercase-title](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/prefer-lowercase-title.md) | Enforce lowercase test names | -| | 🔧 | | [prefer-to-be](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/prefer-to-be.md) | Suggest using `toBe()` | -| | 🔧 | | [prefer-to-have-length](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/prefer-to-have-length.md) | Suggest using `toHaveLength()` | -| | | | [require-top-level-describe](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/require-top-level-describe.md) | Require test cases and hooks to be inside a `test.describe` block | -| ✔ | | | [valid-expect](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/valid-expect.md) | Enforce valid `expect()` usage | +| ✔ | 🔧 | 💡 | Rule | Description | +| :-: | :-: | :-: | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------- | +| ✔ | | | [max-nested-describe](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/max-nested-describe.md) | Enforces a maximum depth to nested describe calls | +| ✔ | 🔧 | | [missing-playwright-await](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/missing-playwright-await.md) | Enforce Playwright APIs to be awaited | +| ✔ | | | [no-conditional-in-test](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/no-conditional-in-test.md) | Disallow conditional logic in tests | +| ✔ | | 💡 | [no-element-handle](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/no-element-handle.md) | Disallow usage of element handles | +| ✔ | | | [no-eval](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/no-eval.md) | Disallow usage of `page.$eval` and `page.$$eval` | +| ✔ | | 💡 | [no-focused-test](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/no-focused-test.md) | Disallow usage of `.only` annotation | +| ✔ | | | [no-force-option](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/no-force-option.md) | Disallow usage of the `{ force: true }` option | +| ✔ | | | [no-page-pause](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/no-page-pause.md) | Disallow using `page.pause` | +| | | | [no-restricted-matchers](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/no-restricted-matchers.md) | Disallow specific matchers & modifiers | +| ✔ | | 💡 | [no-skipped-test](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/no-skipped-test.md) | Disallow usage of the `.skip` annotation | +| ✔ | 🔧 | | [no-useless-not](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/no-useless-not.md) | Disallow usage of `not` matchers when a specific matcher exists | +| ✔ | | 💡 | [no-wait-for-timeout](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/no-wait-for-timeout.md) | Disallow usage of `page.waitForTimeout` | +| | | 💡 | [prefer-strict-equal](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/prefer-strict-equal.md) | Suggest using `toStrictEqual()` | +| | 🔧 | | [prefer-lowercase-title](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/prefer-lowercase-title.md) | Enforce lowercase test names | +| | 🔧 | | [prefer-to-be](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/prefer-to-be.md) | Suggest using `toBe()` | +| | 🔧 | | [prefer-to-have-length](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/prefer-to-have-length.md) | Suggest using `toHaveLength()` | +| | | | [require-top-level-describe](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/require-top-level-describe.md) | Require test cases and hooks to be inside a `test.describe` block | +| | 🔧 | | [require-require-soft-assertions](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/require-require-soft-assertions.md) | Require assertions to use `expect.soft()` | +| ✔ | | | [valid-expect](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/valid-expect.md) | Enforce valid `expect()` usage | diff --git a/docs/rules/require-soft-assertions.md b/docs/rules/require-soft-assertions.md new file mode 100644 index 0000000..0e6bf9b --- /dev/null +++ b/docs/rules/require-soft-assertions.md @@ -0,0 +1,26 @@ +# Require soft assertions (`require-soft-assertions`) + +Some find it easier to write longer test that perform more assertions per test. +In cases like these, it can be helpful to require +[soft assertions](https://playwright.dev/docs/test-assertions#soft-assertions) +in your tests. + +This rule is not enabled by default and is only intended to be used it if fits +your workflow. If you aren't sure if you should use this rule, you probably +shouldn't 🙂. + +## Rule Details + +Examples of **incorrect** code for this rule: + +```javascript +expect(page.locator('foo')).toHaveText('bar'); +expect(page).toHaveTitle('baz'); +``` + +Examples of **correct** code for this rule: + +```javascript +expect.soft(page.locator('foo')).toHaveText('bar'); +expect.soft(page).toHaveTitle('baz'); +``` diff --git a/src/index.ts b/src/index.ts index bbff155..4c213a9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -14,6 +14,7 @@ import preferLowercaseTitle from './rules/prefer-lowercase-title'; import preferToBe from './rules/prefer-to-be'; import preferToHaveLength from './rules/prefer-to-have-length'; import preferStrictEqual from './rules/prefer-strict-equal'; +import requireSoftAssertions from './rules/require-soft-assertions'; import requireTopLevelDescribe from './rules/require-top-level-describe'; import validExpect from './rules/valid-expect'; @@ -91,6 +92,7 @@ export = { 'prefer-to-be': preferToBe, 'prefer-to-have-length': preferToHaveLength, 'require-top-level-describe': requireTopLevelDescribe, + 'require-soft-assertions': requireSoftAssertions, 'valid-expect': validExpect, }, }; From ba832ded87d5be032a0a6e1764b4964a63a70f5b Mon Sep 17 00:00:00 2001 From: Mark Skelton Date: Mon, 16 Jan 2023 17:22:56 -0600 Subject: [PATCH 27/28] Finish rule --- src/rules/require-soft-assertions.ts | 31 +++++++++++++++++++++ test/spec/require-soft-assertions.spec.ts | 33 +++++++++++++++++++++++ test/utils/rule-tester.ts | 3 ++- 3 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 src/rules/require-soft-assertions.ts create mode 100644 test/spec/require-soft-assertions.spec.ts diff --git a/src/rules/require-soft-assertions.ts b/src/rules/require-soft-assertions.ts new file mode 100644 index 0000000..017191d --- /dev/null +++ b/src/rules/require-soft-assertions.ts @@ -0,0 +1,31 @@ +import { Rule } from 'eslint'; +import { getExpectType } from '../utils/ast'; + +export default { + create(context) { + return { + CallExpression(node) { + if (getExpectType(node) === 'standalone') { + context.report({ + node: node.callee, + messageId: 'requireSoft', + fix: (fixer) => fixer.insertTextAfter(node.callee, '.soft'), + }); + } + }, + }; + }, + meta: { + docs: { + description: 'Require all assertions to use `expect.soft`', + recommended: false, + url: 'https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/require-soft-assertions.md', + }, + messages: { + requireSoft: 'Unexpected non-soft assertion', + }, + fixable: 'code', + type: 'suggestion', + schema: [], + }, +} as Rule.RuleModule; diff --git a/test/spec/require-soft-assertions.spec.ts b/test/spec/require-soft-assertions.spec.ts new file mode 100644 index 0000000..9b8bc6f --- /dev/null +++ b/test/spec/require-soft-assertions.spec.ts @@ -0,0 +1,33 @@ +import rule from '../../src/rules/require-soft-assertions'; +import { runRuleTester } from '../utils/rule-tester'; + +const messageId = 'requireSoft'; + +runRuleTester('require-top-level-describe', rule, { + valid: [ + 'expect.soft(page).toHaveTitle("baz")', + 'expect.soft(page.locator("foo")).toHaveText("bar")', + 'expect["soft"](foo).toBe("bar")', + 'expect[`soft`](bar).toHaveText("bar")', + 'expect.poll(() => foo).toBe("bar")', + 'expect["poll"](() => foo).toBe("bar")', + 'expect[`poll`](() => foo).toBe("bar")', + ], + invalid: [ + { + code: 'expect(page).toHaveTitle("baz")', + output: 'expect.soft(page).toHaveTitle("baz")', + errors: [{ messageId, line: 1, column: 1, endColumn: 7 }], + }, + { + code: 'expect(page.locator("foo")).toHaveText("bar")', + output: 'expect.soft(page.locator("foo")).toHaveText("bar")', + errors: [{ messageId, line: 1, column: 1, endColumn: 7 }], + }, + { + code: 'await expect(page.locator("foo")).toHaveText("bar")', + output: 'await expect.soft(page.locator("foo")).toHaveText("bar")', + errors: [{ messageId, line: 1, column: 7, endColumn: 13 }], + }, + ], +}); diff --git a/test/utils/rule-tester.ts b/test/utils/rule-tester.ts index 82c4f32..00007e7 100644 --- a/test/utils/rule-tester.ts +++ b/test/utils/rule-tester.ts @@ -12,7 +12,8 @@ import { RuleTester } from 'eslint'; export function runRuleTester(...args: Parameters) { const config = { parserOptions: { - ecmaVersion: 2018, + ecmaVersion: 2022, + sourceType: 'module', }, }; From 5b9614c32d83258de1bc7630b59645a7d12e70e9 Mon Sep 17 00:00:00 2001 From: Mark Skelton Date: Mon, 16 Jan 2023 17:28:05 -0600 Subject: [PATCH 28/28] Update docs --- docs/rules/require-soft-assertions.md | 8 ++++---- test/spec/require-soft-assertions.spec.ts | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/rules/require-soft-assertions.md b/docs/rules/require-soft-assertions.md index 0e6bf9b..adb12e9 100644 --- a/docs/rules/require-soft-assertions.md +++ b/docs/rules/require-soft-assertions.md @@ -14,13 +14,13 @@ shouldn't 🙂. Examples of **incorrect** code for this rule: ```javascript -expect(page.locator('foo')).toHaveText('bar'); -expect(page).toHaveTitle('baz'); +await expect(page.locator('foo')).toHaveText('bar'); +await expect(page).toHaveTitle('baz'); ``` Examples of **correct** code for this rule: ```javascript -expect.soft(page.locator('foo')).toHaveText('bar'); -expect.soft(page).toHaveTitle('baz'); +await expect.soft(page.locator('foo')).toHaveText('bar'); +await expect.soft(page).toHaveTitle('baz'); ``` diff --git a/test/spec/require-soft-assertions.spec.ts b/test/spec/require-soft-assertions.spec.ts index 9b8bc6f..9bea161 100644 --- a/test/spec/require-soft-assertions.spec.ts +++ b/test/spec/require-soft-assertions.spec.ts @@ -3,7 +3,7 @@ import { runRuleTester } from '../utils/rule-tester'; const messageId = 'requireSoft'; -runRuleTester('require-top-level-describe', rule, { +runRuleTester('require-soft-assertions', rule, { valid: [ 'expect.soft(page).toHaveTitle("baz")', 'expect.soft(page.locator("foo")).toHaveText("bar")',