eslint-plugin-functype 2.202.0 → 2.202.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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(`šŸ“‹ ESLint Plugin Functype - Custom Rules`,`bright`)),console.log(`
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(`šŸ”§ 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(`
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(`• Functype Library: https://github.com/jordanburke/functype`)}function o(){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(`• 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,OA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","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((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1D,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"}
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.202.0`},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};
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.2`},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
@@ -1,15 +1,3 @@
1
1
  import { Rule } from "eslint";
2
- /**
3
- * Reports an `IO` that is built and then dropped, so it never runs:
4
- *
5
- * - an expression statement whose value is an `IO` — `log.info("saved")`, `save(user).tap(audit)`;
6
- * - `await` on an `IO`. `IO` is not a Promise, so `await io` hands back the `IO` itself, unrun.
7
- *
8
- * `no-floating-promises` and `await-thenable` don't see either case, because `IO` is not thenable.
9
- * Returning, yielding, assigning or passing an `IO` along is fine: someone else runs it. `void io`
10
- * marks a deliberate drop and isn't reported.
11
- *
12
- * Type-aware only: without type information it reports nothing.
13
- */
14
2
  declare const rule: Rule.RuleModule;
15
3
  export { rule as default };
@@ -1,2 +1,2 @@
1
- import{isIOByType as e}from"../utils/type-aware.js";const t={meta:{type:`problem`,docs:{description:`Disallow building an IO and never running it`,recommended:!1},schema:[],messages:{floatingIO:`This IO is built and never run, so it does nothing. Run it (.run(), .runOrThrow(), .runExit()), return it, or yield* it inside IO.gen`,awaitedIO:`await on an IO does nothing: IO is not a Promise, so this returns the IO unrun. Await .run() or .runOrThrow() instead`}},create(t){return{ExpressionStatement(n){let r=n.expression;r.type!==`AwaitExpression`&&(r.type!==`UnaryExpression`||r.operator!==`void`)&&e(r,t)&&t.report({node:r,messageId:`floatingIO`})},AwaitExpression(n){e(n.argument,t)&&t.report({node:n,messageId:`awaitedIO`})}}}};export{t as default};
1
+ import{isIOByType as e}from"../utils/type-aware.js";const t=/* @__PURE__ */ new Set([`trace`,`debug`,`info`,`warn`,`error`,`fatal`]),n=e=>{if(e.type!==`CallExpression`)return;let n=e.callee;if(!(n.type!==`MemberExpression`||n.computed||n.property.type!==`Identifier`))return t.has(n.property.name)?n.property.name:void 0},r={meta:{type:`problem`,docs:{description:`Disallow building an IO and never running it`,recommended:!1},schema:[],messages:{floatingIO:`This IO is built and never run, so it does nothing. Run it (.run(), .runOrThrow(), .runExit()), return it, or yield* it inside IO.gen`,floatingLog:`This logger call returns an IO, so it logs nothing until the IO runs. yield* it inside IO.gen, run it (void log.{{level}}(…).run()), or log through a DirectLogger from functype-log/direct (toDirectLogger(log)), whose methods log at once`,awaitedIO:`await on an IO does nothing: IO is not a Promise, so this returns the IO unrun. Await .run() or .runOrThrow() instead`}},create(t){return{ExpressionStatement(r){let i=r.expression;if(i.type===`AwaitExpression`||i.type===`UnaryExpression`&&i.operator===`void`||!e(i,t))return;let a=n(i);a===void 0?t.report({node:i,messageId:`floatingIO`}):t.report({node:i,messageId:`floatingLog`,data:{level:a}})},AwaitExpression(n){e(n.argument,t)&&t.report({node:n,messageId:`awaitedIO`})}}}};export{r as default};
2
2
  //# sourceMappingURL=no-floating-io.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"no-floating-io.js","names":["isIOByType","rule","context","node","expression"],"sources":["../../src/rules/no-floating-io.ts"],"sourcesContent":["import type { Rule } from \"eslint\"\n\nimport type { ASTNode } from \"../types/ast\"\nimport { isIOByType } from \"../utils/type-aware\"\n\n/**\n * Reports an `IO` that is built and then dropped, so it never runs:\n *\n * - an expression statement whose value is an `IO` — `log.info(\"saved\")`, `save(user).tap(audit)`;\n * - `await` on an `IO`. `IO` is not a Promise, so `await io` hands back the `IO` itself, unrun.\n *\n * `no-floating-promises` and `await-thenable` don't see either case, because `IO` is not thenable.\n * Returning, yielding, assigning or passing an `IO` along is fine: someone else runs it. `void io`\n * marks a deliberate drop and isn't reported.\n *\n * Type-aware only: without type information it reports nothing.\n */\nconst rule: Rule.RuleModule = {\n meta: {\n type: \"problem\",\n docs: {\n description: \"Disallow building an IO and never running it\",\n recommended: false,\n },\n schema: [],\n messages: {\n floatingIO:\n \"This IO is built and never run, so it does nothing. Run it (.run(), .runOrThrow(), .runExit()), return it, or yield* it inside IO.gen\",\n awaitedIO:\n \"await on an IO does nothing: IO is not a Promise, so this returns the IO unrun. Await .run() or .runOrThrow() instead\",\n },\n },\n\n create(context) {\n return {\n ExpressionStatement(node: ASTNode) {\n const expression = node.expression as ASTNode\n // `void io` is a deliberate drop; `await io` is reported by the AwaitExpression visitor.\n if (expression.type === \"AwaitExpression\") return\n if (expression.type === \"UnaryExpression\" && expression.operator === \"void\") return\n if (isIOByType(expression, context)) context.report({ node: expression, messageId: \"floatingIO\" })\n },\n AwaitExpression(node: ASTNode) {\n if (isIOByType(node.argument as ASTNode, context)) context.report({ node, messageId: \"awaitedIO\" })\n },\n }\n },\n}\n\nexport default rule\n"],"mappings":"A,oDAiBA,MAAMC,EAAwB,CAC5B,KAAM,CACJ,KAAM,UACN,KAAM,CACJ,YAAa,+CACb,YAAa,EACf,EACA,OAAQ,CAAC,EACT,SAAU,CACR,WACE,wIACF,UACE,uHACJ,CACF,EAEA,OAAOC,EAAS,CACd,MAAO,CACL,oBAAoBC,EAAe,CACjC,IAAMC,EAAaD,EAAK,WAEpBC,EAAW,OAAS,oBACpBA,EAAW,OAAS,mBAAqBA,EAAW,WAAa,SACjEJ,EAAWI,EAAYF,CAAO,GAAGA,EAAQ,OAAO,CAAE,KAAME,EAAY,UAAW,YAAa,CAAC,CACnG,EACA,gBAAgBD,EAAe,CACzBH,EAAWG,EAAK,SAAqBD,CAAO,GAAGA,EAAQ,OAAO,CAAEC,OAAM,UAAW,WAAY,CAAC,CACpG,CACF,CACF,CACF,E"}
1
+ {"version":3,"file":"no-floating-io.js","names":["isIOByType","LOG_LEVELS","logLevelOf","expression","callee","rule","context","node","level"],"sources":["../../src/rules/no-floating-io.ts"],"sourcesContent":["import type { Rule } from \"eslint\"\n\nimport type { ASTNode } from \"../types/ast\"\nimport { isIOByType } from \"../utils/type-aware\"\n\n/**\n * Reports an `IO` that is built and then dropped, so it never runs:\n *\n * - an expression statement whose value is an `IO` — `log.info(\"saved\")`, `save(user).tap(audit)`;\n * - `await` on an `IO`. `IO` is not a Promise, so `await io` hands back the `IO` itself, unrun.\n *\n * `no-floating-promises` and `await-thenable` don't see either case, because `IO` is not thenable.\n * Returning, yielding, assigning or passing an `IO` along is fine: someone else runs it. `void io`\n * marks a deliberate drop and isn't reported.\n *\n * Type-aware only: without type information it reports nothing.\n */\n/** Method names of functype-log's `Logger`, whose calls return an `IO<never, never, void>`. */\nconst LOG_LEVELS: ReadonlySet<string> = new Set([\"trace\", \"debug\", \"info\", \"warn\", \"error\", \"fatal\"])\n\n/** The level of a `log.warn(…)`-shaped call, or `undefined`. Only asked of an expression already known to be an IO. */\nconst logLevelOf = (expression: ASTNode): string | undefined => {\n if (expression.type !== \"CallExpression\") return undefined\n const callee = expression.callee as ASTNode\n if (callee.type !== \"MemberExpression\" || callee.computed || callee.property.type !== \"Identifier\") return undefined\n return LOG_LEVELS.has(callee.property.name) ? callee.property.name : undefined\n}\n\nconst rule: Rule.RuleModule = {\n meta: {\n type: \"problem\",\n docs: {\n description: \"Disallow building an IO and never running it\",\n recommended: false,\n },\n schema: [],\n messages: {\n floatingIO:\n \"This IO is built and never run, so it does nothing. Run it (.run(), .runOrThrow(), .runExit()), return it, or yield* it inside IO.gen\",\n floatingLog:\n \"This logger call returns an IO, so it logs nothing until the IO runs. yield* it inside IO.gen, run it (void log.{{level}}(…).run()), or log through a DirectLogger from functype-log/direct (toDirectLogger(log)), whose methods log at once\",\n awaitedIO:\n \"await on an IO does nothing: IO is not a Promise, so this returns the IO unrun. Await .run() or .runOrThrow() instead\",\n },\n },\n\n create(context) {\n return {\n ExpressionStatement(node: ASTNode) {\n const expression = node.expression as ASTNode\n // `void io` is a deliberate drop; `await io` is reported by the AwaitExpression visitor.\n if (expression.type === \"AwaitExpression\") return\n if (expression.type === \"UnaryExpression\" && expression.operator === \"void\") return\n if (!isIOByType(expression, context)) return\n const level = logLevelOf(expression)\n if (level !== undefined) context.report({ node: expression, messageId: \"floatingLog\", data: { level } })\n else context.report({ node: expression, messageId: \"floatingIO\" })\n },\n AwaitExpression(node: ASTNode) {\n if (isIOByType(node.argument as ASTNode, context)) context.report({ node, messageId: \"awaitedIO\" })\n },\n }\n },\n}\n\nexport default rule\n"],"mappings":"A,oDAkBA,MAAMC,kBAAkC,IAAI,IAAI,CAAC,QAAS,QAAS,OAAQ,OAAQ,QAAS,OAAO,CAAC,EAG9FC,EAAcC,GAA4C,CAC9D,GAAIA,EAAW,OAAS,iBAAkB,OAC1C,IAAMC,EAASD,EAAW,OAC1B,GAAIC,IAAO,OAAS,oBAAsBA,EAAO,UAAYA,EAAO,SAAS,OAAS,cACtF,OAAOH,EAAW,IAAIG,EAAO,SAAS,IAAI,EAAIA,EAAO,SAAS,KAAO,IAAA,EACvE,EAEMC,EAAwB,CAC5B,KAAM,CACJ,KAAM,UACN,KAAM,CACJ,YAAa,+CACb,YAAa,EACf,EACA,OAAQ,CAAC,EACT,SAAU,CACR,WACE,wIACF,YACE,+OACF,UACE,uHACJ,CACF,EAEA,OAAOC,EAAS,CACd,MAAO,CACL,oBAAoBC,EAAe,CACjC,IAAMJ,EAAaI,EAAK,WAIxB,GAFIJ,EAAW,OAAS,mBACpBA,EAAW,OAAS,mBAAqBA,EAAW,WAAa,QACjE,CAACH,EAAWG,EAAYG,CAAO,EAAG,OACtC,IAAME,EAAQN,EAAWC,CAAU,EAC/BK,IAAU,IAAA,GACTF,EAAQ,OAAO,CAAE,KAAMH,EAAY,UAAW,YAAa,CAAC,EADxCG,EAAQ,OAAO,CAAE,KAAMH,EAAY,UAAW,cAAe,KAAM,CAAEK,OAAM,CAAE,CAAC,CAEzG,EACA,gBAAgBD,EAAe,CACzBP,EAAWO,EAAK,SAAqBD,CAAO,GAAGA,EAAQ,OAAO,CAAEC,OAAM,UAAW,WAAY,CAAC,CACpG,CACF,CACF,CACF,E"}
@@ -1,2 +1,2 @@
1
- import{isInsideTaggedDeclaration as e}from"../utils/boundary-tags.js";import{getFunctypeImportsLegacy as t,isAlreadyUsingFunctype as n,isFunctypeType as r}from"../utils/functype-detection.js";import{createImportFixer as i,hasFunctypeSymbol as a}from"../utils/import-fixer.js";import{DEFAULT_WIRE_TYPES as o,WIRE_TYPES_SCHEMA as s,isInsideWireType as c}from"../utils/wire-types.js";const l=/* @__PURE__ */ new Set([`useState`,`useRef`]),u=e=>e.type===`TSNullKeyword`||e.type===`TSUndefinedKeyword`;function d(e){let t=e.parent;if(!t)return!1;if(t.type===`AssignmentPattern`&&t.left===e)return d(t);if(t.type===`TSParameterProperty`)return!0;let n=t.params;return Array.isArray(n)&&n.includes(e)}function f(e){let t=e?.type===`TSTypeAnnotation`?e.parent:void 0;if(t)return t.type===`TSPropertySignature`||d(t)?t:void 0}function p(e){return e.types.flatMap(e=>e.type===`TSUnionType`?p(e):[e])}function m(e,t){if(!t.some(e=>e.type===`TSNullKeyword`))return;let n=e.parent,r=n?.type===`TSTypeAnnotation`?n.parent:void 0,i=r?.type===`TSPropertySignature`?r:void 0;if(i?.optional===!0)return`the ? or the | null`;if(t.some(e=>e.type===`TSUndefinedKeyword`))return n?.type===`TSTypeAliasDeclaration`||i!==void 0?`the | null or the | undefined`:void 0}const h={meta:{type:`suggestion`,hasSuggestions:!0,docs:{description:`Prefer Option<T> over nullable types (T | null | undefined)`,recommended:!0},schema:[{type:`object`,properties:{allowInteropMarker:{type:`boolean`,default:!0},wireTypes:s,allowNullableIntersections:{type:`boolean`,default:!1},allowUseState:{type:`boolean`,default:!0},checkOptionalMembers:{type:`boolean`,default:!1}},additionalProperties:!1}],messages:{preferOption:`Prefer Option<{{type}}> over nullable type '{{nullable}}'. If this is a row, body or payload shape, wrap the type in Wire<…>`,preferOptionReturn:`Prefer Option<{{type}}> as return type over nullable '{{nullable}}'`,preferOptionOverOptional:`Prefer '{{name}}: Option<{{type}}>' over the optional '{{name}}?'. If this is a row, body or payload shape, wrap the type in Wire<…>`,preferWireForThreeStates:`This type has three states, left out, null and set, and Option holds two. If it's a row, body or payload shape, wrap the type in Wire<…>. If it only meant "may be absent", drop {{drop}} and use Option<{{type}}>`,suggestOptionType:`Replace with Option<{{type}}>`,suggestAddImport:`Add {{symbol}} import from functype`}},create(s){let h=s.options[0]||{},g=h.wireTypes??o,_=h.allowInteropMarker!==!1,v=t=>_&&e(t,`interop`,s.sourceCode),y=h.allowUseState!==!1,b=h.checkOptionalMembers===!0;function x(e){let t=e.parent;if(!t)return!1;if(t.type===`TSTypeParameterInstantiation`&&t.parent?.type===`CallExpression`){let e=t.parent.callee,n=e.type===`Identifier`?e.name:e.type===`MemberExpression`&&e.property.type===`Identifier`?e.property.name:null;if(n!==null&&l.has(n))return!0}return x(t)}let S=t(s);function C(e){if(!b||e.optional!==!0||e.type!==`TSPropertySignature`&&!d(e)||c(e,g)||v(e))return;let t=e.typeAnnotation?.typeAnnotation;if(!t||r(t,S))return;let n=t.type===`TSUnionType`?p(t):[t];if(n.some(e=>e.type===`TSNullKeyword`))return;let i=n.filter(e=>!u(e));if(i.length!==1||r(i[0],S))return;let a=e.type===`TSPropertySignature`?e.key:e,o=a.type===`Identifier`?a.name:a.type===`Literal`?String(a.value):s.sourceCode.getText(a);s.report({node:a,messageId:`preferOptionOverOptional`,data:{name:o,type:s.sourceCode.getText(i[0])}})}return{TSPropertySignature:C,Identifier:C,TSUnionType(e){if(e.parent?.type===`TSUnionType`||c(e,g)||v(e)||!e.types||e.types.length<2)return;let t=e.types;if(!t.some(e=>u(e))||t.filter(e=>!u(e)).length!==1||y&&x(e))return;let o=p(e);if(!o.some(e=>u(e)))return;let l=f(e.parent),d=!o.some(e=>e.type===`TSNullKeyword`);if(l&&d&&(!b||l.optional===!0))return;let h=o.filter(e=>!u(e));if(h.length===1){let t=h[0];if(r(t,S)||n(e,S))return;let c=s.sourceCode,l=c.getText(t),u=c.getText(e);if(l.startsWith(`Option<`))return;let d=m(e,o);if(d!==void 0){s.report({node:e,messageId:`preferWireForThreeStates`,data:{type:l,drop:d}});return}let f=[{messageId:`suggestOptionType`,data:{type:l},fix(t){return t.replaceText(e,`Option<${l}>`)}}];a(c,`Option`)||f.push({messageId:`suggestAddImport`,data:{symbol:`Option`},fix:i(c,`Option`)}),s.report({node:e,messageId:`preferOption`,data:{type:l,nullable:u},suggest:f})}}}}};export{h as default};
1
+ import{isInsideTaggedDeclaration as e}from"../utils/boundary-tags.js";import{getFunctypeImportsLegacy as t,isAlreadyUsingFunctype as n,isFunctypeType as r}from"../utils/functype-detection.js";import{createImportFixer as i,hasFunctypeSymbol as a}from"../utils/import-fixer.js";import{DEFAULT_WIRE_TYPES as o,WIRE_TYPES_SCHEMA as s,isInsideWireType as c}from"../utils/wire-types.js";const l=/* @__PURE__ */ new Set([`useState`,`useRef`]),u=e=>e.type===`TSNullKeyword`||e.type===`TSUndefinedKeyword`;function d(e){let t=e.parent;if(!t)return!1;if(t.type===`AssignmentPattern`&&t.left===e)return d(t);if(t.type===`TSParameterProperty`)return!0;let n=t.params;return Array.isArray(n)&&n.includes(e)}function f(e){let t=e?.type===`TSTypeAnnotation`?e.parent:void 0;if(t)return t.type===`TSPropertySignature`||d(t)?t:void 0}function p(e){return e.types.flatMap(e=>e.type===`TSUnionType`?p(e):[e])}function m(e,t){if(!t.some(e=>e.type===`TSNullKeyword`))return;let n=e.parent,r=n?.type===`TSTypeAnnotation`?n.parent:void 0,i=r?.type===`TSPropertySignature`?r:void 0;if(i?.optional===!0)return`the ? or the | null`;if(t.some(e=>e.type===`TSUndefinedKeyword`))return n?.type===`TSTypeAliasDeclaration`||i!==void 0?`the | null or the | undefined`:void 0}const h={meta:{type:`suggestion`,hasSuggestions:!0,docs:{description:`Prefer Option<T> over nullable types (T | null | undefined)`,recommended:!0},schema:[{type:`object`,properties:{allowInteropMarker:{type:`boolean`,default:!0},wireTypes:s,allowNullableIntersections:{type:`boolean`,default:!1},allowUseState:{type:`boolean`,default:!0},checkOptionalMembers:{type:`boolean`,default:!1}},additionalProperties:!1}],messages:{preferOption:`Prefer Option<{{type}}> over nullable type '{{nullable}}'. If this is a row, body or payload shape, wrap the type in Wire<…>. If a host API hands it over or needs it, such as a DOM lookup, tag the declaration @interop <reason>`,preferOptionReturn:`Prefer Option<{{type}}> as return type over nullable '{{nullable}}'`,preferOptionOverOptional:`Prefer '{{name}}: Option<{{type}}>' over the optional '{{name}}?'. If this is a row, body or payload shape, wrap the type in Wire<…>`,preferWireForThreeStates:`This type has three states, left out, null and set, and Option holds two. If it's a row, body or payload shape, wrap the type in Wire<…>. If it only meant "may be absent", drop {{drop}} and use Option<{{type}}>`,suggestOptionType:`Replace with Option<{{type}}>`,suggestAddImport:`Add {{symbol}} import from functype`}},create(s){let h=s.options[0]||{},g=h.wireTypes??o,_=h.allowInteropMarker!==!1,v=t=>_&&e(t,`interop`,s.sourceCode),y=h.allowUseState!==!1,b=h.checkOptionalMembers===!0;function x(e){let t=e.parent;if(!t)return!1;if(t.type===`TSTypeParameterInstantiation`&&t.parent?.type===`CallExpression`){let e=t.parent.callee,n=e.type===`Identifier`?e.name:e.type===`MemberExpression`&&e.property.type===`Identifier`?e.property.name:null;if(n!==null&&l.has(n))return!0}return x(t)}let S=t(s);function C(e){if(!b||e.optional!==!0||e.type!==`TSPropertySignature`&&!d(e)||c(e,g)||v(e))return;let t=e.typeAnnotation?.typeAnnotation;if(!t||r(t,S))return;let n=t.type===`TSUnionType`?p(t):[t];if(n.some(e=>e.type===`TSNullKeyword`))return;let i=n.filter(e=>!u(e));if(i.length!==1||r(i[0],S))return;let a=e.type===`TSPropertySignature`?e.key:e,o=a.type===`Identifier`?a.name:a.type===`Literal`?String(a.value):s.sourceCode.getText(a);s.report({node:a,messageId:`preferOptionOverOptional`,data:{name:o,type:s.sourceCode.getText(i[0])}})}return{TSPropertySignature:C,Identifier:C,TSUnionType(e){if(e.parent?.type===`TSUnionType`||c(e,g)||v(e)||!e.types||e.types.length<2)return;let t=e.types;if(!t.some(e=>u(e))||t.filter(e=>!u(e)).length!==1||y&&x(e))return;let o=p(e);if(!o.some(e=>u(e)))return;let l=f(e.parent),d=!o.some(e=>e.type===`TSNullKeyword`);if(l&&d&&(!b||l.optional===!0))return;let h=o.filter(e=>!u(e));if(h.length===1){let t=h[0];if(r(t,S)||n(e,S))return;let c=s.sourceCode,l=c.getText(t),u=c.getText(e);if(l.startsWith(`Option<`))return;let d=m(e,o);if(d!==void 0){s.report({node:e,messageId:`preferWireForThreeStates`,data:{type:l,drop:d}});return}let f=[{messageId:`suggestOptionType`,data:{type:l},fix(t){return t.replaceText(e,`Option<${l}>`)}}];a(c,`Option`)||f.push({messageId:`suggestAddImport`,data:{symbol:`Option`},fix:i(c,`Option`)}),s.report({node:e,messageId:`preferOption`,data:{type:l,nullable:u},suggest:f})}}}}};export{h as default};
2
2
  //# sourceMappingURL=prefer-option.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"prefer-option.js","names":["isInsideTaggedDeclaration","getFunctypeImportsLegacy","isAlreadyUsingFunctype","isFunctypeType","createImportFixer","hasFunctypeSymbol","DEFAULT_WIRE_TYPES","WIRE_TYPES_SCHEMA","isInsideWireType","REACT_STATE_HOOKS","isNullish","type","isParameter","node","parent","params","memberOrParameterOf","annotation","owner","unionMembers","union","t","threeStateSpellings","members","member","rule","context","options","wireTypes","allowInteropMarker","isExemptByMarker","allowUseState","checkOptionalMembers","isInHookTypeArgument","callee","name","functypeImports","checkOptional","kept","key","direct","undefinedOnly","nonNullTypes","nonNullType","sourceCode","nonNullTypeText","fullType","drop","suggestions","fixer"],"sources":["../../src/rules/prefer-option.ts"],"sourcesContent":["import type { Rule } from \"eslint\"\n\nimport type { ASTNode } from \"../types/ast\"\nimport { INTEROP_TAG, isInsideTaggedDeclaration } from \"../utils/boundary-tags\"\nimport { getFunctypeImportsLegacy, isAlreadyUsingFunctype, isFunctypeType } from \"../utils/functype-detection\"\nimport { createImportFixer, hasFunctypeSymbol } from \"../utils/import-fixer\"\nimport { DEFAULT_WIRE_TYPES, isInsideWireType, WIRE_TYPES_SCHEMA } from \"../utils/wire-types\"\n\nconst REACT_STATE_HOOKS: ReadonlySet<string> = new Set([\"useState\", \"useRef\"])\n\nconst isNullish = (type: ASTNode): boolean => type.type === \"TSNullKeyword\" || type.type === \"TSUndefinedKeyword\"\n\n/** Is `node` a parameter: of a function, a method signature or a function type, with or without a default? */\nfunction isParameter(node: ASTNode): boolean {\n const parent = node.parent as ASTNode | undefined\n if (!parent) return false\n if (parent.type === \"AssignmentPattern\" && parent.left === node) return isParameter(parent)\n if (parent.type === \"TSParameterProperty\") return true\n const params = (parent as { readonly params?: ReadonlyArray<ASTNode> }).params\n return Array.isArray(params) && params.includes(node)\n}\n\n/**\n * The member or parameter a type annotation belongs to, when it's the annotation of a type-literal or\n * interface member (`b: string | undefined`) or a parameter (`(x: string | undefined) => …`). Those are\n * the caller's shapes: a prop, an options-bag field, an argument (#446).\n */\nfunction memberOrParameterOf(annotation: ASTNode | undefined): ASTNode | undefined {\n const owner = annotation?.type === \"TSTypeAnnotation\" ? (annotation.parent as ASTNode | undefined) : undefined\n if (!owner) return undefined\n if (owner.type === \"TSPropertySignature\") return owner\n return isParameter(owner) ? owner : undefined\n}\n\n/**\n * A union's members, with nested unions spread in. The parser drops parentheses, so `(A | null) | undefined`\n * is a union holding a union; spread, it holds A, null and undefined.\n */\nfunction unionMembers(union: ASTNode): ReadonlyArray<ASTNode> {\n return union.types.flatMap((t: ASTNode) => (t.type === \"TSUnionType\" ? unionMembers(t) : [t]))\n}\n\n/**\n * Does a nullable union describe a three-state shape? Left out, cleared and set are three states, and\n * `Option` has two (#448). That's a type alias's body or a type-literal or interface member holding both\n * `null` and `undefined`, or an optional member that can also be `null` (`a?: T | null`). A parameter is a\n * converter's input and a return type is a result, so neither counts.\n *\n * Returns the two spellings of \"absent\" the type uses, for the message to say which to drop, or `undefined`\n * when the union isn't a three-state shape.\n */\nfunction threeStateSpellings(union: ASTNode, members: ReadonlyArray<ASTNode>): string | undefined {\n if (!members.some((t) => t.type === \"TSNullKeyword\")) return undefined\n const parent = union.parent as ASTNode | undefined\n const owner = parent?.type === \"TSTypeAnnotation\" ? (parent.parent as ASTNode | undefined) : undefined\n const member = owner?.type === \"TSPropertySignature\" ? owner : undefined\n if (member?.optional === true) return \"the ? or the | null\"\n if (!members.some((t) => t.type === \"TSUndefinedKeyword\")) return undefined\n return parent?.type === \"TSTypeAliasDeclaration\" || member !== undefined ? \"the | null or the | undefined\" : undefined\n}\n\nconst rule: Rule.RuleModule = {\n meta: {\n type: \"suggestion\",\n hasSuggestions: true,\n docs: {\n description: \"Prefer Option<T> over nullable types (T | null | undefined)\",\n recommended: true,\n },\n schema: [\n {\n type: \"object\",\n properties: {\n allowInteropMarker: {\n type: \"boolean\",\n default: true,\n },\n wireTypes: WIRE_TYPES_SCHEMA,\n allowNullableIntersections: {\n type: \"boolean\",\n default: false,\n },\n allowUseState: {\n type: \"boolean\",\n default: true,\n },\n checkOptionalMembers: {\n type: \"boolean\",\n default: false,\n },\n },\n additionalProperties: false,\n },\n ],\n messages: {\n preferOption:\n \"Prefer Option<{{type}}> over nullable type '{{nullable}}'. If this is a row, body or payload shape, wrap the type in Wire<…>\",\n preferOptionReturn: \"Prefer Option<{{type}}> as return type over nullable '{{nullable}}'\",\n preferOptionOverOptional:\n \"Prefer '{{name}}: Option<{{type}}>' over the optional '{{name}}?'. If this is a row, body or payload shape, wrap the type in Wire<…>\",\n preferWireForThreeStates:\n 'This type has three states, left out, null and set, and Option holds two. If it\\'s a row, body or payload shape, wrap the type in Wire<…>. If it only meant \"may be absent\", drop {{drop}} and use Option<{{type}}>',\n suggestOptionType: \"Replace with Option<{{type}}>\",\n suggestAddImport: \"Add {{symbol}} import from functype\",\n },\n },\n\n create(context) {\n const options = context.options[0] || {}\n // Everything inside `Wire<…>` is the declared serialization shape (#325 B).\n const wireTypes: ReadonlyArray<string> = options.wireTypes ?? DEFAULT_WIRE_TYPES\n // `@interop <reason>` on an enclosing declaration marks a host-contract boundary (#241).\n const allowInteropMarker = options.allowInteropMarker !== false\n const isExemptByMarker = (node: ASTNode): boolean =>\n allowInteropMarker && isInsideTaggedDeclaration(node, INTEROP_TAG, context.sourceCode)\n // `null` is idiomatic React state (`useState<User | null>(null)`, `useRef<El | null>(null)`); an\n // Option in a hook's type argument buys nothing and fights the hook's own API (#325).\n const allowUseState = options.allowUseState !== false\n // `a?: T` and `a: T | undefined` on a member or parameter both mean \"may be absent\", and the caller\n // writes `<X b=\"v\" />` or `f()`. Skip both unless asked to report them (#446).\n const checkOptionalMembers = options.checkOptionalMembers === true\n\n /** Is `node` inside the type argument of a `useState` / `useRef` call (bare or `React.`-qualified)? */\n function isInHookTypeArgument(node: ASTNode): boolean {\n const parent = node.parent\n if (!parent) return false\n if (parent.type === \"TSTypeParameterInstantiation\" && parent.parent?.type === \"CallExpression\") {\n const callee = parent.parent.callee\n const name =\n callee.type === \"Identifier\"\n ? callee.name\n : callee.type === \"MemberExpression\" && callee.property.type === \"Identifier\"\n ? callee.property.name\n : null\n if (name !== null && REACT_STATE_HOOKS.has(name)) return true\n }\n return isInHookTypeArgument(parent)\n }\n\n // Get functype imports if available (but still apply rule even without explicit import)\n const functypeImports = getFunctypeImportsLegacy(context)\n\n /** With checkOptionalMembers, `a?: T` on a member or parameter is reported like `a: T | undefined`. */\n function checkOptional(node: ASTNode): void {\n if (!checkOptionalMembers || node.optional !== true) return\n if (node.type !== \"TSPropertySignature\" && !isParameter(node)) return\n if (isInsideWireType(node, wireTypes) || isExemptByMarker(node)) return\n const annotation = (node.typeAnnotation as ASTNode | undefined)?.typeAnnotation as ASTNode | undefined\n if (!annotation || isFunctypeType(annotation, functypeImports)) return\n const members = annotation.type === \"TSUnionType\" ? unionMembers(annotation) : [annotation]\n // `a?: T | null` is reported once, by the union check.\n if (members.some((t) => t.type === \"TSNullKeyword\")) return\n const kept = members.filter((t) => !isNullish(t))\n if (kept.length !== 1 || isFunctypeType(kept[0], functypeImports)) return\n const key = (node.type === \"TSPropertySignature\" ? node.key : node) as ASTNode\n const name =\n key.type === \"Identifier\"\n ? key.name\n : key.type === \"Literal\"\n ? String(key.value)\n : context.sourceCode.getText(key)\n context.report({\n node: key,\n messageId: \"preferOptionOverOptional\",\n data: { name, type: context.sourceCode.getText(kept[0]) },\n })\n }\n\n return {\n TSPropertySignature: checkOptional,\n Identifier: checkOptional,\n\n TSUnionType(node: ASTNode) {\n // A union nested in a union is part of the outer one, which reports for both.\n if ((node.parent as ASTNode | undefined)?.type === \"TSUnionType\") return\n if (isInsideWireType(node, wireTypes)) return\n if (isExemptByMarker(node)) return\n if (!node.types || node.types.length < 2) return\n // The gate the rule always had: a nullish member of its own beside exactly one other. Spreading\n // nested unions below only refines what that one member is, so nothing new gets reported.\n const direct: ReadonlyArray<ASTNode> = node.types\n if (!direct.some((t) => isNullish(t)) || direct.filter((t) => !isNullish(t)).length !== 1) return\n if (allowUseState && isInHookTypeArgument(node)) return\n\n const members = unionMembers(node)\n const hasNull = members.some((type) => isNullish(type))\n\n if (!hasNull) return\n\n // On a member or parameter, `T | undefined` is the same \"may be absent\" as `?:`: skipped unless\n // checkOptionalMembers is on, and never reported on an optional one (`c?: T | undefined` is the\n // spelling exactOptionalPropertyTypes needs; the optional-member check reports it, once).\n const owner = memberOrParameterOf(node.parent)\n const undefinedOnly = !members.some((type) => type.type === \"TSNullKeyword\")\n if (owner && undefinedOnly && (!checkOptionalMembers || owner.optional === true)) return\n\n const nonNullTypes = members.filter((type) => !isNullish(type))\n\n if (nonNullTypes.length === 1) {\n const nonNullType = nonNullTypes[0]\n\n // Skip if it's already an Option type or other functype type\n if (isFunctypeType(nonNullType, functypeImports)) return\n\n // Skip if we're already in a functype context\n if (isAlreadyUsingFunctype(node, functypeImports)) return\n\n const sourceCode = context.sourceCode\n const nonNullTypeText = sourceCode.getText(nonNullType)\n const fullType = sourceCode.getText(node)\n\n // Skip if it's already an Option type (fallback check)\n if (nonNullTypeText.startsWith(\"Option<\")) return\n\n const drop = threeStateSpellings(node, members)\n if (drop !== undefined) {\n context.report({ node, messageId: \"preferWireForThreeStates\", data: { type: nonNullTypeText, drop } })\n return\n }\n\n const suggestions: Rule.SuggestionReportDescriptor[] = [\n {\n messageId: \"suggestOptionType\",\n data: { type: nonNullTypeText },\n fix(fixer) {\n return fixer.replaceText(node, `Option<${nonNullTypeText}>`)\n },\n },\n ]\n\n if (!hasFunctypeSymbol(sourceCode, \"Option\")) {\n suggestions.push({\n messageId: \"suggestAddImport\",\n data: { symbol: \"Option\" },\n fix: createImportFixer(sourceCode, \"Option\"),\n })\n }\n\n context.report({\n node,\n messageId: \"preferOption\",\n data: {\n type: nonNullTypeText,\n nullable: fullType,\n },\n suggest: suggestions,\n })\n }\n },\n }\n },\n}\n\nexport default rule\n"],"mappings":"A,6XAQA,MAAMS,kBAAyC,IAAI,IAAI,CAAC,WAAY,QAAQ,CAAC,EAEvEC,EAAaC,GAA2BA,EAAK,OAAS,iBAAmB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,GAAS,CAACD,EAAUC,CAAI,CAAC,EAE9D,GAAI+B,EAAa,SAAW,EAAG,CAC7B,IAAMC,EAAcD,EAAa,GAMjC,GAHIvC,EAAewC,EAAaP,CAAe,GAG3ClC,EAAuBW,EAAMuB,CAAe,EAAG,OAEnD,IAAMQ,EAAalB,EAAQ,WACrBmB,EAAkBD,EAAW,QAAQD,CAAW,EAChDG,EAAWF,EAAW,QAAQ/B,CAAI,EAGxC,GAAIgC,EAAgB,WAAW,SAAS,EAAG,OAE3C,IAAME,EAAOzB,EAAoBT,EAAMU,CAAO,EAC9C,GAAIwB,IAAS,IAAA,GAAW,CACtBrB,EAAQ,OAAO,CAAEb,OAAM,UAAW,2BAA4B,KAAM,CAAE,KAAMgC,EAAiBE,MAAK,CAAE,CAAC,EACrG,MACF,CAEA,IAAMC,EAAiD,CACrD,CACE,UAAW,oBACX,KAAM,CAAE,KAAMH,CAAgB,EAC9B,IAAII,EAAO,CACT,OAAOA,EAAM,YAAYpC,EAAM,UAAUgC,EAAgB,EAAE,CAC7D,CACF,CACF,EAEKxC,EAAkBuC,EAAY,QAAQ,GACzCI,EAAY,KAAK,CACf,UAAW,mBACX,KAAM,CAAE,OAAQ,QAAS,EACzB,IAAK5C,EAAkBwC,EAAY,QAAQ,CAC7C,CAAC,EAGHlB,EAAQ,OAAO,CACbb,OACA,UAAW,eACX,KAAM,CACJ,KAAMgC,EACN,SAAUC,CACZ,EACA,QAASE,CACX,CAAC,CACH,CACF,CACF,CACF,CACF,E"}
1
+ {"version":3,"file":"prefer-option.js","names":["isInsideTaggedDeclaration","getFunctypeImportsLegacy","isAlreadyUsingFunctype","isFunctypeType","createImportFixer","hasFunctypeSymbol","DEFAULT_WIRE_TYPES","WIRE_TYPES_SCHEMA","isInsideWireType","REACT_STATE_HOOKS","isNullish","type","isParameter","node","parent","params","memberOrParameterOf","annotation","owner","unionMembers","union","t","threeStateSpellings","members","member","rule","context","options","wireTypes","allowInteropMarker","isExemptByMarker","allowUseState","checkOptionalMembers","isInHookTypeArgument","callee","name","functypeImports","checkOptional","kept","key","direct","undefinedOnly","nonNullTypes","nonNullType","sourceCode","nonNullTypeText","fullType","drop","suggestions","fixer"],"sources":["../../src/rules/prefer-option.ts"],"sourcesContent":["import type { Rule } from \"eslint\"\n\nimport type { ASTNode } from \"../types/ast\"\nimport { INTEROP_TAG, isInsideTaggedDeclaration } from \"../utils/boundary-tags\"\nimport { getFunctypeImportsLegacy, isAlreadyUsingFunctype, isFunctypeType } from \"../utils/functype-detection\"\nimport { createImportFixer, hasFunctypeSymbol } from \"../utils/import-fixer\"\nimport { DEFAULT_WIRE_TYPES, isInsideWireType, WIRE_TYPES_SCHEMA } from \"../utils/wire-types\"\n\nconst REACT_STATE_HOOKS: ReadonlySet<string> = new Set([\"useState\", \"useRef\"])\n\nconst isNullish = (type: ASTNode): boolean => type.type === \"TSNullKeyword\" || type.type === \"TSUndefinedKeyword\"\n\n/** Is `node` a parameter: of a function, a method signature or a function type, with or without a default? */\nfunction isParameter(node: ASTNode): boolean {\n const parent = node.parent as ASTNode | undefined\n if (!parent) return false\n if (parent.type === \"AssignmentPattern\" && parent.left === node) return isParameter(parent)\n if (parent.type === \"TSParameterProperty\") return true\n const params = (parent as { readonly params?: ReadonlyArray<ASTNode> }).params\n return Array.isArray(params) && params.includes(node)\n}\n\n/**\n * The member or parameter a type annotation belongs to, when it's the annotation of a type-literal or\n * interface member (`b: string | undefined`) or a parameter (`(x: string | undefined) => …`). Those are\n * the caller's shapes: a prop, an options-bag field, an argument (#446).\n */\nfunction memberOrParameterOf(annotation: ASTNode | undefined): ASTNode | undefined {\n const owner = annotation?.type === \"TSTypeAnnotation\" ? (annotation.parent as ASTNode | undefined) : undefined\n if (!owner) return undefined\n if (owner.type === \"TSPropertySignature\") return owner\n return isParameter(owner) ? owner : undefined\n}\n\n/**\n * A union's members, with nested unions spread in. The parser drops parentheses, so `(A | null) | undefined`\n * is a union holding a union; spread, it holds A, null and undefined.\n */\nfunction unionMembers(union: ASTNode): ReadonlyArray<ASTNode> {\n return union.types.flatMap((t: ASTNode) => (t.type === \"TSUnionType\" ? unionMembers(t) : [t]))\n}\n\n/**\n * Does a nullable union describe a three-state shape? Left out, cleared and set are three states, and\n * `Option` has two (#448). That's a type alias's body or a type-literal or interface member holding both\n * `null` and `undefined`, or an optional member that can also be `null` (`a?: T | null`). A parameter is a\n * converter's input and a return type is a result, so neither counts.\n *\n * Returns the two spellings of \"absent\" the type uses, for the message to say which to drop, or `undefined`\n * when the union isn't a three-state shape.\n */\nfunction threeStateSpellings(union: ASTNode, members: ReadonlyArray<ASTNode>): string | undefined {\n if (!members.some((t) => t.type === \"TSNullKeyword\")) return undefined\n const parent = union.parent as ASTNode | undefined\n const owner = parent?.type === \"TSTypeAnnotation\" ? (parent.parent as ASTNode | undefined) : undefined\n const member = owner?.type === \"TSPropertySignature\" ? owner : undefined\n if (member?.optional === true) return \"the ? or the | null\"\n if (!members.some((t) => t.type === \"TSUndefinedKeyword\")) return undefined\n return parent?.type === \"TSTypeAliasDeclaration\" || member !== undefined ? \"the | null or the | undefined\" : undefined\n}\n\nconst rule: Rule.RuleModule = {\n meta: {\n type: \"suggestion\",\n hasSuggestions: true,\n docs: {\n description: \"Prefer Option<T> over nullable types (T | null | undefined)\",\n recommended: true,\n },\n schema: [\n {\n type: \"object\",\n properties: {\n allowInteropMarker: {\n type: \"boolean\",\n default: true,\n },\n wireTypes: WIRE_TYPES_SCHEMA,\n allowNullableIntersections: {\n type: \"boolean\",\n default: false,\n },\n allowUseState: {\n type: \"boolean\",\n default: true,\n },\n checkOptionalMembers: {\n type: \"boolean\",\n default: false,\n },\n },\n additionalProperties: false,\n },\n ],\n messages: {\n preferOption:\n \"Prefer Option<{{type}}> over nullable type '{{nullable}}'. If this is a row, body or payload shape, wrap the type in Wire<…>. If a host API hands it over or needs it, such as a DOM lookup, tag the declaration @interop <reason>\",\n preferOptionReturn: \"Prefer Option<{{type}}> as return type over nullable '{{nullable}}'\",\n preferOptionOverOptional:\n \"Prefer '{{name}}: Option<{{type}}>' over the optional '{{name}}?'. If this is a row, body or payload shape, wrap the type in Wire<…>\",\n preferWireForThreeStates:\n 'This type has three states, left out, null and set, and Option holds two. If it\\'s a row, body or payload shape, wrap the type in Wire<…>. If it only meant \"may be absent\", drop {{drop}} and use Option<{{type}}>',\n suggestOptionType: \"Replace with Option<{{type}}>\",\n suggestAddImport: \"Add {{symbol}} import from functype\",\n },\n },\n\n create(context) {\n const options = context.options[0] || {}\n // Everything inside `Wire<…>` is the declared serialization shape (#325 B).\n const wireTypes: ReadonlyArray<string> = options.wireTypes ?? DEFAULT_WIRE_TYPES\n // `@interop <reason>` on an enclosing declaration marks a host-contract boundary (#241).\n const allowInteropMarker = options.allowInteropMarker !== false\n const isExemptByMarker = (node: ASTNode): boolean =>\n allowInteropMarker && isInsideTaggedDeclaration(node, INTEROP_TAG, context.sourceCode)\n // `null` is idiomatic React state (`useState<User | null>(null)`, `useRef<El | null>(null)`); an\n // Option in a hook's type argument buys nothing and fights the hook's own API (#325).\n const allowUseState = options.allowUseState !== false\n // `a?: T` and `a: T | undefined` on a member or parameter both mean \"may be absent\", and the caller\n // writes `<X b=\"v\" />` or `f()`. Skip both unless asked to report them (#446).\n const checkOptionalMembers = options.checkOptionalMembers === true\n\n /** Is `node` inside the type argument of a `useState` / `useRef` call (bare or `React.`-qualified)? */\n function isInHookTypeArgument(node: ASTNode): boolean {\n const parent = node.parent\n if (!parent) return false\n if (parent.type === \"TSTypeParameterInstantiation\" && parent.parent?.type === \"CallExpression\") {\n const callee = parent.parent.callee\n const name =\n callee.type === \"Identifier\"\n ? callee.name\n : callee.type === \"MemberExpression\" && callee.property.type === \"Identifier\"\n ? callee.property.name\n : null\n if (name !== null && REACT_STATE_HOOKS.has(name)) return true\n }\n return isInHookTypeArgument(parent)\n }\n\n // Get functype imports if available (but still apply rule even without explicit import)\n const functypeImports = getFunctypeImportsLegacy(context)\n\n /** With checkOptionalMembers, `a?: T` on a member or parameter is reported like `a: T | undefined`. */\n function checkOptional(node: ASTNode): void {\n if (!checkOptionalMembers || node.optional !== true) return\n if (node.type !== \"TSPropertySignature\" && !isParameter(node)) return\n if (isInsideWireType(node, wireTypes) || isExemptByMarker(node)) return\n const annotation = (node.typeAnnotation as ASTNode | undefined)?.typeAnnotation as ASTNode | undefined\n if (!annotation || isFunctypeType(annotation, functypeImports)) return\n const members = annotation.type === \"TSUnionType\" ? unionMembers(annotation) : [annotation]\n // `a?: T | null` is reported once, by the union check.\n if (members.some((t) => t.type === \"TSNullKeyword\")) return\n const kept = members.filter((t) => !isNullish(t))\n if (kept.length !== 1 || isFunctypeType(kept[0], functypeImports)) return\n const key = (node.type === \"TSPropertySignature\" ? node.key : node) as ASTNode\n const name =\n key.type === \"Identifier\"\n ? key.name\n : key.type === \"Literal\"\n ? String(key.value)\n : context.sourceCode.getText(key)\n context.report({\n node: key,\n messageId: \"preferOptionOverOptional\",\n data: { name, type: context.sourceCode.getText(kept[0]) },\n })\n }\n\n return {\n TSPropertySignature: checkOptional,\n Identifier: checkOptional,\n\n TSUnionType(node: ASTNode) {\n // A union nested in a union is part of the outer one, which reports for both.\n if ((node.parent as ASTNode | undefined)?.type === \"TSUnionType\") return\n if (isInsideWireType(node, wireTypes)) return\n if (isExemptByMarker(node)) return\n if (!node.types || node.types.length < 2) return\n // The gate the rule always had: a nullish member of its own beside exactly one other. Spreading\n // nested unions below only refines what that one member is, so nothing new gets reported.\n const direct: ReadonlyArray<ASTNode> = node.types\n if (!direct.some((t) => isNullish(t)) || direct.filter((t) => !isNullish(t)).length !== 1) return\n if (allowUseState && isInHookTypeArgument(node)) return\n\n const members = unionMembers(node)\n const hasNull = members.some((type) => isNullish(type))\n\n if (!hasNull) return\n\n // On a member or parameter, `T | undefined` is the same \"may be absent\" as `?:`: skipped unless\n // checkOptionalMembers is on, and never reported on an optional one (`c?: T | undefined` is the\n // spelling exactOptionalPropertyTypes needs; the optional-member check reports it, once).\n const owner = memberOrParameterOf(node.parent)\n const undefinedOnly = !members.some((type) => type.type === \"TSNullKeyword\")\n if (owner && undefinedOnly && (!checkOptionalMembers || owner.optional === true)) return\n\n const nonNullTypes = members.filter((type) => !isNullish(type))\n\n if (nonNullTypes.length === 1) {\n const nonNullType = nonNullTypes[0]\n\n // Skip if it's already an Option type or other functype type\n if (isFunctypeType(nonNullType, functypeImports)) return\n\n // Skip if we're already in a functype context\n if (isAlreadyUsingFunctype(node, functypeImports)) return\n\n const sourceCode = context.sourceCode\n const nonNullTypeText = sourceCode.getText(nonNullType)\n const fullType = sourceCode.getText(node)\n\n // Skip if it's already an Option type (fallback check)\n if (nonNullTypeText.startsWith(\"Option<\")) return\n\n const drop = threeStateSpellings(node, members)\n if (drop !== undefined) {\n context.report({ node, messageId: \"preferWireForThreeStates\", data: { type: nonNullTypeText, drop } })\n return\n }\n\n const suggestions: Rule.SuggestionReportDescriptor[] = [\n {\n messageId: \"suggestOptionType\",\n data: { type: nonNullTypeText },\n fix(fixer) {\n return fixer.replaceText(node, `Option<${nonNullTypeText}>`)\n },\n },\n ]\n\n if (!hasFunctypeSymbol(sourceCode, \"Option\")) {\n suggestions.push({\n messageId: \"suggestAddImport\",\n data: { symbol: \"Option\" },\n fix: createImportFixer(sourceCode, \"Option\"),\n })\n }\n\n context.report({\n node,\n messageId: \"preferOption\",\n data: {\n type: nonNullTypeText,\n nullable: fullType,\n },\n suggest: suggestions,\n })\n }\n },\n }\n },\n}\n\nexport default rule\n"],"mappings":"A,6XAQA,MAAMS,kBAAyC,IAAI,IAAI,CAAC,WAAY,QAAQ,CAAC,EAEvEC,EAAaC,GAA2BA,EAAK,OAAS,iBAAmBA,EAAK,OAAS,qBAG7F,SAASC,EAAYC,EAAwB,CAC3C,IAAMC,EAASD,EAAK,OACpB,GAAI,CAACC,EAAQ,MAAO,GACpB,GAAIA,EAAO,OAAS,qBAAuBA,EAAO,OAASD,EAAM,OAAOD,EAAYE,CAAM,EAC1F,GAAIA,EAAO,OAAS,sBAAuB,MAAO,GACl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AW,QAAQD,CAAW,EAChDG,EAAWF,EAAW,QAAQ/B,CAAI,EAGxC,GAAIgC,EAAgB,WAAW,SAAS,EAAG,OAE3C,IAAME,EAAOzB,EAAoBT,EAAMU,CAAO,EAC9C,GAAIwB,IAAS,IAAA,GAAW,CACtBrB,EAAQ,OAAO,CAAEb,OAAM,UAAW,2BAA4B,KAAM,CAAE,KAAMgC,EAAiBE,MAAK,CAAE,CAAC,EACrG,MACF,CAEA,IAAMC,EAAiD,CACrD,CACE,UAAW,oBACX,KAAM,CAAE,KAAMH,CAAgB,EAC9B,IAAII,EAAO,CACT,OAAOA,EAAM,YAAYpC,EAAM,UAAUgC,EAAgB,EAAE,CAC7D,CACF,CACF,EAEKxC,EAAkBuC,EAAY,QAAQ,GACzCI,EAAY,KAAK,CACf,UAAW,mBACX,KAAM,CAAE,OAAQ,QAAS,EACzB,IAAK5C,EAAkBwC,EAAY,QAAQ,CAC7C,CAAC,EAGHlB,EAAQ,OAAO,CACbb,OACA,UAAW,eACX,KAAM,CACJ,KAAMgC,EACN,SAAUC,CACZ,EACA,QAASE,CACX,CAAC,CACH,CACF,CACF,CACF,CACF,E"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-functype",
3
- "version": "2.202.0",
3
+ "version": "2.202.2",
4
4
  "description": "Custom ESLint rules for functional TypeScript programming with functype library patterns including Do notation (ESLint 10+)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -42,7 +42,7 @@
42
42
  "@types/node": "^24.19.2",
43
43
  "@typescript-eslint/rule-tester": "^8.72.2",
44
44
  "eslint-config-prettier": "^10.1.8",
45
- "functype": "^2.2.0",
45
+ "functype": "^2.2.2",
46
46
  "ts-builds": "^5.0.0",
47
47
  "tsdown": "^0.23.7"
48
48
  },