Skip to content

Commit

Permalink
chore: lint with eslint v9
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Sep 25, 2024
1 parent a8c4564 commit 7c9d8f9
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 27 deletions.
3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

7 changes: 0 additions & 7 deletions .eslintrc

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ const handler = (req, res) => {
}

// listener: { url, getURL, server, close, ... }
const listener = await listen(handler, options?)
const listener = await listen(handler, options)
```

## Options
Expand Down
13 changes: 13 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import unjs from "eslint-config-unjs";

// https://github.com/unjs/eslint-config
export default unjs({
ignores: [
"src/lib"
],
rules: {
"unicorn/consistent-destructuring": 0,
"@typescript-eslint/no-non-null-assertion": 0,
"unicorn/no-anonymous-default-export": 0,
},
});
4 changes: 3 additions & 1 deletion src/server/_resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ export async function createResolver() {
const tryResolve = (id: string) => {
try {
return resolve(id);
} catch {}
} catch {
// Ignore errors
}
};

return {
Expand Down
4 changes: 3 additions & 1 deletion src/server/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,9 @@ function normalizeErrorStack(error: Error) {
.map((l) => l.replace(cwd, "."))
.filter((l) => !InternalStackRe.test(l))
.join("\n");
} catch {}
} catch {
// Ignore errors
}
return error;
}

Expand Down
2 changes: 1 addition & 1 deletion src/server/watcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export async function listenAndWatch(
options: Partial<ListenOptions & WatchOptions>,
): Promise<Listener> {
const logger = options.logger || consola.withTag("listhen");
let watcher: AsyncSubscription; // eslint-disable-line prefer-const
let watcher: AsyncSubscription;

// Create dev server
const devServer = await createDevServer(entry, {
Expand Down
1 change: 0 additions & 1 deletion test/cert.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { resolve } from "pathe";
import { Listener } from "../src";
import { TLSCertOptions, _private } from "../src/_cert";

// eslint-disable-next-line no-console
// console.log = fn()

function assertDefaultAttributes(attrs: forge.pki.CertificateField[]) {
Expand Down
15 changes: 4 additions & 11 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import type { IncomingMessage, ServerResponse } from "node:http";
import { describe, afterEach, test, expect } from "vitest";
import { listen, Listener } from "../src";

// eslint-disable-next-line no-console
// console.log = fn()

function handle(request: IncomingMessage, response: ServerResponse) {
Expand Down Expand Up @@ -43,7 +42,7 @@ describe("listhen", () => {
});
expect(listener.url.startsWith("http://")).toBe(true);
expect(listener.url.endsWith("/foo/bar")).toBe(true);
// eslint-disable-next-line no-console

// expect(console.log).toHaveBeenCalledWith(expect.stringMatching('\n > Local: http://localhost:3000/foo/bar'))
});

Expand All @@ -56,9 +55,8 @@ describe("listhen", () => {
test("listen (https - custom)", async () => {
listener = await listen(handle, {
https: {
// eslint-disable-next-line unicorn/prefer-module
key: resolve(__dirname, ".tmp/certs", "key.pem"),
// eslint-disable-next-line unicorn/prefer-module

cert: resolve(__dirname, ".tmp/certs", "cert.pem"),
},
hostname: "localhost",
Expand All @@ -69,9 +67,8 @@ describe("listhen", () => {
test("listen (https - custom - with private key passphrase)", async () => {
listener = await listen(handle, {
https: {
// eslint-disable-next-line unicorn/prefer-module
key: resolve(__dirname, ".tmp/certs", "encrypted-key.pem"),
// eslint-disable-next-line unicorn/prefer-module

cert: resolve(__dirname, ".tmp/certs", "cert.pem"),
passphrase: "cert-pw",
},
Expand All @@ -87,9 +84,8 @@ describe("listhen", () => {
expect(() =>
listen(handle, {
https: {
// eslint-disable-next-line unicorn/prefer-module
key: resolve(__dirname, ".tmp/certs", "encrypted-key.pem"),
// eslint-disable-next-line unicorn/prefer-module

cert: resolve(__dirname, ".tmp/certs", "cert.pem"),
passphrase: "wrong-pw",
},
Expand All @@ -102,7 +98,6 @@ describe("listhen", () => {
test("listen (https - PCKS#12/pfx/p12 - with store passphrase)", async () => {
const listener = await listen(handle, {
https: {
// eslint-disable-next-line unicorn/prefer-module
pfx: resolve(__dirname, ".tmp/certs/keystore.p12"),
passphrase: "store-pw",
},
Expand All @@ -115,7 +110,6 @@ describe("listhen", () => {
expect(() =>
listen(handle, {
https: {
// eslint-disable-next-line unicorn/prefer-module
pfx: resolve(__dirname, ".tmp/certs/keystore.p12"),
},
hostname: "localhost",
Expand All @@ -129,7 +123,6 @@ describe("listhen", () => {
expect(() =>
listen(handle, {
https: {
// eslint-disable-next-line unicorn/prefer-module
pfx: resolve(__dirname, ".tmp/certs/keystore.p12"),
passphrase: "wrong-pw",
},
Expand Down
1 change: 0 additions & 1 deletion test/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { _private } from "../src/_cert";

export async function setup() {
if (!existsSync(resolve("test/.tmp/certs/cert.pem"))) {
// eslint-disable-next-line unicorn/prefer-top-level-await
const start = Date.now();
console.log("Generating certificates...");
await generateCert();
Expand Down

0 comments on commit 7c9d8f9

Please sign in to comment.