Skip to content

Commit 567b93e

Browse files
chore: 🤖 fix new Biome v2 linting issues
1 parent b2cab50 commit 567b93e

File tree

25 files changed

+115
-106
lines changed

25 files changed

+115
-106
lines changed

‎biome.json‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,22 @@
1717
}
1818
},
1919
"files": {
20-
"ignore": [".vscode"]
20+
"includes": ["**", "!**/.vscode"]
21+
},
22+
"linter": {
23+
"rules": {
24+
"style": {
25+
"noParameterAssign": "error",
26+
"useAsConstAssertion": "error",
27+
"useDefaultParameterLast": "error",
28+
"useEnumInitializers": "error",
29+
"useSelfClosingElements": "error",
30+
"useSingleVarDeclarator": "error",
31+
"noUnusedTemplateLiteral": "error",
32+
"useNumberNamespace": "error",
33+
"noInferrableTypes": "error",
34+
"noUselessElse": "error"
35+
}
36+
}
2137
}
2238
}

‎packages/array/src/sample.ts‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
type NonEmptyArray<T> = readonly [T, ...T[]]
2+
3+
function isNotEmpty<T>(value: readonly T[]): value is NonEmptyArray<T> {
4+
return value.length > 0
5+
}
6+
17
/**
28
* Picks a random element from an array, or `undefined` if the provided array
39
* is empty.
@@ -15,8 +21,9 @@
1521
* @returns Random element from the provided array, or `undefined` if the array
1622
* is empty.
1723
*/
24+
export function sample<T>(array: NonEmptyArray<T>): T
1825
export function sample<T>(array: readonly T[]): T | undefined {
19-
if (array.length === 0) return undefined
26+
if (!isNotEmpty(array)) return undefined
2027
return array[Math.floor(Math.random() * array.length)]
2128
}
2229

