eslint-plugin-functype 2.201.0 → 2.202.1
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 -2
- package/dist/cli/list-rules.js +3 -3
- package/dist/cli/list-rules.js.map +1 -1
- package/dist/configs/recommended.d.ts +6 -2
- package/dist/configs/recommended.js +1 -1
- package/dist/configs/recommended.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/rules/index.d.ts +21 -19
- package/dist/rules/index.js +1 -1
- package/dist/rules/index.js.map +1 -1
- package/dist/rules/no-container-mutation.d.ts +21 -0
- package/dist/rules/no-container-mutation.js +2 -0
- package/dist/rules/no-container-mutation.js.map +1 -0
- package/dist/utils/type-aware.d.ts +9 -0
- package/dist/utils/type-aware.js +1 -1
- package/dist/utils/type-aware.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ There is one preset. The code it checks is written by coding agents, and an agen
|
|
|
22
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
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
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`, `no-serialize-container` and `no-
|
|
25
|
+
- **Type-aware rules:** `no-array-mutation`, `no-floating-io`, `no-floating-result`, `no-serialize-container`, `no-uncalled-method` and `no-container-mutation` need typescript-eslint's parser with `parserOptions.projectService`. Without it they report nothing.
|
|
26
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`.
|
|
27
27
|
|
|
28
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`.
|
|
@@ -53,7 +53,7 @@ typescript-eslint, which this plugin runs on, doesn't support TypeScript 7 yet:
|
|
|
53
53
|
}
|
|
54
54
|
```
|
|
55
55
|
|
|
56
|
-
Every rule that works without type information works there. The
|
|
56
|
+
Every rule that works without type information works there. The six type-aware rules, `no-array-mutation`, `no-floating-io`, `no-floating-result`, `no-serialize-container`, `no-uncalled-method` and `no-container-mutation`, report nothing, because Oxlint doesn't pass type information to JS plugins yet. Checked on 2026-11-22 with Oxlint 1.94.0.
|
|
57
57
|
|
|
58
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.
|
|
59
59
|
|
|
@@ -80,6 +80,7 @@ When typescript-eslint supports TypeScript 7.1's new compiler API, the 6.0 alias
|
|
|
80
80
|
| `functype/no-floating-result` | error | off | Don't drop an `Either`/`Try` result; a failure in it is silently ignored |
|
|
81
81
|
| `functype/no-serialize-container` | error | off | Don't send an `Either`/`Option`/`List` to `c.json()` or `JSON.stringify()`; unwrap it first |
|
|
82
82
|
| `functype/no-uncalled-method` | error | | Call a functype method: `list.head()`, not `list.head`; read without `()` it is the function |
|
|
83
|
+
| `functype/no-container-mutation` | error | | Don't change a functype value in place, even through a cast; build a new one |
|
|
83
84
|
| `functype/no-getOrThrow-in-render` | error | | React: no bare `.orThrow()` in a component or hook body; a throw in render unmounts the tree |
|
|
84
85
|
| `functype/must-fold-on-component-return` | error | | React: render an `Option`/`Either`/`Try` with `fold` or `<MatchOption>`, not a guard or `&&` |
|
|
85
86
|
|
|
@@ -332,6 +333,39 @@ results.size // fine: a property
|
|
|
332
333
|
|
|
333
334
|
Measured (2026-11-22) on seven codebases on functype 1.x and 2.x, 1,126 files: no hits. Run on a library's code from before its 2.0 port, it reports the `Option(list.head)` that library shipped. It's `error` in `recommended`, and stays on in `tests`: `expect(list.head)` is one of the bugs it's for.
|
|
334
335
|
|
|
336
|
+
### `functype/no-container-mutation`
|
|
337
|
+
|
|
338
|
+
Reports a write to a functype value that TypeScript can't see. The types mark every field read-only, so such a write needs the value's type hidden: an `as` cast, or a variable that holds one. Since functype 2.2, collections no longer freeze each value, so at run time nothing else stops these writes.
|
|
339
|
+
|
|
340
|
+
```ts ignore
|
|
341
|
+
;(list as unknown as { value: number[] }).value = [9] // reported
|
|
342
|
+
;(list as any).value[0] = 9 // reported: the List's own array
|
|
343
|
+
;(list as any).value.push(9) // reported: a mutating method through a cast
|
|
344
|
+
const record = list as unknown as Record<string, unknown>
|
|
345
|
+
record.extra = 1 // reported: a variable holding a cast
|
|
346
|
+
delete (opt as any).value // reported
|
|
347
|
+
Object.assign(list, { extra: 1 }) // reported: compiles without a cast
|
|
348
|
+
for ((list as any).extra of xs) {
|
|
349
|
+
} // reported
|
|
350
|
+
|
|
351
|
+
list.map((x) => x + 1) // fine: a new List
|
|
352
|
+
if (box.isSome()) box.value.n = 1 // fine: the Option's payload, not the Option
|
|
353
|
+
mine.dirty = true // fine: a field of your own subtype of List
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
- **What it reports:** an assignment, compound assignment, `++`/`--`, `delete`, or a destructuring or `for…of`/`for…in` target whose path starts from a functype value held under an `as` cast or `<T>` assertion. That includes a variable written only where it's declared and initialised from one, or declared `: any`. It also reports a mutating method, such as `push`, `splice`, `sort`, `add`, `set`, `delete` or `clear`, called on data reached through such a value. Called on the functype value itself, cast or not, the method is functype's own and returns a new value, so `(fmap as Map<string, number>).set("a", 1)` isn't reported. And it reports `Object.assign`, `Object.defineProperty`, `Object.defineProperties` and `Object.setPrototypeOf`, and the matching `Reflect` calls, aimed at a functype value, cast or not, since those compile without one. `globalThis.Object.assign` and `Object["assign"]` count too.
|
|
357
|
+
- **What it leaves alone:** a write that compiles without a cast. That's either a field of your own type, or data a container holds but doesn't own, such as an Option's payload or a List element's own field. Freezing never stopped those writes either. A cast anywhere on the path still counts, so `(opt.value as T).n = 1` is reported.
|
|
358
|
+
- **A functype value** has `_tag` and a `fold` that functype itself declares, so a type of your own with that shape isn't reported. A union counts when any of its members is a functype value.
|
|
359
|
+
- **What it can't see:** a value passed to a parameter typed `any` and written there, plain JavaScript, `Reflect.apply` and `.call` on these functions, and a destructured `assign`. Linting can't follow a value once its type is gone, so functype covers those in development instead: under `NODE_ENV=development`, or with `FUNCTYPE_FREEZE=1`, collections freeze each value, and such a write throws. It also doesn't follow a cast through:
|
|
360
|
+
- a variable assigned again after its declaration;
|
|
361
|
+
- an object field;
|
|
362
|
+
- a conditional or `??` (`const o = ok ? (list as any) : null`);
|
|
363
|
+
- a comma expression.
|
|
364
|
+
|
|
365
|
+
**It only runs with type-aware linting** (`parserOptions.projectService`). Without type information it reports nothing.
|
|
366
|
+
|
|
367
|
+
Measured (2026-11-23) on seven codebases, 1,128 files including 343 test files, all with type information: no hits. Writes planted in one of those test files, through a cast-holding variable and through `: any`, are reported. It's `error` in `recommended`, and stays on in `tests`.
|
|
368
|
+
|
|
335
369
|
### React rules
|
|
336
370
|
|
|
337
371
|
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`.
|
package/dist/cli/list-rules.js
CHANGED
|
@@ -4,13 +4,13 @@ import e from"../index.js";import{validatePeerDependencies as t}from"../utils/de
|
|
|
4
4
|
✅ Available:`,`green`)),e.available.forEach(e=>{let t=e.required?`🔧`:`🔌`;console.log(` ${t} ${r(e.name,`green`)} - ${e.description}`)})),e.missing.length>0&&(console.log(r(`
|
|
5
5
|
❌ Missing:`,`red`)),e.missing.forEach(e=>{let t=e.required?`⚠️ `:`💡`,n=e.required?`red`:`yellow`;console.log(` ${t} ${r(e.name,n)} - ${e.description}`)}),e.installCommand&&(console.log(r(`
|
|
6
6
|
📦 Install missing dependencies:`,`bright`)),console.log(` ${r(e.installCommand,`cyan`)}`))),e.warnings.length>0&&(console.log(r(`
|
|
7
|
-
⚠️ Warnings:`,`yellow`)),e.warnings.forEach(e=>console.log(` ${e}`)));let t=e.isValid?`✅ Ready to use`:`❌ Configuration will fail`,n=e.isValid?`green`:`red`;console.log(r(`\n${t}`,n))}async function a(){let n=process.argv.slice(2),a=n.includes(`--help`)||n.includes(`-h`),s=n.includes(`--usage`)||n.includes(`-u`),c=n.includes(`--check-deps`)||n.includes(`--check`);if(a){console.log(r(`📋
|
|
7
|
+
⚠️ Warnings:`,`yellow`)),e.warnings.forEach(e=>console.log(` ${e}`)));let t=e.isValid?`✅ Ready to use`:`❌ Configuration will fail`,n=e.isValid?`green`:`red`;console.log(r(`\n${t}`,n))}async function a(){let n=process.argv.slice(2),a=n.includes(`--help`)||n.includes(`-h`),s=n.includes(`--usage`)||n.includes(`-u`),c=n.includes(`--check-deps`)||n.includes(`--check`);if(a){console.log(r(`📋 eslint-plugin-functype: Custom Rules`,`bright`)),console.log(`
|
|
8
8
|
Usage: pnpm run list-rules [options]`),console.log(`
|
|
9
9
|
Options:`),console.log(` --verbose, -v Show rule descriptions and schemas`),console.log(` --usage, -u Show usage examples`),console.log(` --check-deps Check peer dependency status`),console.log(` --help, -h Show this help message`),console.log(`
|
|
10
|
-
This command lists all custom rules provided by the functype plugin.`);return}if(c){console.log(r(`🔧
|
|
10
|
+
This command lists all custom rules provided by the functype plugin.`);return}if(c){console.log(r(`🔧 eslint-plugin-functype: Dependency Check`,`bright`));let e=t();i(e),e.isValid||process.exit(1);return}console.log(r(`🔧 eslint-plugin-functype: Custom Rules`,`bright`)),e.rules||(console.error(r(`❌ No rules found in plugin.`,`red`)),process.exit(1)),console.log(r(`
|
|
11
11
|
📦 Available Custom Rules:`,`bright`)),console.log(r(`=`.repeat(40),`blue`));let l=Object.keys(e.rules);l.forEach(t=>{let n=e.rules[t],i=`functype/${t}`;if(console.log(`\n${r(`●`,`green`)} ${r(i,`bright`)}`),n.meta?.docs?.description&&console.log(` ${r(`Description:`,`cyan`)} ${n.meta.docs.description}`),n.meta?.type){let e=n.meta.type===`problem`?`red`:n.meta.type===`suggestion`?`yellow`:`blue`;console.log(` ${r(`Type:`,`cyan`)} ${r(n.meta.type,e)}`)}n.meta?.fixable&&console.log(` ${r(`Fixable:`,`cyan`)} ${r(`Yes`,`green`)}`),s&&console.log(` ${r(`Usage:`,`cyan`)} "${i}": "error"`)}),console.log(r(`\n📊 Summary: ${l.length} custom rules available`,`bright`)),s&&o(),console.log(r(`
|
|
12
12
|
💡 Tips:`,`bright`)),console.log(`• Use --verbose to see detailed rule information`),console.log(`• Use --usage to see configuration examples`),console.log(`• All rules are prefixed with "functype/"`),console.log(`• Consider using eslint-config-functype for pre-configured setup`),console.log(r(`
|
|
13
|
-
🔗 Links:`,`bright`)),console.log(`• Documentation: https://github.com/jordanburke/eslint-plugin-functype`),console.log(`• Configuration Bundle: https://github.com/jordanburke/eslint-config-functype`),console.log(`•
|
|
13
|
+
🔗 Links:`,`bright`)),console.log(`• Documentation: https://github.com/jordanburke/eslint-plugin-functype`),console.log(`• Configuration Bundle: https://github.com/jordanburke/eslint-config-functype`),console.log(`• functype library: https://github.com/jordanburke/functype`)}function o(){console.log(r(`
|
|
14
14
|
💡 Usage Examples:`,`bright`)),console.log(r(`=`.repeat(30),`blue`)),console.log(`
|
|
15
15
|
`+r(`ESLint 9+ (flat config):`,`green`)),console.log(` import functypePlugin from "eslint-plugin-functype"`),console.log(` export default [`),console.log(` {`),console.log(` plugins: { functype: functypePlugin },`),console.log(` rules: {`),console.log(` "functype/prefer-option": "error",`),console.log(` "functype/prefer-either": "error",`),console.log(` "functype/no-get-unsafe": "error",`),console.log(` }`),console.log(` }`),console.log(` ]`),console.log(`
|
|
16
16
|
`+r(`With eslint-config-functype (recommended):`,`green`)),console.log(` import functypeConfig from "eslint-config-functype"`),console.log(` export default [functypeConfig.recommended]`)}a().catch(e=>{console.error(r(`❌ Unexpected error:`,`red`),e),process.exit(1)});export{};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-rules.js","names":["plugin","validatePeerDependencies","colors","colorize","text","color","printDependencyStatus","result","dep","icon","warning","status","statusColor","main","args","showHelp","showUsage","checkDeps","rules","ruleName","rule","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,MAAME,EAAS,CACb,MAAO,UACP,OAAQ,UACR,IAAK,WACL,MAAO,WACP,OAAQ,WACR,KAAM,WACN,QAAS,WACT,KAAM,UACR,EAEA,SAASC,EAASC,EAAcC,EAAoC,CAClE,OAAOH,EAAOG,GAASD,EAAOF,EAAO,KACvC,CAIA,SAASI,EAAsBC,EAAgC,CAC7D,QAAQ,IAAIJ,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,QAASC,GAAQ,CAChC,IAAMC,EAAOD,EAAI,SAAW,KAAO,KACnC,QAAQ,IAAI,KAAKC,EAAK,GAAGN,EAASK,EAAI,KAAM,OAAO,EAAE,KAAKA,EAAI,aAAa,CAC7E,CAAC,GAICD,EAAO,QAAQ,OAAS,IAC1B,QAAQ,IAAIJ,EAAS;YAAgB,KAAK,CAAC,EAC3CI,EAAO,QAAQ,QAASC,GAAQ,CAC9B,IAAMC,EAAOD,EAAI,SAAW,MAAQ,KAC9BH,EAAQG,EAAI,SAAW,MAAQ,SACrC,QAAQ,IAAI,KAAKC,EAAK,GAAGN,EAASK,EAAI,KAAMH,CAAK,EAAE,KAAKG,EAAI,aAAa,CAC3E,CAAC,EAEGD,EAAO,iBACT,QAAQ,IAAIJ,EAAS;kCAAsC,QAAQ,CAAC,EACpE,QAAQ,IAAI,MAAMA,EAASI,EAAO,eAAgB,MAAM,GAAG,IAK3DA,EAAO,SAAS,OAAS,I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A,EAAS,2BAA4B,OAAO,CAAC,EAChE,QAAQ,IAAI,uDAAuD,EACnE,QAAQ,IAAI,oBAAoB,EAChC,QAAQ,IAAI,OAAO,EACnB,QAAQ,IAAI,8CAA8C,EAC1D,QAAQ,IAAI,gBAAgB,EAC5B,QAAQ,IAAI,4CAA4C,EACxD,QAAQ,IAAI,4CAA4C,EACxD,QAAQ,IAAI,4CAA4C,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,MAAOW,GAAU,CACtB,QAAQ,MAAMrB,EAAS,sBAAuB,KAAK,EAAGqB,CAAK,EAC3D,QAAQ,KAAK,CAAC,CAChB,CAAC,E"}
|
|
1
|
+
{"version":3,"file":"list-rules.js","names":["plugin","validatePeerDependencies","colors","colorize","text","color","printDependencyStatus","result","dep","icon","warning","status","statusColor","main","args","showHelp","showUsage","checkDeps","rules","ruleName","rule","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,MAAME,EAAS,CACb,MAAO,UACP,OAAQ,UACR,IAAK,WACL,MAAO,WACP,OAAQ,WACR,KAAM,WACN,QAAS,WACT,KAAM,UACR,EAEA,SAASC,EAASC,EAAcC,EAAoC,CAClE,OAAOH,EAAOG,GAASD,EAAOF,EAAO,KACvC,CAIA,SAASI,EAAsBC,EAAgC,CAC7D,QAAQ,IAAIJ,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,QAASC,GAAQ,CAChC,IAAMC,EAAOD,EAAI,SAAW,KAAO,KACnC,QAAQ,IAAI,KAAKC,EAAK,GAAGN,EAASK,EAAI,KAAM,OAAO,EAAE,KAAKA,EAAI,aAAa,CAC7E,CAAC,GAICD,EAAO,QAAQ,OA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AC,EAC5C,QAAQ,IAAI,kDAAkD,EAC9D,QAAQ,IAAI,6CAA6C,EACzD,QAAQ,IAAI,2CAA2C,EACvD,QAAQ,IAAI,kEAAkE,EAE9E,QAAQ,IAAIA,EAAS;WAAe,QAAQ,CAAC,EAC7C,QAAQ,IAAI,wEAAwE,EACpF,QAAQ,IAAI,+EAA+E,EAC3F,QAAQ,IAAI,6DAA6D,CAC3E,CAEA,SAASoB,GAA6B,CACpC,QAAQ,IAAIpB,EAAS;oBAAwB,QAAQ,CAAC,EACtD,QAAQ,IAAIA,EAAS,IAAI,OAAO,EAAE,EAAG,MAAM,CAAC,EAC5C,QAAQ,IAAI;EAAOA,EAAS,2BAA4B,OAAO,CAAC,EAChE,QAAQ,IAAI,uDAAuD,EACnE,QAAQ,IAAI,oBAAoB,EAChC,QAAQ,IAAI,OAAO,EACnB,QAAQ,IAAI,8CAA8C,EAC1D,QAAQ,IAAI,gBAAgB,EAC5B,QAAQ,IAAI,4CAA4C,EACxD,QAAQ,IAAI,4CAA4C,EACxD,QAAQ,IAAI,4CAA4C,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,MAAOW,GAAU,CACtB,QAAQ,MAAMrB,EAAS,sBAAuB,KAAK,EAAGqB,CAAK,EAC3D,QAAQ,KAAK,CAAC,CAChB,CAAC,E"}
|
|
@@ -30,12 +30,15 @@
|
|
|
30
30
|
* - no-serialize-container: 4 calls on agent-todo's API, each a bug that project fixed.
|
|
31
31
|
* - no-uncalled-method: 0 hits on 1,126 files of seven consumers on 1.x and 2.x; it finds the
|
|
32
32
|
* `Option(list.head)` a published library shipped against 2.0 (#603).
|
|
33
|
+
* - no-container-mutation: 0 hits on 1,128 files of seven consumers, 343 of them tests, all type-checked;
|
|
34
|
+
* planted writes through a cast-holding variable are reported. Since functype 2.2 collections no
|
|
35
|
+
* longer freeze each value, so this rule is what reports a write through a cast.
|
|
33
36
|
* - no-getOrThrow-in-render and must-fold-on-component-return fire only inside a React component or
|
|
34
37
|
* hook, and reported nothing on 1,403 files of React code.
|
|
35
38
|
* - no-get-unsafe: an unwrap outside an `@interop` boundary; allowed in test files.
|
|
36
39
|
*
|
|
37
|
-
* no-array-mutation, no-floating-io, no-floating-result, no-serialize-container
|
|
38
|
-
* are type-aware:
|
|
40
|
+
* no-array-mutation, no-floating-io, no-floating-result, no-serialize-container, no-uncalled-method
|
|
41
|
+
* and no-container-mutation are type-aware:
|
|
39
42
|
* without `parserOptions.projectService` they report nothing.
|
|
40
43
|
*/
|
|
41
44
|
declare const recommendedRules: {
|
|
@@ -58,6 +61,7 @@ declare const recommendedRules: {
|
|
|
58
61
|
"functype/no-floating-result": string;
|
|
59
62
|
"functype/no-serialize-container": string;
|
|
60
63
|
"functype/no-uncalled-method": string;
|
|
64
|
+
"functype/no-container-mutation": string;
|
|
61
65
|
"functype/no-getOrThrow-in-render": string;
|
|
62
66
|
"functype/must-fold-on-component-return": string;
|
|
63
67
|
"functype/prefer-flatmap": string;
|
|
@@ -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":[`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-uncalled-method":`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};
|
|
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-uncalled-method":`error`,"functype/no-container-mutation":`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
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recommended.js","names":["recommendedRules"],"sources":["../../src/configs/recommended.ts"],"sourcesContent":["/**\n * The one preset. Code here is written by coding agents, and an agent acts on what fails its build\n * and passes over a warning, so every rule is `error` or `off`, never `warn`. A rule is `error` once it\n * is right on ~95–99% of real code with its known false-positive classes closed (#325); until it is\n * measured, it is `off`, because at `error` it would teach an agent to write `eslint-disable`.\n *\n * In 1.x this was `agent`; `recommended` and `strict` warned on rules still being measured. 2.0 has\n * one preset, and tests.ts relaxes it for test files.\n *\n * `off`, and why:\n * - prefer-flatmap / prefer-do-notation: heuristics without type information; precision unmeasured.\n *\n * `error`, with what it was measured on:\n * - prefer-fold checks functype predicate calls (`isSome()`, `isLeft()`), and guards followed by an\n * unwrap (`checkGuards`): a pass-through guard is a hand-written flatMap. Its null-check heuristic\n * is opt-in (`checkNullable`) because it fired on plain nullables: 31 of 31 hits in a private app\n * monorepo. Inside a React component, a guard followed by an unwrap is also reported by\n * must-fold-on-component-return.\n * - prefer-map leaves loops to no-imperative-loops (`checkForLoops` off), so one loop is one error.\n * - collection-naming is a convention, not a heuristic, so it has no false-positive class.\n * - no-array-mutation: 91 hits across five consumers, every one a real in-place mutation.\n * - prefer-list: about 96% precise on five consumers (#362). Supabase's generated types are skipped\n * by shape. A local array changed by a method or an index write is reported once, by\n * no-array-mutation; a mutated field is still reported by both.\n * - prefer-option / prefer-either / prefer-try: at a real boundary the code marks it instead\n * (`@interop <reason>` or `invariant()` for a throw, `Wire<T>` for a data shape).\n * - no-floating-io: 0 false positives across ~1,340 IO-typed calls in five codebases.\n * - no-floating-result: on agent-todo's API it found the 20 drops that project fixed by hand as real\n * bugs, and in functype it found an async `bracket` that dropped a failed release.\n * - no-serialize-container: 4 calls on agent-todo's API, each a bug that project fixed.\n * - no-uncalled-method: 0 hits on 1,126 files of seven consumers on 1.x and 2.x; it finds the\n * `Option(list.head)` a published library shipped against 2.0 (#603).\n * - no-getOrThrow-in-render and must-fold-on-component-return fire only inside a React component or\n * hook, and reported nothing on 1,403 files of React code.\n * - no-get-unsafe: an unwrap outside an `@interop` boundary; allowed in test files.\n *\n * no-array-mutation, no-floating-io, no-floating-result, no-serialize-container
|
|
1
|
+
{"version":3,"file":"recommended.js","names":["recommendedRules"],"sources":["../../src/configs/recommended.ts"],"sourcesContent":["/**\n * The one preset. Code here is written by coding agents, and an agent acts on what fails its build\n * and passes over a warning, so every rule is `error` or `off`, never `warn`. A rule is `error` once it\n * is right on ~95–99% of real code with its known false-positive classes closed (#325); until it is\n * measured, it is `off`, because at `error` it would teach an agent to write `eslint-disable`.\n *\n * In 1.x this was `agent`; `recommended` and `strict` warned on rules still being measured. 2.0 has\n * one preset, and tests.ts relaxes it for test files.\n *\n * `off`, and why:\n * - prefer-flatmap / prefer-do-notation: heuristics without type information; precision unmeasured.\n *\n * `error`, with what it was measured on:\n * - prefer-fold checks functype predicate calls (`isSome()`, `isLeft()`), and guards followed by an\n * unwrap (`checkGuards`): a pass-through guard is a hand-written flatMap. Its null-check heuristic\n * is opt-in (`checkNullable`) because it fired on plain nullables: 31 of 31 hits in a private app\n * monorepo. Inside a React component, a guard followed by an unwrap is also reported by\n * must-fold-on-component-return.\n * - prefer-map leaves loops to no-imperative-loops (`checkForLoops` off), so one loop is one error.\n * - collection-naming is a convention, not a heuristic, so it has no false-positive class.\n * - no-array-mutation: 91 hits across five consumers, every one a real in-place mutation.\n * - prefer-list: about 96% precise on five consumers (#362). Supabase's generated types are skipped\n * by shape. A local array changed by a method or an index write is reported once, by\n * no-array-mutation; a mutated field is still reported by both.\n * - prefer-option / prefer-either / prefer-try: at a real boundary the code marks it instead\n * (`@interop <reason>` or `invariant()` for a throw, `Wire<T>` for a data shape).\n * - no-floating-io: 0 false positives across ~1,340 IO-typed calls in five codebases.\n * - no-floating-result: on agent-todo's API it found the 20 drops that project fixed by hand as real\n * bugs, and in functype it found an async `bracket` that dropped a failed release.\n * - no-serialize-container: 4 calls on agent-todo's API, each a bug that project fixed.\n * - no-uncalled-method: 0 hits on 1,126 files of seven consumers on 1.x and 2.x; it finds the\n * `Option(list.head)` a published library shipped against 2.0 (#603).\n * - no-container-mutation: 0 hits on 1,128 files of seven consumers, 343 of them tests, all type-checked;\n * planted writes through a cast-holding variable are reported. Since functype 2.2 collections no\n * longer freeze each value, so this rule is what reports a write through a cast.\n * - no-getOrThrow-in-render and must-fold-on-component-return fire only inside a React component or\n * hook, and reported nothing on 1,403 files of React code.\n * - no-get-unsafe: an unwrap outside an `@interop` boundary; allowed in test files.\n *\n * no-array-mutation, no-floating-io, no-floating-result, no-serialize-container, no-uncalled-method\n * and no-container-mutation are type-aware:\n * without `parserOptions.projectService` they report nothing.\n */\nconst recommendedRules = {\n \"functype/no-let\": \"error\",\n \"functype/no-imperative-loops\": \"error\",\n \"functype/prefer-functype-map\": \"error\",\n \"functype/prefer-functype-set\": \"error\",\n \"functype/prefer-map\": \"error\",\n \"functype/prefer-fold\": [\"error\", { checkGuards: true }],\n \"functype/collection-naming\": \"error\",\n \"functype/prefer-list\": \"error\",\n \"functype/no-array-mutation\": \"error\",\n \"functype/prefer-option\": \"error\",\n \"functype/prefer-either\": \"error\",\n \"functype/prefer-try\": \"error\",\n \"functype/no-get-unsafe\": \"error\",\n \"functype/no-floating-io\": \"error\",\n \"functype/no-floating-result\": \"error\",\n \"functype/no-serialize-container\": \"error\",\n \"functype/no-uncalled-method\": \"error\",\n \"functype/no-container-mutation\": \"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}\n\nexport default recommendedRules\n"],"mappings":"AA2CA,MAAMA,EAAmB,CACvB,kBAAmB,QACnB,+BAAgC,QAChC,+BAAgC,QAChC,+BAAgC,QAChC,sBAAuB,QACvB,uBAAwB,CAAC,QAAS,CAAE,YAAa,EAAK,CAAC,EACvD,6BAA8B,QAC9B,uBAAwB,QACxB,6BAA8B,QAC9B,yBAA0B,QAC1B,yBAA0B,QAC1B,sBAAuB,QACvB,yBAA0B,QAC1B,0BAA2B,QAC3B,8BAA+B,QAC/B,kCAAmC,QACnC,8BAA+B,QAC/B,iCAAkC,QAClC,mCAAoC,QACpC,yCAA0C,QAC1C,0BAA2B,MAC3B,8BAA+B,KACjC,E"}
|
package/dist/index.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ declare const plugin: {
|
|
|
18
18
|
"no-floating-io": import("eslint").Rule.RuleModule;
|
|
19
19
|
"no-floating-result": import("eslint").Rule.RuleModule;
|
|
20
20
|
"no-serialize-container": import("eslint").Rule.RuleModule;
|
|
21
|
+
"no-container-mutation": import("eslint").Rule.RuleModule;
|
|
21
22
|
"no-uncalled-method": import("eslint").Rule.RuleModule;
|
|
22
23
|
"no-getOrThrow-in-render": import("eslint").Rule.RuleModule;
|
|
23
24
|
"must-fold-on-component-return": import("eslint").Rule.RuleModule;
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e from"./configs/recommended.js";import t,{testFiles as n}from"./configs/tests.js";import r from"./rules/index.js";const i={rules:r,meta:{name:`eslint-plugin-functype`,version:`2.
|
|
1
|
+
import e from"./configs/recommended.js";import t,{testFiles as n}from"./configs/tests.js";import r from"./rules/index.js";const i={rules:r,meta:{name:`eslint-plugin-functype`,version:`2.202.1`},configs:{}};i.configs={recommended:{name:`functype-plugin/recommended`,plugins:{functype:i},rules:e},tests:{name:`functype-plugin/tests`,plugins:{functype:i},files:n,rules:t}};export{i as default};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/rules/index.d.ts
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
import rule from "./collection-naming.js";
|
|
2
2
|
import rule$1 from "./must-fold-on-component-return.js";
|
|
3
3
|
import rule$2 from "./no-array-mutation.js";
|
|
4
|
-
import rule$3 from "./no-
|
|
5
|
-
import rule$4 from "./no-floating-
|
|
6
|
-
import rule$
|
|
7
|
-
import rule$
|
|
8
|
-
import rule$
|
|
9
|
-
import rule$8 from "./no-
|
|
10
|
-
import rule$9 from "./no-
|
|
11
|
-
import rule$10 from "./no-
|
|
12
|
-
import rule$11 from "./
|
|
13
|
-
import rule$12 from "./prefer-
|
|
14
|
-
import rule$13 from "./prefer-
|
|
15
|
-
import rule$14 from "./prefer-
|
|
16
|
-
import rule$15 from "./prefer-
|
|
17
|
-
import rule$16 from "./prefer-functype-
|
|
18
|
-
import rule$17 from "./prefer-
|
|
19
|
-
import rule$18 from "./prefer-
|
|
20
|
-
import rule$19 from "./prefer-
|
|
21
|
-
import rule$20 from "./prefer-
|
|
4
|
+
import rule$3 from "./no-container-mutation.js";
|
|
5
|
+
import rule$4 from "./no-floating-io.js";
|
|
6
|
+
import rule$5 from "./no-floating-result.js";
|
|
7
|
+
import rule$7 from "./no-get-unsafe.js";
|
|
8
|
+
import rule$6 from "./no-getOrThrow-in-render.js";
|
|
9
|
+
import rule$8 from "./no-imperative-loops.js";
|
|
10
|
+
import rule$9 from "./no-let.js";
|
|
11
|
+
import rule$10 from "./no-serialize-container.js";
|
|
12
|
+
import rule$11 from "./no-uncalled-method.js";
|
|
13
|
+
import rule$12 from "./prefer-do-notation.js";
|
|
14
|
+
import rule$13 from "./prefer-either.js";
|
|
15
|
+
import rule$14 from "./prefer-flatmap.js";
|
|
16
|
+
import rule$15 from "./prefer-fold.js";
|
|
17
|
+
import rule$16 from "./prefer-functype-map.js";
|
|
18
|
+
import rule$17 from "./prefer-functype-set.js";
|
|
19
|
+
import rule$18 from "./prefer-list.js";
|
|
20
|
+
import rule$19 from "./prefer-map.js";
|
|
21
|
+
import rule$20 from "./prefer-option.js";
|
|
22
|
+
import rule$21 from "./prefer-try.js";
|
|
22
23
|
declare const _default: {
|
|
23
24
|
"prefer-option": import("eslint").Rule.RuleModule;
|
|
24
25
|
"prefer-either": import("eslint").Rule.RuleModule;
|
|
@@ -38,8 +39,9 @@ declare const _default: {
|
|
|
38
39
|
"no-floating-io": import("eslint").Rule.RuleModule;
|
|
39
40
|
"no-floating-result": import("eslint").Rule.RuleModule;
|
|
40
41
|
"no-serialize-container": import("eslint").Rule.RuleModule;
|
|
42
|
+
"no-container-mutation": import("eslint").Rule.RuleModule;
|
|
41
43
|
"no-uncalled-method": import("eslint").Rule.RuleModule;
|
|
42
44
|
"no-getOrThrow-in-render": import("eslint").Rule.RuleModule;
|
|
43
45
|
"must-fold-on-component-return": import("eslint").Rule.RuleModule;
|
|
44
46
|
};
|
|
45
|
-
export { rule as collectionNaming, _default as default, rule$1 as mustFoldOnComponentReturn, rule$2 as noArrayMutation, rule$3 as
|
|
47
|
+
export { rule as collectionNaming, _default as default, rule$1 as mustFoldOnComponentReturn, rule$2 as noArrayMutation, rule$3 as noContainerMutation, rule$4 as noFloatingIo, rule$5 as noFloatingResult, rule$6 as noGetOrThrowInRender, rule$7 as noGetUnsafe, rule$8 as noImperativeLoops, rule$9 as noLet, rule$10 as noSerializeContainer, rule$11 as noUncalledMethod, rule$12 as preferDoNotation, rule$13 as preferEither, rule$14 as preferFlatmap, rule$15 as preferFold, rule$16 as preferFunctypeMap, rule$17 as preferFunctypeSet, rule$18 as preferList, rule$19 as preferMap, rule$20 as preferOption, rule$21 as preferTry };
|
package/dist/rules/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e from"./collection-naming.js";import t from"./must-fold-on-component-return.js";import n from"./no-array-mutation.js";import r from"./no-floating-io.js";import
|
|
1
|
+
import e from"./collection-naming.js";import t from"./must-fold-on-component-return.js";import n from"./no-array-mutation.js";import r from"./no-container-mutation.js";import i from"./no-floating-io.js";import a from"./no-floating-result.js";import o from"./no-get-unsafe.js";import s from"./no-getOrThrow-in-render.js";import c from"./no-imperative-loops.js";import l from"./no-let.js";import u from"./no-serialize-container.js";import d from"./no-uncalled-method.js";import f from"./prefer-do-notation.js";import p from"./prefer-either.js";import m from"./prefer-flatmap.js";import h from"./prefer-fold.js";import g from"./prefer-functype-map.js";import _ from"./prefer-functype-set.js";import v from"./prefer-list.js";import y from"./prefer-map.js";import b from"./prefer-option.js";import x from"./prefer-try.js";var S={"prefer-option":b,"prefer-either":p,"prefer-try":x,"prefer-list":v,"no-get-unsafe":o,"no-let":l,"prefer-fold":h,"prefer-map":y,"prefer-flatmap":m,"prefer-functype-map":g,"prefer-functype-set":_,"no-imperative-loops":c,"prefer-do-notation":f,"collection-naming":e,"no-array-mutation":n,"no-floating-io":i,"no-floating-result":a,"no-serialize-container":u,"no-container-mutation":r,"no-uncalled-method":d,"no-getOrThrow-in-render":s,"must-fold-on-component-return":t};export{e as collectionNaming,S as default,t as mustFoldOnComponentReturn,n as noArrayMutation,r as noContainerMutation,i as noFloatingIo,a as noFloatingResult,s as noGetOrThrowInRender,o as noGetUnsafe,c as noImperativeLoops,l as noLet,u as noSerializeContainer,d as noUncalledMethod,f as preferDoNotation,p as preferEither,m as preferFlatmap,h as preferFold,g as preferFunctypeMap,_ as preferFunctypeSet,v as preferList,y as preferMap,b as preferOption,x as preferTry};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/rules/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["preferOption","preferEither","preferTry","preferList","noGetUnsafe","noLet","preferFold","preferMap","preferFlatmap","preferFunctypeMap","preferFunctypeSet","noImperativeLoops","preferDoNotation","collectionNaming","noArrayMutation","noFloatingIo","noFloatingResult","noSerializeContainer","noUncalledMethod","noGetOrThrowInRender","mustFoldOnComponentReturn","rule","rule$1","rule$2","rule$3","rule$4","rule$
|
|
1
|
+
{"version":3,"file":"index.js","names":["preferOption","preferEither","preferTry","preferList","noGetUnsafe","noLet","preferFold","preferMap","preferFlatmap","preferFunctypeMap","preferFunctypeSet","noImperativeLoops","preferDoNotation","collectionNaming","noArrayMutation","noFloatingIo","noFloatingResult","noSerializeContainer","noContainerMutation","noUncalledMethod","noGetOrThrowInRender","mustFoldOnComponentReturn","rule","rule$1","rule$2","rule$3","rule$4","rule$5","rule$7","rule$6","rule$8","rule$9","rule$10","rule$11","rule$12","rule$13","rule$14","rule$15","rule$16","rule$17","rule$18","rule$19","rule$20","rule$21","rules_default"],"sources":["../../src/rules/index.ts"],"sourcesContent":["import collectionNaming from \"./collection-naming\"\nimport mustFoldOnComponentReturn from \"./must-fold-on-component-return\"\nimport noArrayMutation from \"./no-array-mutation\"\nimport noContainerMutation from \"./no-container-mutation\"\nimport noFloatingIo from \"./no-floating-io\"\nimport noFloatingResult from \"./no-floating-result\"\nimport noGetUnsafe from \"./no-get-unsafe\"\nimport noGetOrThrowInRender from \"./no-getOrThrow-in-render\"\nimport noImperativeLoops from \"./no-imperative-loops\"\nimport noLet from \"./no-let\"\nimport noSerializeContainer from \"./no-serialize-container\"\nimport noUncalledMethod from \"./no-uncalled-method\"\nimport preferDoNotation from \"./prefer-do-notation\"\nimport preferEither from \"./prefer-either\"\nimport preferFlatmap from \"./prefer-flatmap\"\nimport preferFold from \"./prefer-fold\"\nimport preferFunctypeMap from \"./prefer-functype-map\"\nimport preferFunctypeSet from \"./prefer-functype-set\"\nimport preferList from \"./prefer-list\"\nimport preferMap from \"./prefer-map\"\nimport preferOption from \"./prefer-option\"\nimport preferTry from \"./prefer-try\"\n\nexport {\n collectionNaming,\n mustFoldOnComponentReturn,\n noArrayMutation,\n noContainerMutation,\n noFloatingIo,\n noFloatingResult,\n noGetOrThrowInRender,\n noGetUnsafe,\n noImperativeLoops,\n noLet,\n noSerializeContainer,\n noUncalledMethod,\n preferDoNotation,\n preferEither,\n preferFlatmap,\n preferFold,\n preferFunctypeMap,\n preferFunctypeSet,\n preferList,\n preferMap,\n preferOption,\n preferTry,\n}\n\nexport default {\n \"prefer-option\": preferOption,\n \"prefer-either\": preferEither,\n \"prefer-try\": preferTry,\n \"prefer-list\": preferList,\n \"no-get-unsafe\": noGetUnsafe,\n \"no-let\": noLet,\n \"prefer-fold\": preferFold,\n \"prefer-map\": preferMap,\n \"prefer-flatmap\": preferFlatmap,\n \"prefer-functype-map\": preferFunctypeMap,\n \"prefer-functype-set\": preferFunctypeSet,\n \"no-imperative-loops\": noImperativeLoops,\n \"prefer-do-notation\": preferDoNotation,\n \"collection-naming\": collectionNaming,\n \"no-array-mutation\": noArrayMutation,\n \"no-floating-io\": noFloatingIo,\n \"no-floating-result\": noFloatingResult,\n \"no-serialize-container\": noSerializeContainer,\n \"no-container-mutation\": noContainerMutation,\n \"no-uncalled-method\": noUncalledMethod,\n \"no-getOrThrow-in-render\": noGetOrThrowInRender,\n \"must-fold-on-component-return\": mustFoldOnComponentReturn,\n}\n"],"mappings":"A,izBAgDA,IAAA4C,EAAe,CACb,gBAAiB5C,EACjB,gBAAiBC,EACjB,aAAcC,EACd,cAAeC,EACf,gBAAiBC,EACjB,SAAUC,EACV,cAAeC,EACf,aAAcC,EACd,iBAAkBC,EAClB,sBAAuBC,EACvB,sBAAuBC,EACvB,sBAAuBC,EACvB,qBAAsBC,EACtB,oBAAqBC,EACrB,oBAAqBC,EACrB,iBAAkBC,EAClB,qBAAsBC,EACtB,yBAA0BC,EAC1B,wBAAyBC,EACzB,qBAAsBC,EACtB,0BAA2BC,EAC3B,gCAAiCC,CACnC,E"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Rule } from "eslint";
|
|
2
|
+
/**
|
|
3
|
+
* Reports a write to a functype value that TypeScript can't see. The types mark every field read-only,
|
|
4
|
+
* so such a write needs the value's type hidden: an `as` cast, or a variable that holds one
|
|
5
|
+
* (`const o = list as any; o.x = 1`). The rule reports:
|
|
6
|
+
*
|
|
7
|
+
* - an assignment, compound assignment, `++`/`--`, `delete`, destructuring or `for…of`/`for…in` target
|
|
8
|
+
* whose path starts from a functype value held under a hiding cast; and
|
|
9
|
+
* - a mutating method (`push`, `splice`, `sort`, `add`, `set`, `delete`, `clear` and the like) called on
|
|
10
|
+
* data reached through such a value: `(list as any).value.push(9)`. Called on the functype value
|
|
11
|
+
* itself, cast or not, the method is functype's own and builds a new value, so it isn't reported; and
|
|
12
|
+
* - `Object.assign`, `Object.defineProperty(ies)`, `Object.setPrototypeOf` and the matching `Reflect`
|
|
13
|
+
* calls aimed at a functype value, cast or not, since those compile without one.
|
|
14
|
+
*
|
|
15
|
+
* A write that compiles without a cast is left alone: it is to a field of your own type, or to the data a
|
|
16
|
+
* container holds (an Option's payload, a List element's own field), which the container doesn't own.
|
|
17
|
+
* Only values whose `fold` functype declares count. Type-aware only: without type information it reports
|
|
18
|
+
* nothing. It can't see a value passed to an `any` parameter and written there, or plain JavaScript.
|
|
19
|
+
*/
|
|
20
|
+
declare const rule: Rule.RuleModule;
|
|
21
|
+
export { rule as default };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{functypeValueByType as e}from"../utils/type-aware.js";const t=/* @__PURE__ */ new Set([`TSAsExpression`,`TSTypeAssertion`]),n=/* @__PURE__ */ new Set([`TSNonNullExpression`,`TSSatisfiesExpression`,`ChainExpression`]),r={Object:/* @__PURE__ */ new Set([`assign`,`defineProperty`,`defineProperties`,`setPrototypeOf`]),Reflect:/* @__PURE__ */ new Set([`set`,`defineProperty`,`deleteProperty`,`setPrototypeOf`])},i=/* @__PURE__ */ new Set([`push`,`pop`,`shift`,`unshift`,`splice`,`sort`,`reverse`,`fill`,`copyWithin`,`add`,`set`,`delete`,`clear`]),a=/* @__PURE__ */ new Set([`globalThis`,`window`,`self`,`global`]),o=e=>{let t=e.property;return!e.computed&&t.type===`Identifier`?t.name:e.computed&&t.type===`Literal`&&typeof t.value==`string`?t.value:void 0},s=e=>{if(e.type===`Identifier`)return e.name;if(e.type!==`MemberExpression`)return;let t=e.object;return t.type===`Identifier`&&a.has(t.name)?o(e):void 0},c=e=>{let t=e.callee;if(t.type!==`MemberExpression`)return!1;let n=s(t.object),i=o(t);return n!==void 0&&i!==void 0&&(r[n]?.has(i)??!1)},l=e=>{if(e==null)return[];switch(e.type){case`MemberExpression`:return[e];case`ObjectPattern`:return e.properties.flatMap(e=>l(e.type===`RestElement`?e.argument:e.value));case`ArrayPattern`:return e.elements.flatMap(e=>l(e));case`RestElement`:return l(e.argument);case`AssignmentPattern`:return l(e.left);default:return t.has(e.type)||n.has(e.type)?l(e.expression):[]}},u={meta:{type:`problem`,docs:{description:`Disallow changing a functype value in place`,recommended:!1},schema:[],messages:{mutation:`This changes a {{name}} in place. functype values don't change after they're built, and other values share their data. Build a new one instead: map, filter, add, set or concat`}},create(r){let a=(e,t)=>e===null?void 0:e.set.get(t)??a(e.upper,t),s=e=>{let t=a(r.sourceCode.getScope(e),e.name),n=t?.defs[0];if(t===void 0||t.defs.length!==1||n?.type!==`Variable`)return;let i=n.node;if(i.id?.type!==`Identifier`||i.init==null||t.references.filter(e=>e.isWrite()).length>1)return;let o=i.id.typeAnnotation?.typeAnnotation,s=o?.type===`TSAnyKeyword`||o?.type===`TSUnknownKeyword`;return{init:i.init,erased:s}},u=(i,a,o=0)=>{if(o>10)return;if(t.has(i.type))return u(i.expression,!0,o+1);if(n.has(i.type))return u(i.expression,a,o+1);let c=e(i,r);if(c!==void 0)return a?c:void 0;if(i.type===`MemberExpression`)return u(i.object,a,o+1);if(i.type!==`Identifier`)return;let l=s(i);return l===void 0?void 0:u(l.init,a||l.erased,o+1)},d=(i,a=0)=>{if(a>10)return;if(t.has(i.type)||n.has(i.type))return d(i.expression,a+1);let o=e(i,r);if(o!==void 0)return o;if(i.type===`MemberExpression`)return u(i,!1,a+1);if(i.type!==`Identifier`)return;let c=s(i);return c===void 0?void 0:d(c.init,a+1)},f=(i,a=0)=>{if(a>10)return!1;if(t.has(i.type)||n.has(i.type))return f(i.expression,a+1);if(e(i,r)!==void 0)return!0;if(i.type!==`Identifier`)return!1;let o=s(i);return o!==void 0&&f(o.init,a+1)},p=(e,t)=>{t!==void 0&&r.report({node:e,messageId:`mutation`,data:{name:t}})},m=(e,r)=>{let i=n.has(r.type)||t.has(r.type)?r.expression:r;i.type===`MemberExpression`&&p(e,u(i.object,!1))},h=(e,t)=>{l(t).forEach(t=>m(e,t))};return{AssignmentExpression(e){h(e,e.left)},UpdateExpression(e){m(e,e.argument)},UnaryExpression(e){e.operator===`delete`&&m(e,e.argument)},"ForOfStatement, ForInStatement"(e){let t=e.left;t.type!==`VariableDeclaration`&&h(e,t)},CallExpression(e){let t=e.callee;if(t.type===`MemberExpression`&&!c(e)){let n=o(t),r=t.object;if(n!==void 0&&i.has(n)&&!f(r)){p(e,u(r,!1));return}}let[n]=e.arguments;n!==void 0&&n.type!==`SpreadElement`&&c(e)&&p(e,d(n))}}}};export{u as default};
|
|
2
|
+
//# sourceMappingURL=no-container-mutation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-container-mutation.js","names":["functypeValueByType","ERASING","TRANSPARENT","TARGET_FIRST","MUTATING_METHODS","GLOBALS","keyName","member","property","namespaceName","node","object","isTargetFirstCall","call","callee","namespace","method","memberTargets","pattern","p","rule","context","findVariable","scope","name","soleValue","identifier","variable","definition","declarator","r","annotation","erased","hiddenRoot","depth","held","targetRoot","isContainerItself","report","checkMember","write","target","checkPattern","left","receiver","first"],"sources":["../../src/rules/no-container-mutation.ts"],"sourcesContent":["import type { Rule, Scope } from \"eslint\"\n\nimport type { ASTNode } from \"../types/ast\"\nimport { functypeValueByType } from \"../utils/type-aware\"\n\n/** Casts that hide a value's type from TypeScript: `x as T`, `<T>x`. */\nconst ERASING: ReadonlySet<string> = new Set([\"TSAsExpression\", \"TSTypeAssertion\"])\n\n/** Wrappers that keep a value's type: `x!`, `x satisfies T`, `a?.b`. */\nconst TRANSPARENT: ReadonlySet<string> = new Set([\"TSNonNullExpression\", \"TSSatisfiesExpression\", \"ChainExpression\"])\n\n/** Calls that change their first argument: `Object.assign(target, …)`, `Reflect.set(target, …)`. */\nconst TARGET_FIRST: Readonly<Record<string, ReadonlySet<string>>> = {\n Object: new Set([\"assign\", \"defineProperty\", \"defineProperties\", \"setPrototypeOf\"]),\n Reflect: new Set([\"set\", \"defineProperty\", \"deleteProperty\", \"setPrototypeOf\"]),\n}\n\n/**\n * Methods that change the array, Set or Map they're called on. Through a cast, they change the data a\n * container holds: `(list as any).value.push(9)`.\n */\nconst MUTATING_METHODS: ReadonlySet<string> = new Set([\n \"push\",\n \"pop\",\n \"shift\",\n \"unshift\",\n \"splice\",\n \"sort\",\n \"reverse\",\n \"fill\",\n \"copyWithin\",\n \"add\",\n \"set\",\n \"delete\",\n \"clear\",\n])\n\n/** Names the global object goes by: `globalThis.Object.assign(…)`. */\nconst GLOBALS: ReadonlySet<string> = new Set([\"globalThis\", \"window\", \"self\", \"global\"])\n\nconst keyName = (member: ASTNode): string | undefined => {\n const property = member.property as ASTNode\n if (!member.computed && property.type === \"Identifier\") return property.name\n return member.computed && property.type === \"Literal\" && typeof property.value === \"string\"\n ? property.value\n : undefined\n}\n\n/** `Object` or `Reflect`, also reached as `globalThis.Object`. */\nconst namespaceName = (node: ASTNode): string | undefined => {\n if (node.type === \"Identifier\") return node.name\n if (node.type !== \"MemberExpression\") return undefined\n const object = node.object as ASTNode\n return object.type === \"Identifier\" && GLOBALS.has(object.name) ? keyName(node) : undefined\n}\n\nconst isTargetFirstCall = (call: ASTNode): boolean => {\n const callee = call.callee as ASTNode\n if (callee.type !== \"MemberExpression\") return false\n const namespace = namespaceName(callee.object as ASTNode)\n const method = keyName(callee)\n return namespace !== undefined && method !== undefined && (TARGET_FIRST[namespace]?.has(method) ?? false)\n}\n\n/** The member expressions a destructuring or loop target writes to: `(list as any).x` in `({ a: (list as any).x } = o)`. */\nconst memberTargets = (pattern: ASTNode | null | undefined): ReadonlyArray<ASTNode> => {\n if (pattern === null || pattern === undefined) return []\n switch (pattern.type) {\n case \"MemberExpression\":\n return [pattern]\n case \"ObjectPattern\":\n return (pattern.properties as ReadonlyArray<ASTNode>).flatMap((p) =>\n memberTargets(p.type === \"RestElement\" ? (p.argument as ASTNode) : (p.value as ASTNode)),\n )\n case \"ArrayPattern\":\n return (pattern.elements as ReadonlyArray<ASTNode | null>).flatMap((e) => memberTargets(e))\n case \"RestElement\":\n return memberTargets(pattern.argument as ASTNode)\n case \"AssignmentPattern\":\n return memberTargets(pattern.left as ASTNode)\n default:\n return ERASING.has(pattern.type) || TRANSPARENT.has(pattern.type)\n ? memberTargets(pattern.expression as ASTNode)\n : []\n }\n}\n\n/**\n * Reports a write to a functype value that TypeScript can't see. The types mark every field read-only,\n * so such a write needs the value's type hidden: an `as` cast, or a variable that holds one\n * (`const o = list as any; o.x = 1`). The rule reports:\n *\n * - an assignment, compound assignment, `++`/`--`, `delete`, destructuring or `for…of`/`for…in` target\n * whose path starts from a functype value held under a hiding cast; and\n * - a mutating method (`push`, `splice`, `sort`, `add`, `set`, `delete`, `clear` and the like) called on\n * data reached through such a value: `(list as any).value.push(9)`. Called on the functype value\n * itself, cast or not, the method is functype's own and builds a new value, so it isn't reported; and\n * - `Object.assign`, `Object.defineProperty(ies)`, `Object.setPrototypeOf` and the matching `Reflect`\n * calls aimed at a functype value, cast or not, since those compile without one.\n *\n * A write that compiles without a cast is left alone: it is to a field of your own type, or to the data a\n * container holds (an Option's payload, a List element's own field), which the container doesn't own.\n * Only values whose `fold` functype declares count. Type-aware only: without type information it reports\n * nothing. It can't see a value passed to an `any` parameter and written there, or plain JavaScript.\n */\nconst rule: Rule.RuleModule = {\n meta: {\n type: \"problem\",\n docs: {\n description: \"Disallow changing a functype value in place\",\n recommended: false,\n },\n schema: [],\n messages: {\n mutation:\n \"This changes a {{name}} in place. functype values don't change after they're built, and other values share their data. Build a new one instead: map, filter, add, set or concat\",\n },\n },\n\n create(context) {\n const findVariable = (scope: Scope.Scope | null, name: string): Scope.Variable | undefined =>\n scope === null ? undefined : (scope.set.get(name) ?? findVariable(scope.upper, name))\n\n /** The one value a variable ever holds: the initialiser of a variable written only where it's declared. */\n const soleValue = (identifier: ASTNode): { readonly init: ASTNode; readonly erased: boolean } | undefined => {\n const variable = findVariable(context.sourceCode.getScope(identifier as never), identifier.name)\n const definition = variable?.defs[0]\n if (variable === undefined || variable.defs.length !== 1 || definition?.type !== \"Variable\") return undefined\n const declarator = definition.node as unknown as ASTNode\n if (declarator.id?.type !== \"Identifier\" || declarator.init == null) return undefined\n if (variable.references.filter((r) => r.isWrite()).length > 1) return undefined\n // `const o: any = list` hides the type as a cast does.\n const annotation = (declarator.id.typeAnnotation as ASTNode | undefined)?.typeAnnotation as ASTNode | undefined\n const erased = annotation?.type === \"TSAnyKeyword\" || annotation?.type === \"TSUnknownKeyword\"\n return { init: declarator.init as ASTNode, erased }\n }\n\n /**\n * The functype value a written path starts from, if it was hidden from TypeScript on the way: `list`\n * in `(list as any).value[0]`, or in `o.x` after `const o = list as any`.\n */\n const hiddenRoot = (node: ASTNode, erased: boolean, depth = 0): string | undefined => {\n if (depth > 10) return undefined\n if (ERASING.has(node.type)) return hiddenRoot(node.expression as ASTNode, true, depth + 1)\n if (TRANSPARENT.has(node.type)) return hiddenRoot(node.expression as ASTNode, erased, depth + 1)\n const name = functypeValueByType(node, context)\n if (name !== undefined) return erased ? name : undefined\n if (node.type === \"MemberExpression\") return hiddenRoot(node.object as ASTNode, erased, depth + 1)\n if (node.type !== \"Identifier\") return undefined\n const held = soleValue(node)\n return held === undefined ? undefined : hiddenRoot(held.init, erased || held.erased, depth + 1)\n }\n\n /**\n * The functype value a call's target is, cast or not: `list` in `Object.assign(list, …)` or\n * `Object.assign(o, …)` after `const o = list`. A member of one counts only when a cast hides it, so\n * `Object.assign(opt.value, …)` on an Option's payload is left alone, as `opt.value.n = 1` is.\n */\n const targetRoot = (node: ASTNode, depth = 0): string | undefined => {\n if (depth > 10) return undefined\n if (ERASING.has(node.type) || TRANSPARENT.has(node.type)) return targetRoot(node.expression as ASTNode, depth + 1)\n const name = functypeValueByType(node, context)\n if (name !== undefined) return name\n if (node.type === \"MemberExpression\") return hiddenRoot(node, false, depth + 1)\n if (node.type !== \"Identifier\") return undefined\n const held = soleValue(node)\n return held === undefined ? undefined : targetRoot(held.init, depth + 1)\n }\n\n /**\n * Is `node` the functype value itself, however it's cast or aliased? Then a method called on it is\n * functype's own and builds a new value: `(fmap as FMap<K, V>).set(k, v)`, `(list as any).add(1)`.\n */\n const isContainerItself = (node: ASTNode, depth = 0): boolean => {\n if (depth > 10) return false\n if (ERASING.has(node.type) || TRANSPARENT.has(node.type))\n return isContainerItself(node.expression as ASTNode, depth + 1)\n if (functypeValueByType(node, context) !== undefined) return true\n if (node.type !== \"Identifier\") return false\n const held = soleValue(node)\n return held !== undefined && isContainerItself(held.init, depth + 1)\n }\n\n const report = (node: ASTNode, name: string | undefined): void => {\n if (name !== undefined) context.report({ node, messageId: \"mutation\", data: { name } })\n }\n\n /** A written member: `(list as any).x` writes into whatever `(list as any)` is. */\n const checkMember = (write: ASTNode, target: ASTNode): void => {\n const member = TRANSPARENT.has(target.type) || ERASING.has(target.type) ? (target.expression as ASTNode) : target\n if (member.type === \"MemberExpression\") report(write, hiddenRoot(member.object as ASTNode, false))\n }\n\n const checkPattern = (write: ASTNode, pattern: ASTNode): void => {\n memberTargets(pattern).forEach((target) => checkMember(write, target))\n }\n\n return {\n AssignmentExpression(node: ASTNode) {\n checkPattern(node, node.left as ASTNode)\n },\n UpdateExpression(node: ASTNode) {\n checkMember(node, node.argument as ASTNode)\n },\n UnaryExpression(node: ASTNode) {\n if (node.operator === \"delete\") checkMember(node, node.argument as ASTNode)\n },\n \"ForOfStatement, ForInStatement\"(node: ASTNode) {\n const left = node.left as ASTNode\n if (left.type !== \"VariableDeclaration\") checkPattern(node, left)\n },\n CallExpression(node: ASTNode) {\n const callee = node.callee as ASTNode\n // Object.* and Reflect.* first: `Reflect.set` is a target-first call, not a Map's `set`.\n if (callee.type === \"MemberExpression\" && !isTargetFirstCall(node)) {\n const method = keyName(callee)\n const receiver = callee.object as ASTNode\n if (method !== undefined && MUTATING_METHODS.has(method) && !isContainerItself(receiver)) {\n report(node, hiddenRoot(receiver, false))\n return\n }\n }\n const [first] = node.arguments as ReadonlyArray<ASTNode>\n if (first !== undefined && first.type !== \"SpreadElement\" && isTargetFirstCall(node)) {\n report(node, targetRoot(first))\n }\n },\n }\n },\n}\n\nexport default rule\n"],"mappings":"A,6DAMA,MAAMC,kBAA+B,IAAI,IAAI,CAAC,iBAAkB,iBAAiB,CAAC,EAG5EC,kBAAmC,IAAI,IAAI,CAAC,sBAAuB,wBAAyB,iBAAiB,CAAC,EAG9GC,EAA8D,CAClE,uBAAQ,IAAI,IAAI,CAAC,SAAU,iBAAkB,mBAAoB,gBAAgB,CAAC,EAClF,wBAAS,IAAI,IAAI,CAAC,MAAO,iBAAkB,iBAAkB,gBAAgB,CAAC,CAChF,EAMMC,kBAAwC,IAAI,IAAI,CACpD,OACA,MACA,QACA,UACA,SACA,OACA,UACA,OACA,aACA,MACA,MACA,SACA,OACF,CAAC,EAGKC,kBAA+B,IAAI,IAAI,CAAC,aAAc,SAAU,OAAQ,QAAQ,CAAC,EAEjFC,EAAWC,GAAwC,CACvD,IAAMC,EAAWD,EAAO,SAExB,MADI,CAACA,EAAO,UAAYC,EAAS,OAAS,aAAqBA,EAAS,KACjED,EAAO,UAAYC,EAAS,OAAS,WAAa,OAAOA,EAAS,OAAU,SAC/EA,EAAS,MACT,IAAA,EACN,EAGM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C,GAAgBF,EAAgBtB,IAA2B,CAC/DD,EAAcC,CAAO,CAAC,CAAC,QAASuB,GAAWF,EAAYC,EAAOC,CAAM,CAAC,CACvE,EAEA,MAAO,CACL,qBAAqB/B,EAAe,CAClCgC,EAAahC,EAAMA,EAAK,IAAe,CACzC,EACA,iBAAiBA,EAAe,CAC9B6B,EAAY7B,EAAMA,EAAK,QAAmB,CAC5C,EACA,gBAAgBA,EAAe,CACzBA,EAAK,WAAa,UAAU6B,EAAY7B,EAAMA,EAAK,QAAmB,CAC5E,EACA,iCAAiCA,EAAe,CAC9C,IAAMiC,EAAOjC,EAAK,KACdiC,EAAK,OAAS,uBAAuBD,EAAahC,EAAMiC,CAAI,CAClE,EACA,eAAejC,EAAe,CAC5B,IAAMI,EAASJ,EAAK,OAEpB,GAAII,EAAO,OAAS,oBAAsB,CAACF,EAAkBF,CAAI,EAAG,CAClE,IAAMM,EAASV,EAAQQ,CAAM,EACvB8B,EAAW9B,EAAO,OACxB,GAAIE,IAAW,IAAA,IAAaZ,EAAiB,IAAIY,CAAM,GAAK,CAACqB,EAAkBO,CAAQ,EAAG,CACxFN,EAAO5B,EAAMuB,EAAWW,EAAU,EAAK,CAAC,EACxC,MACF,CACF,CACA,GAAM,CAACC,GAASnC,EAAK,UACjBmC,IAAU,IAAA,IAAaA,EAAM,OAAS,iBAAmBjC,EAAkBF,CAAI,GACjF4B,EAAO5B,EAAM0B,EAAWS,CAAK,CAAC,CAElC,CACF,CACF,CACF,E"}
|
|
@@ -54,6 +54,15 @@ export declare const containerInsideByType: (node: ASTNode, context: Rule.RuleCo
|
|
|
54
54
|
* `undefined` when type information isn't available.
|
|
55
55
|
*/
|
|
56
56
|
export declare const functypeMethodByType: (object: ASTNode, name: string, context: Rule.RuleContext) => string | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* If `node`'s value is a functype value, the container's name (`List`, `Option`, `Either`); otherwise
|
|
59
|
+
* `undefined`. A functype value has `_tag` and a `fold` that functype itself declares, so a user type
|
|
60
|
+
* with the same shape doesn't count. A type parameter is read through its constraint, and a union counts
|
|
61
|
+
* when any of its members is a functype value (`List<number> | string[]`).
|
|
62
|
+
*
|
|
63
|
+
* `undefined` when type information isn't available.
|
|
64
|
+
*/
|
|
65
|
+
export declare const functypeValueByType: (node: ASTNode, context: Rule.RuleContext) => string | undefined;
|
|
57
66
|
/**
|
|
58
67
|
* Does `node` (an expression) flow into a slot that is typed as an array, a tuple or `any`/`unknown`?
|
|
59
68
|
* That's the expected type TypeScript checks it against: the parameter it is passed to, the property
|
package/dist/utils/type-aware.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=/* @__PURE__ */ new Set([`Iterable`,`AsyncIterable`,`IterableIterator`,`ArrayLike`]),t=e=>{let t=e.sourceCode.parserServices;return t?.program&&t.esTreeNodeToTSNodeMap?t:void 0},n=(e,n)=>{let r=t(n);if(!r)return;let i=r.esTreeNodeToTSNodeMap.get(e);if(!i)return;let a=r.program.getTypeChecker(),o=a.getNonNullableType(a.getTypeAtLocation(i));return a.getPropertyOfType(o,`orThrow`)!==void 0&&a.getPropertyOfType(o,`fold`)!==void 0},r=(e,n)=>{let r=t(n);if(!r)return;let i=r.esTreeNodeToTSNodeMap.get(e);if(!i)return;let a=r.program.getTypeChecker(),o=a.getNonNullableType(a.getTypeAtLocation(i));return a.getPropertyOfType(o,`runExit`)!==void 0&&a.getPropertyOfType(o,`provideLayer`)!==void 0},i=(e,n)=>{let r=t(n);if(!r)return;let i=r.esTreeNodeToTSNodeMap.get(e);if(!i)return;let a=r.program.getTypeChecker(),o=a.getNonNullableType(a.getTypeAtLocation(i)),s=(e,t)=>a.getPropertyOfType(e,t)!==void 0;return(o.types??[o]).some(e=>s(e,`fold`)&&(s(e,`isLeft`)||s(e,`isFailure`))&&!s(e,`runExit`))},a={LeftOf:`Either`,RightOf:`Either`,SomeOf:`Option`,NoneOf:`Option`,SuccessOf:`Try`,FailureOf:`Try`,SuccessExitOf:`Exit`,FailureExitOf:`Exit`,DieExitOf:`Exit`,InterruptedExitOf:`Exit`},o=e=>{let t=(e.aliasSymbol?.name??e.getSymbol?.()?.name)?.replace(/\$\d+$/,``);return t===void 0||t.startsWith(`__`)?`functype container`:a[t]??t},s=e=>{let t=e.getSymbol?.();return t===void 0||t.name.startsWith(`__`)?!1:(t.getDeclarations?.()??[]).some(e=>e.getSourceFile().fileName.includes(`/node_modules/`))},c=(e,n)=>{let r=t(n);if(!r)return;let i=r.esTreeNodeToTSNodeMap.get(e);if(!i)return;let a=r.program.getTypeChecker(),c=/* @__PURE__ */ new Set,l=e=>a.getPropertyOfType(e,`_tag`)!==void 0&&a.getPropertyOfType(e,`fold`)!==void 0,u=(e,t)=>e===``?t:t.startsWith(`[`)?e+t:`${e}.${t}`,d=(e,t,n)=>{if(n>4||c.has(e)||
|
|
1
|
+
const e=/* @__PURE__ */ new Set([`Iterable`,`AsyncIterable`,`IterableIterator`,`ArrayLike`]),t=e=>{let t=e.sourceCode.parserServices;return t?.program&&t.esTreeNodeToTSNodeMap?t:void 0},n=(e,n)=>{let r=t(n);if(!r)return;let i=r.esTreeNodeToTSNodeMap.get(e);if(!i)return;let a=r.program.getTypeChecker(),o=a.getNonNullableType(a.getTypeAtLocation(i));return a.getPropertyOfType(o,`orThrow`)!==void 0&&a.getPropertyOfType(o,`fold`)!==void 0},r=(e,n)=>{let r=t(n);if(!r)return;let i=r.esTreeNodeToTSNodeMap.get(e);if(!i)return;let a=r.program.getTypeChecker(),o=a.getNonNullableType(a.getTypeAtLocation(i));return a.getPropertyOfType(o,`runExit`)!==void 0&&a.getPropertyOfType(o,`provideLayer`)!==void 0},i=(e,n)=>{let r=t(n);if(!r)return;let i=r.esTreeNodeToTSNodeMap.get(e);if(!i)return;let a=r.program.getTypeChecker(),o=a.getNonNullableType(a.getTypeAtLocation(i)),s=(e,t)=>a.getPropertyOfType(e,t)!==void 0;return(o.types??[o]).some(e=>s(e,`fold`)&&(s(e,`isLeft`)||s(e,`isFailure`))&&!s(e,`runExit`))},a={LeftOf:`Either`,RightOf:`Either`,SomeOf:`Option`,NoneOf:`Option`,SuccessOf:`Try`,FailureOf:`Try`,SuccessExitOf:`Exit`,FailureExitOf:`Exit`,DieExitOf:`Exit`,InterruptedExitOf:`Exit`},o=e=>{let t=(e.aliasSymbol?.name??e.getSymbol?.()?.name)?.replace(/\$\d+$/,``);return t===void 0||t.startsWith(`__`)?`functype container`:a[t]??t},s=e=>{let t=e.getSymbol?.();return t===void 0||t.name.startsWith(`__`)?!1:(t.getDeclarations?.()??[]).some(e=>e.getSourceFile().fileName.includes(`/node_modules/`))},c=(e,n)=>{let r=t(n);if(!r)return;let i=r.esTreeNodeToTSNodeMap.get(e);if(!i)return;let a=r.program.getTypeChecker(),c=/* @__PURE__ */ new Set,l=e=>a.getPropertyOfType(e,`_tag`)!==void 0&&a.getPropertyOfType(e,`fold`)!==void 0,u=(e,t)=>e===``?t:t.startsWith(`[`)?e+t:`${e}.${t}`,d=(e,t,n)=>{if(n>4||c.has(e)||p(e))return;c.add(e);let r=e;if(l(e))return{path:t,name:o(r)};if(r.isUnionOrIntersection?.()===!0)return(r.types??[]).map(e=>d(e,t,n)).find(e=>e!==void 0);if((r.getCallSignatures?.()??[]).length>0)return;if(a.isArrayLikeType(e)||a.isTupleType(e))return a.getTypeArguments(e).map(e=>d(e,t===``?`[]`:`${t}[]`,n+1)).find(e=>e!==void 0);let f=a.getIndexInfoOfType(e,0)?.type,m=f===void 0?void 0:d(f,u(t,`[key]`),n+1);if(m!==void 0)return m;if(!(r.getSymbol?.()===void 0||s(r)))return a.getPropertiesOfType(e).map(e=>d(a.getTypeOfSymbolAtLocation(e,i),u(t,e.name),n+1)).find(e=>e!==void 0)};return d(a.getTypeAtLocation(i),``,0)},l=/(?:^|[\\/])functype[\\/](?:dist|src)[\\/]/,u=e=>l.test(e.getSourceFile().fileName),d=(e,n,r)=>{let i=t(r);if(!i)return;let a=i.esTreeNodeToTSNodeMap.get(e);if(!a)return;let s=i.program.getTypeChecker(),c=s.getNonNullableType(s.getTypeAtLocation(a)),l=p(c)?s.getApparentType?.(c)??c:c;if(s.getPropertyOfType(l,`_tag`)===void 0||s.getPropertyOfType(l,`fold`)===void 0)return;let d=s.getPropertyOfType(l,n),f=d?.getDeclarations?.()??[];return f.length>0&&f.every(e=>Array.isArray(e.parameters)&&u(e))&&(s.getTypeOfSymbolAtLocation(d,a).getCallSignatures?.()??[]).length>0?o(l):void 0},f=(e,n)=>{let r=t(n);if(!r)return;let i=r.esTreeNodeToTSNodeMap.get(e);if(!i)return;let a=r.program.getTypeChecker(),s=a.getNonNullableType(a.getTypeAtLocation(i)),c=p(s)?a.getApparentType?.(s)??s:s,l=e=>{if(a.getPropertyOfType(e,`_tag`)===void 0)return!1;let t=a.getPropertyOfType(e,`fold`)?.getDeclarations?.()??[];return t.length>0&&t.every(u)};if(l(c))return o(c);let d=(c.types??[]).find(l);return d===void 0?void 0:o(d)},p=e=>e.isTypeParameter?.()===!0,m=e=>{let t=e.parent;if(!t)return null;if((t.type===`CallExpression`||t.type===`NewExpression`)&&t.callee!==e){let n=t.arguments.indexOf(e);return n<0?null:{call:t,argument:e,index:n}}return t.type===`TSAsExpression`||t.type===`TSSatisfiesExpression`||t.type===`ConditionalExpression`&&t.test!==e||t.type===`LogicalExpression`||t.type===`Property`||t.type===`ObjectExpression`||t.type===`ArrayExpression`||t.type===`SpreadElement`?m(t):null},h=(e,t,n)=>{let r=m(n),i=r?t.esTreeNodeToTSNodeMap.get(r.call):void 0,a=i?e.getResolvedSignature(i)?.getDeclaration()?.parameters:void 0;if(!r||!a||a.length===0)return!1;let o=a[Math.min(r.index,a.length-1)];if(o?.type===void 0)return!1;let s=e.getTypeAtLocation(o.type);return(s.types??[s]).some(p)},g=(e,t,n)=>{let r=m(n),i=r?t.esTreeNodeToTSNodeMap.get(r.call):void 0,a=i?e.getResolvedSignature(i):void 0,o=r?t.esTreeNodeToTSNodeMap.get(r.argument):void 0;if(!a||!o)return!1;let s=e.getTypeAtLocation(o),c=t=>t===s||e.isTypeAssignableTo(s,t)&&e.isTypeAssignableTo(t,s),l=(t,n)=>{if(n>3)return!1;if(c(t))return!0;let{types:r,target:i}=t;if(r)return r.some(e=>l(e,n+1));if(i!==void 0&&(e.isTupleType(t)||e.isArrayLikeType(t)))return e.getTypeArguments(t).some(e=>l(e,n+1));let a=e.getAwaitedType(t);return a!==void 0&&a!==t&&l(a,n+1)};return l(e.getReturnTypeOfSignature(a),0)},_=(e,t,n)=>y(n.type)||p(n.type)&&!g(e,t,n.at),v=(t,n,r)=>{if(_(t,n,r))return!0;let{types:i,symbol:a}=r.type;return i?i.some(e=>v(t,n,{type:e,at:r.at})):a?.name!==void 0&&e.has(a.name)?!0:!p(r.type)&&t.isArrayLikeType(r.type)},y=e=>{let{flags:t}=e;return t!==void 0&&!!(t&3)},b=(e,t)=>{let{types:n,symbol:r}=t;return n?n.some(t=>b(e,t)):r?.name===`Array`&&e.isArrayLikeType(t)},x=e=>e.computed?null:e.key?.type===`Identifier`?e.key.name:e.key?.type===`Literal`&&typeof e.key.value==`string`?e.key.value:null,S=(e,t,n,r,i=0)=>{if(i>4)return;let a=t.esTreeNodeToTSNodeMap.get(n),o=a?e.getContextualType(a):void 0;if(o!==void 0)return{type:o,at:n};let s=n.parent;if(s?.type===`ArrowFunctionExpression`&&s.body===n){let n=s.parent;if(n?.type===`VariableDeclarator`&&n.init===s&&n.id?.type===`Identifier`)return(r.sourceCode.getDeclaredVariables(n)[0]?.references??[]).map(e=>e.identifier.parent).filter(e=>e?.type===`CallExpression`).map(n=>S(e,t,n,r,i+1)).find(e=>e!==void 0)}if((s?.type===`CallExpression`||s?.type===`NewExpression`)&&s.callee!==n){let r=s.arguments.indexOf(n),i=t.esTreeNodeToTSNodeMap.get(s),a=r>=0&&i?e.getResolvedSignature(i)?.parameters[r]:void 0;return a===void 0?void 0:{type:e.getTypeOfSymbolAtLocation(a,i),at:n}}let c=s?.type===`Property`&&s.value===n?s.parent:void 0;if(c?.type!==`ObjectExpression`)return;let l=S(e,t,c,r,i+1);if(l===void 0||_(e,t,l))return l;let u=l.type,d=x(s);if(d===null){let r=s.key,i=r?t.esTreeNodeToTSNodeMap.get(r):void 0,o=i?e.getTypeAtLocation(i):void 0,c=o?.value??o?.types?.[0]?.value,l=typeof c==`string`?e.getPropertyOfType(u,c):void 0,d=l===void 0?e.getIndexInfoOfType(u,0)?.type:e.getTypeOfSymbolAtLocation(l,a);return d===void 0?void 0:{type:d,at:n}}let f=e.getPropertyOfType(u,d);return f===void 0?void 0:{type:e.getTypeOfSymbolAtLocation(f,a),at:n}},C=(e,n)=>{let r=t(n);if(!r)return;let i=r.program.getTypeChecker(),a=S(i,r,e,n);if(a!==void 0)return h(i,r,a.at)?!g(i,r,a.at):v(i,r,a)},w=(e,n)=>{let r=t(n);if(!r)return;let i=r.program.getTypeChecker(),a=S(i,r,e,n);return a===void 0||h(i,r,a.at)?!1:b(i,a.type)},T=(e,n)=>{let r=t(n);if(!r)return;let i=r.esTreeNodeToTSNodeMap.get(e);if(!i)return;let a=r.program.getTypeChecker(),o=a.getTypeAtLocation(i);if(y(o))return!0;if(!a.isArrayLikeType(o))return!1;let s=a.getTypeArguments(o)[0];return s!==void 0&&y(s)},E=e=>t(e)!==void 0;export{i as canCarryFailureByType,c as containerInsideByType,C as flowsIntoArraySlot,w as flowsIntoMutableArraySlot,d as functypeMethodByType,f as functypeValueByType,E as hasTypeInformation,n as isExtractableByType,r as isIOByType,T as isUntypedExpression};
|
|
2
2
|
//# sourceMappingURL=type-aware.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-aware.js","names":["CONSUMED_COLLECTION_TYPES","typedServices","context","services","isExtractableByType","node","tsNode","checker","type","isIOByType","canCarryFailureByType","has","member","name","MEMBER_TO_CONTAINER","containerName","raw","isFromDependency","symbol","declaration","containerInsideByType","seen","isContainer","at","path","step","find","depth","isTypeParameter","shape","h","element","indexed","byIndex","property","FUNCTYPE_FILE","isDeclaredByFunctype","functypeMethodByType","object","read","declarations","d","enclosingCall","parent","index","isGenericParameterArgument","found","callTs","parameters","declared","annotated","handsArgumentBack","signature","argTs","argType","sameAsArgument","candidate","search","types","target","awaited","isOpaqueSink","slot","isUntyped","isArrayLikeOrUntyped","flags","isMutableArrayType","propertyKey","expectedSlot","own","declarator","ref","call","parameter","objectLiteral","outerSlot","outer","key","keyNode","keyTs","keyType","literal","named","flowsIntoArraySlot","flowsIntoMutableArraySlot","isUntypedExpression","hasTypeInformation"],"sources":["../../src/utils/type-aware.ts"],"sourcesContent":["import type { Rule } from \"eslint\"\n\nimport type { ASTNode } from \"../types/ast\"\n\n/**\n * Type-aware helpers that work only when the consumer turns on type-aware linting\n * (`parserOptions.projectService` or `project`). Without it they report \"unknown\", and a rule\n * falls back to its syntactic heuristic.\n *\n * The checker is reached through `parserServices` and typed structurally here, so the plugin\n * takes no runtime dependency on `typescript`.\n */\n\ntype TypeLike = object\n\ntype CheckerLike = {\n getTypeAtLocation(node: unknown): TypeLike\n getNonNullableType(type: TypeLike): TypeLike\n getPropertyOfType(type: TypeLike, name: string): unknown\n getContextualType(node: unknown): TypeLike | undefined\n isArrayLikeType(type: TypeLike): boolean\n getTypeOfSymbolAtLocation(symbol: unknown, node: unknown): TypeLike\n getTypeArguments(type: TypeLike): ReadonlyArray<TypeLike>\n getResolvedSignature(node: unknown): SignatureLike | undefined\n getIndexInfoOfType(type: TypeLike, kind: number): { readonly type: TypeLike } | undefined\n getReturnTypeOfSignature(signature: unknown): TypeLike\n getAwaitedType(type: TypeLike): TypeLike | undefined\n isTupleType(type: TypeLike): boolean\n isTypeAssignableTo(source: TypeLike, target: TypeLike): boolean\n getPropertiesOfType(type: TypeLike): ReadonlyArray<{ readonly name: string }>\n getApparentType?(type: TypeLike): TypeLike\n}\n\ntype SignatureLike = {\n readonly parameters: ReadonlyArray<unknown>\n getDeclaration(): { readonly parameters?: ReadonlyArray<unknown> } | undefined\n}\n\n/** `ts.TypeFlags.Any` / `Unknown`, inlined so the plugin needs no runtime `typescript` import. */\nconst ANY_OR_UNKNOWN_FLAGS = 1 | 2\n\n/** Interfaces a consumer reads through rather than keeps: `importKey(…, usages: Iterable<KeyUsage>)`, `new Set(values)`. */\nconst CONSUMED_COLLECTION_TYPES: ReadonlySet<string> = new Set([\n \"Iterable\",\n \"AsyncIterable\",\n \"IterableIterator\",\n \"ArrayLike\",\n])\n\ntype TypedServices = {\n readonly program: { getTypeChecker(): CheckerLike }\n readonly esTreeNodeToTSNodeMap: { get(node: unknown): unknown }\n}\n\nconst typedServices = (context: Rule.RuleContext): TypedServices | undefined => {\n const services = context.sourceCode.parserServices as Partial<TypedServices> | undefined\n return services?.program && services.esTreeNodeToTSNodeMap ? (services as TypedServices) : undefined\n}\n\n/**\n * Is `node`'s type a functype extractable container (Option, Either, Try, Lazy, …)? Structural:\n * the type, after stripping `null` / `undefined`, has both `orThrow` and `fold` — true of every\n * functype container, including union types like `Either` (each member has both). Native\n * collections (`Map#get`) and arbitrary objects don't.\n *\n * `undefined` when type information isn't available, so the caller can fall back.\n */\nexport const isExtractableByType = (node: ASTNode, context: Rule.RuleContext): boolean | undefined => {\n const services = typedServices(context)\n if (!services) return undefined\n const tsNode = services.esTreeNodeToTSNodeMap.get(node)\n if (!tsNode) return undefined\n const checker = services.program.getTypeChecker()\n const type = checker.getNonNullableType(checker.getTypeAtLocation(tsNode))\n return (\n checker.getPropertyOfType(type, \"orThrow\") !== undefined && checker.getPropertyOfType(type, \"fold\") !== undefined\n )\n}\n\n/**\n * Is `node`'s type a functype `IO`? Structural: the type has both `runExit` and `provideLayer`, which\n * only `IO` carries — `Lazy` and the other containers have neither — and has carried since\n * well before 1.9, so older functype versions are recognized too. A union of IOs counts.\n * `any` and `unknown` have no properties, so they don't.\n *\n * `undefined` when type information isn't available.\n */\nexport const isIOByType = (node: ASTNode, context: Rule.RuleContext): boolean | undefined => {\n const services = typedServices(context)\n if (!services) return undefined\n const tsNode = services.esTreeNodeToTSNodeMap.get(node)\n if (!tsNode) return undefined\n const checker = services.program.getTypeChecker()\n const type = checker.getNonNullableType(checker.getTypeAtLocation(tsNode))\n return (\n checker.getPropertyOfType(type, \"runExit\") !== undefined &&\n checker.getPropertyOfType(type, \"provideLayer\") !== undefined\n )\n}\n\n/**\n * Can `node`'s value carry a failure that dropping it would lose? Structural: the type, or a member of\n * its union, has `fold` and `isLeft` or `isFailure`. That covers Either, Try, Exit, Validation and\n * Either-shaped wrappers such as a `ServiceResult`, and leaves out Option and List, whose `None` or\n * empty value is no error. An `IO` is left to no-floating-io: it hasn't run, so it holds no failure yet.\n *\n * `undefined` when type information isn't available.\n */\nexport const canCarryFailureByType = (node: ASTNode, context: Rule.RuleContext): boolean | undefined => {\n const services = typedServices(context)\n if (!services) return undefined\n const tsNode = services.esTreeNodeToTSNodeMap.get(node)\n if (!tsNode) return undefined\n const checker = services.program.getTypeChecker()\n const type = checker.getNonNullableType(checker.getTypeAtLocation(tsNode))\n const has = (member: TypeLike, name: string): boolean => checker.getPropertyOfType(member, name) !== undefined\n const carries = (member: TypeLike): boolean =>\n has(member, \"fold\") && (has(member, \"isLeft\") || has(member, \"isFailure\")) && !has(member, \"runExit\")\n const members = (type as { readonly types?: ReadonlyArray<TypeLike> }).types ?? [type]\n return members.some(carries)\n}\n\n/** Where a functype container sits inside a value, and what it is called. */\nexport type ContainerAt = { readonly path: string; readonly name: string }\n\ntype TypeShape = {\n readonly types?: ReadonlyArray<TypeLike>\n readonly aliasSymbol?: SymbolShape\n isUnionOrIntersection?: () => boolean\n getSymbol?: () => SymbolShape | undefined\n getCallSignatures?: () => ReadonlyArray<unknown>\n}\ntype SymbolShape = {\n readonly name: string\n getDeclarations?: () => ReadonlyArray<{ getSourceFile(): { readonly fileName: string } }> | undefined\n}\n\nconst SERIALIZE_DEPTH = 4\n\n/** A name to show for a container type: `Either`, `Option`, `List`, or the generic fallback. */\n/** Member names TypeScript shows once a union loses its alias (`Either<E, A> | null`), mapped back. */\nconst MEMBER_TO_CONTAINER: Readonly<Record<string, string>> = {\n LeftOf: \"Either\",\n RightOf: \"Either\",\n SomeOf: \"Option\",\n NoneOf: \"Option\",\n SuccessOf: \"Try\",\n FailureOf: \"Try\",\n SuccessExitOf: \"Exit\",\n FailureExitOf: \"Exit\",\n DieExitOf: \"Exit\",\n InterruptedExitOf: \"Exit\",\n}\n\nconst containerName = (type: TypeShape): string => {\n // A bundled .d.ts renames a clashing declaration `Map$1`.\n const raw = (type.aliasSymbol?.name ?? type.getSymbol?.()?.name)?.replace(/\\$\\d+$/, \"\")\n if (raw === undefined || raw.startsWith(\"__\")) return \"functype container\"\n return MEMBER_TO_CONTAINER[raw] ?? raw\n}\n\n/** Declared in a dependency or the TypeScript lib: Stripe objects, Date, Request. Never descended into. */\nconst isFromDependency = (type: TypeShape): boolean => {\n // The type's own symbol, not its alias: `Partial<User>` and `Omit<Row, \"x\">` are anonymous mapped\n // types whose alias is declared in TypeScript's lib, and their properties are the caller's.\n const symbol = type.getSymbol?.()\n if (symbol === undefined || symbol.name.startsWith(\"__\")) return false\n return (symbol.getDeclarations?.() ?? []).some((declaration) =>\n declaration.getSourceFile().fileName.includes(\"/node_modules/\"),\n )\n}\n\n/**\n * The first functype container inside the value `node` evaluates to, and the path to it: `subscription`,\n * `items[]`, or empty for the whole value. A container is a type with `_tag` and `fold`, which every\n * functype container has and its `toJSON()` envelope doesn't. Walks unions, intersections, array and\n * tuple elements, object properties and string index signatures, up to 4 levels deep, and checks for a\n * container before skipping types declared in node_modules, where functype itself lives (#364).\n *\n * `undefined` when there is none, or when type information isn't available.\n */\nexport const containerInsideByType = (node: ASTNode, context: Rule.RuleContext): ContainerAt | undefined => {\n const services = typedServices(context)\n if (!services) return undefined\n const tsNode = services.esTreeNodeToTSNodeMap.get(node)\n if (!tsNode) return undefined\n const checker = services.program.getTypeChecker()\n const seen = new Set<TypeLike>()\n const isContainer = (type: TypeLike): boolean =>\n checker.getPropertyOfType(type, \"_tag\") !== undefined && checker.getPropertyOfType(type, \"fold\") !== undefined\n const at = (path: string, step: string): string =>\n path === \"\" ? step : step.startsWith(\"[\") ? path + step : `${path}.${step}`\n\n const find = (type: TypeLike, path: string, depth: number): ContainerAt | undefined => {\n if (depth > SERIALIZE_DEPTH || seen.has(type) || isTypeParameter(type)) return undefined\n seen.add(type)\n const shape = type as TypeShape\n // Before splitting: an Either union has `_tag` and `fold` on every member, and `Stack` is an\n // intersection whose `_tag` and `fold` come from different members.\n if (isContainer(type)) return { path, name: containerName(shape) }\n if (shape.isUnionOrIntersection?.() === true) {\n return (shape.types ?? []).map((member) => find(member, path, depth)).find((h) => h !== undefined)\n }\n if ((shape.getCallSignatures?.() ?? []).length > 0) return undefined\n if (checker.isArrayLikeType(type) || checker.isTupleType(type)) {\n return checker\n .getTypeArguments(type)\n .map((element) => find(element, path === \"\" ? \"[]\" : `${path}[]`, depth + 1))\n .find((h) => h !== undefined)\n }\n // Before the dependency skip: `Record<string, Option<T>>` is declared in TypeScript's lib.\n const indexed = checker.getIndexInfoOfType(type, 0)?.type\n const byIndex = indexed === undefined ? undefined : find(indexed, at(path, \"[key]\"), depth + 1)\n if (byIndex !== undefined) return byIndex\n if (shape.getSymbol?.() === undefined || isFromDependency(shape)) return undefined\n return checker\n .getPropertiesOfType(type)\n .map((property) => find(checker.getTypeOfSymbolAtLocation(property, tsNode), at(path, property.name), depth + 1))\n .find((h) => h !== undefined)\n }\n\n return find(checker.getTypeAtLocation(tsNode), \"\", 0)\n}\n\ntype MemberDeclaration = {\n readonly parameters?: unknown\n getSourceFile(): { readonly fileName: string }\n}\ntype MemberSymbol = { getDeclarations?: () => ReadonlyArray<MemberDeclaration> | undefined }\n\n/**\n * Declared by functype itself: its published `dist` (`node_modules/functype/dist/…`, pnpm's\n * `.pnpm/functype@x/node_modules/functype/dist/…`) or, inside this repo, `packages/functype/{src,dist}`.\n */\nconst FUNCTYPE_FILE = /(?:^|[\\\\/])functype[\\\\/](?:dist|src)[\\\\/]/\nconst isDeclaredByFunctype = (declaration: MemberDeclaration): boolean =>\n FUNCTYPE_FILE.test(declaration.getSourceFile().fileName)\n\n/**\n * If `object` is a functype container and `name` is one of its methods, the container's name\n * (`List`, `Option`, `Either`); otherwise `undefined`. A container has `_tag` and `fold`. A method is\n * declared in functype's own files, so a user type with the same shape (a union with `_tag` and a\n * `fold`, or an interface extending `List` with methods of its own) never counts for those methods. It is a\n * callable member whose declaration has parameters (`head(): A | undefined`, `fold<B>(…)`), so neither\n * function-valued data (`readonly value: R` on a `Right` holding a callback) nor a getter (`size`) is one. A type parameter is read\n * through its constraint.\n *\n * `undefined` when type information isn't available.\n */\nexport const functypeMethodByType = (object: ASTNode, name: string, context: Rule.RuleContext): string | undefined => {\n const services = typedServices(context)\n if (!services) return undefined\n const tsNode = services.esTreeNodeToTSNodeMap.get(object)\n if (!tsNode) return undefined\n const checker = services.program.getTypeChecker()\n const read = checker.getNonNullableType(checker.getTypeAtLocation(tsNode))\n const type = isTypeParameter(read) ? (checker.getApparentType?.(read) ?? read) : read\n const isContainer =\n checker.getPropertyOfType(type, \"_tag\") !== undefined && checker.getPropertyOfType(type, \"fold\") !== undefined\n if (!isContainer) return undefined\n const member = checker.getPropertyOfType(type, name) as MemberSymbol | undefined\n const declarations = member?.getDeclarations?.() ?? []\n // A getter (`get size(): number`) has parameters too, but reading it gives its value, not a function.\n const isCallable = (): boolean =>\n ((checker.getTypeOfSymbolAtLocation(member, tsNode) as TypeShape).getCallSignatures?.() ?? []).length > 0\n const isMethod =\n declarations.length > 0 &&\n declarations.every((d) => Array.isArray(d.parameters) && isDeclaredByFunctype(d)) &&\n isCallable()\n return isMethod ? containerName(type as TypeShape) : undefined\n}\n\n/** A slot's expected type and the expression TypeScript computed it for. */\ntype Slot = { readonly type: TypeLike; readonly at: ASTNode }\n\n/**\n * Uses the `Type` object's own predicate rather than a `TypeFlags` bit: TypeScript renumbers its flags\n * between majors (TypeParameter is `1 << 19` in TS 6, `1 << 18` before), and the plugin has no runtime\n * `typescript` import to read them from.\n */\nconst isTypeParameter = (type: TypeLike): boolean =>\n (type as { isTypeParameter?: () => boolean }).isTypeParameter?.() === true\n\n/**\n * `f(…, arg, …)` where `at` is `arg` or sits inside it (an object property, an array element, a spread,\n * a conditional branch, an `as`): the call, the whole argument, and its index.\n */\nconst enclosingCall = (\n at: ASTNode,\n): { readonly call: ASTNode; readonly argument: ASTNode; readonly index: number } | null => {\n const parent = at.parent as ASTNode | undefined\n if (!parent) return null\n if ((parent.type === \"CallExpression\" || parent.type === \"NewExpression\") && parent.callee !== at) {\n const index = (parent.arguments as ReadonlyArray<ASTNode>).indexOf(at)\n return index < 0 ? null : { call: parent, argument: at, index }\n }\n const passesThrough =\n parent.type === \"TSAsExpression\" ||\n parent.type === \"TSSatisfiesExpression\" ||\n (parent.type === \"ConditionalExpression\" && parent.test !== at) ||\n parent.type === \"LogicalExpression\" ||\n parent.type === \"Property\" ||\n parent.type === \"ObjectExpression\" ||\n parent.type === \"ArrayExpression\" ||\n parent.type === \"SpreadElement\"\n return passesThrough ? enclosingCall(parent) : null\n}\n\n/**\n * Is the parameter that `at` is passed to (directly or nested) declared as a type parameter, or a union\n * containing one — `json<T>(data: T)`, `useState<S>(init: S | (() => S))`? Then TypeScript's expected type for `at` is only an echo of what it inferred from\n * `at` itself (`[1, 2]` → `number[]`), not a shape the library demands.\n */\nconst isGenericParameterArgument = (checker: CheckerLike, services: TypedServices, at: ASTNode): boolean => {\n const found = enclosingCall(at)\n const callTs = found ? services.esTreeNodeToTSNodeMap.get(found.call) : undefined\n const parameters = callTs ? checker.getResolvedSignature(callTs)?.getDeclaration()?.parameters : undefined\n if (!found || !parameters || parameters.length === 0) return false\n const declared = parameters[Math.min(found.index, parameters.length - 1)] as { readonly type?: unknown } | undefined\n // The parameter's type annotation node (`T` in `value: T`); asking for the declaration node's type gives `any`.\n if (declared?.type === undefined) return false\n const annotated = checker.getTypeAtLocation(declared.type)\n // React's `useState<S>(init: S | (() => S))`: a union that contains the type parameter is generic too.\n const members = (annotated as { types?: ReadonlyArray<TypeLike> }).types ?? [annotated]\n return members.some(isTypeParameter)\n}\n\n/**\n * Does the generic call around `at` hand the argument straight back to the caller — `useState(init)`\n * returning `[init, set]`, `identity(x)`, a `Promise` of it? Then the shape stays the caller's, and a\n * type parameter isn't a sink. Looks only at the return type itself, union / intersection members,\n * tuple and array elements, and an awaited Promise, not object properties: Hono's `c.json<T>` returns a\n * `Response` that carries a *parsed* copy of `T` for its RPC client, which the caller doesn't get back.\n */\nconst handsArgumentBack = (checker: CheckerLike, services: TypedServices, at: ASTNode): boolean => {\n const found = enclosingCall(at)\n const callTs = found ? services.esTreeNodeToTSNodeMap.get(found.call) : undefined\n const signature = callTs ? checker.getResolvedSignature(callTs) : undefined\n const argTs = found ? services.esTreeNodeToTSNodeMap.get(found.argument) : undefined\n if (!signature || !argTs) return false\n const argType = checker.getTypeAtLocation(argTs)\n const sameAsArgument = (candidate: TypeLike): boolean =>\n candidate === argType ||\n (checker.isTypeAssignableTo(argType, candidate) && checker.isTypeAssignableTo(candidate, argType))\n const search = (type: TypeLike, depth: number): boolean => {\n if (depth > 3) return false\n if (sameAsArgument(type)) return true\n const { types, target } = type as { types?: ReadonlyArray<TypeLike>; target?: unknown }\n if (types) return types.some((member) => search(member, depth + 1))\n if (target !== undefined && (checker.isTupleType(type) || checker.isArrayLikeType(type))) {\n return checker.getTypeArguments(type).some((element) => search(element, depth + 1))\n }\n const awaited = checker.getAwaitedType(type)\n return awaited !== undefined && awaited !== type && search(awaited, depth + 1)\n }\n return search(checker.getReturnTypeOfSignature(signature), 0)\n}\n\n/**\n * Untyped, or a type parameter of a call that doesn't hand the argument back: an object handed to\n * `c.json<T>(data: T)` or `JSON.stringify` goes to a sink. `useState<T>(init: T)` is not one.\n */\nconst isOpaqueSink = (checker: CheckerLike, services: TypedServices, slot: Slot): boolean =>\n isUntyped(slot.type) || (isTypeParameter(slot.type) && !handsArgumentBack(checker, services, slot.at))\n\nconst isArrayLikeOrUntyped = (checker: CheckerLike, services: TypedServices, slot: Slot): boolean => {\n if (isOpaqueSink(checker, services, slot)) return true\n const { types, symbol } = slot.type as { types?: ReadonlyArray<TypeLike>; symbol?: { name?: string } }\n if (types) return types.some((member) => isArrayLikeOrUntyped(checker, services, { type: member, at: slot.at }))\n if (symbol?.name !== undefined && CONSUMED_COLLECTION_TYPES.has(symbol.name)) return true\n return !isTypeParameter(slot.type) && checker.isArrayLikeType(slot.type)\n}\n\nconst isUntyped = (type: TypeLike): boolean => {\n const { flags } = type as { flags?: number }\n return flags !== undefined && (flags & ANY_OR_UNKNOWN_FLAGS) !== 0\n}\n\n/** The mutable `Array` type, as opposed to `ReadonlyArray`: the one a `ReadonlyArray` can't be passed to. */\nconst isMutableArrayType = (checker: CheckerLike, type: TypeLike): boolean => {\n const { types, symbol } = type as { types?: ReadonlyArray<TypeLike>; symbol?: { name?: string } }\n if (types) return types.some((member) => isMutableArrayType(checker, member))\n return symbol?.name === \"Array\" && checker.isArrayLikeType(type)\n}\n\n/** The name a property is written under: `params` in `{ params }`, `parts` in `{ parts: … }` or `{ \"parts\": … }`. */\nconst propertyKey = (property: ASTNode): string | null => {\n if (property.computed) return null\n if (property.key?.type === \"Identifier\") return property.key.name\n return property.key?.type === \"Literal\" && typeof property.key.value === \"string\" ? property.key.value : null\n}\n\n/**\n * The expected type of `node`, looking through object literals when TypeScript gives the value none of\n * its own. Two cases: a shorthand `{ params }` passed to a function, where the expected type is that\n * property's type on the parameter; and `[…]` in `JSON.stringify({ parts: [...] })`, where the object is\n * passed to an `any` parameter, so the whole object is going to an untyped host.\n */\nconst expectedSlot = (\n checker: CheckerLike,\n services: TypedServices,\n node: ASTNode,\n context: Rule.RuleContext,\n depth = 0,\n): Slot | undefined => {\n if (depth > 4) return undefined\n const tsNode = services.esTreeNodeToTSNodeMap.get(node)\n const own = tsNode ? checker.getContextualType(tsNode) : undefined\n if (own !== undefined) return { type: own, at: node }\n const parent = node.parent as ASTNode | undefined\n // `const metadata = (url) => ({ … })` with no declared return type: the object goes wherever the\n // calls' results go (`c.json(metadata(url))`), so take the expected type at the first call site.\n if (parent?.type === \"ArrowFunctionExpression\" && parent.body === node) {\n const declarator = parent.parent as ASTNode | undefined\n if (\n declarator?.type === \"VariableDeclarator\" &&\n declarator.init === parent &&\n declarator.id?.type === \"Identifier\"\n ) {\n const variable = context.sourceCode.getDeclaredVariables(declarator)[0]\n const calls = (variable?.references ?? [])\n .map((ref) => (ref.identifier as unknown as ASTNode).parent as ASTNode | undefined)\n .filter((call): call is ASTNode => call?.type === \"CallExpression\")\n return calls\n .map((call) => expectedSlot(checker, services, call, context, depth + 1))\n .find((slot) => slot !== undefined)\n }\n }\n // An argument to an overloaded function (`crypto.subtle.importKey(…, [\"decrypt\"])`) gets no contextual\n // type; the parameter of the overload TypeScript picked is the expected type.\n if ((parent?.type === \"CallExpression\" || parent?.type === \"NewExpression\") && parent.callee !== node) {\n const index = (parent.arguments as ReadonlyArray<ASTNode>).indexOf(node)\n const call = services.esTreeNodeToTSNodeMap.get(parent)\n const parameter = index >= 0 && call ? checker.getResolvedSignature(call)?.parameters[index] : undefined\n return parameter === undefined ? undefined : { type: checker.getTypeOfSymbolAtLocation(parameter, call), at: node }\n }\n const objectLiteral = parent?.type === \"Property\" && parent.value === node ? (parent.parent as ASTNode) : undefined\n if (objectLiteral?.type !== \"ObjectExpression\") return undefined\n const outerSlot = expectedSlot(checker, services, objectLiteral, context, depth + 1)\n if (outerSlot === undefined || isOpaqueSink(checker, services, outerSlot)) return outerSlot\n const outer = outerSlot.type\n const key = propertyKey(parent as ASTNode)\n // `{ [k]: [...] }` (a reduce accumulator keyed by category): the property named by the key's literal\n // type, else the string index signature's type.\n if (key === null) {\n const keyNode = (parent as ASTNode).key\n const keyTs = keyNode ? services.esTreeNodeToTSNodeMap.get(keyNode) : undefined\n const keyType = keyTs\n ? (checker.getTypeAtLocation(keyTs) as { value?: unknown; types?: ReadonlyArray<{ value?: unknown }> })\n : undefined\n const literal = keyType?.value ?? keyType?.types?.[0]?.value\n const named = typeof literal === \"string\" ? checker.getPropertyOfType(outer, literal) : undefined\n const type =\n named !== undefined\n ? checker.getTypeOfSymbolAtLocation(named, tsNode)\n : checker.getIndexInfoOfType(outer, 0)?.type\n return type === undefined ? undefined : { type, at: node }\n }\n const member = checker.getPropertyOfType(outer, key)\n return member === undefined ? undefined : { type: checker.getTypeOfSymbolAtLocation(member, tsNode), at: node }\n}\n\n/**\n * Does `node` (an expression) flow into a slot that is typed as an array, a tuple or `any`/`unknown`?\n * That's the expected type TypeScript checks it against: the parameter it is passed to, the property\n * it initialises, the declared return type. A literal in such a slot is handed to code that requires an\n * array, such as drizzle's `.values([...])` or an index definition, so `List` can't go there. A literal\n * inside an object passed to an `any` parameter (a `JSON.stringify` request body) counts too.\n *\n * `undefined` when type information isn't available, or when there is no expected type (a free-standing\n * literal), so the caller can fall back.\n */\nexport const flowsIntoArraySlot = (node: ASTNode, context: Rule.RuleContext): boolean | undefined => {\n const services = typedServices(context)\n if (!services) return undefined\n const checker = services.program.getTypeChecker()\n const slot = expectedSlot(checker, services, node, context)\n if (slot === undefined) return undefined\n // A bare `T` parameter: a sink unless the call hands the argument straight back (`useState`, `identity`).\n if (isGenericParameterArgument(checker, services, slot.at)) return !handsArgumentBack(checker, services, slot.at)\n return isArrayLikeOrUntyped(checker, services, slot)\n}\n\n/**\n * Does `node` flow into a slot that requires a *mutable* array — a parameter typed `T[]`, such as pg's\n * `query(text, values: unknown[])`, drizzle's `inArray(col, values)` or ReactFlow's `nodes`? There a\n * `ReadonlyArray` won't type-check, so a mutable annotation is what the library demands.\n *\n * `undefined` when type information isn't available.\n */\nexport const flowsIntoMutableArraySlot = (node: ASTNode, context: Rule.RuleContext): boolean | undefined => {\n const services = typedServices(context)\n if (!services) return undefined\n const checker = services.program.getTypeChecker()\n const slot = expectedSlot(checker, services, node, context)\n if (slot === undefined || isGenericParameterArgument(checker, services, slot.at)) return false\n return isMutableArrayType(checker, slot.type)\n}\n\n/**\n * Is `node`'s own type `any` / `unknown`, or an array of them — `JSON.parse(raw)`, `await res.json()`,\n * `raw` after `Array.isArray(raw)` (narrowed to `any[]`)? `undefined` when type information isn't available.\n */\nexport const isUntypedExpression = (node: ASTNode, context: Rule.RuleContext): boolean | undefined => {\n const services = typedServices(context)\n if (!services) return undefined\n const tsNode = services.esTreeNodeToTSNodeMap.get(node)\n if (!tsNode) return undefined\n const checker = services.program.getTypeChecker()\n const type = checker.getTypeAtLocation(tsNode)\n if (isUntyped(type)) return true\n if (!checker.isArrayLikeType(type)) return false\n const element = checker.getTypeArguments(type)[0]\n return element !== undefined && isUntyped(element)\n}\n\n/** Is type-aware linting on for this file (`parserOptions.projectService` or `project`)? */\nexport const hasTypeInformation = (context: Rule.RuleContext): boolean => typedServices(context) !== undefined\n"],"mappings":"AAuCA,MAGMA,kBAAiD,IAAI,IAAI,CAC7D,WACA,gBACA,mBACA,WACF,CAAC,EAOKC,EAAiBC,GAAyD,CAC9E,IAAMC,EAAWD,EAAQ,WAAW,eACpC,OAAOC,GAAU,SAAWA,EAAS,sBAAyBA,EAA6B,IAAA,EAC7F,EAUaC,GAAuBC,EAAeH,IAAmD,CACpG,IAAMC,EAAWF,EAAcC,CAAO,EACtC,GAAI,CAACC,EAAU,OACf,IAAMG,EAASH,EAAS,sBAAsB,IAAIE,CAAI,EACtD,GAAI,CAACC,EAAQ,OACb,IAAMC,EAAUJ,EAAS,QAAQ,eAAe,EAC1CK,EAAOD,EAAQ,mBAAmBA,EAAQ,kBAAkBD,CAAM,CAAC,EACzE,OACEC,EAAQ,kBAAkBC,EAAM,SAAS,IAAM,IAAA,IAAaD,EAAQ,kBAAkBC,EAAM,MAAM,IAAM,IAAA,EAE5G,EAUaC,GAAcJ,EAAeH,IAAmD,CAC3F,IAAMC,EAAWF,EAAcC,CAAO,EACtC,GAAI,CAACC,EAAU,OACf,IAAMG,EAASH,EAAS,sBAAsB,IAAIE,CAAI,EACtD,GAAI,CAACC,EAAQ,OACb,IAAMC,EAAUJ,EAAS,QAAQ,e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,EAAmB3D,EAASuD,EAAK,IAAI,CAC9C,EAMauB,GAAuBhF,EAAeH,IAAmD,CACpG,IAAMC,EAAWF,EAAcC,CAAO,EACtC,GAAI,CAACC,EAAU,OACf,IAAMG,EAASH,EAAS,sBAAsB,IAAIE,CAAI,EACtD,GAAI,CAACC,EAAQ,OACb,IAAMC,EAAUJ,EAAS,QAAQ,eAAe,EAC1CK,EAAOD,EAAQ,kBAAkBD,CAAM,EAC7C,GAAIyD,EAAUvD,CAAI,EAAG,MAAO,GAC5B,GAAI,CAACD,EAAQ,gBAAgBC,CAAI,EAAG,MAAO,GAC3C,IAAMuB,EAAUxB,EAAQ,iBAAiBC,CAAI,CAAC,CAAC,GAC/C,OAAOuB,IAAY,IAAA,IAAagC,EAAUhC,CAAO,CACnD,EAGauD,EAAsBpF,GAAuCD,EAAcC,CAAO,IAAM,IAAA,G"}
|
|
1
|
+
{"version":3,"file":"type-aware.js","names":["CONSUMED_COLLECTION_TYPES","typedServices","context","services","isExtractableByType","node","tsNode","checker","type","isIOByType","canCarryFailureByType","has","member","name","MEMBER_TO_CONTAINER","containerName","raw","isFromDependency","symbol","declaration","containerInsideByType","seen","isContainer","at","path","step","find","depth","isTypeParameter","shape","h","element","indexed","byIndex","property","FUNCTYPE_FILE","isDeclaredByFunctype","functypeMethodByType","object","read","declarations","d","functypeValueByType","isFunctype","candidate","enclosingCall","parent","index","isGenericParameterArgument","found","callTs","parameters","declared","annotated","handsArgumentBack","signature","argTs","argType","sameAsArgument","search","types","target","awaited","isOpaqueSink","slot","isUntyped","isArrayLikeOrUntyped","flags","isMutableArrayType","propertyKey","expectedSlot","own","declarator","ref","call","parameter","objectLiteral","outerSlot","outer","key","keyNode","keyTs","keyType","literal","named","flowsIntoArraySlot","flowsIntoMutableArraySlot","isUntypedExpression","hasTypeInformation"],"sources":["../../src/utils/type-aware.ts"],"sourcesContent":["import type { Rule } from \"eslint\"\n\nimport type { ASTNode } from \"../types/ast\"\n\n/**\n * Type-aware helpers that work only when the consumer turns on type-aware linting\n * (`parserOptions.projectService` or `project`). Without it they report \"unknown\", and a rule\n * falls back to its syntactic heuristic.\n *\n * The checker is reached through `parserServices` and typed structurally here, so the plugin\n * takes no runtime dependency on `typescript`.\n */\n\ntype TypeLike = object\n\ntype CheckerLike = {\n getTypeAtLocation(node: unknown): TypeLike\n getNonNullableType(type: TypeLike): TypeLike\n getPropertyOfType(type: TypeLike, name: string): unknown\n getContextualType(node: unknown): TypeLike | undefined\n isArrayLikeType(type: TypeLike): boolean\n getTypeOfSymbolAtLocation(symbol: unknown, node: unknown): TypeLike\n getTypeArguments(type: TypeLike): ReadonlyArray<TypeLike>\n getResolvedSignature(node: unknown): SignatureLike | undefined\n getIndexInfoOfType(type: TypeLike, kind: number): { readonly type: TypeLike } | undefined\n getReturnTypeOfSignature(signature: unknown): TypeLike\n getAwaitedType(type: TypeLike): TypeLike | undefined\n isTupleType(type: TypeLike): boolean\n isTypeAssignableTo(source: TypeLike, target: TypeLike): boolean\n getPropertiesOfType(type: TypeLike): ReadonlyArray<{ readonly name: string }>\n getApparentType?(type: TypeLike): TypeLike\n}\n\ntype SignatureLike = {\n readonly parameters: ReadonlyArray<unknown>\n getDeclaration(): { readonly parameters?: ReadonlyArray<unknown> } | undefined\n}\n\n/** `ts.TypeFlags.Any` / `Unknown`, inlined so the plugin needs no runtime `typescript` import. */\nconst ANY_OR_UNKNOWN_FLAGS = 1 | 2\n\n/** Interfaces a consumer reads through rather than keeps: `importKey(…, usages: Iterable<KeyUsage>)`, `new Set(values)`. */\nconst CONSUMED_COLLECTION_TYPES: ReadonlySet<string> = new Set([\n \"Iterable\",\n \"AsyncIterable\",\n \"IterableIterator\",\n \"ArrayLike\",\n])\n\ntype TypedServices = {\n readonly program: { getTypeChecker(): CheckerLike }\n readonly esTreeNodeToTSNodeMap: { get(node: unknown): unknown }\n}\n\nconst typedServices = (context: Rule.RuleContext): TypedServices | undefined => {\n const services = context.sourceCode.parserServices as Partial<TypedServices> | undefined\n return services?.program && services.esTreeNodeToTSNodeMap ? (services as TypedServices) : undefined\n}\n\n/**\n * Is `node`'s type a functype extractable container (Option, Either, Try, Lazy, …)? Structural:\n * the type, after stripping `null` / `undefined`, has both `orThrow` and `fold` — true of every\n * functype container, including union types like `Either` (each member has both). Native\n * collections (`Map#get`) and arbitrary objects don't.\n *\n * `undefined` when type information isn't available, so the caller can fall back.\n */\nexport const isExtractableByType = (node: ASTNode, context: Rule.RuleContext): boolean | undefined => {\n const services = typedServices(context)\n if (!services) return undefined\n const tsNode = services.esTreeNodeToTSNodeMap.get(node)\n if (!tsNode) return undefined\n const checker = services.program.getTypeChecker()\n const type = checker.getNonNullableType(checker.getTypeAtLocation(tsNode))\n return (\n checker.getPropertyOfType(type, \"orThrow\") !== undefined && checker.getPropertyOfType(type, \"fold\") !== undefined\n )\n}\n\n/**\n * Is `node`'s type a functype `IO`? Structural: the type has both `runExit` and `provideLayer`, which\n * only `IO` carries — `Lazy` and the other containers have neither — and has carried since\n * well before 1.9, so older functype versions are recognized too. A union of IOs counts.\n * `any` and `unknown` have no properties, so they don't.\n *\n * `undefined` when type information isn't available.\n */\nexport const isIOByType = (node: ASTNode, context: Rule.RuleContext): boolean | undefined => {\n const services = typedServices(context)\n if (!services) return undefined\n const tsNode = services.esTreeNodeToTSNodeMap.get(node)\n if (!tsNode) return undefined\n const checker = services.program.getTypeChecker()\n const type = checker.getNonNullableType(checker.getTypeAtLocation(tsNode))\n return (\n checker.getPropertyOfType(type, \"runExit\") !== undefined &&\n checker.getPropertyOfType(type, \"provideLayer\") !== undefined\n )\n}\n\n/**\n * Can `node`'s value carry a failure that dropping it would lose? Structural: the type, or a member of\n * its union, has `fold` and `isLeft` or `isFailure`. That covers Either, Try, Exit, Validation and\n * Either-shaped wrappers such as a `ServiceResult`, and leaves out Option and List, whose `None` or\n * empty value is no error. An `IO` is left to no-floating-io: it hasn't run, so it holds no failure yet.\n *\n * `undefined` when type information isn't available.\n */\nexport const canCarryFailureByType = (node: ASTNode, context: Rule.RuleContext): boolean | undefined => {\n const services = typedServices(context)\n if (!services) return undefined\n const tsNode = services.esTreeNodeToTSNodeMap.get(node)\n if (!tsNode) return undefined\n const checker = services.program.getTypeChecker()\n const type = checker.getNonNullableType(checker.getTypeAtLocation(tsNode))\n const has = (member: TypeLike, name: string): boolean => checker.getPropertyOfType(member, name) !== undefined\n const carries = (member: TypeLike): boolean =>\n has(member, \"fold\") && (has(member, \"isLeft\") || has(member, \"isFailure\")) && !has(member, \"runExit\")\n const members = (type as { readonly types?: ReadonlyArray<TypeLike> }).types ?? [type]\n return members.some(carries)\n}\n\n/** Where a functype container sits inside a value, and what it is called. */\nexport type ContainerAt = { readonly path: string; readonly name: string }\n\ntype TypeShape = {\n readonly types?: ReadonlyArray<TypeLike>\n readonly aliasSymbol?: SymbolShape\n isUnionOrIntersection?: () => boolean\n getSymbol?: () => SymbolShape | undefined\n getCallSignatures?: () => ReadonlyArray<unknown>\n}\ntype SymbolShape = {\n readonly name: string\n getDeclarations?: () => ReadonlyArray<{ getSourceFile(): { readonly fileName: string } }> | undefined\n}\n\nconst SERIALIZE_DEPTH = 4\n\n/** A name to show for a container type: `Either`, `Option`, `List`, or the generic fallback. */\n/** Member names TypeScript shows once a union loses its alias (`Either<E, A> | null`), mapped back. */\nconst MEMBER_TO_CONTAINER: Readonly<Record<string, string>> = {\n LeftOf: \"Either\",\n RightOf: \"Either\",\n SomeOf: \"Option\",\n NoneOf: \"Option\",\n SuccessOf: \"Try\",\n FailureOf: \"Try\",\n SuccessExitOf: \"Exit\",\n FailureExitOf: \"Exit\",\n DieExitOf: \"Exit\",\n InterruptedExitOf: \"Exit\",\n}\n\nconst containerName = (type: TypeShape): string => {\n // A bundled .d.ts renames a clashing declaration `Map$1`.\n const raw = (type.aliasSymbol?.name ?? type.getSymbol?.()?.name)?.replace(/\\$\\d+$/, \"\")\n if (raw === undefined || raw.startsWith(\"__\")) return \"functype container\"\n return MEMBER_TO_CONTAINER[raw] ?? raw\n}\n\n/** Declared in a dependency or the TypeScript lib: Stripe objects, Date, Request. Never descended into. */\nconst isFromDependency = (type: TypeShape): boolean => {\n // The type's own symbol, not its alias: `Partial<User>` and `Omit<Row, \"x\">` are anonymous mapped\n // types whose alias is declared in TypeScript's lib, and their properties are the caller's.\n const symbol = type.getSymbol?.()\n if (symbol === undefined || symbol.name.startsWith(\"__\")) return false\n return (symbol.getDeclarations?.() ?? []).some((declaration) =>\n declaration.getSourceFile().fileName.includes(\"/node_modules/\"),\n )\n}\n\n/**\n * The first functype container inside the value `node` evaluates to, and the path to it: `subscription`,\n * `items[]`, or empty for the whole value. A container is a type with `_tag` and `fold`, which every\n * functype container has and its `toJSON()` envelope doesn't. Walks unions, intersections, array and\n * tuple elements, object properties and string index signatures, up to 4 levels deep, and checks for a\n * container before skipping types declared in node_modules, where functype itself lives (#364).\n *\n * `undefined` when there is none, or when type information isn't available.\n */\nexport const containerInsideByType = (node: ASTNode, context: Rule.RuleContext): ContainerAt | undefined => {\n const services = typedServices(context)\n if (!services) return undefined\n const tsNode = services.esTreeNodeToTSNodeMap.get(node)\n if (!tsNode) return undefined\n const checker = services.program.getTypeChecker()\n const seen = new Set<TypeLike>()\n const isContainer = (type: TypeLike): boolean =>\n checker.getPropertyOfType(type, \"_tag\") !== undefined && checker.getPropertyOfType(type, \"fold\") !== undefined\n const at = (path: string, step: string): string =>\n path === \"\" ? step : step.startsWith(\"[\") ? path + step : `${path}.${step}`\n\n const find = (type: TypeLike, path: string, depth: number): ContainerAt | undefined => {\n if (depth > SERIALIZE_DEPTH || seen.has(type) || isTypeParameter(type)) return undefined\n seen.add(type)\n const shape = type as TypeShape\n // Before splitting: an Either union has `_tag` and `fold` on every member, and `Stack` is an\n // intersection whose `_tag` and `fold` come from different members.\n if (isContainer(type)) return { path, name: containerName(shape) }\n if (shape.isUnionOrIntersection?.() === true) {\n return (shape.types ?? []).map((member) => find(member, path, depth)).find((h) => h !== undefined)\n }\n if ((shape.getCallSignatures?.() ?? []).length > 0) return undefined\n if (checker.isArrayLikeType(type) || checker.isTupleType(type)) {\n return checker\n .getTypeArguments(type)\n .map((element) => find(element, path === \"\" ? \"[]\" : `${path}[]`, depth + 1))\n .find((h) => h !== undefined)\n }\n // Before the dependency skip: `Record<string, Option<T>>` is declared in TypeScript's lib.\n const indexed = checker.getIndexInfoOfType(type, 0)?.type\n const byIndex = indexed === undefined ? undefined : find(indexed, at(path, \"[key]\"), depth + 1)\n if (byIndex !== undefined) return byIndex\n if (shape.getSymbol?.() === undefined || isFromDependency(shape)) return undefined\n return checker\n .getPropertiesOfType(type)\n .map((property) => find(checker.getTypeOfSymbolAtLocation(property, tsNode), at(path, property.name), depth + 1))\n .find((h) => h !== undefined)\n }\n\n return find(checker.getTypeAtLocation(tsNode), \"\", 0)\n}\n\ntype MemberDeclaration = {\n readonly parameters?: unknown\n getSourceFile(): { readonly fileName: string }\n}\ntype MemberSymbol = { getDeclarations?: () => ReadonlyArray<MemberDeclaration> | undefined }\n\n/**\n * Declared by functype itself: its published `dist` (`node_modules/functype/dist/…`, pnpm's\n * `.pnpm/functype@x/node_modules/functype/dist/…`) or, inside this repo, `packages/functype/{src,dist}`.\n */\nconst FUNCTYPE_FILE = /(?:^|[\\\\/])functype[\\\\/](?:dist|src)[\\\\/]/\nconst isDeclaredByFunctype = (declaration: MemberDeclaration): boolean =>\n FUNCTYPE_FILE.test(declaration.getSourceFile().fileName)\n\n/**\n * If `object` is a functype container and `name` is one of its methods, the container's name\n * (`List`, `Option`, `Either`); otherwise `undefined`. A container has `_tag` and `fold`. A method is\n * declared in functype's own files, so a user type with the same shape (a union with `_tag` and a\n * `fold`, or an interface extending `List` with methods of its own) never counts for those methods. It is a\n * callable member whose declaration has parameters (`head(): A | undefined`, `fold<B>(…)`), so neither\n * function-valued data (`readonly value: R` on a `Right` holding a callback) nor a getter (`size`) is one. A type parameter is read\n * through its constraint.\n *\n * `undefined` when type information isn't available.\n */\nexport const functypeMethodByType = (object: ASTNode, name: string, context: Rule.RuleContext): string | undefined => {\n const services = typedServices(context)\n if (!services) return undefined\n const tsNode = services.esTreeNodeToTSNodeMap.get(object)\n if (!tsNode) return undefined\n const checker = services.program.getTypeChecker()\n const read = checker.getNonNullableType(checker.getTypeAtLocation(tsNode))\n const type = isTypeParameter(read) ? (checker.getApparentType?.(read) ?? read) : read\n const isContainer =\n checker.getPropertyOfType(type, \"_tag\") !== undefined && checker.getPropertyOfType(type, \"fold\") !== undefined\n if (!isContainer) return undefined\n const member = checker.getPropertyOfType(type, name) as MemberSymbol | undefined\n const declarations = member?.getDeclarations?.() ?? []\n // A getter (`get size(): number`) has parameters too, but reading it gives its value, not a function.\n const isCallable = (): boolean =>\n ((checker.getTypeOfSymbolAtLocation(member, tsNode) as TypeShape).getCallSignatures?.() ?? []).length > 0\n const isMethod =\n declarations.length > 0 &&\n declarations.every((d) => Array.isArray(d.parameters) && isDeclaredByFunctype(d)) &&\n isCallable()\n return isMethod ? containerName(type as TypeShape) : undefined\n}\n\n/**\n * If `node`'s value is a functype value, the container's name (`List`, `Option`, `Either`); otherwise\n * `undefined`. A functype value has `_tag` and a `fold` that functype itself declares, so a user type\n * with the same shape doesn't count. A type parameter is read through its constraint, and a union counts\n * when any of its members is a functype value (`List<number> | string[]`).\n *\n * `undefined` when type information isn't available.\n */\nexport const functypeValueByType = (node: ASTNode, context: Rule.RuleContext): string | undefined => {\n const services = typedServices(context)\n if (!services) return undefined\n const tsNode = services.esTreeNodeToTSNodeMap.get(node)\n if (!tsNode) return undefined\n const checker = services.program.getTypeChecker()\n const read = checker.getNonNullableType(checker.getTypeAtLocation(tsNode))\n const type = isTypeParameter(read) ? (checker.getApparentType?.(read) ?? read) : read\n const isFunctype = (candidate: TypeLike): boolean => {\n if (checker.getPropertyOfType(candidate, \"_tag\") === undefined) return false\n const fold = checker.getPropertyOfType(candidate, \"fold\") as MemberSymbol | undefined\n const declarations = fold?.getDeclarations?.() ?? []\n return declarations.length > 0 && declarations.every(isDeclaredByFunctype)\n }\n if (isFunctype(type)) return containerName(type as TypeShape)\n // A union whose members aren't all functype values: `List<number> | string[]`.\n const member = ((type as TypeShape).types ?? []).find(isFunctype)\n return member === undefined ? undefined : containerName(member as TypeShape)\n}\n\n/** A slot's expected type and the expression TypeScript computed it for. */\ntype Slot = { readonly type: TypeLike; readonly at: ASTNode }\n\n/**\n * Uses the `Type` object's own predicate rather than a `TypeFlags` bit: TypeScript renumbers its flags\n * between majors (TypeParameter is `1 << 19` in TS 6, `1 << 18` before), and the plugin has no runtime\n * `typescript` import to read them from.\n */\nconst isTypeParameter = (type: TypeLike): boolean =>\n (type as { isTypeParameter?: () => boolean }).isTypeParameter?.() === true\n\n/**\n * `f(…, arg, …)` where `at` is `arg` or sits inside it (an object property, an array element, a spread,\n * a conditional branch, an `as`): the call, the whole argument, and its index.\n */\nconst enclosingCall = (\n at: ASTNode,\n): { readonly call: ASTNode; readonly argument: ASTNode; readonly index: number } | null => {\n const parent = at.parent as ASTNode | undefined\n if (!parent) return null\n if ((parent.type === \"CallExpression\" || parent.type === \"NewExpression\") && parent.callee !== at) {\n const index = (parent.arguments as ReadonlyArray<ASTNode>).indexOf(at)\n return index < 0 ? null : { call: parent, argument: at, index }\n }\n const passesThrough =\n parent.type === \"TSAsExpression\" ||\n parent.type === \"TSSatisfiesExpression\" ||\n (parent.type === \"ConditionalExpression\" && parent.test !== at) ||\n parent.type === \"LogicalExpression\" ||\n parent.type === \"Property\" ||\n parent.type === \"ObjectExpression\" ||\n parent.type === \"ArrayExpression\" ||\n parent.type === \"SpreadElement\"\n return passesThrough ? enclosingCall(parent) : null\n}\n\n/**\n * Is the parameter that `at` is passed to (directly or nested) declared as a type parameter, or a union\n * containing one — `json<T>(data: T)`, `useState<S>(init: S | (() => S))`? Then TypeScript's expected type for `at` is only an echo of what it inferred from\n * `at` itself (`[1, 2]` → `number[]`), not a shape the library demands.\n */\nconst isGenericParameterArgument = (checker: CheckerLike, services: TypedServices, at: ASTNode): boolean => {\n const found = enclosingCall(at)\n const callTs = found ? services.esTreeNodeToTSNodeMap.get(found.call) : undefined\n const parameters = callTs ? checker.getResolvedSignature(callTs)?.getDeclaration()?.parameters : undefined\n if (!found || !parameters || parameters.length === 0) return false\n const declared = parameters[Math.min(found.index, parameters.length - 1)] as { readonly type?: unknown } | undefined\n // The parameter's type annotation node (`T` in `value: T`); asking for the declaration node's type gives `any`.\n if (declared?.type === undefined) return false\n const annotated = checker.getTypeAtLocation(declared.type)\n // React's `useState<S>(init: S | (() => S))`: a union that contains the type parameter is generic too.\n const members = (annotated as { types?: ReadonlyArray<TypeLike> }).types ?? [annotated]\n return members.some(isTypeParameter)\n}\n\n/**\n * Does the generic call around `at` hand the argument straight back to the caller — `useState(init)`\n * returning `[init, set]`, `identity(x)`, a `Promise` of it? Then the shape stays the caller's, and a\n * type parameter isn't a sink. Looks only at the return type itself, union / intersection members,\n * tuple and array elements, and an awaited Promise, not object properties: Hono's `c.json<T>` returns a\n * `Response` that carries a *parsed* copy of `T` for its RPC client, which the caller doesn't get back.\n */\nconst handsArgumentBack = (checker: CheckerLike, services: TypedServices, at: ASTNode): boolean => {\n const found = enclosingCall(at)\n const callTs = found ? services.esTreeNodeToTSNodeMap.get(found.call) : undefined\n const signature = callTs ? checker.getResolvedSignature(callTs) : undefined\n const argTs = found ? services.esTreeNodeToTSNodeMap.get(found.argument) : undefined\n if (!signature || !argTs) return false\n const argType = checker.getTypeAtLocation(argTs)\n const sameAsArgument = (candidate: TypeLike): boolean =>\n candidate === argType ||\n (checker.isTypeAssignableTo(argType, candidate) && checker.isTypeAssignableTo(candidate, argType))\n const search = (type: TypeLike, depth: number): boolean => {\n if (depth > 3) return false\n if (sameAsArgument(type)) return true\n const { types, target } = type as { types?: ReadonlyArray<TypeLike>; target?: unknown }\n if (types) return types.some((member) => search(member, depth + 1))\n if (target !== undefined && (checker.isTupleType(type) || checker.isArrayLikeType(type))) {\n return checker.getTypeArguments(type).some((element) => search(element, depth + 1))\n }\n const awaited = checker.getAwaitedType(type)\n return awaited !== undefined && awaited !== type && search(awaited, depth + 1)\n }\n return search(checker.getReturnTypeOfSignature(signature), 0)\n}\n\n/**\n * Untyped, or a type parameter of a call that doesn't hand the argument back: an object handed to\n * `c.json<T>(data: T)` or `JSON.stringify` goes to a sink. `useState<T>(init: T)` is not one.\n */\nconst isOpaqueSink = (checker: CheckerLike, services: TypedServices, slot: Slot): boolean =>\n isUntyped(slot.type) || (isTypeParameter(slot.type) && !handsArgumentBack(checker, services, slot.at))\n\nconst isArrayLikeOrUntyped = (checker: CheckerLike, services: TypedServices, slot: Slot): boolean => {\n if (isOpaqueSink(checker, services, slot)) return true\n const { types, symbol } = slot.type as { types?: ReadonlyArray<TypeLike>; symbol?: { name?: string } }\n if (types) return types.some((member) => isArrayLikeOrUntyped(checker, services, { type: member, at: slot.at }))\n if (symbol?.name !== undefined && CONSUMED_COLLECTION_TYPES.has(symbol.name)) return true\n return !isTypeParameter(slot.type) && checker.isArrayLikeType(slot.type)\n}\n\nconst isUntyped = (type: TypeLike): boolean => {\n const { flags } = type as { flags?: number }\n return flags !== undefined && (flags & ANY_OR_UNKNOWN_FLAGS) !== 0\n}\n\n/** The mutable `Array` type, as opposed to `ReadonlyArray`: the one a `ReadonlyArray` can't be passed to. */\nconst isMutableArrayType = (checker: CheckerLike, type: TypeLike): boolean => {\n const { types, symbol } = type as { types?: ReadonlyArray<TypeLike>; symbol?: { name?: string } }\n if (types) return types.some((member) => isMutableArrayType(checker, member))\n return symbol?.name === \"Array\" && checker.isArrayLikeType(type)\n}\n\n/** The name a property is written under: `params` in `{ params }`, `parts` in `{ parts: … }` or `{ \"parts\": … }`. */\nconst propertyKey = (property: ASTNode): string | null => {\n if (property.computed) return null\n if (property.key?.type === \"Identifier\") return property.key.name\n return property.key?.type === \"Literal\" && typeof property.key.value === \"string\" ? property.key.value : null\n}\n\n/**\n * The expected type of `node`, looking through object literals when TypeScript gives the value none of\n * its own. Two cases: a shorthand `{ params }` passed to a function, where the expected type is that\n * property's type on the parameter; and `[…]` in `JSON.stringify({ parts: [...] })`, where the object is\n * passed to an `any` parameter, so the whole object is going to an untyped host.\n */\nconst expectedSlot = (\n checker: CheckerLike,\n services: TypedServices,\n node: ASTNode,\n context: Rule.RuleContext,\n depth = 0,\n): Slot | undefined => {\n if (depth > 4) return undefined\n const tsNode = services.esTreeNodeToTSNodeMap.get(node)\n const own = tsNode ? checker.getContextualType(tsNode) : undefined\n if (own !== undefined) return { type: own, at: node }\n const parent = node.parent as ASTNode | undefined\n // `const metadata = (url) => ({ … })` with no declared return type: the object goes wherever the\n // calls' results go (`c.json(metadata(url))`), so take the expected type at the first call site.\n if (parent?.type === \"ArrowFunctionExpression\" && parent.body === node) {\n const declarator = parent.parent as ASTNode | undefined\n if (\n declarator?.type === \"VariableDeclarator\" &&\n declarator.init === parent &&\n declarator.id?.type === \"Identifier\"\n ) {\n const variable = context.sourceCode.getDeclaredVariables(declarator)[0]\n const calls = (variable?.references ?? [])\n .map((ref) => (ref.identifier as unknown as ASTNode).parent as ASTNode | undefined)\n .filter((call): call is ASTNode => call?.type === \"CallExpression\")\n return calls\n .map((call) => expectedSlot(checker, services, call, context, depth + 1))\n .find((slot) => slot !== undefined)\n }\n }\n // An argument to an overloaded function (`crypto.subtle.importKey(…, [\"decrypt\"])`) gets no contextual\n // type; the parameter of the overload TypeScript picked is the expected type.\n if ((parent?.type === \"CallExpression\" || parent?.type === \"NewExpression\") && parent.callee !== node) {\n const index = (parent.arguments as ReadonlyArray<ASTNode>).indexOf(node)\n const call = services.esTreeNodeToTSNodeMap.get(parent)\n const parameter = index >= 0 && call ? checker.getResolvedSignature(call)?.parameters[index] : undefined\n return parameter === undefined ? undefined : { type: checker.getTypeOfSymbolAtLocation(parameter, call), at: node }\n }\n const objectLiteral = parent?.type === \"Property\" && parent.value === node ? (parent.parent as ASTNode) : undefined\n if (objectLiteral?.type !== \"ObjectExpression\") return undefined\n const outerSlot = expectedSlot(checker, services, objectLiteral, context, depth + 1)\n if (outerSlot === undefined || isOpaqueSink(checker, services, outerSlot)) return outerSlot\n const outer = outerSlot.type\n const key = propertyKey(parent as ASTNode)\n // `{ [k]: [...] }` (a reduce accumulator keyed by category): the property named by the key's literal\n // type, else the string index signature's type.\n if (key === null) {\n const keyNode = (parent as ASTNode).key\n const keyTs = keyNode ? services.esTreeNodeToTSNodeMap.get(keyNode) : undefined\n const keyType = keyTs\n ? (checker.getTypeAtLocation(keyTs) as { value?: unknown; types?: ReadonlyArray<{ value?: unknown }> })\n : undefined\n const literal = keyType?.value ?? keyType?.types?.[0]?.value\n const named = typeof literal === \"string\" ? checker.getPropertyOfType(outer, literal) : undefined\n const type =\n named !== undefined\n ? checker.getTypeOfSymbolAtLocation(named, tsNode)\n : checker.getIndexInfoOfType(outer, 0)?.type\n return type === undefined ? undefined : { type, at: node }\n }\n const member = checker.getPropertyOfType(outer, key)\n return member === undefined ? undefined : { type: checker.getTypeOfSymbolAtLocation(member, tsNode), at: node }\n}\n\n/**\n * Does `node` (an expression) flow into a slot that is typed as an array, a tuple or `any`/`unknown`?\n * That's the expected type TypeScript checks it against: the parameter it is passed to, the property\n * it initialises, the declared return type. A literal in such a slot is handed to code that requires an\n * array, such as drizzle's `.values([...])` or an index definition, so `List` can't go there. A literal\n * inside an object passed to an `any` parameter (a `JSON.stringify` request body) counts too.\n *\n * `undefined` when type information isn't available, or when there is no expected type (a free-standing\n * literal), so the caller can fall back.\n */\nexport const flowsIntoArraySlot = (node: ASTNode, context: Rule.RuleContext): boolean | undefined => {\n const services = typedServices(context)\n if (!services) return undefined\n const checker = services.program.getTypeChecker()\n const slot = expectedSlot(checker, services, node, context)\n if (slot === undefined) return undefined\n // A bare `T` parameter: a sink unless the call hands the argument straight back (`useState`, `identity`).\n if (isGenericParameterArgument(checker, services, slot.at)) return !handsArgumentBack(checker, services, slot.at)\n return isArrayLikeOrUntyped(checker, services, slot)\n}\n\n/**\n * Does `node` flow into a slot that requires a *mutable* array — a parameter typed `T[]`, such as pg's\n * `query(text, values: unknown[])`, drizzle's `inArray(col, values)` or ReactFlow's `nodes`? There a\n * `ReadonlyArray` won't type-check, so a mutable annotation is what the library demands.\n *\n * `undefined` when type information isn't available.\n */\nexport const flowsIntoMutableArraySlot = (node: ASTNode, context: Rule.RuleContext): boolean | undefined => {\n const services = typedServices(context)\n if (!services) return undefined\n const checker = services.program.getTypeChecker()\n const slot = expectedSlot(checker, services, node, context)\n if (slot === undefined || isGenericParameterArgument(checker, services, slot.at)) return false\n return isMutableArrayType(checker, slot.type)\n}\n\n/**\n * Is `node`'s own type `any` / `unknown`, or an array of them — `JSON.parse(raw)`, `await res.json()`,\n * `raw` after `Array.isArray(raw)` (narrowed to `any[]`)? `undefined` when type information isn't available.\n */\nexport const isUntypedExpression = (node: ASTNode, context: Rule.RuleContext): boolean | undefined => {\n const services = typedServices(context)\n if (!services) return undefined\n const tsNode = services.esTreeNodeToTSNodeMap.get(node)\n if (!tsNode) return undefined\n const checker = services.program.getTypeChecker()\n const type = checker.getTypeAtLocation(tsNode)\n if (isUntyped(type)) return true\n if (!checker.isArrayLikeType(type)) return false\n const element = checker.getTypeArguments(type)[0]\n return element !== undefined && isUntyped(element)\n}\n\n/** Is type-aware linting on for this file (`parserOptions.projectService` or `project`)? */\nexport const hasTypeInformation = (context: Rule.RuleContext): boolean => typedServices(context) !== undefined\n"],"mappings":"AAuCA,MAGMA,kBAAiD,IAAI,IAAI,CAC7D,WACA,gBACA,mBACA,WACF,CAAC,EAOKC,EAAiBC,GAAyD,CAC9E,IAAMC,EAAWD,EAAQ,WAAW,eACpC,OAAOC,GAAU,SAAWA,EAAS,sBAAyBA,EAA6B,IAAA,EAC7F,EAUaC,GAAuBC,EAAeH,IAAmD,CACpG,IAAMC,EAAWF,EAAcC,CAAO,EACtC,GAAI,CAACC,EAAU,OACf,IAAMG,EAASH,EAAS,sBAAsB,IAAIE,CAAI,EACtD,GAAI,CAACC,EAAQ,OACb,IAAMC,EAAUJ,EAAS,QAAQ,eAAe,EAC1CK,EAAOD,EAAQ,mBAAm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,IAAMG,EAASH,EAAS,sBAAsB,IAAIE,CAAI,EACtD,GAAI,CAACC,EAAQ,OACb,IAAMC,EAAUJ,EAAS,QAAQ,eAAe,EAC1CK,EAAOD,EAAQ,kBAAkBD,CAAM,EAC7C,GAAI2D,EAAUzD,CAAI,EAAG,MAAO,GAC5B,GAAI,CAACD,EAAQ,gBAAgBC,CAAI,EAAG,MAAO,GAC3C,IAAMuB,EAAUxB,EAAQ,iBAAiBC,CAAI,CAAC,CAAC,GAC/C,OAAOuB,IAAY,IAAA,IAAakC,EAAUlC,CAAO,CACnD,EAGayD,EAAsBtF,GAAuCD,EAAcC,CAAO,IAAM,IAAA,G"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-functype",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.202.1",
|
|
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.2",
|
|
43
43
|
"@typescript-eslint/rule-tester": "^8.72.2",
|
|
44
44
|
"eslint-config-prettier": "^10.1.8",
|
|
45
|
-
"functype": "^2.1
|
|
45
|
+
"functype": "^2.2.1",
|
|
46
46
|
"ts-builds": "^5.0.0",
|
|
47
47
|
"tsdown": "^0.23.7"
|
|
48
48
|
},
|