generated from nhcarrigan/template
feat: add rules for playwright (!3)
Reviewed-on: https://codeberg.org/nhcarrigan/eslint-config/pulls/3 Co-authored-by: Naomi Carrigan <commits@nhcarrigan.com> Co-committed-by: Naomi Carrigan <commits@nhcarrigan.com>
This commit is contained in:
parent
883274a3e4
commit
96935e12b4
@ -40,6 +40,7 @@
|
||||
"eslint-plugin-deprecation": "3.0.0",
|
||||
"eslint-plugin-import": "2.29.1",
|
||||
"eslint-plugin-jsdoc": "48.8.3",
|
||||
"eslint-plugin-playwright": "1.6.2",
|
||||
"eslint-plugin-prettier": "5.2.1",
|
||||
"eslint-plugin-sort-keys-fix": "1.1.2",
|
||||
"eslint-plugin-unicorn": "55.0.0",
|
||||
|
32
pnpm-lock.yaml
generated
32
pnpm-lock.yaml
generated
@ -44,6 +44,9 @@ importers:
|
||||
eslint-plugin-jsdoc:
|
||||
specifier: 48.8.3
|
||||
version: 48.8.3(eslint@9.7.0)
|
||||
eslint-plugin-playwright:
|
||||
specifier: 1.6.2
|
||||
version: 1.6.2(eslint@9.7.0)
|
||||
eslint-plugin-prettier:
|
||||
specifier: 5.2.1
|
||||
version: 5.2.1(@types/eslint@9.6.0)(eslint-config-prettier@9.1.0(eslint@9.7.0))(eslint@9.7.0)(prettier@3.3.3)
|
||||
@ -871,6 +874,16 @@ packages:
|
||||
peerDependencies:
|
||||
eslint: ^7.0.0 || ^8.0.0 || ^9.0.0
|
||||
|
||||
eslint-plugin-playwright@1.6.2:
|
||||
resolution: {integrity: sha512-mraN4Em3b5jLt01q7qWPyLg0Q5v3KAWfJSlEWwldyUXoa7DSPrBR4k6B6LROLqipsG8ndkwWMdjl1Ffdh15tag==}
|
||||
engines: {node: '>=16.6.0'}
|
||||
peerDependencies:
|
||||
eslint: '>=8.40.0'
|
||||
eslint-plugin-jest: '>=25'
|
||||
peerDependenciesMeta:
|
||||
eslint-plugin-jest:
|
||||
optional: true
|
||||
|
||||
eslint-plugin-prettier@5.2.1:
|
||||
resolution: {integrity: sha512-gH3iR3g4JfF+yYPaJYkN7jEl9QbweL/YfkoRlNnuIEHEz1vHVlCmWOS+eGGiRuzHQXdJFCOTxRgvju9b8VUmrw==}
|
||||
engines: {node: ^14.18.0 || >=16.0.0}
|
||||
@ -1029,6 +1042,10 @@ packages:
|
||||
resolution: {integrity: sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==}
|
||||
engines: {node: '>=10.13.0'}
|
||||
|
||||
globals@13.24.0:
|
||||
resolution: {integrity: sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==}
|
||||
engines: {node: '>=8'}
|
||||
|
||||
globals@14.0.0:
|
||||
resolution: {integrity: sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==}
|
||||
engines: {node: '>=18'}
|
||||
@ -1641,6 +1658,10 @@ packages:
|
||||
resolution: {integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==}
|
||||
engines: {node: '>= 0.8.0'}
|
||||
|
||||
type-fest@0.20.2:
|
||||
resolution: {integrity: sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==}
|
||||
engines: {node: '>=10'}
|
||||
|
||||
type-fest@0.6.0:
|
||||
resolution: {integrity: sha512-q+MB8nYR1KDLrgr4G5yemftpMC7/QLqVndBmEEdqzmNj5dcFOO4Oo8qlwZE3ULT3+Zim1F8Kq4cBnikNhlCMlg==}
|
||||
engines: {node: '>=8'}
|
||||
@ -2591,6 +2612,11 @@ snapshots:
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
eslint-plugin-playwright@1.6.2(eslint@9.7.0):
|
||||
dependencies:
|
||||
eslint: 9.7.0
|
||||
globals: 13.24.0
|
||||
|
||||
eslint-plugin-prettier@5.2.1(@types/eslint@9.6.0)(eslint-config-prettier@9.1.0(eslint@9.7.0))(eslint@9.7.0)(prettier@3.3.3):
|
||||
dependencies:
|
||||
eslint: 9.7.0
|
||||
@ -2805,6 +2831,10 @@ snapshots:
|
||||
dependencies:
|
||||
is-glob: 4.0.3
|
||||
|
||||
globals@13.24.0:
|
||||
dependencies:
|
||||
type-fest: 0.20.2
|
||||
|
||||
globals@14.0.0: {}
|
||||
|
||||
globals@15.8.0: {}
|
||||
@ -3374,6 +3404,8 @@ snapshots:
|
||||
dependencies:
|
||||
prelude-ls: 1.2.1
|
||||
|
||||
type-fest@0.20.2: {}
|
||||
|
||||
type-fest@0.6.0: {}
|
||||
|
||||
type-fest@0.8.1: {}
|
||||
|
@ -12,6 +12,7 @@ import vitest from "@vitest/eslint-plugin";
|
||||
import deprecation from "eslint-plugin-deprecation";
|
||||
import importPlugin from "eslint-plugin-import";
|
||||
import jsdoc from "eslint-plugin-jsdoc";
|
||||
import playwright from "eslint-plugin-playwright";
|
||||
import sortKeysFix from "eslint-plugin-sort-keys-fix";
|
||||
import unicorn from "eslint-plugin-unicorn";
|
||||
import globals from "globals";
|
||||
@ -19,6 +20,7 @@ import { deprecationRules } from "./rules/deprecation.js";
|
||||
import { disabledEslintRules, eslintRules } from "./rules/eslint.js";
|
||||
import { importRules } from "./rules/import.js";
|
||||
import { jsdocRules } from "./rules/jsdoc.js";
|
||||
import { playwrightRules } from "./rules/playwright.js";
|
||||
import { sortKeysFixRules } from "./rules/sortKeysFix.js";
|
||||
import { stylisticRules } from "./rules/stylistic.js";
|
||||
import { typescriptEslintRules, typescriptEslintRulesWithTypes }
|
||||
@ -49,6 +51,8 @@ const config: Array<Linter.Config> = [
|
||||
"deprecation": fixupPluginRules(deprecation),
|
||||
"import": fixupPluginRules(importPlugin as ESLint.Plugin),
|
||||
"jsdoc": jsdoc,
|
||||
// @ts-expect-error I'm not sure what's going on here, to be honest.
|
||||
"playwright": fixupPluginRules(playwright),
|
||||
"sort-keys-fix": sortKeysFix as ESLint.Plugin,
|
||||
// @ts-expect-error They haven't typedef this yet because it technically doesn't support eslint9
|
||||
"stylistic": fixupPluginRules(stylistic),
|
||||
@ -67,6 +71,7 @@ const config: Array<Linter.Config> = [
|
||||
...unicornRules,
|
||||
...sortKeysFixRules,
|
||||
...vitestRules,
|
||||
...playwrightRules,
|
||||
},
|
||||
},
|
||||
{
|
||||
|
53
src/rules/playwright.ts
Normal file
53
src/rules/playwright.ts
Normal file
@ -0,0 +1,53 @@
|
||||
/**
|
||||
* @copyright nhcarrigan
|
||||
* @license Naomi's Public License
|
||||
* @author Naomi Carrigan
|
||||
*/
|
||||
|
||||
import type { Linter } from "eslint";
|
||||
|
||||
export const playwrightRules: Linter.RulesRecord = {
|
||||
"playwright/expect-expect": "warn",
|
||||
"playwright/max-nested-describe": [ "warn", { max: 2 } ],
|
||||
"playwright/missing-playwright-await": "warn",
|
||||
"playwright/no-commented-out-tests": "warn",
|
||||
"playwright/no-conditional-expect": "warn",
|
||||
"playwright/no-conditional-in-test": "warn",
|
||||
"playwright/no-duplicate-hooks": "warn",
|
||||
"playwright/no-element-handle": "warn",
|
||||
"playwright/no-eval": "warn",
|
||||
"playwright/no-focused-test": "warn",
|
||||
"playwright/no-force-option": "warn",
|
||||
"playwright/no-get-by-title": "warn",
|
||||
"playwright/no-nested-step": "warn",
|
||||
"playwright/no-networkidle": "warn",
|
||||
"playwright/no-nth-methods": "warn",
|
||||
"playwright/no-page-pause": "warn",
|
||||
"playwright/no-raw-locators": "warn",
|
||||
"playwright/no-skipped-test": "warn",
|
||||
"playwright/no-standalone-expect": "warn",
|
||||
"playwright/no-unsafe-references": "warn",
|
||||
"playwright/no-useless-await": "warn",
|
||||
"playwright/no-useless-not": "warn",
|
||||
"playwright/no-wait-for-selector": "warn",
|
||||
"playwright/no-wait-for-timeout": "warn",
|
||||
"playwright/prefer-comparison-matcher": "warn",
|
||||
"playwright/prefer-equality-matcher": "warn",
|
||||
"playwright/prefer-hooks-in-order": "warn",
|
||||
"playwright/prefer-hooks-on-top": "warn",
|
||||
"playwright/prefer-lowercase-title": "warn",
|
||||
"playwright/prefer-strict-equal": "warn",
|
||||
"playwright/prefer-to-be": "warn",
|
||||
"playwright/prefer-to-contain": "warn",
|
||||
"playwright/prefer-to-have-count": "warn",
|
||||
"playwright/prefer-to-have-length": "warn",
|
||||
"playwright/prefer-web-first-assertions": "warn",
|
||||
"playwright/require-hook": "warn",
|
||||
"playwright/require-to-throw-message": "warn",
|
||||
"playwright/require-top-level-describe": "warn",
|
||||
"playwright/valid-describe-callback": "warn",
|
||||
"playwright/valid-expect":
|
||||
[ "warn", { maxArgs: 2, minArgs: 2 } ],
|
||||
"playwright/valid-expect-in-promise": "warn",
|
||||
"playwright/valid-title": "warn",
|
||||
};
|
@ -8,6 +8,7 @@ import { describe, expect, it } from "vitest";
|
||||
import { eslintRules } from "../src/rules/eslint.ts";
|
||||
import { importRules } from "../src/rules/import.js";
|
||||
import { jsdocRules } from "../src/rules/jsdoc.js";
|
||||
import { playwrightRules } from "../src/rules/playwright.ts";
|
||||
import { stylisticRules } from "../src/rules/stylistic.ts";
|
||||
import { typescriptEslintRules } from "../src/rules/typescriptEslint.js";
|
||||
import { unicornRules } from "../src/rules/unicorn.js";
|
||||
@ -44,6 +45,16 @@ describe("no rules should be turned off in", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("playwright rules", () => {
|
||||
expect.assertions(42);
|
||||
const rules = Object.entries(playwrightRules);
|
||||
for (const [ name, rule ] of rules) {
|
||||
expect(Array.isArray(rule)
|
||||
? rule.at(0)
|
||||
: rule, `${name} appears to be turned off - this project does not use any external configs, so all rules should be off by default.`).not.toBe("off");
|
||||
}
|
||||
});
|
||||
|
||||
it("stylistic rules", () => {
|
||||
expect.assertions(65);
|
||||
const rules = Object.entries(stylisticRules);
|
||||
|
21
test/playwright.spec.ts
Normal file
21
test/playwright.spec.ts
Normal file
@ -0,0 +1,21 @@
|
||||
/**
|
||||
* @copyright nhcarrigan
|
||||
* @license Naomi's Public License
|
||||
* @author Naomi Carrigan
|
||||
*/
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { playwrightRules } from "../src/rules/playwright.ts";
|
||||
|
||||
describe("playwright configs", () => {
|
||||
it("should never be an error", () => {
|
||||
expect.assertions(42);
|
||||
const rules = Object.entries(playwrightRules);
|
||||
for (const [ name, rule ] of rules) {
|
||||
expect(Array.isArray(rule)
|
||||
? rule.at(0)
|
||||
: rule, `${name} appears to be set to an error!`).not.toBe("error");
|
||||
continue;
|
||||
}
|
||||
});
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user