@@ -38,12 +45,11 @@ export function sample<T>(array: readonly T[]): T | undefined {
3845
* @returns Array of random elements from the provided array.
3946
*/
4047
export function sampleN<T>(array: readonly T[], sampleSize: number): T[] {
41-
if (array.length === 0) return []
48+
if (!isNotEmpty(array)) return []
4249
const maxSamples = Math.max(0, sampleSize)
4350
const result = new Array<T>(maxSamples)
4451
for (let i = 0; i < maxSamples; i++) {
45-
// biome-ignore lint/style/noNonNullAssertion: <explanation>
46-
result[i] = sample(array)!
52+
result[i] = sample(array)
4753
}
4854
return result
4955
}

‎packages/emitter/src/index.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
interface Events {
2-
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
3-
[name: string]: (...args: any[]) => void
2+
[name: string]: (...args: unknown[]) => void
43
}
54

65
interface Emitter<E extends Events> {

‎packages/error/src/index.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,22 @@ export class BaseError extends Error {
1111
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error#Custom_Error_Types
1212
*/
1313
public static imprint(instance: BaseError): void {
14-
// biome-ignore lint/complexity/noThisInStatic: <explanation>
14+
// biome-ignore lint/complexity/noThisInStatic: imprint class name
1515
instance.name = this.name
1616

1717
if (Error.captureStackTrace) {
18-
// biome-ignore lint/complexity/noThisInStatic: <explanation>
18+
// biome-ignore lint/complexity/noThisInStatic: imprint stack trace
1919
Error.captureStackTrace(instance, this.constructor)
2020
}
2121

2222
if (Object.setPrototypeOf) {
23-
// biome-ignore lint/complexity/noThisInStatic: <explanation>
23+
// biome-ignore lint/complexity/noThisInStatic: imprint class prototype
2424
Object.setPrototypeOf(instance, this.prototype)
2525
}
2626
}
2727

2828
public static fromString(message?: string): BaseError {
29-
// biome-ignore lint/complexity/noThisInStatic: <explanation>
29+
// biome-ignore lint/complexity/noThisInStatic: constructor method
3030
return new this(message)
3131
}
3232
}
@@ -40,13 +40,13 @@ export class ComplexError extends BaseError {
4040
) {
4141
super(message)
4242
ComplexError.imprint(this)
43-
this.causes = Array<Error | BaseError>().concat(causes)
43+
this.causes = ([] as ReadonlyArray<Error | BaseError>).concat(causes)
4444
}
4545

4646
public static fromErrors(
4747
errors: readonly (Error | BaseError)[],
4848
): ComplexError {
49-
// biome-ignore lint/complexity/noThisInStatic: <explanation>
49+
// biome-ignore lint/complexity/noThisInStatic: constructor method
5050
return new this(undefined, errors)
5151
}
5252
}

‎packages/flux-actions/src/index.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
1+
// biome-ignore lint/suspicious/noExplicitAny: ignore
22
export interface Action<P = any, M = any> {
33
type: string
44
payload: P
55
meta: M
66
}
77

8-
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
8+
// biome-ignore lint/suspicious/noExplicitAny: ignore
99
type ActionCreator<P = any, M = any> = {
1010
type: string
1111
(payload: P, meta?: M): Action<P, M>
@@ -15,7 +15,7 @@ type ActionCreator<P = any, M = any> = {
1515

1616
type Reducer<S> = (state: S | undefined, action: Action) => S
1717

18-
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
18+
// biome-ignore lint/suspicious/noExplicitAny: ignore
1919
type ReduceHandler<S, P = any, M = any> = (state: S, action: Action<P, M>) => S
2020

2121
type ReducerMatch<S> = [ActionCreator, ReduceHandler<S>]
@@ -58,7 +58,7 @@ function createReducer<S>(
5858
on(creators, handler) {
5959
return createReducer(initialState, [
6060
...matches,
61-
...Array<ActionCreator>()
61+
...([] as ActionCreator[])
6262
.concat(creators)
6363
.map<ReducerMatch<S>>((creator) => [creator, handler]),
6464
])

‎packages/interpolate/src/index.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export function interpolate(
77
const regexp = RegExp(pattern, 'g')
88

99
return (data: ReplaceMap<string | number | null | undefined> = {}): string =>
10-
template.replace(regexp, (match, capture = '') => {
10+
template.replace(regexp, (_match, capture = '') => {
1111
const key = capture.trim()
1212
const value = Array.isArray(data)
1313
? data[Number.parseInt(key, 10)]

‎packages/jest-either/src/shared/predicates.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
import { isPlainObject } from '@pacote/is-plain-object'
22
import { pipe } from 'fp-ts/function'
33
import { type Either, fold } from 'fp-ts/lib/Either'
4-
import { F, equals, map, where } from 'ramda'
4+
import { equals, F, map, where } from 'ramda'
55

66
export interface AsymmetricMatcher {
77
asymmetricMatch(other: unknown): boolean
88
}
99

1010
export function isAsymmetricMatcher(
11-
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
11+
// biome-ignore lint/suspicious/noExplicitAny: can be anything
1212
matcher: any,
1313
): matcher is AsymmetricMatcher {
1414
return typeof matcher.asymmetricMatch === 'function'
1515
}
1616

17-
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
17+
// biome-ignore lint/suspicious/noExplicitAny: can be anything
1818
export const matchObject = (s: any) => (o: unknown) =>
1919
isPlainObject(o) ? where(map(matchObject, s), o) : equals(s, o)
2020

‎packages/jest-either/src/toBeEither.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const failMessage = (actual: unknown) => () =>
2323
'',
2424
)}\n\nExpected Either, received:\n ${printReceived(actual)}`
2525

26-
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
26+
// biome-ignore lint/suspicious/noExplicitAny: receives anything
2727
function isEither(actual: any): actual is Either<unknown, unknown> {
2828
return (
2929
actual !== undefined &&

‎packages/jest-either/src/toMatchLeft.ts‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,11 @@ const failMessage =
3636
export function toMatchLeft(
3737
actual: Either<string, unknown>,
3838
expected: RegExp,
39-
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
40-
): any
39+
): unknown
4140
export function toMatchLeft<L>(
4241
actual: Either<L, unknown>,
4342
expected: Partial<L>,
44-
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
45-
): any
43+
): unknown
4644
export function toMatchLeft<L>(
4745
actual: Either<L, unknown>,
4846
expected: RegExp | Partial<L>,

‎packages/jest-either/src/toMatchRight.ts‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,11 @@ const failMessage =
3636
export function toMatchRight(
3737
actual: Either<unknown, string>,
3838
expected: RegExp,
39-
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
40-
): any
39+
): unknown
4140
export function toMatchRight<R>(
4241
actual: Either<unknown, R>,
4342
expected: Partial<R>,
44-
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
45-
): any
43+
): unknown
4644
export function toMatchRight<R>(
4745
actual: Either<unknown, string | R>,
4846
expected: RegExp | Partial<R>,

0 commit comments

Comments
 (0)