From 77d2ebd25357becd7b1bbbb0bc3216b01c44c16c Mon Sep 17 00:00:00 2001 From: Daniel Sales Date: Wed, 19 Jun 2024 01:17:56 +0200 Subject: [PATCH] chore: fix some tests and scripts --- package.json | 2 +- src/CreatePicker.ts | 1 + src/Picker.ts | 3 +++ src/RemoverPicker.spec.ts | 2 +- src/SinglePicker.spec.ts | 2 +- src/SinglePicker.ts | 1 + src/WeightPicker.spec.ts | 2 +- src/WeightPicker.ts | 1 + src/readme.spec.ts | 2 +- 9 files changed, 11 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index ad7493b..92d3b00 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "lint:fix": "eslint ./src/*.ts --fix", "postdocs": "lib/docs/generate_footer.sh", "postpublish": "pnpm clean", - "prebuild": "pnpm lint:fix &&p npm clean && pnpm rebuild && pnpm test", + "prebuild": "pnpm lint:fix && pnpm clean && pnpm rebuild && pnpm test", "prepublishOnly": "pnpm build", "test": "jest", "test:coverage": "jest --coverage", diff --git a/src/CreatePicker.ts b/src/CreatePicker.ts index df2b5ba..7473ca0 100644 --- a/src/CreatePicker.ts +++ b/src/CreatePicker.ts @@ -1,3 +1,4 @@ +// eslint-disable-next-line import/no-cycle import { Picker } from "./Picker"; import { DefaultPickerOptions, PickerOptions } from "./PickerOptions"; import { SinglePicker } from "./SinglePicker"; diff --git a/src/Picker.ts b/src/Picker.ts index dcce16e..c250994 100644 --- a/src/Picker.ts +++ b/src/Picker.ts @@ -1,4 +1,5 @@ import seedRandom from "seed-random"; +// eslint-disable-next-line import/no-cycle import { create } from "./CreatePicker"; import { DefaultPickOptions, PickOptions } from "./PickOptions"; import { PickerOptions } from "./PickerOptions"; @@ -14,6 +15,7 @@ export abstract class Picker { Object.freeze(options); } + // eslint-disable-next-line accessor-pairs get data(): Readonly { return this.innerData; } @@ -171,6 +173,7 @@ export abstract class Picker { return this.innerData.splice(index, 1)[0]; } + // eslint-disable-next-line accessor-pairs get length(): number { return this.innerData.length; } diff --git a/src/RemoverPicker.spec.ts b/src/RemoverPicker.spec.ts index 0d43dd4..9f76e59 100644 --- a/src/RemoverPicker.spec.ts +++ b/src/RemoverPicker.spec.ts @@ -1,4 +1,4 @@ -import create from "./CreatePicker"; +import { create } from "./CreatePicker"; import { PickOptions } from "./PickOptions"; const data = [1, 2, 3, 4, 5, 6]; diff --git a/src/SinglePicker.spec.ts b/src/SinglePicker.spec.ts index 4a23db9..5e9f269 100644 --- a/src/SinglePicker.spec.ts +++ b/src/SinglePicker.spec.ts @@ -1,5 +1,5 @@ /* eslint-disable prefer-destructuring */ -import create from "./CreatePicker"; +import { create } from "./CreatePicker"; import { PickOptions } from "./PickOptions"; const data = [1, 2, 3, 4, 5, 6]; diff --git a/src/SinglePicker.ts b/src/SinglePicker.ts index 83aa1ef..42c5be7 100644 --- a/src/SinglePicker.ts +++ b/src/SinglePicker.ts @@ -3,6 +3,7 @@ import { Picker as AbstractPicker } from "./Picker"; export class SinglePicker extends AbstractPicker { throwDart = (dart: number): T | undefined => this.innerData[dart]; + // eslint-disable-next-line accessor-pairs get weight(): number { return this.innerData.length; } diff --git a/src/WeightPicker.spec.ts b/src/WeightPicker.spec.ts index 97c945e..b88ef3c 100644 --- a/src/WeightPicker.spec.ts +++ b/src/WeightPicker.spec.ts @@ -1,4 +1,4 @@ -import create from "./CreatePicker"; +import { create } from "./CreatePicker"; function createSample() { const picker = create([1, 2, 3, 4, 5, 6], { diff --git a/src/WeightPicker.ts b/src/WeightPicker.ts index a5765b9..2786155 100644 --- a/src/WeightPicker.ts +++ b/src/WeightPicker.ts @@ -57,6 +57,7 @@ export class WeightPicker extends Picker { }; } + // eslint-disable-next-line accessor-pairs get weight(): number { let size = 0; diff --git a/src/readme.spec.ts b/src/readme.spec.ts index c7477cf..df5c6a5 100644 --- a/src/readme.spec.ts +++ b/src/readme.spec.ts @@ -1,4 +1,4 @@ -import create from "./CreatePicker"; +import { create } from "./CreatePicker"; import { RandomMode } from "./RandomMode"; import { newPicker, Picker } from ".";