From 51b056564d55838335e5221ce051545ea4e61785 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Tue, 16 Jul 2024 20:25:42 +0200 Subject: [PATCH] chore: lint with eslint v9 --- .eslintignore | 1 - .eslintrc | 9 --------- eslint.config.mjs | 10 ++++++++++ test/encoding.test.ts | 4 ++-- test/parse.test.ts | 4 ++-- test/url.test.ts | 2 +- test/utilities.test.ts | 6 +++--- 7 files changed, 18 insertions(+), 18 deletions(-) delete mode 100644 .eslintignore delete mode 100644 .eslintrc create mode 100644 eslint.config.mjs diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 1521c8b7..00000000 --- a/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -dist diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index c471a771..00000000 --- a/.eslintrc +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": [ - "eslint-config-unjs" - ], - "rules": { - "unicorn/prevent-abbreviations": 0, - "unicorn/no-abusive-eslint-disable": 0 - } -} diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 00000000..e4bbbd41 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,10 @@ +import unjs from "eslint-config-unjs"; + +// https://github.com/unjs/eslint-config +export default unjs({ + ignores: [], + rules: { + "unicorn/prevent-abbreviations": 0, + "unicorn/no-abusive-eslint-disable": 0 +}, +}); \ No newline at end of file diff --git a/test/encoding.test.ts b/test/encoding.test.ts index 60b86796..c110b233 100644 --- a/test/encoding.test.ts +++ b/test/encoding.test.ts @@ -94,7 +94,7 @@ describe("encodeQueryValue", () => { out: "apple,banana,cherry", }, { - input: "!@#$%^&*()_+{}[]|\\:;<>,./?", + input: String.raw`!@#$%^&*()_+{}[]|\:;<>,./?`, out: "!@%23$%25^%26*()_%2B%7B%7D%5B%5D|%5C:;%3C%3E,.%2F?", }, ]; @@ -149,7 +149,7 @@ describe("encodeParam", () => { { input: "1+2=3", out: "1%2B2=3" }, { input: "áéíóú", out: "%C3%A1%C3%A9%C3%AD%C3%B3%C3%BA" }, { - input: "!@#$%^&*()_-+=[]{}\\|;:'\",.<>/?", + input: String.raw`!@#$%^&*()_-+=[]{}\|;:'",.<>/?`, out: "!@%23$%25%5E%26*()_-%2B=%5B%5D%7B%7D%5C|;:'%22,.%3C%3E%2F%3F", }, { input: 123, out: "123" }, diff --git a/test/parse.test.ts b/test/parse.test.ts index c6e85653..e3566710 100644 --- a/test/parse.test.ts +++ b/test/parse.test.ts @@ -71,7 +71,7 @@ describe("parseURL", () => { }, }, { - input: "https://host.name\\@foo.bar/meme3.php?url=http://0.0.0.0/2.svg", + input: String.raw`https://host.name\@foo.bar/meme3.php?url=http://0.0.0.0/2.svg`, out: { auth: "", hash: "", @@ -178,7 +178,7 @@ describe("parseURL", () => { for (const t of tests) { test(t.input.toString(), () => { - expect(JSON.parse(JSON.stringify(parseURL(t.input)))).toEqual(t.out); + expect(structuredClone(parseURL(t.input))).toEqual(t.out); }); } }); diff --git a/test/url.test.ts b/test/url.test.ts index a30714c0..9cf1ce81 100644 --- a/test/url.test.ts +++ b/test/url.test.ts @@ -70,7 +70,7 @@ describe("$URL", () => { for (const t of tests) { test(t.input + " throw", () => { - expect(() => new $URL(t.input as any)).toThrow(TypeError(t.out)); + expect(() => new $URL(t.input as any)).toThrow(new TypeError(t.out)); }); } }); diff --git a/test/utilities.test.ts b/test/utilities.test.ts index d288f6dc..c7fd0571 100644 --- a/test/utilities.test.ts +++ b/test/utilities.test.ts @@ -28,7 +28,7 @@ describe("hasProtocol", () => { { input: "https://", out: [true, true, true] }, { input: "https://test.com", out: [true, true, true] }, { input: "file:///home/user", out: [true, true, true] }, - { input: "https:\\/foo.com", out: [true, true, true] }, + { input: String.raw`https:\/foo.com`, out: [true, true, true] }, // Has protocol (non strict) { input: "tel:", out: [true, false, true] }, @@ -43,8 +43,8 @@ describe("hasProtocol", () => { { input: "//test.com", out: [false, false, true] }, { input: "///test.com", out: [false, false, true] }, { input: "/\t//test.com", out: [false, false, true] }, - { input: "/\\/test.com", out: [false, false, true] }, - { input: "/\\localhost//", out: [false, false, true] }, + { input: String.raw`/\/test.com`, out: [false, false, true] }, + { input: String.raw`/\localhost//`, out: [false, false, true] }, ]; for (const t of tests) {