Skip to content

Commit

Permalink
Lints
Browse files Browse the repository at this point in the history
  • Loading branch information
nvie committed Dec 23, 2023
1 parent 11b3c39 commit 86a6bf8
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/__tests__/annotate.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable no-restricted-syntax */
/* eslint-disable @typescript-eslint/no-explicit-any */

import { annotate, array, circularRef, merge, object, scalar } from '../annotate';

Expand Down Expand Up @@ -125,7 +126,7 @@ describe('parsing is idempotent', () => {

describe('annotating circular objects', () => {
it('circular arrays', () => {
var circularArray: any[] = ['foo', [42 /* circular ref will go here */]];
const circularArray: any[] = ['foo', [42 /* circular ref will go here */]];
circularArray[1].push(circularArray);

const expected = array([scalar('foo'), array([scalar(42), circularRef()])]);
Expand All @@ -137,7 +138,7 @@ describe('annotating circular objects', () => {
});

it('circular objects', () => {
var circularObject = {
const circularObject = {
foo: 42,
bar: { qux: 'hello' },
};
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/format.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { formatInline, formatShort } from '../format';
const whitespace_re = /^\s*$/;

export function dedent(value: string): string {
let lines = value.split('\n');
const lines = value.split('\n');
if (lines.length > 0 && whitespace_re.test(lines[0])) {
lines.shift();
}
Expand Down
2 changes: 2 additions & 0 deletions src/lib/_helpers.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/no-explicit-any */

/**
* Returns all the keys from T where `undefined` can be assigned to.
*/
Expand Down
4 changes: 3 additions & 1 deletion src/lib/objects.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/no-explicit-any */

import { annotateObject, merge, updateText } from '../annotate';
import { define } from '../Decoder';
import { subtract, isPojo } from '../_utils';
Expand Down Expand Up @@ -39,7 +41,7 @@ export function object<DS extends Record<string, Decoder<any>>>(
// value.
const missingKeys = subtract(knownKeys, actualKeys);

let record = {};
const record = {};
let errors: Record<string, Annotation> | null = null;

Object.keys(decodersByKey).forEach((key) => {
Expand Down
2 changes: 2 additions & 0 deletions src/lib/unions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ function nest(errText: string): string {
* first one that accepts the input "wins". If all decoders reject the input,
* the input gets rejected.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function either<T extends readonly Decoder<any>[]>(
...decoders: T
): Decoder<DecoderTypes<T>> {
Expand Down Expand Up @@ -127,6 +128,7 @@ export function oneOf<C extends Scalar>(constants: readonly C[]): Decoder<C> {
* error messages and is more performant at runtime because it doesn't have to
* try all decoders one by one.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function taggedUnion<O extends Record<string, Decoder<any>>>(
field: string,
mapping: O,
Expand Down
3 changes: 3 additions & 0 deletions src/lib/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import { annotate } from '../annotate';
import { define } from '../Decoder';
import type { Decoder } from '../Decoder';

// eslint-disable-next-line @typescript-eslint/ban-types
export interface Klass<T> extends Function {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
new (...args: readonly any[]): T;
}

Expand All @@ -11,6 +13,7 @@ export type Instance<K> = K extends Klass<infer T> ? T : never;
/**
* Accepts any value that is an ``instanceof`` the given class.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function instanceOf<K extends Klass<any>>(klass: K): Decoder<Instance<K>> {
return define((blob, ok, err) =>
blob instanceof klass ? ok(blob) : err(`Must be ${klass.name} instance`),
Expand Down

0 comments on commit 86a6bf8

Please sign in to comment.