eslint-plugin-functype 2.127.1 ā 2.200.0
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 +93 -87
- package/dist/cli/list-rules.js.map +1 -1
- package/dist/configs/recommended.d.ts +40 -46
- package/dist/configs/recommended.js +1 -1
- package/dist/configs/recommended.js.map +1 -1
- package/dist/configs/tests.d.ts +8 -5
- package/dist/configs/tests.js +1 -1
- package/dist/configs/tests.js.map +1 -1
- package/dist/index.d.ts +1 -4
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/rules/collection-naming.d.ts +1 -4
- package/dist/rules/collection-naming.js.map +1 -1
- package/dist/rules/index.d.ts +1 -4
- package/dist/rules/index.js.map +1 -1
- package/dist/rules/must-fold-on-component-return.d.ts +1 -4
- package/dist/rules/must-fold-on-component-return.js.map +1 -1
- package/dist/rules/no-array-mutation.d.ts +1 -4
- package/dist/rules/no-array-mutation.js +1 -1
- package/dist/rules/no-array-mutation.js.map +1 -1
- package/dist/rules/no-floating-io.d.ts +1 -4
- package/dist/rules/no-floating-io.js.map +1 -1
- package/dist/rules/no-floating-result.d.ts +1 -4
- package/dist/rules/no-floating-result.js.map +1 -1
- package/dist/rules/no-get-unsafe.d.ts +1 -4
- package/dist/rules/no-get-unsafe.js +1 -1
- package/dist/rules/no-get-unsafe.js.map +1 -1
- package/dist/rules/no-getOrThrow-in-render.d.ts +1 -4
- package/dist/rules/no-getOrThrow-in-render.js +1 -1
- package/dist/rules/no-getOrThrow-in-render.js.map +1 -1
- package/dist/rules/no-imperative-loops.d.ts +1 -4
- package/dist/rules/no-imperative-loops.js +1 -1
- package/dist/rules/no-imperative-loops.js.map +1 -1
- package/dist/rules/no-let.d.ts +1 -4
- package/dist/rules/no-let.js.map +1 -1
- package/dist/rules/no-serialize-container.d.ts +1 -4
- package/dist/rules/no-serialize-container.js.map +1 -1
- package/dist/rules/prefer-do-notation.d.ts +1 -4
- package/dist/rules/prefer-do-notation.js +1 -1
- package/dist/rules/prefer-do-notation.js.map +1 -1
- package/dist/rules/prefer-either.d.ts +1 -4
- package/dist/rules/prefer-either.js.map +1 -1
- package/dist/rules/prefer-flatmap.d.ts +1 -4
- package/dist/rules/prefer-flatmap.js +1 -1
- package/dist/rules/prefer-flatmap.js.map +1 -1
- package/dist/rules/prefer-fold.d.ts +1 -4
- package/dist/rules/prefer-fold.js +1 -1
- package/dist/rules/prefer-fold.js.map +1 -1
- package/dist/rules/prefer-functype-map.d.ts +1 -4
- package/dist/rules/prefer-functype-map.js.map +1 -1
- package/dist/rules/prefer-functype-set.d.ts +1 -4
- package/dist/rules/prefer-functype-set.js.map +1 -1
- package/dist/rules/prefer-list.d.ts +1 -4
- package/dist/rules/prefer-list.js +2 -2
- package/dist/rules/prefer-list.js.map +1 -1
- package/dist/rules/prefer-map.d.ts +1 -4
- package/dist/rules/prefer-map.js.map +1 -1
- package/dist/rules/prefer-option.d.ts +1 -4
- package/dist/rules/prefer-option.js.map +1 -1
- package/dist/rules/prefer-try.d.ts +1 -4
- package/dist/rules/prefer-try.js +1 -1
- package/dist/rules/prefer-try.js.map +1 -1
- package/dist/types/ast.d.ts +1 -4
- package/dist/utils/array-mutation.d.ts +1 -4
- package/dist/utils/array-mutation.js.map +1 -1
- package/dist/utils/ast-walk.d.ts +1 -4
- package/dist/utils/ast-walk.js.map +1 -1
- package/dist/utils/async-detection.d.ts +1 -4
- package/dist/utils/async-detection.js.map +1 -1
- package/dist/utils/boundary-tags.d.ts +1 -4
- package/dist/utils/boundary-tags.js.map +1 -1
- package/dist/utils/collection-binding.d.ts +1 -4
- package/dist/utils/collection-binding.js.map +1 -1
- package/dist/utils/dependency-validator.d.ts +1 -3
- package/dist/utils/dependency-validator.js.map +1 -1
- package/dist/utils/functype-detection.d.ts +1 -4
- package/dist/utils/functype-detection.js +1 -1
- package/dist/utils/functype-detection.js.map +1 -1
- package/dist/utils/functype-predicates.d.ts +1 -4
- package/dist/utils/functype-predicates.js.map +1 -1
- package/dist/utils/host-throws.d.ts +1 -4
- package/dist/utils/host-throws.js.map +1 -1
- package/dist/utils/import-fixer.d.ts +1 -4
- package/dist/utils/import-fixer.js.map +1 -1
- package/dist/utils/mutable-collection.d.ts +1 -4
- package/dist/utils/mutable-collection.js.map +1 -1
- package/dist/utils/react-render.d.ts +1 -4
- package/dist/utils/react-render.js.map +1 -1
- package/dist/utils/readonly-contract.d.ts +1 -4
- package/dist/utils/readonly-contract.js.map +1 -1
- package/dist/utils/type-aware.d.ts +2 -5
- package/dist/utils/type-aware.js +1 -1
- package/dist/utils/type-aware.js.map +1 -1
- package/dist/utils/wire-types.d.ts +1 -4
- package/dist/utils/wire-types.js.map +1 -1
- package/package.json +5 -5
- package/dist/configs/agent.d.ts +0 -45
- package/dist/configs/agent.js +0 -2
- package/dist/configs/agent.js.map +0 -1
- package/dist/configs/strict.d.ts +0 -26
- package/dist/configs/strict.js +0 -2
- package/dist/configs/strict.js.map +0 -1
package/README.md
CHANGED
|
@@ -14,61 +14,80 @@ npm install -D eslint-plugin-functype eslint
|
|
|
14
14
|
// eslint.config.mjs
|
|
15
15
|
import functype from "eslint-plugin-functype"
|
|
16
16
|
|
|
17
|
-
export default [functype.configs.recommended]
|
|
17
|
+
export default [functype.configs.recommended, functype.configs.tests]
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
There is one preset. The code it checks is written by coding agents, and an agent acts on what fails its build and passes over a warning, so every rule is `error` or `off`. `tests` relaxes it for test files.
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
- **`error`:** every rule whose precision is measured on real code. A forgotten `.run()`, a dropped `Either` or a throw in render is the kind of mistake an agent makes and a reviewer misses.
|
|
23
|
+
- **`off`:** `prefer-flatmap` and `prefer-do-notation`, whose precision is unmeasured. At `error` they would teach an agent to write `eslint-disable`. Each moves to `error` once it's measured.
|
|
24
|
+
- **At a real boundary, mark it** rather than disable the rule: `@interop <reason>` or `invariant()` for a throw (see below), `Wire<T>` for a data shape.
|
|
25
|
+
- **Type-aware rules:** `no-array-mutation`, `no-floating-io`, `no-floating-result` and `no-serialize-container` need typescript-eslint's parser with `parserOptions.projectService`. Without it they report nothing.
|
|
26
|
+
- **Make sure the agent runs lint.** An error it never sees doesn't steer it, so put `eslint` in the check it runs before it's done, such as `pnpm validate`.
|
|
24
27
|
|
|
25
|
-
|
|
26
|
-
```
|
|
28
|
+
In 1.x the plugin had three presets: `recommended` and `strict`, which warned on rules still being measured, and `agent`, which didn't. 2.0's `recommended` is 1.x's `agent`, and `strict` and `agent` are gone: a config that names one fails to load (ESLint reports an `Unexpected undefined config`), so update it to `recommended`.
|
|
27
29
|
|
|
28
|
-
|
|
30
|
+
## TypeScript 7
|
|
29
31
|
|
|
30
|
-
|
|
32
|
+
typescript-eslint, which this plugin runs on, doesn't support TypeScript 7 yet: it loads the TypeScript 6 compiler API, and TypeScript 7.0 ships none. With `typescript@7` as a project's only `typescript`, `npm install` fails on typescript-eslint's peer range, and a forced install fails at lint time with "typescript-eslint does not support TS 7.0". Two paths work today.
|
|
31
33
|
|
|
32
|
-
|
|
33
|
-
import functype from "eslint-plugin-functype"
|
|
34
|
+
**Run TypeScript 7 side by side with 6.0, which is the setup Microsoft and typescript-eslint point to.** Alias `typescript` to the 6.0 package, so lint loads the 6.0 API, and install TypeScript 7 as `@typescript/native`:
|
|
34
35
|
|
|
35
|
-
|
|
36
|
+
```json
|
|
37
|
+
{
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"typescript": "npm:@typescript/typescript6@6.0.2",
|
|
40
|
+
"@typescript/native": "npm:typescript@7.0.2"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
36
43
|
```
|
|
37
44
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
45
|
+
`tsc` is then TypeScript 7 and `tsc6` is 6.0. Keep the name `@typescript/native`: under npm, the name decides which package's `tsc` gets linked, and with another alias name `tsc` ran 6.0. typescript-eslint 8.73.0 also declares an optional peer `@typescript/native` for TypeScript 7.1 builds, so a package manager may warn that 7.0.2 misses its range, or install a 7.1 nightly beside it; lint results are the same either way. ESLint, typescript-eslint and every rule here, the type-aware ones included, run unchanged. Checked on 2026-11-22 with typescript-eslint 8.73.0, ESLint 10.14.0 and this plugin's 2.127.2: `no-floating-result` and `no-array-mutation` reported, and `tsc` 7.0.2 type-checked the same project.
|
|
46
|
+
|
|
47
|
+
**Or run the plugin in Oxlint, without type information.** Oxlint loads it as a JS plugin, unchanged, on a project with only TypeScript 7. In `.oxlintrc.json`:
|
|
48
|
+
|
|
49
|
+
```json
|
|
50
|
+
{
|
|
51
|
+
"jsPlugins": ["eslint-plugin-functype"],
|
|
52
|
+
"rules": { "functype/no-let": "error", "functype/prefer-option": "error", "functype/prefer-list": "error" }
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Every rule that works without type information works there. The four type-aware rules, `no-array-mutation`, `no-floating-io`, `no-floating-result` and `no-serialize-container`, report nothing, because Oxlint doesn't pass type information to JS plugins yet. Checked on 2026-11-22 with Oxlint 1.94.0.
|
|
57
|
+
|
|
58
|
+
When typescript-eslint supports TypeScript 7.1's new compiler API, the 6.0 alias can go and nothing in this plugin changes; its `@typescript/native` peer suggests that name stays. Until then, prefer the side-by-side setup, which keeps the type-aware rules.
|
|
43
59
|
|
|
44
60
|
## Rules
|
|
45
61
|
|
|
46
|
-
| Rule |
|
|
47
|
-
| ---------------------------------------- |
|
|
48
|
-
| `functype/no-let` |
|
|
49
|
-
| `functype/no-imperative-loops` |
|
|
50
|
-
| `functype/prefer-functype-map` |
|
|
51
|
-
| `functype/prefer-functype-set` |
|
|
52
|
-
| `functype/collection-naming` |
|
|
53
|
-
| `functype/prefer-map` |
|
|
54
|
-
| `functype/prefer-fold` | error
|
|
55
|
-
| `functype/prefer-option` |
|
|
56
|
-
| `functype/prefer-either` |
|
|
57
|
-
| `functype/prefer-try` |
|
|
58
|
-
| `functype/prefer-flatmap` |
|
|
59
|
-
| `functype/prefer-do-notation` |
|
|
60
|
-
| `functype/no-get-unsafe` |
|
|
61
|
-
| `functype/prefer-list` |
|
|
62
|
-
| `functype/no-array-mutation` |
|
|
63
|
-
| `functype/no-floating-io` |
|
|
64
|
-
| `functype/no-floating-result` |
|
|
65
|
-
| `functype/no-serialize-container` |
|
|
66
|
-
| `functype/no-getOrThrow-in-render` |
|
|
67
|
-
| `functype/must-fold-on-component-return` |
|
|
62
|
+
| Rule | `recommended` | `tests` | Description |
|
|
63
|
+
| ---------------------------------------- | :-----------: | :-----: | -------------------------------------------------------------------------------------------- |
|
|
64
|
+
| `functype/no-let` | error | | Use `const`; no reassignment |
|
|
65
|
+
| `functype/no-imperative-loops` | error | | Use `List`/array methods, async traversal or `IO.forEach` instead of loops |
|
|
66
|
+
| `functype/prefer-functype-map` | error | | Use functype `Map` instead of a native `Map` you only read |
|
|
67
|
+
| `functype/prefer-functype-set` | error | | Use functype `Set` instead of a native `Set` you only read |
|
|
68
|
+
| `functype/collection-naming` | error | | Import functype's `Map`/`Set` under their own names; spell the built-in `globalThis.Map` |
|
|
69
|
+
| `functype/prefer-map` | error | | Use `map` instead of pushing inside `forEach` |
|
|
70
|
+
| `functype/prefer-fold` | error¹ | | Use `fold` instead of branching on `isSome()`/`isLeft()`/⦠|
|
|
71
|
+
| `functype/prefer-option` | error | off | Use `Option` instead of `null`/`undefined` |
|
|
72
|
+
| `functype/prefer-either` | error | off | Use `Either` for typed domain errors instead of `throw` |
|
|
73
|
+
| `functype/prefer-try` | error | off | Use `Try` / `Try.fromPromise` instead of try/catch |
|
|
74
|
+
| `functype/prefer-flatmap` | off | | Use `flatMap` instead of `map().flat()` |
|
|
75
|
+
| `functype/prefer-do-notation` | off | | Use `Do` notation for chained operations |
|
|
76
|
+
| `functype/no-get-unsafe` | error² | | Disallow unsafe extraction (`.orThrow()`, `.expect()`) |
|
|
77
|
+
| `functype/prefer-list` | error | | Use `List` instead of native arrays |
|
|
78
|
+
| `functype/no-array-mutation` | error | | Don't change an array in place (`push`, `sort`, `xs[i] = v`ā¦); build a new one |
|
|
79
|
+
| `functype/no-floating-io` | error | | Don't build an `IO` and drop it, or `await` it unrun; run, return or `yield*` it |
|
|
80
|
+
| `functype/no-floating-result` | error | off | Don't drop an `Either`/`Try` result; a failure in it is silently ignored |
|
|
81
|
+
| `functype/no-serialize-container` | error | off | Don't send an `Either`/`Option`/`List` to `c.json()` or `JSON.stringify()`; unwrap it first |
|
|
82
|
+
| `functype/no-getOrThrow-in-render` | error | | React: no bare `.orThrow()` in a component or hook body; a throw in render unmounts the tree |
|
|
83
|
+
| `functype/must-fold-on-component-return` | error | | React: render an `Option`/`Either`/`Try` with `fold` or `<MatchOption>`, not a guard or `&&` |
|
|
84
|
+
|
|
85
|
+
¹ With `checkGuards: true`: a guard followed by an unwrap is reported too.
|
|
86
|
+
² Allowed in test files by its own `allowInTests` option.
|
|
68
87
|
|
|
69
88
|
### Severity policy
|
|
70
89
|
|
|
71
|
-
A rule is **`error`
|
|
90
|
+
A rule is **`error` once it is right on ~95ā99% of real code**, meaning its known false-positive classes are closed. Until then it is `off`, never `warn`: a warning is advice an agent passes over, and a rule that is reliably right should fail the build.
|
|
72
91
|
|
|
73
92
|
`prefer-fold` reports only; its rewrite is a suggestion you apply, never an autofix, so `eslint --fix` can't change code on your behalf.
|
|
74
93
|
|
|
@@ -83,7 +102,7 @@ A rule is **`error` in `recommended` once it is right on ~95ā99% of real code*
|
|
|
83
102
|
| A router's control flow: `throw redirect(ā¦)` or `throw notFound()` in a loader or route guard | nothing: recognized by its import (below) |
|
|
84
103
|
| Anything that can fail in normal operation | return an `Either` |
|
|
85
104
|
|
|
86
|
-
```ts
|
|
105
|
+
```ts ignore
|
|
87
106
|
import { invariant } from "functype"
|
|
88
107
|
|
|
89
108
|
function deriveRunId(workflowId: string, step: number): string {
|
|
@@ -119,7 +138,7 @@ TanStack Router redirects or shows Not found only when `beforeLoad` or `loader`
|
|
|
119
138
|
| `react-router` | `redirect`, `redirectDocument`, `replace`, `data` |
|
|
120
139
|
| `react-router-dom` (React Router 6), `@remix-run/node`, `@remix-run/cloudflare` | `redirect`, `redirectDocument`, `replace`, `data`, `json` |
|
|
121
140
|
|
|
122
|
-
```ts
|
|
141
|
+
```ts ignore
|
|
123
142
|
import { redirect } from "@tanstack/react-router"
|
|
124
143
|
|
|
125
144
|
beforeLoad: ({ params }) => {
|
|
@@ -136,11 +155,11 @@ Prefer either tool to `eslint-disable`. A disable covers a whole file or line an
|
|
|
136
155
|
|
|
137
156
|
### `functype/prefer-list`
|
|
138
157
|
|
|
139
|
-
| Option | Default | Description
|
|
140
|
-
| --------------------- | :-----: |
|
|
141
|
-
| `allowArraysInTests` | `true` | Silence the rule inside test files (`.test.ts`, `.spec.ts`, `__tests__/`, `/test/`, `/tests/`).
|
|
142
|
-
| `allowReadonlyArrays` | `true` | When `true`, `ReadonlyArray<T
|
|
143
|
-
| `allowArrayLiterals` | `false` | When `true`, `const xs = [1, 2, 3]` is not reported. Useful when you want type-position enforcement but tolerate idiomatic literals like `[...map.entries()]`. Mutable `T[]` in type positions is always reported regardless.
|
|
158
|
+
| Option | Default | Description |
|
|
159
|
+
| --------------------- | :-----: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
160
|
+
| `allowArraysInTests` | `true` | Silence the rule inside test files (`.test.ts`, `.spec.ts`, `__tests__/`, `/test/`, `/tests/`). |
|
|
161
|
+
| `allowReadonlyArrays` | `true` | When `true`, `ReadonlyArray<T>`, `readonly T[]` **and** `Readonly<T[]>` pass. When `false`, all three are flagged consistently. Use `false` in combination with `Wire<T>` from `functype` to hold the rule at `error` ā every unmarked `ReadonlyArray<T>` becomes a lint error, and wrapping a boundary type in `Wire<ā¦>` is the explicit escape hatch. |
|
|
162
|
+
| `allowArrayLiterals` | `false` | When `true`, `const xs = [1, 2, 3]` is not reported. Useful when you want type-position enforcement but tolerate idiomatic literals like `[...map.entries()]`. Mutable `T[]` in type positions is always reported regardless. |
|
|
144
163
|
|
|
145
164
|
**What it reports.** The defect is a collection that can change under you, so:
|
|
146
165
|
|
|
@@ -161,7 +180,7 @@ Prefer either tool to `eslint-disable`. A disable covers a whole file or line an
|
|
|
161
180
|
|
|
162
181
|
**Without type information, array literals aren't reported at all.** The rule can't tell a literal handed to a library from one of your own, so it reports neither rather than guess. Type positions and in-place mutation are still reported. Turn on type-aware linting to get literal checks.
|
|
163
182
|
|
|
164
|
-
Also skipped: `as const` and other tuple assertions, tuple rest elements (`[string, ...string[]]`), rest parameters (`...args: T[]`), literals passed straight into `List(ā¦)` / `Set(ā¦)`, and files marked generated (`@generated`, "auto-generated", "DO NOT EDIT").
|
|
183
|
+
Also skipped: `as const` and other tuple assertions, tuple rest elements (`[string, ...string[]]`), rest parameters (`...args: T[]`), literals passed straight into `List(ā¦)` / `Set(ā¦)`, and files marked generated (`@generated`, "auto-generated", "DO NOT EDIT"). Supabase's generated types carry no marker, so a file whose top level exports both `Json` and `Database` is skipped too. Any other generator with no marker needs an `ignores` entry. Anything still reported that is a deliberate host shape gets `Wire<ā¦>`.
|
|
165
184
|
|
|
166
185
|
Measured on five consumers (2026-10-10), with type-aware linting: **2,000 hits under 2.114, 696 after.** By repo, before ā after: a private app monorepo 821 ā 215, agent-todo 843 ā 328, dokploy-mcp-server 170 ā 68, ts-builds 111 ā 43, supabase-typed-query 55 ā 42. Known false positives left: 25 hits in agent-todo's unmarked Supabase types (an `ignores` entry), one nested ReactFlow return type (`Wire`), one AWS SES request built in an untyped object. Linting all of that monorepo with the rule on takes about 18 seconds.
|
|
167
186
|
|
|
@@ -194,7 +213,7 @@ Reports changing an array in place:
|
|
|
194
213
|
|
|
195
214
|
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
215
|
|
|
197
|
-
```ts
|
|
216
|
+
```ts ignore
|
|
198
217
|
rows.push(row) // reported ā [...rows, row], or build rows with map / flatMap
|
|
199
218
|
xs.sort(byRank) // reported ā xs.toSorted(byRank)
|
|
200
219
|
xs[i] = v // reported ā xs.with(i, v)
|
|
@@ -215,7 +234,9 @@ For a host that has to mutate, such as a charting library that takes the array i
|
|
|
215
234
|
| `allowInTests` | `true` | Silence the rule inside test files. |
|
|
216
235
|
| `allowInteropMarker` | `true` | Skip code inside a declaration tagged `@interop <reason>`. |
|
|
217
236
|
|
|
218
|
-
Measured on five consumers (2026-10-10): 91 hits, every one a real in-place mutation. Most were `push` accumulators building a list or a Markdown body line by line; the rest were `sort` on a named array and element assignment. It's `
|
|
237
|
+
Measured on five consumers (2026-10-10): 91 hits, every one a real in-place mutation. Most were `push` accumulators building a list or a Markdown body line by line; the rest were `sort` on a named array and element assignment. It's `error` in every preset since 2.0. In 1.x it was `off` in `recommended`, to avoid failing builds on a minor upgrade.
|
|
238
|
+
|
|
239
|
+
A local array that is declared and then changed by a method or an index write (`acc.push(x)`, `acc[i] = x`) is reported once, here at the change: with type information, `prefer-list` leaves its declaration to this rule. Without type information this rule reports nothing, so `prefer-list` reports the declaration instead. A field, a change through an alias, `acc[i]++` and `delete acc[i]` can still be reported by both. The dedupe assumes this rule is on, as it is in `recommended`.
|
|
219
240
|
|
|
220
241
|
### `functype/no-floating-io`
|
|
221
242
|
|
|
@@ -226,7 +247,7 @@ Reports an `IO` that is built and never run, so it does nothing:
|
|
|
226
247
|
|
|
227
248
|
`no-floating-promises` and `await-thenable` miss both, because `IO` isn't thenable.
|
|
228
249
|
|
|
229
|
-
```ts
|
|
250
|
+
```ts ignore
|
|
230
251
|
log.info("saved") // reported, when info returns an IO ā yield* it, or .run() it
|
|
231
252
|
save(user).tap(audit) // reported ā return it, or run it
|
|
232
253
|
const user = await loadUser(id) // reported: user is the IO ā await loadUser(id).runOrThrow()
|
|
@@ -236,13 +257,13 @@ void save(user) // fine: a deliberate drop
|
|
|
236
257
|
|
|
237
258
|
**It only runs with type-aware linting** (`parserOptions.projectService`). It recognizes `IO` by its type (it has `runExit` and `provideLayer`), whatever the call is named. Without type information it reports nothing.
|
|
238
259
|
|
|
239
|
-
Measured (2026-10-16) on functype's own source and tests, functype-log, functype-react, agent-todo's agent-gate-api and a private web app's API: 0 false positives across about 1,340 IO-typed calls. The only hits were four deliberate drops in type-only tests. It's `
|
|
260
|
+
Measured (2026-10-16) on functype's own source and tests, functype-log, functype-react, agent-todo's agent-gate-api and a private web app's API: 0 false positives across about 1,340 IO-typed calls. The only hits were four deliberate drops in type-only tests. It's `error` in `recommended`.
|
|
240
261
|
|
|
241
262
|
### `functype/no-floating-result`
|
|
242
263
|
|
|
243
264
|
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
265
|
|
|
245
|
-
```ts
|
|
266
|
+
```ts ignore
|
|
246
267
|
await userService.updateSubscription(id, plan) // reported: a failed write goes unnoticed
|
|
247
268
|
parse(input) // reported, when parse returns an Either
|
|
248
269
|
await save(user).run() // reported: run() returns an Either ā check it, or use runOrThrow()
|
|
@@ -252,20 +273,20 @@ await audit.write(entry).tapLeft((e) => log.error(e)) // fine: a best-effort wri
|
|
|
252
273
|
void (await cache.refresh()) // fine: a deliberate drop
|
|
253
274
|
```
|
|
254
275
|
|
|
255
|
-
- **What counts:** a type, or a member of its union, with `fold` and `isLeft` or `isFailure`. That covers `Either`, `Try`, `Exit`, `Validation
|
|
276
|
+
- **What counts:** a type, or a member of its union, with `fold` and `isLeft` or `isFailure`. That covers `Either`, `Try`, `Exit`, `Validation` and Either-shaped wrappers such as a `ServiceResult`. An ignored `Option` or `List` loses no error, so it isn't reported. An `IO` that is never run is `no-floating-io`'s.
|
|
256
277
|
- **Handled chains:** a chain that passes through `.tapError(ā¦)` or `.tapLeft(ā¦)` isn't reported, because it handles its failure. A `.flatMap(ā¦)` after the handler can bring in a new failure, so that chain is reported again. `Try` has no failure tap, so mark a deliberate `Try` drop with `void`.
|
|
257
278
|
- **Tests:** a test that calls something for its side effect and then checks mocks is reported too. Assert on the result, or turn the rule off for test files.
|
|
258
279
|
- **Not seen yet:** a drop inside a callback, such as `xs.forEach((x) => save(x))`, or in the first part of a comma expression, isn't its own statement, so it isn't reported. `ok && save(x)` and `ok ? a() : b()` are.
|
|
259
280
|
|
|
260
281
|
**It only runs with type-aware linting** (`parserOptions.projectService`). Without type information it reports nothing.
|
|
261
282
|
|
|
262
|
-
Measured (2026-10-30) on agent-todo's agent-gate-api, which kept a hand-written check for this: at the commit that added that check, the rule reports 20 drops in production code. agent-todo fixed every one of them as a real bug, among them 8 in the Stripe webhook handler, where a failed write still answered Stripe 200. On the current code, after those fixes, it reports none in production code and 12 in tests. functype-os, functype-log, functype-react, functype-eval and functype-mcp-server report none. It's `error` in `
|
|
283
|
+
Measured (2026-10-30) on agent-todo's agent-gate-api, which kept a hand-written check for this: at the commit that added that check, the rule reports 20 drops in production code. agent-todo fixed every one of them as a real bug, among them 8 in the Stripe webhook handler, where a failed write still answered Stripe 200. On the current code, after those fixes, it reports none in production code and 12 in tests. functype-os, functype-log, functype-react, functype-eval and functype-mcp-server report none. It's `error` in `recommended`, and `off` in `tests`, where a result is often dropped on purpose.
|
|
263
284
|
|
|
264
285
|
### `functype/no-serialize-container`
|
|
265
286
|
|
|
266
287
|
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
288
|
|
|
268
|
-
```ts
|
|
289
|
+
```ts ignore
|
|
269
290
|
return c.json(await svc.getDetails(id)) // reported: sends the Either's envelope
|
|
270
291
|
return c.json({ user, subscription: details }) // reported, at subscription
|
|
271
292
|
return JSON.stringify({ success: true, checkout }) // reported, at checkout: an MCP tool reporting success on failure
|
|
@@ -281,26 +302,11 @@ return c.json(result.toJSON()) // fine: the envelope on purpose
|
|
|
281
302
|
|
|
282
303
|
**It only runs with type-aware linting** (`parserOptions.projectService`). Without type information it reports nothing.
|
|
283
304
|
|
|
284
|
-
Measured (2026-10-31) on agent-todo's agent-gate-api, which kept a hand-written check for this. Before its fix commit (f002b90), the rule reports 4 calls, and each is a bug agent-todo fixed: `GET /billing`, which showed every paying user "billing account isn't properly linked" for about nine months; `PATCH /user/me` and `PATCH /user/preferences`, which answered 200 with a `Left` in the body; and an MCP tool that reported success on failure. On the current code it reports none, and none in agent-todo's UI or in functype's own packages. It's `error` in `
|
|
305
|
+
Measured (2026-10-31) on agent-todo's agent-gate-api, which kept a hand-written check for this. Before its fix commit (f002b90), the rule reports 4 calls, and each is a bug agent-todo fixed: `GET /billing`, which showed every paying user "billing account isn't properly linked" for about nine months; `PATCH /user/me` and `PATCH /user/preferences`, which answered 200 with a `Left` in the body; and an MCP tool that reported success on failure. On the current code it reports none, and none in agent-todo's UI or in functype's own packages. It's `error` in `recommended`, and `off` in `tests`, which assert on a container's `JSON.stringify` envelope.
|
|
285
306
|
|
|
286
307
|
### React rules
|
|
287
308
|
|
|
288
|
-
Two rules are for React code. They fire only inside a **component** (a function named in PascalCase whose body has JSX, including one wrapped in `memo` or `forwardRef`) or a **hook** (a function named `use` + a capital letter), so other code rarely trips them. The one exception is a non-React function whose name starts with `use` + a capital letter, which is read as a hook. Both are `
|
|
289
|
-
|
|
290
|
-
```js
|
|
291
|
-
import functype from "eslint-plugin-functype"
|
|
292
|
-
|
|
293
|
-
export default [
|
|
294
|
-
functype.configs.recommended,
|
|
295
|
-
{
|
|
296
|
-
files: ["**/*.tsx", "**/*.jsx"],
|
|
297
|
-
rules: {
|
|
298
|
-
"functype/no-getOrThrow-in-render": "error",
|
|
299
|
-
"functype/must-fold-on-component-return": "warn",
|
|
300
|
-
},
|
|
301
|
-
},
|
|
302
|
-
]
|
|
303
|
-
```
|
|
309
|
+
Two rules are for React code. They fire only inside a **component** (a function named in PascalCase whose body has JSX, including one wrapped in `memo` or `forwardRef`) or a **hook** (a function named `use` + a capital letter), so other code rarely trips them. The one exception is a non-React function whose name starts with `use` + a capital letter, which is read as a hook. Both are `error` in `recommended`.
|
|
304
310
|
|
|
305
311
|
Both work without type information. With it (`parserOptions.projectService`), the receiver must also be a functype container, so an unrelated object that happens to have an `orThrow` or `isSome` method is not reported.
|
|
306
312
|
|
|
@@ -310,7 +316,7 @@ Only the component's or hook's own body counts as render. An event handler, an e
|
|
|
310
316
|
|
|
311
317
|
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
318
|
|
|
313
|
-
```tsx
|
|
319
|
+
```tsx ignore
|
|
314
320
|
function Profile({ user }: { user: Option<User> }) {
|
|
315
321
|
const u = user.orThrow() // reported ā user.fold(() => <SignIn />, (u) => <Card user={u} />)
|
|
316
322
|
return <Card user={u} />
|
|
@@ -342,7 +348,7 @@ Reports a component that chooses what it renders by asking an `Option`, `Either`
|
|
|
342
348
|
- 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
349
|
- a **short-circuit**: `{user.isSome() && <Card />}`, which renders one case and silently drops the other.
|
|
344
350
|
|
|
345
|
-
```tsx
|
|
351
|
+
```tsx ignore
|
|
346
352
|
function Profile({ user }: { user: Option<User> }) {
|
|
347
353
|
if (user.isNone()) return <SignIn /> // reported
|
|
348
354
|
return <Card user={user.orThrow()} />
|
|
@@ -361,7 +367,7 @@ const header = <h1>{user.isSome() && <Badge />}</h1> // reported ā {user.fold(
|
|
|
361
367
|
|
|
362
368
|
The message names the `Match` component that fits: `<MatchOption>` for `isSome`/`isNone`, `<MatchEither>` for `isLeft`/`isRight`, `<MatchTry>` for `isSuccess`/`isFailure`.
|
|
363
369
|
|
|
364
|
-
A ternary or an if/else on a predicate is `prefer-fold`'s, everywhere, so this rule leaves it alone rather than report it twice.
|
|
370
|
+
A ternary or an if/else on a predicate is `prefer-fold`'s, everywhere, so this rule leaves it alone rather than report it twice. `prefer-fold`'s `checkGuards` is on in `recommended`, so an early return followed by an unwrap is reported by both rules. Only a predicate _call_ counts: `state.isPending` on a `useIO` result and `items.isEmpty` are properties, and are never reported. A guard that does other work before it returns, or returns something other than JSX or `null`, is not reported either. The rule reports only; there are no suggestions, because the rewrite moves code between branches.
|
|
365
371
|
|
|
366
372
|
| Option | Default | Description |
|
|
367
373
|
| -------------------- | :-----: | ---------------------------------------------------------- |
|
|
@@ -381,7 +387,7 @@ Measured (2026-10-25) with both rules on functype-react's source and tests (type
|
|
|
381
387
|
|
|
382
388
|
`.orThrow(error)` and `.orThrow((e) => error)` are not reported: the caller chose the error, which is the documented way to throw for a host that needs it (see the decision table above). A bare `.orThrow()` throws a generic error and is reported.
|
|
383
389
|
|
|
384
|
-
The rule reports each match with two suggestions ā `.
|
|
390
|
+
The rule reports each match with two suggestions ā `.getOrElse(() => default)` for value fallback and `.fold(onNone, onSome)` for branch handling. There is no autofix: the correct replacement depends on human judgment about a default value, and `.expect(msg)` would silently lose its argument. Apply a suggestion explicitly in your editor when you know which one fits.
|
|
385
391
|
|
|
386
392
|
### `functype/prefer-fold`
|
|
387
393
|
|
|
@@ -389,16 +395,16 @@ The rule reports each match with two suggestions ā `.orElse(default)` for valu
|
|
|
389
395
|
| --------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
390
396
|
| `minComplexity` | `2` | Minimum if/else chain length (root + branches) before it is reported. |
|
|
391
397
|
| `checkNullable` | `false` | Also report null checks on plain values (`x === null ? a : b`). Off because whether `x` should be an `Option` is `prefer-option`'s call; at `error` this path fired on JSX, style objects and conditional spreads. |
|
|
392
|
-
| `checkGuards` | `false` | Also report a guard followed by an unwrap: `if (e.isLeft()) return ā¦` and then `e.value` / `e.orThrow()` / `e.get()` later in the same block.
|
|
398
|
+
| `checkGuards` | `false` | Also report a guard followed by an unwrap: `if (e.isLeft()) return ā¦` and then `e.value` / `e.orThrow()` / `e.get()` later in the same block. On in `recommended`. |
|
|
393
399
|
|
|
394
|
-
Reports only; the rewrite is a **suggestion, never an autofix**. A fold rewrite can't be proven type-correct without type information, and `eslint --fix` applies fixable rules at warn severity too, so an autofix here would rewrite working code during `validate`. The suggestion reads narrowed values through the fold's parameters (`e.value` after `isLeft()` becomes `left`), omits unused parameters, keeps `return` on if/else chains, parenthesizes object-literal branches, and offers `a.
|
|
400
|
+
Reports only; the rewrite is a **suggestion, never an autofix**. A fold rewrite can't be proven type-correct without type information, and `eslint --fix` applies fixable rules at warn severity too, so an autofix here would rewrite working code during `validate`. The suggestion reads narrowed values through the fold's parameters (`e.value` after `isLeft()` becomes `left`), omits unused parameters, keeps `return` on if/else chains, parenthesizes object-literal branches, and offers `a.orElse(() => b)` for `a.isSome() ? a : b`. Rewrites follow the syntax tree, so text inside strings, template literals and comments is left alone. No suggestion is offered when the rewrite would drop a comment or could not type-check (`a.isSome() ? a : 5`). Suggestions are applied by hand, so review each one: the rule has no type information and can't prove the result compiles.
|
|
395
401
|
|
|
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: `
|
|
402
|
+
**`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: `getOrElse(() => 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
403
|
|
|
398
|
-
```ts
|
|
404
|
+
```ts ignore
|
|
399
405
|
if (e.isLeft()) return e // hands the failure back ā e.flatMap(ā¦) / e.map(ā¦)
|
|
400
406
|
if (e.isLeft()) return Left({ kind: e.value.kind }) // a new failure ā e.mapLeft(ā¦).flatMap(ā¦)
|
|
401
|
-
if (o.isNone()) return 0 // a fallback ā o.map(ā¦).
|
|
407
|
+
if (o.isNone()) return 0 // a fallback ā o.map(ā¦).getOrElse(() => 0), or o.fold(() => 0, ā¦)
|
|
402
408
|
if (r.isLeft()) return c.json({ error: r.value }, 500) // fallback reads the failure ā r.fold(ā¦), only
|
|
403
409
|
if (a.isLeft()) return a
|
|
404
410
|
if (b.isLeft()) return b // several in a row ā Do(function* () { ⦠})
|
|
@@ -411,7 +417,7 @@ if (t.isFailure()) {
|
|
|
411
417
|
|
|
412
418
|
`orThrow(error)` / `orThrow((e) => ā¦)` after a guard isn't counted as an unwrap, matching `no-get-unsafe`, which treats a named error as a deliberate host throw. A receiver reassigned after the guard isn't reported. Only the negative predicates (`isLeft` / `isNone` / `isFailure`) are matched; `if (!e.isRight())` isn't yet.
|
|
413
419
|
|
|
414
|
-
Pass-through guards are the clear case: they are hand-written `flatMap`. Fallback and other-work-first guards are closer to a style choice, since TypeScript narrows `Either` after the guard (Rust's `let-else` and Swift's `guard let` make the same trade). For `Option` and `Try` the guard doesn't narrow `.value`, so the case is stronger there.
|
|
420
|
+
Pass-through guards are the clear case: they are hand-written `flatMap`. Fallback and other-work-first guards are closer to a style choice, since TypeScript narrows `Either` after the guard (Rust's `let-else` and Swift's `guard let` make the same trade). For `Option` and `Try` the guard doesn't narrow `.value`, so the case is stronger there. It is on in `recommended`. To turn it off, set `"functype/prefer-fold": ["error", { "checkGuards": false }]`; a bare `"error"` after the preset keeps it on, because ESLint keeps the earlier options.
|
|
415
421
|
|
|
416
422
|
When the code after the guard awaits, the advice uses `flatMapAsync` / `foldAsync`. Declarations tagged `@interop <reason>` are skipped. On a private app monorepo it finds 75 guards, all of this shape.
|
|
417
423
|
|
|
@@ -432,7 +438,7 @@ A union nested in a union, such as `(string | null) | undefined`, is read as one
|
|
|
432
438
|
|
|
433
439
|
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
440
|
|
|
435
|
-
```ts
|
|
441
|
+
```ts ignore
|
|
436
442
|
type Props = {
|
|
437
443
|
a?: string // fine
|
|
438
444
|
b: string | undefined // fine: the same "may be absent" as a?
|
|
@@ -450,11 +456,11 @@ Return types, variables, class fields and generic arguments (`Array<string | und
|
|
|
450
456
|
| Option | Default | Description |
|
|
451
457
|
| ------------------- | ------- | ----------------------------------------------------------------------------------------- |
|
|
452
458
|
| `minChainDepth` | `3` | Report a `.flatMap(ā¦)` chain once it has this many `flatMap`/`map`/`filter`/`fold` steps. |
|
|
453
|
-
| `detectMixedMonads` | `true` | Report a composition chain that moves between Option, Either
|
|
459
|
+
| `detectMixedMonads` | `true` | Report a composition chain that moves between Option, Either and Try. |
|
|
454
460
|
|
|
455
461
|
It reports three shapes, each once, at the outermost step:
|
|
456
462
|
|
|
457
|
-
```ts
|
|
463
|
+
```ts ignore
|
|
458
464
|
o.flatMap(f).flatMap(g).flatMap(h) // a flatMap chain 3 steps deep ā Do notation
|
|
459
465
|
Option(x)
|
|
460
466
|
.flatMap((v) => Either.right(v))
|
|
@@ -462,7 +468,7 @@ Option(x)
|
|
|
462
468
|
user && user.profile && user.profile.name // a guard on each step of a path ā user?.profile?.name
|
|
463
469
|
```
|
|
464
470
|
|
|
465
|
-
- **Only chains on a monad count.** With type information the type of the value each step is called on decides, so an array's `.flatMap(ā¦)` chain is never reported, and neither is one after `.getOrElse([])` or `.fold(ā¦)` has unwrapped the monad. Without it, the chain must start from a monad constructor, companion or conversion (`Option(x)`, `Either.right(x)`, `Try(f).toOption()`), an identifier annotated with a monad type, or one named like a monad (`option`, `result`, or a capitalized suffix such as `userOption`; `entry` and `registry` don't count).
|
|
471
|
+
- **Only chains on a monad count.** With type information the type of the value each step is called on decides, so an array's `.flatMap(ā¦)` chain is never reported, and neither is one after `.getOrElse(() => [])` or `.fold(ā¦)` has unwrapped the monad. Without it, the chain must start from a monad constructor, companion or conversion (`Option(x)`, `Either.right(x)`, `Try(f).toOption()`), an identifier annotated with a monad type, or one named like a monad (`option`, `result`, or a capitalized suffix such as `userOption`; `entry` and `registry` don't count).
|
|
466
472
|
- **Mixing is read along the chain**, from the monad each step's callback returns. A conversion such as `.toOption()` keeps the chain in one monad, and a monad built somewhere inside a callback isn't a step.
|
|
467
473
|
- **A guard chain is read from the AST.** Each operand must be a property of the one before it, so `isAdmin && settings.theme && user.profile.name` isn't one.
|
|
468
474
|
- **It has no autofix.** It reports only, so `eslint --fix` can't change code on its behalf.
|
|
@@ -541,7 +547,7 @@ import functype from "eslint-plugin-functype"
|
|
|
541
547
|
export default [recommended, functype.configs.recommended, testOverrides, functype.configs.tests]
|
|
542
548
|
```
|
|
543
549
|
|
|
544
|
-
`functype.configs.tests` turns off `prefer-option`, `prefer-either` and `
|
|
550
|
+
`functype.configs.tests` turns off `prefer-option`, `prefer-either`, `prefer-try`, `no-floating-result` and `no-serialize-container` for the same test files as `test-overrides`: tests call plain `T | undefined` APIs, assert on thrown errors, drop results on purpose and assert on `JSON.stringify` envelopes. It changes no other rule. `no-let` and `no-imperative-loops` already skip test files themselves, unless you set their `allowInTests: false`. Put both after the recommended configs, so they win.
|
|
545
551
|
|
|
546
552
|
## License
|
|
547
553
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-rules.js","names":["plugin","colors","colorize","color","text","printDependencyStatus","result","icon","dep","warning","status","statusColor","main","args","showHelp","showUsage","checkDeps","validatePeerDependencies","rules","rule","ruleName","fullName","typeColor","printCustomUsageInfo","error"],"sources":["../../src/cli/list-rules.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport plugin from \"../index.js\"\nimport { validatePeerDependencies, type ValidationResult } from \"../utils/dependency-validator.js\"\n\n// Colors for console output\nconst colors = {\n reset: \"\\x1b[0m\",\n bright: \"\\x1b[1m\",\n red: \"\\x1b[31m\",\n green: \"\\x1b[32m\",\n yellow: \"\\x1b[33m\",\n blue: \"\\x1b[34m\",\n magenta: \"\\x1b[35m\",\n cyan: \"\\x1b[36m\",\n} as const\n\nfunction colorize(text: string, color: keyof typeof colors): string {\n return colors[color] + text + colors.reset\n}\n\n// Removed unused utility functions - they were for the old config-based approach\n\nfunction printDependencyStatus(result: ValidationResult): void {\n console.log(colorize(\"\\nš Dependency Status Check:\", \"bright\"))\n console.log(colorize(\"=\".repeat(40), \"blue\"))\n\n // Show available dependencies\n if (result.available.length > 0) {\n console.log(colorize(\"\\nā
Available:\", \"green\"))\n result.available.forEach((dep) => {\n const icon = dep.required ? \"š§\" : \"š\"\n console.log(` ${icon} ${colorize(dep.name, \"green\")} - ${dep.description}`)\n })\n }\n\n // Show missing dependencies\n if (result.missing.length > 0) {\n console.log(colorize(\"\\nā Missing:\", \"red\"))\n result.missing.forEach((dep) => {\n const icon = dep.required ? \"ā ļø \" : \"š”\"\n const color = dep.required ? \"red\" : \"yellow\"\n console.log(` ${icon} ${colorize(dep.name, color)} - ${dep.description}`)\n })\n\n if (result.installCommand) {\n console.log(colorize(\"\\nš¦ Install missing dependencies:\", \"bright\"))\n console.log(` ${colorize(result.installCommand, \"cyan\")}`)\n }\n }\n\n // Show warnings\n if (result.warnings.length > 0) {\n console.log(colorize(\"\\nā ļø Warnings:\", \"yellow\"))\n result.warnings.forEach((warning) => console.log(` ${warning}`))\n }\n\n // Overall status\n const status = result.isValid ? \"ā
Ready to use\" : \"ā Configuration will fail\"\n const statusColor = result.isValid ? \"green\" : \"red\"\n console.log(colorize(`\\n${status}`, statusColor))\n}\n\nasync function main(): Promise<void> {\n const args = process.argv.slice(2)\n const showHelp = args.includes(\"--help\") || args.includes(\"-h\")\n const showUsage = args.includes(\"--usage\") || args.includes(\"-u\")\n const checkDeps = args.includes(\"--check-deps\") || args.includes(\"--check\")\n\n if (showHelp) {\n console.log(colorize(\"š ESLint Plugin Functype - Custom Rules\", \"bright\"))\n console.log(\"\\nUsage: pnpm run list-rules [options]\")\n console.log(\"\\nOptions:\")\n console.log(\" --verbose, -v Show rule descriptions and schemas\")\n console.log(\" --usage, -u Show usage examples\")\n console.log(\" --check-deps Check peer dependency status\")\n console.log(\" --help, -h Show this help message\")\n console.log(\"\\nThis command lists all custom rules provided by the functype plugin.\")\n return\n }\n\n // Handle dependency check\n if (checkDeps) {\n console.log(colorize(\"š§ ESLint Plugin Functype - Dependency Check\", \"bright\"))\n const result = validatePeerDependencies()\n printDependencyStatus(result)\n\n if (!result.isValid) {\n process.exit(1)\n }\n return\n }\n\n console.log(colorize(\"š§ ESLint Plugin Functype - Custom Rules\", \"bright\"))\n\n if (!plugin.rules) {\n console.error(colorize(\"ā No rules found in plugin.\", \"red\"))\n process.exit(1)\n }\n\n console.log(colorize(\"\\nš¦ Available Custom Rules:\", \"bright\"))\n console.log(colorize(\"=\".repeat(40), \"blue\"))\n\n const rules = Object.keys(plugin.rules)\n\n rules.forEach((ruleName) => {\n const rule = plugin.rules[ruleName]\n const fullName = `functype/${ruleName}`\n\n console.log(`\\n${colorize(\"ā\", \"green\")} ${colorize(fullName, \"bright\")}`)\n\n if (rule.meta?.docs?.description) {\n console.log(` ${colorize(\"Description:\", \"cyan\")} ${rule.meta.docs.description}`)\n }\n\n if (rule.meta?.type) {\n const typeColor = rule.meta.type === \"problem\" ? \"red\" : rule.meta.type === \"suggestion\" ? \"yellow\" : \"blue\"\n console.log(` ${colorize(\"Type:\", \"cyan\")} ${colorize(rule.meta.type, typeColor)}`)\n }\n\n if (rule.meta?.fixable) {\n console.log(` ${colorize(\"Fixable:\", \"cyan\")} ${colorize(\"Yes\", \"green\")}`)\n }\n\n if (showUsage) {\n console.log(` ${colorize(\"Usage:\", \"cyan\")} \"${fullName}\": \"error\"`)\n }\n })\n\n console.log(colorize(`\\nš Summary: ${rules.length} custom rules available`, \"bright\"))\n\n if (showUsage) {\n printCustomUsageInfo()\n }\n\n console.log(colorize(\"\\nš” Tips:\", \"bright\"))\n console.log(\"⢠Use --verbose to see detailed rule information\")\n console.log(\"⢠Use --usage to see configuration examples\")\n console.log('⢠All rules are prefixed with \"functype/\"')\n console.log(\"⢠Consider using eslint-config-functype for pre-configured setup\")\n\n console.log(colorize(\"\\nš Links:\", \"bright\"))\n console.log(\"⢠Documentation: https://github.com/jordanburke/eslint-plugin-functype\")\n console.log(\"⢠Configuration Bundle: https://github.com/jordanburke/eslint-config-functype\")\n console.log(\"⢠Functype Library: https://github.com/jordanburke/functype\")\n}\n\nfunction printCustomUsageInfo(): void {\n console.log(colorize(\"\\nš” Usage Examples:\", \"bright\"))\n console.log(colorize(\"=\".repeat(30), \"blue\"))\n console.log(\"\\n\" + colorize(\"ESLint 9+ (flat config):\", \"green\"))\n console.log(' import functypePlugin from \"eslint-plugin-functype\"')\n console.log(\" export default [\")\n console.log(\" {\")\n console.log(\" plugins: { functype: functypePlugin },\")\n console.log(\" rules: {\")\n console.log(' \"functype/prefer-option\": \"error\",')\n console.log(' \"functype/prefer-either\": \"error\",')\n console.log(' \"functype/no-get-unsafe\": \"error\",')\n console.log(\" }\")\n console.log(\" }\")\n console.log(\" ]\")\n console.log(\"\\n\" + colorize(\"With eslint-config-functype (recommended):\", \"green\"))\n console.log(' import functypeConfig from \"eslint-config-functype\"')\n console.log(\" export default [functypeConfig.recommended]\")\n}\n\n// Run the CLI\nmain().catch((error) => {\n console.error(colorize(\"ā Unexpected error:\", \"red\"), error)\n process.exit(1)\n})\n"],"mappings":";uGAMA,MAAMC,EAAS,CACb,MAAO,UACP,OAAQ,UACR,IAAK,WACL,MAAO,WACP,OAAQ,WACR,KAAM,WACN,QAAS,WACT,KAAM,UACR,EAEA,SAASC,EAAS,EAAc,EAAoC,CAClE,OAAOD,EAAOE,GAASC,EAAOH,EAAO,KACvC,CAIA,SAASI,EAAsB,EAAgC,CAC7D,QAAQ,IAAIH,EAAS;6BAAiC,QAAQ,CAAC,EAC/D,QAAQ,IAAIA,EAAS,IAAI,OAAO,EAAE,EAAG,MAAM,CAAC,EAGxCI,EAAO,UAAU,OAAS,IAC5B,QAAQ,IAAIJ,EAAS;cAAkB,OAAO,CAAC,EAC/CI,EAAO,UAAU,QAAS,GAAQ,C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status","statusColor","main","args","showHelp","showUsage","checkDeps","validatePeerDependencies","rules","rule","ruleName","fullName","typeColor","printCustomUsageInfo","error"],"sources":["../../src/cli/list-rules.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport plugin from \"../index.js\"\nimport { validatePeerDependencies, type ValidationResult } from \"../utils/dependency-validator.js\"\n\n// Colors for console output\nconst colors = {\n reset: \"\\x1b[0m\",\n bright: \"\\x1b[1m\",\n red: \"\\x1b[31m\",\n green: \"\\x1b[32m\",\n yellow: \"\\x1b[33m\",\n blue: \"\\x1b[34m\",\n magenta: \"\\x1b[35m\",\n cyan: \"\\x1b[36m\",\n} as const\n\nfunction colorize(text: string, color: keyof typeof colors): string {\n return colors[color] + text + colors.reset\n}\n\n// Removed unused utility functions - they were for the old config-based approach\n\nfunction printDependencyStatus(result: ValidationResult): void {\n console.log(colorize(\"\\nš Dependency Status Check:\", \"bright\"))\n console.log(colorize(\"=\".repeat(40), \"blue\"))\n\n // Show available dependencies\n if (result.available.length > 0) {\n console.log(colorize(\"\\nā
Available:\", \"green\"))\n result.available.forEach((dep) => {\n const icon = dep.required ? \"š§\" : \"š\"\n console.log(` ${icon} ${colorize(dep.name, \"green\")} - ${dep.description}`)\n })\n }\n\n // Show missing dependencies\n if (result.missing.length > 0) {\n console.log(colorize(\"\\nā Missing:\", \"red\"))\n result.missing.forEach((dep) => {\n const icon = dep.required ? \"ā ļø \" : \"š”\"\n const color = dep.required ? \"red\" : \"yellow\"\n console.log(` ${icon} ${colorize(dep.name, color)} - ${dep.description}`)\n })\n\n if (result.installCommand) {\n console.log(colorize(\"\\nš¦ Install missing dependencies:\", \"bright\"))\n console.log(` ${colorize(result.installCommand, \"cyan\")}`)\n }\n }\n\n // Show warnings\n if (result.warnings.length > 0) {\n console.log(colorize(\"\\nā ļø Warnings:\", \"yellow\"))\n result.warnings.forEach((warning) => console.log(` ${warning}`))\n }\n\n // Overall status\n const status = result.isValid ? \"ā
Ready to use\" : \"ā Configuration will fail\"\n const statusColor = result.isValid ? \"green\" : \"red\"\n console.log(colorize(`\\n${status}`, statusColor))\n}\n\nasync function main(): Promise<void> {\n const args = process.argv.slice(2)\n const showHelp = args.includes(\"--help\") || args.includes(\"-h\")\n const showUsage = args.includes(\"--usage\") || args.includes(\"-u\")\n const checkDeps = args.includes(\"--check-deps\") || args.includes(\"--check\")\n\n if (showHelp) {\n console.log(colorize(\"š ESLint Plugin Functype - Custom Rules\", \"bright\"))\n console.log(\"\\nUsage: pnpm run list-rules [options]\")\n console.log(\"\\nOptions:\")\n console.log(\" --verbose, -v Show rule descriptions and schemas\")\n console.log(\" --usage, -u Show usage examples\")\n console.log(\" --check-deps Check peer dependency status\")\n console.log(\" --help, -h Show this help message\")\n console.log(\"\\nThis command lists all custom rules provided by the functype plugin.\")\n return\n }\n\n // Handle dependency check\n if (checkDeps) {\n console.log(colorize(\"š§ ESLint Plugin Functype - Dependency Check\", \"bright\"))\n const result = validatePeerDependencies()\n printDependencyStatus(result)\n\n if (!result.isValid) {\n process.exit(1)\n }\n return\n }\n\n console.log(colorize(\"š§ ESLint Plugin Functype - Custom Rules\", \"bright\"))\n\n if (!plugin.rules) {\n console.error(colorize(\"ā No rules found in plugin.\", \"red\"))\n process.exit(1)\n }\n\n console.log(colorize(\"\\nš¦ Available Custom Rules:\", \"bright\"))\n console.log(colorize(\"=\".repeat(40), \"blue\"))\n\n const rules = Object.keys(plugin.rules)\n\n rules.forEach((ruleName) => {\n const rule = plugin.rules[ruleName]\n const fullName = `functype/${ruleName}`\n\n console.log(`\\n${colorize(\"ā\", \"green\")} ${colorize(fullName, \"bright\")}`)\n\n if (rule.meta?.docs?.description) {\n console.log(` ${colorize(\"Description:\", \"cyan\")} ${rule.meta.docs.description}`)\n }\n\n if (rule.meta?.type) {\n const typeColor = rule.meta.type === \"problem\" ? \"red\" : rule.meta.type === \"suggestion\" ? \"yellow\" : \"blue\"\n console.log(` ${colorize(\"Type:\", \"cyan\")} ${colorize(rule.meta.type, typeColor)}`)\n }\n\n if (rule.meta?.fixable) {\n console.log(` ${colorize(\"Fixable:\", \"cyan\")} ${colorize(\"Yes\", \"green\")}`)\n }\n\n if (showUsage) {\n console.log(` ${colorize(\"Usage:\", \"cyan\")} \"${fullName}\": \"error\"`)\n }\n })\n\n console.log(colorize(`\\nš Summary: ${rules.length} custom rules available`, \"bright\"))\n\n if (showUsage) {\n printCustomUsageInfo()\n }\n\n console.log(colorize(\"\\nš” Tips:\", \"bright\"))\n console.log(\"⢠Use --verbose to see detailed rule information\")\n console.log(\"⢠Use --usage to see configuration examples\")\n console.log('⢠All rules are prefixed with \"functype/\"')\n console.log(\"⢠Consider using eslint-config-functype for pre-configured setup\")\n\n console.log(colorize(\"\\nš Links:\", \"bright\"))\n console.log(\"⢠Documentation: https://github.com/jordanburke/eslint-plugin-functype\")\n console.log(\"⢠Configuration Bundle: https://github.com/jordanburke/eslint-config-functype\")\n console.log(\"⢠Functype Library: https://github.com/jordanburke/functype\")\n}\n\nfunction printCustomUsageInfo(): void {\n console.log(colorize(\"\\nš” Usage Examples:\", \"bright\"))\n console.log(colorize(\"=\".repeat(30), \"blue\"))\n console.log(\"\\n\" + colorize(\"ESLint 9+ (flat config):\", \"green\"))\n console.log(' import functypePlugin from \"eslint-plugin-functype\"')\n console.log(\" export default [\")\n console.log(\" {\")\n console.log(\" plugins: { functype: functypePlugin },\")\n console.log(\" rules: {\")\n console.log(' \"functype/prefer-option\": \"error\",')\n console.log(' \"functype/prefer-either\": \"error\",')\n console.log(' \"functype/no-get-unsafe\": \"error\",')\n console.log(\" }\")\n console.log(\" }\")\n console.log(\" ]\")\n console.log(\"\\n\" + colorize(\"With eslint-config-functype (recommended):\", \"green\"))\n console.log(' import functypeConfig from \"eslint-config-functype\"')\n console.log(\" export default [functypeConfig.recommended]\")\n}\n\n// Run the CLI\nmain().catch((error) => {\n console.error(colorize(\"ā Unexpected error:\", \"red\"), error)\n process.exit(1)\n})\n"],"mappings":";A,uGAMA,MAAMC,EAAS,CACb,MAAO,U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A4C,EACxD,QAAQ,IAAI,SAAS,EACrB,QAAQ,IAAI,OAAO,EACnB,QAAQ,IAAI,KAAK,EACjB,QAAQ,IAAI;EAAOA,EAAS,6CAA8C,OAAO,CAAC,EAClF,QAAQ,IAAI,uDAAuD,EACnE,QAAQ,IAAI,+CAA+C,CAC7D,CAGAU,EAAK,CAAC,CAAC,MAAO,GAAU,CACtB,QAAQ,MAAMV,EAAS,sBAAuB,KAAK,EAAGsB,CAAK,EAC3D,QAAQ,KAAK,CAAC,CAChB,CAAC,E"}
|
|
@@ -1,45 +1,39 @@
|
|
|
1
|
-
//#region src/configs/recommended.d.ts
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* is
|
|
6
|
-
*
|
|
2
|
+
* The one preset. Code here is written by coding agents, and an agent acts on what fails its build
|
|
3
|
+
* and passes over a warning, so every rule is `error` or `off`, never `warn`. A rule is `error` once it
|
|
4
|
+
* is right on ~95ā99% of real code with its known false-positive classes closed (#325); until it is
|
|
5
|
+
* measured, it is `off`, because at `error` it would teach an agent to write `eslint-disable`.
|
|
7
6
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* (JSON rows, DTOs) and on throws that are correct (bug checks, host contracts). Wire<T> (#325 B),
|
|
11
|
-
* invariant() and @interop (#342) close those; graduating them is a measured decision.
|
|
12
|
-
* - prefer-flatmap / prefer-do-notation: heuristics without type information; precision unmeasured.
|
|
13
|
-
*
|
|
14
|
-
* Graduated with a precision condition: prefer-fold checks functype predicate calls (`isSome()`,
|
|
15
|
-
* `isLeft()`) only; its null-check heuristic is opt-in (`checkNullable`) because it fired on plain
|
|
16
|
-
* nullables ā 31 of 31 hits in a private app monorepo. prefer-map leaves loops to no-imperative-loops (`checkForLoops`
|
|
17
|
-
* off), so one loop is one error.
|
|
18
|
-
*
|
|
19
|
-
* collection-naming is a convention, not a heuristic ā functype's Map/Set imported under their own names,
|
|
20
|
-
* the built-in spelled globalThis.Map ā so it has no false-positive class and starts at error.
|
|
21
|
-
*
|
|
22
|
-
* no-array-mutation is off here only because turning a new error on in a 1.x minor would fail consumers'
|
|
23
|
-
* builds on upgrade (91 hits across five consumers, every one a real in-place mutation). It's `error` in
|
|
24
|
-
* strict, and planned for `error` here in 2.0. It is type-aware: without type information it reports nothing.
|
|
7
|
+
* In 1.x this was `agent`; `recommended` and `strict` warned on rules still being measured. 2.0 has
|
|
8
|
+
* one preset, and tests.ts relaxes it for test files.
|
|
25
9
|
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* measuring it against functype-os, whose async methods return IO there. Type-aware, like no-array-mutation.
|
|
29
|
-
*
|
|
30
|
-
* no-floating-result (1.23) is off here and `error` in strict: a dropped Either or Try is a defect, not a
|
|
31
|
-
* style, and on agent-todo's API it found the 20 drops that project fixed by hand as real bugs. Turning a
|
|
32
|
-
* new error on here would fail consumers' builds on a 1.x minor, so it moves to `error` here in 2.0. Type-aware.
|
|
33
|
-
*
|
|
34
|
-
* no-serialize-container (1.23) is off here and `error` in strict, for the same reason: a container sent
|
|
35
|
-
* to `c.json()` or `JSON.stringify()` is a defect, and turning a new error on here would fail consumers'
|
|
36
|
-
* builds on a 1.x minor. It moves to `error` here in 2.0. Type-aware.
|
|
10
|
+
* `off`, and why:
|
|
11
|
+
* - prefer-flatmap / prefer-do-notation: heuristics without type information; precision unmeasured.
|
|
37
12
|
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
13
|
+
* `error`, with what it was measured on:
|
|
14
|
+
* - prefer-fold checks functype predicate calls (`isSome()`, `isLeft()`), and guards followed by an
|
|
15
|
+
* unwrap (`checkGuards`): a pass-through guard is a hand-written flatMap. Its null-check heuristic
|
|
16
|
+
* is opt-in (`checkNullable`) because it fired on plain nullables: 31 of 31 hits in a private app
|
|
17
|
+
* monorepo. Inside a React component, a guard followed by an unwrap is also reported by
|
|
18
|
+
* must-fold-on-component-return.
|
|
19
|
+
* - prefer-map leaves loops to no-imperative-loops (`checkForLoops` off), so one loop is one error.
|
|
20
|
+
* - collection-naming is a convention, not a heuristic, so it has no false-positive class.
|
|
21
|
+
* - no-array-mutation: 91 hits across five consumers, every one a real in-place mutation.
|
|
22
|
+
* - prefer-list: about 96% precise on five consumers (#362). Supabase's generated types are skipped
|
|
23
|
+
* by shape. A local array changed by a method or an index write is reported once, by
|
|
24
|
+
* no-array-mutation; a mutated field is still reported by both.
|
|
25
|
+
* - prefer-option / prefer-either / prefer-try: at a real boundary the code marks it instead
|
|
26
|
+
* (`@interop <reason>` or `invariant()` for a throw, `Wire<T>` for a data shape).
|
|
27
|
+
* - no-floating-io: 0 false positives across ~1,340 IO-typed calls in five codebases.
|
|
28
|
+
* - no-floating-result: on agent-todo's API it found the 20 drops that project fixed by hand as real
|
|
29
|
+
* bugs, and in functype it found an async `bracket` that dropped a failed release.
|
|
30
|
+
* - no-serialize-container: 4 calls on agent-todo's API, each a bug that project fixed.
|
|
31
|
+
* - no-getOrThrow-in-render and must-fold-on-component-return fire only inside a React component or
|
|
32
|
+
* hook, and reported nothing on 1,403 files of React code.
|
|
33
|
+
* - no-get-unsafe: an unwrap outside an `@interop` boundary; allowed in test files.
|
|
34
|
+
*
|
|
35
|
+
* no-array-mutation, no-floating-io, no-floating-result and no-serialize-container are type-aware:
|
|
36
|
+
* without `parserOptions.projectService` they report nothing.
|
|
43
37
|
*/
|
|
44
38
|
declare const recommendedRules: {
|
|
45
39
|
"functype/no-let": string;
|
|
@@ -47,22 +41,22 @@ declare const recommendedRules: {
|
|
|
47
41
|
"functype/prefer-functype-map": string;
|
|
48
42
|
"functype/prefer-functype-set": string;
|
|
49
43
|
"functype/prefer-map": string;
|
|
50
|
-
"functype/prefer-fold": string
|
|
44
|
+
"functype/prefer-fold": (string | {
|
|
45
|
+
checkGuards: boolean;
|
|
46
|
+
})[];
|
|
51
47
|
"functype/collection-naming": string;
|
|
48
|
+
"functype/prefer-list": string;
|
|
49
|
+
"functype/no-array-mutation": string;
|
|
52
50
|
"functype/prefer-option": string;
|
|
53
51
|
"functype/prefer-either": string;
|
|
54
52
|
"functype/prefer-try": string;
|
|
55
|
-
"functype/prefer-flatmap": string;
|
|
56
|
-
"functype/prefer-do-notation": string;
|
|
57
53
|
"functype/no-get-unsafe": string;
|
|
58
|
-
"functype/prefer-list": string;
|
|
59
|
-
"functype/no-array-mutation": string;
|
|
60
54
|
"functype/no-floating-io": string;
|
|
61
55
|
"functype/no-floating-result": string;
|
|
62
56
|
"functype/no-serialize-container": string;
|
|
63
57
|
"functype/no-getOrThrow-in-render": string;
|
|
64
58
|
"functype/must-fold-on-component-return": string;
|
|
59
|
+
"functype/prefer-flatmap": string;
|
|
60
|
+
"functype/prefer-do-notation": string;
|
|
65
61
|
};
|
|
66
|
-
|
|
67
|
-
export { recommendedRules as default };
|
|
68
|
-
//# sourceMappingURL=recommended.d.ts.map
|
|
62
|
+
export { recommendedRules as default };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e={"functype/no-let":`error`,"functype/no-imperative-loops":`error`,"functype/prefer-functype-map":`error`,"functype/prefer-functype-set":`error`,"functype/prefer-map":`error`,"functype/prefer-fold"
|
|
1
|
+
const e={"functype/no-let":`error`,"functype/no-imperative-loops":`error`,"functype/prefer-functype-map":`error`,"functype/prefer-functype-set":`error`,"functype/prefer-map":`error`,"functype/prefer-fold":[`error`,{checkGuards:!0}],"functype/collection-naming":`error`,"functype/prefer-list":`error`,"functype/no-array-mutation":`error`,"functype/prefer-option":`error`,"functype/prefer-either":`error`,"functype/prefer-try":`error`,"functype/no-get-unsafe":`error`,"functype/no-floating-io":`error`,"functype/no-floating-result":`error`,"functype/no-serialize-container":`error`,"functype/no-getOrThrow-in-render":`error`,"functype/must-fold-on-component-return":`error`,"functype/prefer-flatmap":`off`,"functype/prefer-do-notation":`off`};export{e as default};
|
|
2
2
|
//# sourceMappingURL=recommended.js.map
|