eslint-plugin-functype 2.121.1 → 2.122.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 +36 -20
- package/dist/configs/agent.d.ts +44 -0
- package/dist/configs/agent.js +2 -0
- package/dist/configs/agent.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -25,28 +25,44 @@ import functype from "eslint-plugin-functype"
|
|
|
25
25
|
export default [functype.configs.strict]
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
+
### Agent mode
|
|
29
|
+
|
|
30
|
+
For code a coding agent writes. An agent acts on what fails its build and passes over a warning, so `agent` has no warnings: every rule is `error` or `off`.
|
|
31
|
+
|
|
32
|
+
```js
|
|
33
|
+
import functype from "eslint-plugin-functype"
|
|
34
|
+
|
|
35
|
+
export default [functype.configs.agent]
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
- **`error`:** everything `strict` errors on, plus `no-floating-io` and the two React rules, which `strict` still warns on while they're measured. A forgotten `.run()` or a throw in render is the kind of mistake an agent makes and a reviewer misses.
|
|
39
|
+
- **`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. `prefer-list` is off too: with type-aware linting, `no-array-mutation`, at `error`, covers its in-place-change case, and the rest asks for `ReadonlyArray<T>` types, a typing choice `strict` keeps at `warn`.
|
|
40
|
+
- `prefer-option`, `prefer-either` and `prefer-try` are `error`, as in `strict`. At a real boundary the agent marks it instead: `@interop <reason>` or `invariant()` for a throw (see below), `Wire<T>` for a data shape.
|
|
41
|
+
- `no-array-mutation` and `no-floating-io` need type-aware linting (typescript-eslint's parser with `parserOptions.projectService`). Without it they report nothing.
|
|
42
|
+
- 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`.
|
|
43
|
+
|
|
28
44
|
## Rules
|
|
29
45
|
|
|
30
|
-
| Rule | Recommended | Strict | Description |
|
|
31
|
-
| ---------------------------------------- | :---------: | :----: | -------------------------------------------------------------------------------------------- |
|
|
32
|
-
| `functype/no-let` | error | error | Use `const`; no reassignment |
|
|
33
|
-
| `functype/no-imperative-loops` | error | error | Use `List`/array methods, async traversal or `IO.forEach` instead of loops |
|
|
34
|
-
| `functype/prefer-functype-map` | error | error | Use functype `Map` instead of a native `Map` you only read |
|
|
35
|
-
| `functype/prefer-functype-set` | error | error | Use functype `Set` instead of a native `Set` you only read |
|
|
36
|
-
| `functype/collection-naming` | error | error | Import functype's `Map`/`Set` under their own names; spell the built-in `globalThis.Map` |
|
|
37
|
-
| `functype/prefer-map` | error | error | Use `map` instead of pushing inside `forEach` |
|
|
38
|
-
| `functype/prefer-fold` | error | error | Use `fold` instead of branching on `isSome()`/`isLeft()`/… |
|
|
39
|
-
| `functype/prefer-option` | warn | error | Use `Option` instead of `null`/`undefined` |
|
|
40
|
-
| `functype/prefer-either` | warn | error | Use `Either` for typed domain errors instead of `throw` |
|
|
41
|
-
| `functype/prefer-try` | warn | error | Use `Try` / `Try.fromPromise` instead of try/catch |
|
|
42
|
-
| `functype/prefer-flatmap` | warn | warn | Use `flatMap` instead of `map().flat()` |
|
|
43
|
-
| `functype/prefer-do-notation` | warn | warn | Use `Do` notation for chained operations |
|
|
44
|
-
| `functype/no-get-unsafe` | off | error | Disallow unsafe extraction (`.orThrow()`, `.expect()`) |
|
|
45
|
-
| `functype/prefer-list` | off | warn | Use `List` instead of native arrays |
|
|
46
|
-
| `functype/no-array-mutation` | off | error | Don't change an array in place (`push`, `sort`, `xs[i] = v`…); build a new one |
|
|
47
|
-
| `functype/no-floating-io` | off | warn | Don't build an `IO` and drop it, or `await` it unrun; run, return or `yield*` it |
|
|
48
|
-
| `functype/no-getOrThrow-in-render` | off | warn | React: no bare `.orThrow()` in a component or hook body; a throw in render unmounts the tree |
|
|
49
|
-
| `functype/must-fold-on-component-return` | off | warn | React: render an `Option`/`Either`/`Try` with `fold` or `<MatchOption>`, not a guard or `&&` |
|
|
46
|
+
| Rule | Recommended | Strict | Agent | Description |
|
|
47
|
+
| ---------------------------------------- | :---------: | :----: | :---: | -------------------------------------------------------------------------------------------- |
|
|
48
|
+
| `functype/no-let` | error | error | error | Use `const`; no reassignment |
|
|
49
|
+
| `functype/no-imperative-loops` | error | error | error | Use `List`/array methods, async traversal or `IO.forEach` instead of loops |
|
|
50
|
+
| `functype/prefer-functype-map` | error | error | error | Use functype `Map` instead of a native `Map` you only read |
|
|
51
|
+
| `functype/prefer-functype-set` | error | error | error | Use functype `Set` instead of a native `Set` you only read |
|
|
52
|
+
| `functype/collection-naming` | error | error | error | Import functype's `Map`/`Set` under their own names; spell the built-in `globalThis.Map` |
|
|
53
|
+
| `functype/prefer-map` | error | error | error | Use `map` instead of pushing inside `forEach` |
|
|
54
|
+
| `functype/prefer-fold` | error | error | error | Use `fold` instead of branching on `isSome()`/`isLeft()`/… |
|
|
55
|
+
| `functype/prefer-option` | warn | error | error | Use `Option` instead of `null`/`undefined` |
|
|
56
|
+
| `functype/prefer-either` | warn | error | error | Use `Either` for typed domain errors instead of `throw` |
|
|
57
|
+
| `functype/prefer-try` | warn | error | error | Use `Try` / `Try.fromPromise` instead of try/catch |
|
|
58
|
+
| `functype/prefer-flatmap` | warn | warn | off | Use `flatMap` instead of `map().flat()` |
|
|
59
|
+
| `functype/prefer-do-notation` | warn | warn | off | Use `Do` notation for chained operations |
|
|
60
|
+
| `functype/no-get-unsafe` | off | error | error | Disallow unsafe extraction (`.orThrow()`, `.expect()`) |
|
|
61
|
+
| `functype/prefer-list` | off | warn | off | Use `List` instead of native arrays |
|
|
62
|
+
| `functype/no-array-mutation` | off | error | error | Don't change an array in place (`push`, `sort`, `xs[i] = v`…); build a new one |
|
|
63
|
+
| `functype/no-floating-io` | off | warn | error | Don't build an `IO` and drop it, or `await` it unrun; run, return or `yield*` it |
|
|
64
|
+
| `functype/no-getOrThrow-in-render` | off | warn | error | React: no bare `.orThrow()` in a component or hook body; a throw in render unmounts the tree |
|
|
65
|
+
| `functype/must-fold-on-component-return` | off | warn | error | React: render an `Option`/`Either`/`Try` with `fold` or `<MatchOption>`, not a guard or `&&` |
|
|
50
66
|
|
|
51
67
|
### Severity policy
|
|
52
68
|
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
//#region src/configs/agent.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* The preset for code a coding agent writes. An agent acts on what fails its build and passes over a
|
|
4
|
+
* warning, so this preset has none: every rule is `error` or `off`.
|
|
5
|
+
*
|
|
6
|
+
* `error`: everything `strict` errors on, plus three rules `strict` still warns on while they are
|
|
7
|
+
* measured. no-floating-io has had 0 false positives across ~1,340 IO-typed calls, and the two React
|
|
8
|
+
* rules none across 1,403 files. A forgotten `.run()` or a throw in render is the kind of mistake an
|
|
9
|
+
* agent makes and a human reviewer misses. prefer-option, prefer-either and prefer-try are `error` here
|
|
10
|
+
* as in `strict`: at a real boundary an agent marks it (`@interop <reason>` or `invariant()` for a
|
|
11
|
+
* throw, `Wire<T>` for a data shape) instead of leaving the reader to guess.
|
|
12
|
+
*
|
|
13
|
+
* `off`: prefer-flatmap and prefer-do-notation, whose precision is unmeasured. At `error` they would
|
|
14
|
+
* teach an agent to write `eslint-disable`; each moves to `error` here once it is measured. Also
|
|
15
|
+
* prefer-list: with type-aware linting, its in-place-change case is no-array-mutation's, which is `error`
|
|
16
|
+
* here, and the rest
|
|
17
|
+
* asks for `ReadonlyArray<T>` types, a typing choice `strict` keeps at `warn`.
|
|
18
|
+
*
|
|
19
|
+
* no-array-mutation and no-floating-io are type-aware: without `parserOptions.projectService` they
|
|
20
|
+
* report nothing.
|
|
21
|
+
*/
|
|
22
|
+
declare const agentRules: {
|
|
23
|
+
"functype/no-floating-io": string;
|
|
24
|
+
"functype/no-getOrThrow-in-render": string;
|
|
25
|
+
"functype/must-fold-on-component-return": string;
|
|
26
|
+
"functype/prefer-flatmap": string;
|
|
27
|
+
"functype/prefer-do-notation": string;
|
|
28
|
+
"functype/prefer-list": string;
|
|
29
|
+
"functype/prefer-option": string;
|
|
30
|
+
"functype/prefer-either": string;
|
|
31
|
+
"functype/prefer-try": string;
|
|
32
|
+
"functype/no-get-unsafe": string;
|
|
33
|
+
"functype/no-array-mutation": string;
|
|
34
|
+
"functype/prefer-functype-map": string;
|
|
35
|
+
"functype/prefer-functype-set": string;
|
|
36
|
+
"functype/no-imperative-loops": string;
|
|
37
|
+
"functype/no-let": string;
|
|
38
|
+
"functype/prefer-map": string;
|
|
39
|
+
"functype/prefer-fold": string;
|
|
40
|
+
"functype/collection-naming": string;
|
|
41
|
+
};
|
|
42
|
+
//#endregion
|
|
43
|
+
export { agentRules as default };
|
|
44
|
+
//# sourceMappingURL=agent.d.ts.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import e from"./strict.js";const t={...e,"functype/no-floating-io":`error`,"functype/no-getOrThrow-in-render":`error`,"functype/must-fold-on-component-return":`error`,"functype/prefer-flatmap":`off`,"functype/prefer-do-notation":`off`,"functype/prefer-list":`off`};export{t as default};
|
|
2
|
+
//# sourceMappingURL=agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.js","names":["strictRules","agentRules"],"sources":["../../src/configs/agent.ts"],"sourcesContent":["import strictRules from \"./strict\"\n\n/**\n * The preset for code a coding agent writes. An agent acts on what fails its build and passes over a\n * warning, so this preset has none: every rule is `error` or `off`.\n *\n * `error`: everything `strict` errors on, plus three rules `strict` still warns on while they are\n * measured. no-floating-io has had 0 false positives across ~1,340 IO-typed calls, and the two React\n * rules none across 1,403 files. A forgotten `.run()` or a throw in render is the kind of mistake an\n * agent makes and a human reviewer misses. prefer-option, prefer-either and prefer-try are `error` here\n * as in `strict`: at a real boundary an agent marks it (`@interop <reason>` or `invariant()` for a\n * throw, `Wire<T>` for a data shape) instead of leaving the reader to guess.\n *\n * `off`: prefer-flatmap and prefer-do-notation, whose precision is unmeasured. At `error` they would\n * teach an agent to write `eslint-disable`; each moves to `error` here once it is measured. Also\n * prefer-list: with type-aware linting, its in-place-change case is no-array-mutation's, which is `error`\n * here, and the rest\n * asks for `ReadonlyArray<T>` types, a typing choice `strict` keeps at `warn`.\n *\n * no-array-mutation and no-floating-io are type-aware: without `parserOptions.projectService` they\n * report nothing.\n */\nconst agentRules = {\n ...strictRules,\n \"functype/no-floating-io\": \"error\",\n \"functype/no-getOrThrow-in-render\": \"error\",\n \"functype/must-fold-on-component-return\": \"error\",\n \"functype/prefer-flatmap\": \"off\",\n \"functype/prefer-do-notation\": \"off\",\n \"functype/prefer-list\": \"off\",\n}\n\nexport default agentRules\n"],"mappings":"2BAsBA,MAAMC,EAAa,CACjB,GAAGD,EACH,0BAA2B,QAC3B,mCAAoC,QACpC,yCAA0C,QAC1C,0BAA2B,MAC3B,8BAA+B,MAC/B,uBAAwB,KAC1B"}
|
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"./rules/index.js";const
|
|
1
|
+
import e from"./configs/recommended.js";import t from"./configs/strict.js";import n from"./configs/agent.js";import r from"./rules/index.js";const i={rules:r,meta:{name:`eslint-plugin-functype`,version:`2.0.0`},configs:{}};i.configs={recommended:{name:`functype-plugin/recommended`,plugins:{functype:i},rules:e},strict:{name:`functype-plugin/strict`,plugins:{functype:i},rules:t},agent:{name:`functype-plugin/agent`,plugins:{functype:i},rules:n}};export{i as default};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["recommendedRules","strictRules","rules_default","plugin"],"sources":["../src/index.ts"],"sourcesContent":["import recommendedRules from \"./configs/recommended\"\nimport strictRules from \"./configs/strict\"\nimport rules from \"./rules\"\n\nconst plugin = {\n rules,\n meta: {\n name: \"eslint-plugin-functype\",\n version: \"2.0.0\",\n },\n configs: {} as Record<string, unknown>,\n}\n\n// Self-referencing plugin in configs (ESLint flat config pattern)\nplugin.configs = {\n recommended: {\n name: \"functype-plugin/recommended\",\n plugins: { functype: plugin },\n rules: recommendedRules,\n },\n strict: {\n name: \"functype-plugin/strict\",\n plugins: { functype: plugin },\n rules: strictRules,\n },\n}\n\nexport default plugin\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":["recommendedRules","strictRules","agentRules","rules_default","plugin"],"sources":["../src/index.ts"],"sourcesContent":["import agentRules from \"./configs/agent\"\nimport recommendedRules from \"./configs/recommended\"\nimport strictRules from \"./configs/strict\"\nimport rules from \"./rules\"\n\nconst plugin = {\n rules,\n meta: {\n name: \"eslint-plugin-functype\",\n version: \"2.0.0\",\n },\n configs: {} as Record<string, unknown>,\n}\n\n// Self-referencing plugin in configs (ESLint flat config pattern)\nplugin.configs = {\n recommended: {\n name: \"functype-plugin/recommended\",\n plugins: { functype: plugin },\n rules: recommendedRules,\n },\n strict: {\n name: \"functype-plugin/strict\",\n plugins: { functype: plugin },\n rules: strictRules,\n },\n agent: {\n name: \"functype-plugin/agent\",\n plugins: { functype: plugin },\n rules: agentRules,\n },\n}\n\nexport default plugin\n"],"mappings":"6IAKA,MAAMI,EAAS,CACb,MAAAD,EACA,KAAM,CACJ,KAAM,yBACN,QAAS,OACX,EACA,QAAS,CAAC,CACZ,EAGA,EAAO,QAAU,CACf,YAAa,CACX,KAAM,8BACN,QAAS,CAAE,SAAUC,CAAO,EAC5B,MAAOJ,CACT,EACA,OAAQ,CACN,KAAM,yBACN,QAAS,CAAE,SAAUI,CAAO,EAC5B,MAAOH,CACT,EACA,MAAO,CACL,KAAM,wBACN,QAAS,CAAE,SAAUG,CAAO,EAC5B,MAAOF,CACT,CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-functype",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.122.0",
|
|
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.
|
|
45
|
+
"functype": "^1.22.0",
|
|
46
46
|
"ts-builds": "^3.4.3",
|
|
47
47
|
"tsdown": "^0.23.0"
|
|
48
48
|
},
|