Skip to content

Commit

Permalink
upd: Updated to ESLint 9.
Browse files Browse the repository at this point in the history
  • Loading branch information
Byloth committed Oct 11, 2024
1 parent 81415a8 commit 74f23ef
Show file tree
Hide file tree
Showing 24 changed files with 403 additions and 470 deletions.
7 changes: 0 additions & 7 deletions .eslintrc.cjs

This file was deleted.

16 changes: 16 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import path from "node:path";
import { fileURLToPath } from "node:url";

import eslintTs from "@byloth/eslint-config-typescript";
import { includeIgnoreFile } from "@eslint/compat";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const gitignorePath = path.resolve(__dirname, ".gitignore");

export default [includeIgnoreFile(gitignorePath), ...eslintTs, {
rules: {
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/unified-signatures": "off"
}
}];
13 changes: 5 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,17 @@
"build": "vite build",
"preview": "vite preview",
"typecheck": "tsc",
"lint": "eslint --ext .cjs,.js,.json,.ts --ignore-path .gitignore .",
"lint": "eslint .",
"test": "vitest",
"prepare": "husky",
"ci": "pnpm install --frozen-lockfile"
},
"devDependencies": {
"@byloth/eslint-config-typescript": "^2.8.3",
"@types/node": "^20.16.5",
"@typescript-eslint/eslint-plugin": "^7.18.0",
"@typescript-eslint/parser": "^7.18.0",
"eslint": "^8.57.1",
"@byloth/eslint-config-typescript": "^3.0.0",
"@types/node": "^20.16.11",
"husky": "^9.1.6",
"typescript": "^5.6.2",
"vite": "^5.4.7"
"typescript": "^5.6.3",
"vite": "^5.4.8"
},
"packageManager": "pnpm@9.3.0+sha512.ee7b93e0c2bd11409c6424f92b866f31d3ea1bef5fbe47d3c7500cdc3c9668833d2e55681ad66df5b640c61fa9dc25d546efa54d76d7f8bf54b13614ac293631"
}
704 changes: 312 additions & 392 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions src/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */

// @ts-ignore
export const isBrowser = ((typeof window !== "undefined") && (typeof window.document !== "undefined"));

// @ts-ignore
export const isNode = ((typeof process !== "undefined") && (process.versions?.node));

// @ts-ignore
export const isWebWorker = ((typeof self === "object") && (self.constructor?.name === "DedicatedWorkerGlobalScope"));
8 changes: 4 additions & 4 deletions src/models/aggregators/aggregated-async-iterator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,11 @@ export default class AggregatedAsyncIterator<K extends PropertyKey, T>
});
}

public async find(predicate: MaybeAsyncKeyedIteratee<K, T, boolean>): Promise<ReducedIterator<K, T | void>>;
public async find(predicate: MaybeAsyncKeyedIteratee<K, T, boolean>): Promise<ReducedIterator<K, T | undefined>>;
public async find<S extends T>(predicate: MaybeAsyncKeyedTypeGuardIteratee<K, T, S>)
: Promise<ReducedIterator<K, S | void>>;
: Promise<ReducedIterator<K, S | undefined>>;

public async find(predicate: MaybeAsyncKeyedIteratee<K, T, boolean>): Promise<ReducedIterator<K, T | void>>
public async find(predicate: MaybeAsyncKeyedIteratee<K, T, boolean>): Promise<ReducedIterator<K, T | undefined>>
{
const values = new Map<K, [number, T | undefined]>();

Expand Down Expand Up @@ -347,5 +347,5 @@ export default class AggregatedAsyncIterator<K extends PropertyKey, T>
return groups;
}

public get [Symbol.toStringTag]() { return "AggregatedAsyncIterator"; }
public readonly [Symbol.toStringTag]: string = "AggregatedAsyncIterator";
}
8 changes: 4 additions & 4 deletions src/models/aggregators/aggregated-iterator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,9 @@ export default class AggregatedIterator<K extends PropertyKey, T>
});
}

public find(predicate: KeyedIteratee<K, T, boolean>): ReducedIterator<K, T | void>;
public find<S extends T>(predicate: KeyedTypeGuardIteratee<K, T, S>): ReducedIterator<K, S | void>;
public find(predicate: KeyedIteratee<K, T, boolean>): ReducedIterator<K, T | void>
public find(predicate: KeyedIteratee<K, T, boolean>): ReducedIterator<K, T | undefined>;
public find<S extends T>(predicate: KeyedTypeGuardIteratee<K, T, S>): ReducedIterator<K, S | undefined>;
public find(predicate: KeyedIteratee<K, T, boolean>): ReducedIterator<K, T | undefined>
{
const values = new Map<K, [number, T | undefined]>();

Expand Down Expand Up @@ -337,5 +337,5 @@ export default class AggregatedIterator<K extends PropertyKey, T>
return groups;
}

