Repository: dubzzz/fast-check
Pull request #5803: 🚨 Fix lint error in `ConstantArbitrary` class
Author: login: ahrjarrett
Created: 2025-03-08T10:00:00Z | Merged: 2025-03-08T17:58:39Z

**Description**

This PR fixes the linting error that was backed out of #5783

- [x] The name of my PR follows [gitmoji](https://gitmoji.dev/) specification
- [x] My PR references one of several related issues (if any)
  - [x] New features or breaking changes must come with an associated Issue or Discussion
  - [x] My PR does not add any new dependency without an associated Issue or Discussion
- [x] My PR includes bumps details, please run `pnpm run bump` and flag the impacts properly
- [x] My PR adds relevant tests and they would have failed without my PR (when applicable)




Diff:
diff --git a/.changeset/bitter-grapes-pull.md b/.changeset/bitter-grapes-pull.md
new file mode 100644
index 00000000000..bc09a307c79
--- /dev/null
+++ b/.changeset/bitter-grapes-pull.md
@@ -0,0 +1,5 @@
+---
+'fast-check': patch
+---
+
+🚨 Fix lint error in `ConstantArbitrary` class
diff --git a/packages/fast-check/src/arbitrary/_internals/ConstantArbitrary.ts b/packages/fast-check/src/arbitrary/_internals/ConstantArbitrary.ts
index 8b33b3cb11a..1e866041db6 100644
--- a/packages/fast-check/src/arbitrary/_internals/ConstantArbitrary.ts
+++ b/packages/fast-check/src/arbitrary/_internals/ConstantArbitrary.ts
@@ -7,38 +7,6 @@ import { Set, safeHas } from '../../utils/globals';
 
 const safeObjectIs = Object.is;
 
-/** @internal */
-export class ConstantArbitrary<T> extends Arbitrary<T> {
-  private fastValues: FastConstantValuesLookup<T> | undefined;
-
-  constructor(readonly values: T[]) {
-    super();
-  }
-  generate(mrng: Random, _biasFactor: number | undefined): Value<T> {
-    const idx = this.values.length === 1 ? 0 : mrng.nextInt(0, this.values.length - 1);
-    const value = this.values[idx];
-    if (!hasCloneMethod(value)) {
-      return new Value(value, idx);
-    }
-    return new Value(value, idx, () => value[cloneMethod]());
-  }
-  canShrinkWithoutContext(value: unknown): value is T {
-    if (this.values.length === 1) {
-      return safeObjectIs(this.values[0], value);
-    }
-    if (this.fastValues === undefined) {
-      this.fastValues = new FastConstantValuesLookup(this.values);
-    }
-    return this.fastValues.has(value);
-  }
-  shrink(value: T, context?: unknown): Stream<Value<T>> {
-    if (context === 0 || safeObjectIs(value, this.values[0])) {
-      return Stream.nil();
-    }
-    return Stream.of(new Value(this.values[0], 0));
-  }
-}
-
 /** @internal */
 class FastConstantValuesLookup<T> {
   private readonly hasMinusZero: boolean;
@@ -71,3 +39,35 @@ class FastConstantValuesLookup<T> {
     return safeHas(this.fastValues, value);
   }
 }
+
+/** @internal */
+export class ConstantArbitrary<T> extends Arbitrary<T> {
+  private fastValues: FastConstantValuesLookup<T> | undefined;
+
+  constructor(readonly values: T[]) {
+    super();
+  }
+  generate(mrng: Random, _biasFactor: number | undefined): Value<T> {
+    const idx = this.values.length === 1 ? 0 : mrng.nextInt(0, this.values.length - 1);
+    const value = this.values[idx];
+    if (!hasCloneMethod(value)) {
+      return new Value(value, idx);
+    }
+    return new Value(value, idx, () => value[cloneMethod]());
+  }
+  canShrinkWithoutContext(value: unknown): value is T {
+    if (this.values.length === 1) {
+      return safeObjectIs(this.values[0], value);
+    }
+    if (this.fastValues === undefined) {
+      this.fastValues = new FastConstantValuesLookup(this.values);
+    }
+    return this.fastValues.has(value);
+  }
+  shrink(value: T, context?: unknown): Stream<Value<T>> {
+    if (context === 0 || safeObjectIs(value, this.values[0])) {
+      return Stream.nil();
+    }
+    return Stream.of(new Value(this.values[0], 0));
+  }
+}
diff --git a/packages/fast-check/src/arbitrary/_internals/helpers/BiasNumericRange.ts b/packages/fast-check/src/arbitrary/_internals/helpers/BiasNumericRange.ts
index 8e5f1f908df..48f468161e3 100644
--- a/packages/fast-check/src/arbitrary/_internals/helpers/BiasNumericRange.ts
+++ b/packages/fast-check/src/arbitrary/_internals/helpers/BiasNumericRange.ts
@@ -11,7 +11,6 @@ export function integerLogLike(v: number): number {
 /** @internal */
 export function bigIntLogLike(v: bigint): bigint {
   if (v === BigInt(0)) return BigInt(0);
-  // eslint-disable-next-line @typescript-eslint/no-base-to-string
   return BigInt(String(v).length);
 }
 
diff --git a/packages/fast-check/src/check/model/commands/ScheduledCommand.ts b/packages/fast-check/src/check/model/commands/ScheduledCommand.ts
index bab77fcce24..b9edffaa93e 100644
--- a/packages/fast-check/src/check/model/commands/ScheduledCommand.ts
+++ b/packages/fast-check/src/check/model/commands/ScheduledCommand.ts
@@ -41,7 +41,6 @@ export class ScheduledCommand<Model extends object, Real, RunResult, CheckAsync
         label: `run@${this.cmd.toString()}`,
         builder: async () => {
           try {
-            // eslint-disable-next-line @typescript-eslint/await-thenable
             await this.cmd.run(m, r);
           } catch (err) {
             error = err;


Reviews:
user: login: dubzzz
state: COMMENTED
author_association: OWNER
submitted_at: 2025-03-08T10:36:55Z
user: login: dubzzz
state: DISMISSED
author_association: OWNER
submitted_at: 2025-03-08T10:37:41Z
user: login: dubzzz
state: COMMENTED
author_association: OWNER
submitted_at: 2025-03-08T15:34:36Z
user: login: dubzzz
state: COMMENTED
author_association: OWNER
submitted_at: 2025-03-08T17:51:21Z
user: login: dubzzz
state: APPROVED
author_association: OWNER
submitted_at: 2025-03-08T17:51:44Z

Review comments:
diff_hunk: @@ -11,7 +11,7 @@ export function integerLogLike(v: number): number {
 /** @internal */
 export function bigIntLogLike(v: bigint): bigint {
   if (v === BigInt(0)) return BigInt(0);
-  // eslint-disable-next-line @typescript-eslint/no-base-to-string
+   
path: packages/fast-check/src/arbitrary/_internals/helpers/BiasNumericRange.ts
user: login: dubzzz
body: ```suggestion
```

created_at: 2025-03-08T10:36:23Z
author_association: OWNER
diff_hunk: @@ -41,7 +41,7 @@ export class ScheduledCommand<Model extends object, Real, RunResult, CheckAsync
         label: `run@${this.cmd.toString()}`,
         builder: async () => {
           try {
-            // eslint-disable-next-line @typescript-eslint/await-thenable
+             
path: packages/fast-check/src/check/model/commands/ScheduledCommand.ts
user: login: dubzzz
body: ```suggestion
```

created_at: 2025-03-08T10:36:36Z
author_association: OWNER
diff_hunk: @@ -41,7 +41,7 @@ export function runMainThread<Ts extends [unknown, ...unknown[]]>(
           return;
         }
         worker.register(predicateId, property.getPayload(inputs), resolve, reject, () =>
-          // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
+           
path: packages/worker/src/internals/MainThreadRunner.ts
user: login: dubzzz
body: ```suggestion
```

created_at: 2025-03-08T10:36:46Z
author_association: OWNER
diff_hunk: @@ -41,7 +41,6 @@ export function runMainThread<Ts extends [unknown, ...unknown[]]>(
           return;
         }
         worker.register(predicateId, property.getPayload(inputs), resolve, reject, () =>
-          // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
path: packages/worker/src/internals/MainThreadRunner.ts
user: login: dubzzz
body:   Actually this one needs to be added back. It seems that our CI check is not happy with this one being missing. I'm pretty sure that it's linked to the fact that our CI job does not rely on a pre-built version of fast-check. This it cannot know that a precondition is of type Error while it can know it when executed locally (usually you have the code built).

Thus I'd keep the disable comment for now.
created_at: 2025-03-08T15:34:24Z
author_association: OWNER
diff_hunk: @@ -0,0 +1,6 @@
+---
+'fast-check': patch
+'@fast-check/worker': patch
path: .changeset/bitter-grapes-pull.md
user: login: dubzzz
body: ```suggestion
```
created_at: 2025-03-08T17:51:20Z
author_association: OWNER

PR comments:
user: login: changeset-bot[bot]
created_at: 2025-03-08T10:00:05Z
body: ###  🦋  Changeset detected

Latest commit: 17a51124097a8b8d8cf2a12977da5fba41468f2c

**The changes in this PR will be included in the next version bump.**

<details><summary>This PR includes changesets to release 1 package</summary>

  | Name       | Type  |
| ---------- | ----- |
| fast-check | Patch |

</details>

Not sure what this means? [Click here  to learn what changesets are](https://github.com/changesets/changesets/blob/main/docs/adding-a-changeset.md).

[Click here if you're a maintainer who wants to add another changeset to this PR](https://github.com/ahrjarrett/fast-check/new/@ahrjarrett/lint-fix?filename=.changeset/pink-terms-tie.md&value=---%0A%22fast-check%22%3A%20patch%0A---%0A%0A%F0%9F%9A%A8%20Fix%20lint%20error%20in%20%60ConstantArbitrary%60%20class%0A)


author_association: NONE
user: login: pkg-pr-new[bot]
created_at: 2025-03-08T10:41:37Z
body: 
[Open in Stackblitz](https://pkg.pr.new/template/ee23df55-105e-401a-b222-5821b06a915d) • [@fast-check/examples](https://pkg.pr.new/template/310ce183-12ef-4314-a4e8-45661cd2f9fc)


<details><summary><b>@fast-check/ava</b></summary><p>

```
npm i https://pkg.pr.new/@fast-check/ava@5803
```

</p></details>
      
    

<details><summary><b>@fast-check/expect-type</b></summary><p>

```
npm i https://pkg.pr.new/@fast-check/expect-type@5803
```

</p></details>
      
    

<details><summary><b>fast-check</b></summary><p>

```
npm i https://pkg.pr.new/fast-check@5803
```

</p></details>
      
    

<details><summary><b>@fast-check/jest</b></summary><p>

```
npm i https://pkg.pr.new/@fast-check/jest@5803
```

</p></details>
      
    

<details><summary><b>@fast-check/packaged</b></summary><p>

```
npm i https://pkg.pr.new/@fast-check/packaged@5803
```

</p></details>
      
    

<details><summary><b>@fast-check/vitest</b></summary><p>

```
npm i https://pkg.pr.new/@fast-check/vitest@5803
```

</p></details>
      
    

<details><summary><b>@fast-check/poisoning</b></summary><p>

```
npm i https://pkg.pr.new/@fast-check/poisoning@5803
```

</p></details>
      
    

<details><summary><b>@fast-check/worker</b></summary><p>

```
npm i https://pkg.pr.new/@fast-check/worker@5803
```

</p></details>
      
    

_commit: <a href="https://github.com/dubzzz/fast-check/runs/38428191603"><code>17a5112</code></a>_

author_association: NONE
user: login: codecov[bot]
created_at: 2025-03-08T10:44:02Z
body: ## [Codecov](https://app.codecov.io/gh/dubzzz/fast-check/pull/5803?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 94.73%. Comparing base [(`eeff420`)](https://app.codecov.io/gh/dubzzz/fast-check/commit/eeff4208f4be4632814a0f0c4d95383d4cbc671b?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN) to head [(`17a5112`)](https://app.codecov.io/gh/dubzzz/fast-check/commit/17a51124097a8b8d8cf2a12977da5fba41468f2c?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN).
> Report is 6 commits behind head on main.

<details><summary>Additional details and impacted files</summary>


```diff
@@           Coverage Diff           @@
##             main    #5803   +/-   ##
=======================================
  Coverage   94.73%   94.73%           
=======================================
  Files         212      212           
  Lines       10057    10057           
  Branches     2670     2670           
=======================================
  Hits         9527     9527           
  Misses        530      530           
```

| [Flag](https://app.codecov.io/gh/dubzzz/fast-check/pull/5803/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN) | Coverage Δ | |
|---|---|---|
| [unit-tests](https://app.codecov.io/gh/dubzzz/fast-check/pull/5803/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN) | `94.73% <100.00%> (ø)` | |
| [unit-tests-18.x-Linux](https://app.codecov.io/gh/dubzzz/fast-check/pull/5803/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN) | `94.73% <100.00%> (?)` | |
| [unit-tests-20.x-Linux](https://app.codecov.io/gh/dubzzz/fast-check/pull/5803/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN) | `94.68% <100.00%> (?)` | |
| [unit-tests-22.x-Linux](https://app.codecov.io/gh/dubzzz/fast-check/pull/5803/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN) | `94.73% <100.00%> (ø)` | |
| [unit-tests-latest-Linux](https://app.codecov.io/gh/dubzzz/fast-check/pull/5803/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN) | `94.73% <100.00%> (ø)` | |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN#carryforward-flags-in-the-pull-request-comment) to find out more.

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/dubzzz/fast-check/pull/5803?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN).

<details><summary>🚀 New features to boost your workflow: </summary>

- ❄ [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- 📦 [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
author_association: NONE