diff --git a/eslint.config.mjs b/eslint.config.mjs index 104ad06..2ad2b68 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -38,8 +38,9 @@ export default tseslint.config( "@typescript-eslint/consistent-type-imports": "error", "@typescript-eslint/explicit-module-boundary-types": "error", - "@typescript-eslint/restrict-template-expressions": ["error", { allowNumber: true }], "@typescript-eslint/no-explicit-any": "error", + "@typescript-eslint/no-unnecessary-condition": ["error", { allowConstantLoopConditions: true }], + "@typescript-eslint/restrict-template-expressions": ["error", { allowNumber: true }], "@typescript-eslint/no-unused-vars": [ "warn", { args: "all", argsIgnorePattern: "^_.*", varsIgnorePattern: "^_.*" }, @@ -60,12 +61,13 @@ export default tseslint.config( // ------------------------------- { rules: { + //"@typescript-eslint/consistent-type-definitions": "off", //"@typescript-eslint/no-empty-function": "off", //"@typescript-eslint/no-inferrable-types": "off", "@typescript-eslint/no-non-null-assertion": "off", - //"no-constant-condition": "off", - //"@typescript-eslint/consistent-type-definitions": "off", + "@typescript-eslint/unified-signatures": "off", //"@typescript-eslint/use-unknown-in-catch-callback-variable": "off", + //"no-constant-condition": "off", }, }, diff --git a/src/builtins.ts b/src/builtins.ts index 912e266..a9ac194 100644 --- a/src/builtins.ts +++ b/src/builtins.ts @@ -11,7 +11,7 @@ export function find(iterable: Iterable, predicate?: Predicate): T | un const it = iter(iterable); if (predicate === undefined) { const value = it.next(); - return value.done ? value.value : value.value; + return value.done ? undefined : value.value; } else { let res: IteratorResult; let i = 0; @@ -215,7 +215,6 @@ function range_(start: number, stop: number, step: number): IterableIterator; export function range(start: number, stop: number, step?: number): IterableIterator; export function range(startOrStop: number, definitelyStop?: number, step = 1): IterableIterator { diff --git a/src/custom.ts b/src/custom.ts index b1c5a30..b21e045 100644 --- a/src/custom.ts +++ b/src/custom.ts @@ -7,7 +7,7 @@ function isNullish(x: T): x is NonNullable { return x != null; } -function isDefined(x: T): boolean { +function isDefined(x: unknown): boolean { return x !== undefined; } diff --git a/src/itertools.ts b/src/itertools.ts index 31c7bc8..be161bc 100644 --- a/src/itertools.ts +++ b/src/itertools.ts @@ -345,7 +345,7 @@ export function* izipMany(...iters: Iterable[]): IterableIterator { export function* permutations(iterable: Iterable, r?: number): IterableIterator { const pool = Array.from(iterable); const n = pool.length; - const x = r === undefined ? n : r; + const x = r ?? n; if (x > n) { return; diff --git a/src/more-itertools.ts b/src/more-itertools.ts index c2c4e4c..e68520a 100644 --- a/src/more-itertools.ts +++ b/src/more-itertools.ts @@ -1,4 +1,4 @@ -import { enumerate, iter, map } from "./builtins"; +import { iter, map } from "./builtins"; import { izip, repeat } from "./itertools"; import type { Predicate, Primitive } from "./types"; import { primitiveIdentity } from "./utils";