eslint-plugin-functype 2.127.1 → 2.127.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -11
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -83,7 +83,7 @@ A rule is **`error` in `recommended` once it is right on ~95–99% of real code*
|
|
|
83
83
|
| A router's control flow: `throw redirect(…)` or `throw notFound()` in a loader or route guard | nothing: recognized by its import (below) |
|
|
84
84
|
| Anything that can fail in normal operation | return an `Either` |
|
|
85
85
|
|
|
86
|
-
```ts
|
|
86
|
+
```ts ignore
|
|
87
87
|
import { invariant } from "functype"
|
|
88
88
|
|
|
89
89
|
function deriveRunId(workflowId: string, step: number): string {
|
|
@@ -119,7 +119,7 @@ TanStack Router redirects or shows Not found only when `beforeLoad` or `loader`
|
|
|
119
119
|
| `react-router` | `redirect`, `redirectDocument`, `replace`, `data` |
|
|
120
120
|
| `react-router-dom` (React Router 6), `@remix-run/node`, `@remix-run/cloudflare` | `redirect`, `redirectDocument`, `replace`, `data`, `json` |
|
|
121
121
|
|
|
122
|
-
```ts
|
|
122
|
+
```ts ignore
|
|
123
123
|
import { redirect } from "@tanstack/react-router"
|
|
124
124
|
|
|
125
125
|
beforeLoad: ({ params }) => {
|
|
@@ -194,7 +194,7 @@ Reports changing an array in place:
|
|
|
194
194
|
|
|
195
195
|
It catches the mutation wherever the array came from, including an inferred `const rows = load(); rows.push(x)`, which `prefer-list` can't see because there's no annotation or literal.
|
|
196
196
|
|
|
197
|
-
```ts
|
|
197
|
+
```ts ignore
|
|
198
198
|
rows.push(row) // reported → [...rows, row], or build rows with map / flatMap
|
|
199
199
|
xs.sort(byRank) // reported → xs.toSorted(byRank)
|
|
200
200
|
xs[i] = v // reported → xs.with(i, v)
|
|
@@ -226,7 +226,7 @@ Reports an `IO` that is built and never run, so it does nothing:
|
|
|
226
226
|
|
|
227
227
|
`no-floating-promises` and `await-thenable` miss both, because `IO` isn't thenable.
|
|
228
228
|
|
|
229
|
-
```ts
|
|
229
|
+
```ts ignore
|
|
230
230
|
log.info("saved") // reported, when info returns an IO → yield* it, or .run() it
|
|
231
231
|
save(user).tap(audit) // reported → return it, or run it
|
|
232
232
|
const user = await loadUser(id) // reported: user is the IO → await loadUser(id).runOrThrow()
|
|
@@ -242,7 +242,7 @@ Measured (2026-10-16) on functype's own source and tests, functype-log, functype
|
|
|
242
242
|
|
|
243
243
|
Reports a statement that computes a result that can carry a failure, such as an `Either` or `Try`, and drops it. A `Left` or `Failure` in it is silently ignored. `no-floating-promises` doesn't help: awaiting the promise satisfies it while the result inside is thrown away.
|
|
244
244
|
|
|
245
|
-
```ts
|
|
245
|
+
```ts ignore
|
|
246
246
|
await userService.updateSubscription(id, plan) // reported: a failed write goes unnoticed
|
|
247
247
|
parse(input) // reported, when parse returns an Either
|
|
248
248
|
await save(user).run() // reported: run() returns an Either → check it, or use runOrThrow()
|
|
@@ -265,7 +265,7 @@ Measured (2026-10-30) on agent-todo's agent-gate-api, which kept a hand-written
|
|
|
265
265
|
|
|
266
266
|
Reports a functype container handed to a JSON sink, anywhere inside the value. An `Either`, `Option` or `List` serializes as its `{"@functype", _tag, value}` envelope, so a client reading `subscription.plan` gets `undefined`, and a body built around a `Left` answers 200. The compiler can't catch it, because `c.json()` and `JSON.stringify()` accept any value.
|
|
267
267
|
|
|
268
|
-
```ts
|
|
268
|
+
```ts ignore
|
|
269
269
|
return c.json(await svc.getDetails(id)) // reported: sends the Either's envelope
|
|
270
270
|
return c.json({ user, subscription: details }) // reported, at subscription
|
|
271
271
|
return JSON.stringify({ success: true, checkout }) // reported, at checkout: an MCP tool reporting success on failure
|
|
@@ -310,7 +310,7 @@ Only the component's or hook's own body counts as render. An event handler, an e
|
|
|
310
310
|
|
|
311
311
|
Reports a bare `.orThrow()` (or the older `.getOrThrow()`) in a component or hook body. When the value is missing it throws during render, and React unmounts the tree up to the nearest error boundary.
|
|
312
312
|
|
|
313
|
-
```tsx
|
|
313
|
+
```tsx ignore
|
|
314
314
|
function Profile({ user }: { user: Option<User> }) {
|
|
315
315
|
const u = user.orThrow() // reported → user.fold(() => <SignIn />, (u) => <Card user={u} />)
|
|
316
316
|
return <Card user={u} />
|
|
@@ -342,7 +342,7 @@ Reports a component that chooses what it renders by asking an `Option`, `Either`
|
|
|
342
342
|
- an **early return**: `if (user.isNone()) return <SignIn />` (or `return null`, `if (!user.isSome())`, `if (busy || user.isNone())`), with the other case rendered below it;
|
|
343
343
|
- a **short-circuit**: `{user.isSome() && <Card />}`, which renders one case and silently drops the other.
|
|
344
344
|
|
|
345
|
-
```tsx
|
|
345
|
+
```tsx ignore
|
|
346
346
|
function Profile({ user }: { user: Option<User> }) {
|
|
347
347
|
if (user.isNone()) return <SignIn /> // reported
|
|
348
348
|
return <Card user={user.orThrow()} />
|
|
@@ -395,7 +395,7 @@ Reports only; the rewrite is a **suggestion, never an autofix**. A fold rewrite
|
|
|
395
395
|
|
|
396
396
|
**`checkGuards`: guard, then unwrap.** Checking a container with an early exit and then pulling the value out is imperative branching. Getting a value out is fine: `orElse(default)` and `fold` are both proper exits and are never reported. What's reported is the shape below. The message picks its advice from what the guard does:
|
|
397
397
|
|
|
398
|
-
```ts
|
|
398
|
+
```ts ignore
|
|
399
399
|
if (e.isLeft()) return e // hands the failure back → e.flatMap(…) / e.map(…)
|
|
400
400
|
if (e.isLeft()) return Left({ kind: e.value.kind }) // a new failure → e.mapLeft(…).flatMap(…)
|
|
401
401
|
if (o.isNone()) return 0 // a fallback → o.map(…).orElse(0), or o.fold(() => 0, …)
|
|
@@ -432,7 +432,7 @@ A union nested in a union, such as `(string | null) | undefined`, is read as one
|
|
|
432
432
|
|
|
433
433
|
On a type-literal or interface member, and on a parameter, `a?: T` and `a: T | undefined` both mean "may be absent", so both are skipped by default. The caller writes `<X b="v" />` or `f()`, and an `Option` there would make every caller wrap the value. Skipping only one spelling would teach people to rewrite `b: string | undefined` as `b?: string`, which makes a required key optional.
|
|
434
434
|
|
|
435
|
-
```ts
|
|
435
|
+
```ts ignore
|
|
436
436
|
type Props = {
|
|
437
437
|
a?: string // fine
|
|
438
438
|
b: string | undefined // fine: the same "may be absent" as a?
|
|
@@ -454,7 +454,7 @@ Return types, variables, class fields and generic arguments (`Array<string | und
|
|
|
454
454
|
|
|
455
455
|
It reports three shapes, each once, at the outermost step:
|
|
456
456
|
|
|
457
|
-
```ts
|
|
457
|
+
```ts ignore
|
|
458
458
|
o.flatMap(f).flatMap(g).flatMap(h) // a flatMap chain 3 steps deep → Do notation
|
|
459
459
|
Option(x)
|
|
460
460
|
.flatMap((v) => Either.right(v))
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e from"./configs/recommended.js";import t from"./configs/strict.js";import n from"./configs/agent.js";import r,{testFiles as i}from"./configs/tests.js";import a from"./rules/index.js";const o={rules:a,meta:{name:`eslint-plugin-functype`,version:`2.127.
|
|
1
|
+
import e from"./configs/recommended.js";import t from"./configs/strict.js";import n from"./configs/agent.js";import r,{testFiles as i}from"./configs/tests.js";import a from"./rules/index.js";const o={rules:a,meta:{name:`eslint-plugin-functype`,version:`2.127.2`},configs:{}};o.configs={recommended:{name:`functype-plugin/recommended`,plugins:{functype:o},rules:e},strict:{name:`functype-plugin/strict`,plugins:{functype:o},rules:t},agent:{name:`functype-plugin/agent`,plugins:{functype:o},rules:n},tests:{name:`functype-plugin/tests`,plugins:{functype:o},files:i,rules:r}};export{o as default};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-functype",
|
|
3
|
-
"version": "2.127.
|
|
3
|
+
"version": "2.127.2",
|
|
4
4
|
"description": "Custom ESLint rules for functional TypeScript programming with functype library patterns including Do notation (ESLint 10+)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@types/node": "^24.19.1",
|
|
43
43
|
"@typescript-eslint/rule-tester": "^8.71.0",
|
|
44
44
|
"eslint-config-prettier": "^10.1.8",
|
|
45
|
-
"functype": "^1.27.
|
|
45
|
+
"functype": "^1.27.2",
|
|
46
46
|
"ts-builds": "^4.5.0",
|
|
47
47
|
"tsdown": "^0.23.0"
|
|
48
48
|
},
|