public get [Symbol.toStringTag]() { return "AggregatedIterator"; }
public readonly [Symbol.toStringTag]: string = "AggregatedIterator";
}
2 changes: 1 addition & 1 deletion src/models/aggregators/reduced-iterator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,5 +209,5 @@ export default class ReducedIterator<K extends PropertyKey, T>
return Object.fromEntries(this.items()) as Record<K, T>;
}

public get [Symbol.toStringTag]() { return "ReducedIterator"; }
public readonly [Symbol.toStringTag]: string = "ReducedIterator";
}
6 changes: 3 additions & 3 deletions src/models/exceptions/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default class Exception extends Error
}
}

public get [Symbol.toStringTag]() { return "Exception"; }
public readonly [Symbol.toStringTag]: string = "Exception";
}

export class FatalErrorException extends Exception
Expand All @@ -55,7 +55,7 @@ export class FatalErrorException extends Exception
super(message, cause, name);
}

public get [Symbol.toStringTag]() { return "FatalErrorException"; }
public readonly [Symbol.toStringTag]: string = "FatalErrorException";
}
export class NotImplementedException extends FatalErrorException
{
Expand All @@ -69,5 +69,5 @@ export class NotImplementedException extends FatalErrorException
super(message, cause, name);
}

public get [Symbol.toStringTag]() { return "NotImplementedException"; }
public readonly [Symbol.toStringTag]: string = "NotImplementedException";
}
26 changes: 13 additions & 13 deletions src/models/exceptions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export class FileException extends Exception
super(message, cause, name);
}

public get [Symbol.toStringTag]() { return "FileException"; }
public readonly [Symbol.toStringTag]: string = "FileException";
}
export class FileExistsException extends FileException
{
Expand All @@ -16,7 +16,7 @@ export class FileExistsException extends FileException
super(message, cause, name);
}

public get [Symbol.toStringTag]() { return "FileExistsException"; }
public readonly [Symbol.toStringTag]: string = "FileExistsException";
}
export class FileNotFoundException extends FileException
{
Expand All @@ -25,7 +25,7 @@ export class FileNotFoundException extends FileException
super(message, cause, name);
}

public get [Symbol.toStringTag]() { return "FileNotFoundException"; }
public readonly [Symbol.toStringTag]: string = "FileNotFoundException";
}

export class KeyException extends Exception
Expand All @@ -35,7 +35,7 @@ export class KeyException extends Exception
super(message, cause, name);
}

public get [Symbol.toStringTag]() { return "KeyException"; }
public readonly [Symbol.toStringTag]: string = "KeyException";
}
export class NetworkException extends Exception
{
Expand All @@ -44,7 +44,7 @@ export class NetworkException extends Exception
super(message, cause, name);
}

public get [Symbol.toStringTag]() { return "NetworkException"; }
public readonly [Symbol.toStringTag]: string = "NetworkException";
}
export class PermissionException extends Exception
{
Expand All @@ -53,7 +53,7 @@ export class PermissionException extends Exception
super(message, cause, name);
}

public get [Symbol.toStringTag]() { return "PermissionException"; }
public readonly [Symbol.toStringTag]: string = "PermissionException";
}
export class ReferenceException extends Exception
{
Expand All @@ -62,7 +62,7 @@ export class ReferenceException extends Exception
super(message, cause, name);
}

public get [Symbol.toStringTag]() { return "ReferenceException"; }
public readonly [Symbol.toStringTag]: string = "ReferenceException";
}

export class RuntimeException extends Exception
Expand All @@ -72,7 +72,7 @@ export class RuntimeException extends Exception
super(message, cause, name);
}

public get [Symbol.toStringTag]() { return "RuntimeException"; }
public readonly [Symbol.toStringTag]: string = "RuntimeException";
}
export class EnvironmentException extends RuntimeException
{
Expand All @@ -81,7 +81,7 @@ export class EnvironmentException extends RuntimeException
super(message, cause, name);
}

public get [Symbol.toStringTag]() { return "EnvironmentException"; }
public readonly [Symbol.toStringTag]: string = "EnvironmentException";
}

export class TimeoutException extends Exception
Expand All @@ -91,7 +91,7 @@ export class TimeoutException extends Exception
super(message, cause, name);
}

public get [Symbol.toStringTag]() { return "TimeoutException"; }
public readonly [Symbol.toStringTag]: string = "TimeoutException";
}
export class TypeException extends Exception
{
Expand All @@ -100,7 +100,7 @@ export class TypeException extends Exception
super(message, cause, name);
}

public get [Symbol.toStringTag]() { return "TypeException"; }
public readonly [Symbol.toStringTag]: string = "TypeException";
}

export class ValueException extends Exception
Expand All @@ -110,7 +110,7 @@ export class ValueException extends Exception
super(message, cause, name);
}

public get [Symbol.toStringTag]() { return "ValueException"; }
public readonly [Symbol.toStringTag]: string = "ValueException";
}
export class RangeException extends ValueException
{
Expand All @@ -119,7 +119,7 @@ export class RangeException extends ValueException
super(message, cause, name);
}

public get [Symbol.toStringTag]() { return "RangeException"; }
public readonly [Symbol.toStringTag]: string = "RangeException";
}

export { Exception };
Expand Down
2 changes: 2 additions & 0 deletions src/models/game-loop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,6 @@ export default class GameLoop
this._handle = undefined;
this._isRunning = false;
}

public readonly [Symbol.toStringTag]: string = "GameLoop";
}
18 changes: 6 additions & 12 deletions src/models/iterators/smart-async-iterator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ export default class SmartAsyncIterator<T, R = void, N = undefined> implements A
{
let index = 0;

// eslint-disable-next-line no-constant-condition
while (true)
{
const result = await this._iterator.next();
Expand All @@ -112,7 +111,6 @@ export default class SmartAsyncIterator<T, R = void, N = undefined> implements A
{
let index = 0;

// eslint-disable-next-line no-constant-condition
while (true)
{
const result = await this._iterator.next();
Expand Down Expand Up @@ -179,7 +177,6 @@ export default class SmartAsyncIterator<T, R = void, N = undefined> implements A
index += 1;
}

// eslint-disable-next-line no-constant-condition
while (true)
{
const result = await this._iterator.next();
Expand Down Expand Up @@ -216,11 +213,11 @@ export default class SmartAsyncIterator<T, R = void, N = undefined> implements A
});
}

public drop(count: number): SmartAsyncIterator<T, R | void>
public drop(count: number): SmartAsyncIterator<T, R | undefined>
{
const iterator = this._iterator;

return new SmartAsyncIterator<T, R | void>(async function* ()
return new SmartAsyncIterator<T, R | undefined>(async function* ()
{
let index = 0;

Expand All @@ -241,11 +238,11 @@ export default class SmartAsyncIterator<T, R = void, N = undefined> implements A
}
});
}
public take(limit: number): SmartAsyncIterator<T, R | void>
public take(limit: number): SmartAsyncIterator<T, R | undefined>
{
const iterator = this._iterator;

return new SmartAsyncIterator<T, R | void>(async function* ()
return new SmartAsyncIterator<T, R | undefined>(async function* ()
{
let index = 0;

Expand All @@ -263,11 +260,10 @@ export default class SmartAsyncIterator<T, R = void, N = undefined> implements A
});
}

public async find(predicate: MaybeAsyncIteratee<T, boolean>): Promise<T | void>
public async find(predicate: MaybeAsyncIteratee<T, boolean>): Promise<T | undefined>
{
let index = 0;

// eslint-disable-next-line no-constant-condition
while (true)
{
const result = await this._iterator.next();
Expand Down Expand Up @@ -309,7 +305,6 @@ export default class SmartAsyncIterator<T, R = void, N = undefined> implements A
{
let index = 0;

// eslint-disable-next-line no-constant-condition
while (true)
{
const result = await this._iterator.next();
Expand All @@ -322,7 +317,6 @@ export default class SmartAsyncIterator<T, R = void, N = undefined> implements A
{
let index = 0;

// eslint-disable-next-line no-constant-condition
while (true)
{
const result = await this._iterator.next();
Expand Down Expand Up @@ -354,7 +348,7 @@ export default class SmartAsyncIterator<T, R = void, N = undefined> implements A
return Array.fromAsync(this as AsyncIterable<T>);
}

public get [Symbol.toStringTag]() { return "SmartAsyncIterator"; }
public readonly [Symbol.toStringTag]: string = "SmartAsyncIterator";

public [Symbol.asyncIterator](): SmartAsyncIterator<T, R, N> { return this; }
}
Loading

0 comments on commit 74f23ef

Please sign in to comment.