eslint-plugin-functype 2.109.0 → 2.110.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +110 -19
- package/dist/cli/list-rules.js.map +1 -1
- package/dist/configs/recommended.d.ts +21 -5
- package/dist/configs/recommended.js +1 -1
- package/dist/configs/recommended.js.map +1 -1
- package/dist/configs/strict.d.ts +1 -1
- package/dist/configs/strict.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/rules/index.js.map +1 -1
- package/dist/rules/no-get-unsafe.js.map +1 -1
- package/dist/rules/no-imperative-loops.js +1 -1
- package/dist/rules/no-imperative-loops.js.map +1 -1
- package/dist/rules/no-let.js.map +1 -1
- package/dist/rules/prefer-do-notation.js +1 -1
- package/dist/rules/prefer-do-notation.js.map +1 -1
- package/dist/rules/prefer-either.js +1 -1
- package/dist/rules/prefer-either.js.map +1 -1
- package/dist/rules/prefer-flatmap.js +1 -1
- package/dist/rules/prefer-flatmap.js.map +1 -1
- package/dist/rules/prefer-fold.js +1 -1
- package/dist/rules/prefer-fold.js.map +1 -1
- package/dist/rules/prefer-functype-map.js +1 -1
- package/dist/rules/prefer-functype-map.js.map +1 -1
- package/dist/rules/prefer-functype-set.js +1 -1
- package/dist/rules/prefer-functype-set.js.map +1 -1
- package/dist/rules/prefer-list.js +1 -1
- package/dist/rules/prefer-list.js.map +1 -1
- package/dist/rules/prefer-map.js +1 -1
- package/dist/rules/prefer-map.js.map +1 -1
- package/dist/rules/prefer-option.js +1 -1
- package/dist/rules/prefer-option.js.map +1 -1
- package/dist/rules/prefer-try.js +1 -1
- package/dist/rules/prefer-try.js.map +1 -1
- package/dist/types/ast.d.ts +1 -2
- package/dist/utils/ast-walk.d.ts +12 -0
- package/dist/utils/ast-walk.js +2 -0
- package/dist/utils/ast-walk.js.map +1 -0
- package/dist/utils/async-detection.d.ts +6 -0
- package/dist/utils/async-detection.js +2 -0
- package/dist/utils/async-detection.js.map +1 -0
- package/dist/utils/boundary-tags.d.ts +25 -0
- package/dist/utils/boundary-tags.js +2 -0
- package/dist/utils/boundary-tags.js.map +1 -0
- package/dist/utils/dependency-validator.d.ts +4 -5
- package/dist/utils/dependency-validator.js +1 -1
- package/dist/utils/dependency-validator.js.map +1 -1
- package/dist/utils/functype-detection.d.ts +13 -14
- package/dist/utils/functype-detection.js +1 -1
- package/dist/utils/functype-detection.js.map +1 -1
- package/dist/utils/import-fixer.d.ts +2 -3
- package/dist/utils/import-fixer.js.map +1 -1
- package/dist/utils/mutable-collection.d.ts +30 -0
- package/dist/utils/mutable-collection.js +2 -0
- package/dist/utils/mutable-collection.js.map +1 -0
- package/dist/utils/wire-types.d.ts +21 -0
- package/dist/utils/wire-types.js +2 -0
- package/dist/utils/wire-types.js.map +1 -0
- package/package.json +6 -6
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ASTNode } from "../types/ast.js";
|
|
2
|
+
import { SourceCode } from "eslint";
|
|
3
|
+
//#region src/utils/mutable-collection.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Detects a native Set/Map that the code mutates on purpose — a cache, a registry, an in-place
|
|
6
|
+
* accumulator, a React copy-then-add. functype's collections are immutable, so they cannot express
|
|
7
|
+
* these, and a rule that suggests them there is noise (#324).
|
|
8
|
+
*
|
|
9
|
+
* Mutation means a call of one of `mutators` on the collection itself:
|
|
10
|
+
* - directly on a `new` expression that copies something (`new Set(prev).add(id)`) — an empty
|
|
11
|
+
* `new Map().set(a, 1).set(b, 2)` is a builder, a `Map.of` candidate, and is NOT exempt;
|
|
12
|
+
* - through the variable, parameter or later-assigned `let` it is bound to;
|
|
13
|
+
* - through `this.<field>` in the owning class (field initializer, constructor assignment, or
|
|
14
|
+
* constructor parameter property).
|
|
15
|
+
*
|
|
16
|
+
* Not followed: aliases (`const t = s; t.add(x)`), `useRef(new Set()).current.add(x)`, a mutator
|
|
17
|
+
* passed as a callback (`xs.forEach(seen.add, seen)`), and a collection passed into another function.
|
|
18
|
+
*/
|
|
19
|
+
export declare const SET_MUTATORS: ReadonlyArray<string>;
|
|
20
|
+
export declare const MAP_MUTATORS: ReadonlyArray<string>;
|
|
21
|
+
/** `new Set(...)` / `new Map(...)` that is mutated, directly or through what it is bound to. */
|
|
22
|
+
export declare const isMutatedCollection: (newExpr: ASTNode, mutators: ReadonlyArray<string>, sourceCode: SourceCode) => boolean;
|
|
23
|
+
/**
|
|
24
|
+
* A `Set<T>` / `Map<K, V>` type reference annotating a binding that is mutated — a variable
|
|
25
|
+
* (`let s: Set<T>`), a parameter (`(s: Set<T>) =>`), a class field (`private s: Set<T>`), or a
|
|
26
|
+
* constructor parameter property (`constructor(private s: Set<T>)`).
|
|
27
|
+
*/
|
|
28
|
+
export declare const annotatesMutatedBinding: (typeRef: ASTNode, mutators: ReadonlyArray<string>, sourceCode: SourceCode) => boolean;
|
|
29
|
+
//#endregion
|
|
30
|
+
//# sourceMappingURL=mutable-collection.d.ts.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{descendants as e}from"./ast-walk.js";const t=[`add`,`delete`,`clear`],n=[`set`,`delete`,`clear`],r=(e,t)=>{let n=e.parent;return n?.type===`TSNonNullExpression`&&n.expression===e?r(n,t):n?.type===`MemberExpression`&&n.object===e&&!n.computed&&n.property.type===`Identifier`&&t.includes(n.property.name)&&n.parent?.type===`CallExpression`&&n.parent.callee===n},i=e=>e?.type===`Identifier`?e.name:e?.type===`PrivateIdentifier`?`#${e.name}`:null,a=e=>e==null?null:e.type===`ClassBody`?e:a(e.parent),o=(t,n,o)=>{let s=a(t);return s!==null&&e(s).some(e=>e.type===`MemberExpression`&&e.object.type===`ThisExpression`&&!e.computed&&i(e.property)===n&&r(e,o))},s=(e,t,n)=>{let r=e=>e===null?null:e.set.get(t)??r(e.upper);return r(n.getScope(e))},c=(e,t,n)=>s(e,e.name,n)?.references.some(e=>r(e.identifier,t))??!1,l=(e,t,n)=>{let r=e.parent?.type===`AssignmentPattern`?e.parent.parent:e.parent;return r?.type===`TSParameterProperty`?o(r,e.name,t):c(e,t,n)},u=(e,t,n,r)=>{let a=e?.type===`VariableDeclarator`?e.id:(e?.type===`AssignmentExpression`||e?.type===`AssignmentPattern`)&&e.right===t?e.left:null;if(a?.type===`Identifier`)return l(a,n,r);if(a?.type===`MemberExpression`&&a.object.type===`ThisExpression`){let t=i(a.property);return t!==null&&o(e,t,n)}if(e?.type===`PropertyDefinition`&&e.value===t){let t=i(e.key);return t!==null&&o(e,t,n)}return!1},d=(e,t,n)=>e.arguments.length>0&&r(e,t)||u(e.parent,e,t,n),f=(e,t,n)=>{let r=e.parent;if(r?.type!==`TSTypeAnnotation`||r.typeAnnotation!==e)return!1;let a=r.parent;if(a?.type===`Identifier`)return l(a,t,n);if(a?.type===`PropertyDefinition`){let e=i(a.key);return e!==null&&o(a,e,t)}return!1};export{n as MAP_MUTATORS,t as SET_MUTATORS,f as annotatesMutatedBinding,d as isMutatedCollection};
|
|
2
|
+
//# sourceMappingURL=mutable-collection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutable-collection.js","names":["SET_MUTATORS","MAP_MUTATORS","isMutatorCallOn","parent","expr","mutators","fieldName","key","enclosingClassBody","node","isFieldMutated","body","descendants","n","name","resolveVariable","lookup","scope","sourceCode","isNameMutated","identifier","ref","isIdentifierBindingMutated","owner","isBindingMutated","target","binding","value","isMutatedCollection","newExpr","annotatesMutatedBinding","annotation","typeRef"],"sources":["../../src/utils/mutable-collection.ts"],"sourcesContent":["import type { Scope, SourceCode } from \"eslint\"\n\nimport type { ASTNode } from \"../types/ast\"\nimport { descendants } from \"./ast-walk\"\n\n/**\n * Detects a native Set/Map that the code mutates on purpose — a cache, a registry, an in-place\n * accumulator, a React copy-then-add. functype's collections are immutable, so they cannot express\n * these, and a rule that suggests them there is noise (#324).\n *\n * Mutation means a call of one of `mutators` on the collection itself:\n * - directly on a `new` expression that copies something (`new Set(prev).add(id)`) — an empty\n * `new Map().set(a, 1).set(b, 2)` is a builder, a `Map.of` candidate, and is NOT exempt;\n * - through the variable, parameter or later-assigned `let` it is bound to;\n * - through `this.<field>` in the owning class (field initializer, constructor assignment, or\n * constructor parameter property).\n *\n * Not followed: aliases (`const t = s; t.add(x)`), `useRef(new Set()).current.add(x)`, a mutator\n * passed as a callback (`xs.forEach(seen.add, seen)`), and a collection passed into another function.\n */\n\nexport const SET_MUTATORS: ReadonlyArray<string> = [\"add\", \"delete\", \"clear\"]\nexport const MAP_MUTATORS: ReadonlyArray<string> = [\"set\", \"delete\", \"clear\"]\n\n/** `expr.add(...)` / `expr!.add(...)` — `expr` is the object of a called mutator member. */\nconst isMutatorCallOn = (expr: ASTNode, mutators: ReadonlyArray<string>): boolean => {\n const parent = expr.parent\n if (parent?.type === \"TSNonNullExpression\" && parent.expression === expr) return isMutatorCallOn(parent, mutators)\n return (\n parent?.type === \"MemberExpression\" &&\n parent.object === expr &&\n !parent.computed &&\n parent.property.type === \"Identifier\" &&\n mutators.includes(parent.property.name) &&\n parent.parent?.type === \"CallExpression\" &&\n parent.parent.callee === parent\n )\n}\n\n/** The field name for `foo` / `#foo` keys, matching how `this.foo` / `this.#foo` spell it. */\nconst fieldName = (key: ASTNode): string | null =>\n key?.type === \"Identifier\" ? key.name : key?.type === \"PrivateIdentifier\" ? `#${key.name}` : null\n\nconst enclosingClassBody = (node: ASTNode): ASTNode | null =>\n node === null || node === undefined ? null : node.type === \"ClassBody\" ? node : enclosingClassBody(node.parent)\n\n/** Is `this.<name>` mutated anywhere in the class that contains `node`? */\nconst isFieldMutated = (node: ASTNode, name: string, mutators: ReadonlyArray<string>): boolean => {\n const body = enclosingClassBody(node)\n if (body === null) return false\n return descendants(body).some(\n (n) =>\n n.type === \"MemberExpression\" &&\n n.object.type === \"ThisExpression\" &&\n !n.computed &&\n fieldName(n.property) === name &&\n isMutatorCallOn(n, mutators),\n )\n}\n\n/** Lexical lookup of `name` from the scope that contains `node`. */\nconst resolveVariable = (node: ASTNode, name: string, sourceCode: SourceCode): Scope.Variable | null => {\n const lookup = (scope: Scope.Scope | null): Scope.Variable | null =>\n scope === null ? null : (scope.set.get(name) ?? lookup(scope.upper))\n return lookup(sourceCode.getScope(node))\n}\n\n/** Is any reference to the variable named by `identifier` the object of a mutator call? */\nconst isNameMutated = (identifier: ASTNode, mutators: ReadonlyArray<string>, sourceCode: SourceCode): boolean =>\n resolveVariable(identifier, identifier.name, sourceCode)?.references.some((ref) =>\n isMutatorCallOn(ref.identifier, mutators),\n ) ?? false\n\n/**\n * Is the binding identified by `identifier` mutated? A constructor parameter property is a class\n * field; any other identifier is a variable or parameter.\n */\nconst isIdentifierBindingMutated = (\n identifier: ASTNode,\n mutators: ReadonlyArray<string>,\n sourceCode: SourceCode,\n): boolean => {\n const owner = identifier.parent?.type === \"AssignmentPattern\" ? identifier.parent.parent : identifier.parent\n return owner?.type === \"TSParameterProperty\"\n ? isFieldMutated(owner, identifier.name, mutators)\n : isNameMutated(identifier, mutators, sourceCode)\n}\n\n/** Is the binding that `value` initializes or is assigned to mutated? */\nconst isBindingMutated = (\n binding: ASTNode,\n value: ASTNode,\n mutators: ReadonlyArray<string>,\n sourceCode: SourceCode,\n): boolean => {\n // `const s = new Set()` / `s = new Set()` / `(s = new Set()) =>` / `constructor(private s = new Set())`\n const target =\n binding?.type === \"VariableDeclarator\"\n ? binding.id\n : binding?.type === \"AssignmentExpression\" || binding?.type === \"AssignmentPattern\"\n ? binding.right === value\n ? binding.left\n : null\n : null\n if (target?.type === \"Identifier\") return isIdentifierBindingMutated(target, mutators, sourceCode)\n if (target?.type === \"MemberExpression\" && target.object.type === \"ThisExpression\") {\n const name = fieldName(target.property)\n return name !== null && isFieldMutated(binding, name, mutators)\n }\n if (binding?.type === \"PropertyDefinition\" && binding.value === value) {\n const name = fieldName(binding.key)\n return name !== null && isFieldMutated(binding, name, mutators)\n }\n return false\n}\n\n/** `new Set(...)` / `new Map(...)` that is mutated, directly or through what it is bound to. */\nexport const isMutatedCollection = (\n newExpr: ASTNode,\n mutators: ReadonlyArray<string>,\n sourceCode: SourceCode,\n): boolean =>\n (newExpr.arguments.length > 0 && isMutatorCallOn(newExpr, mutators)) ||\n isBindingMutated(newExpr.parent, newExpr, mutators, sourceCode)\n\n/**\n * A `Set<T>` / `Map<K, V>` type reference annotating a binding that is mutated — a variable\n * (`let s: Set<T>`), a parameter (`(s: Set<T>) =>`), a class field (`private s: Set<T>`), or a\n * constructor parameter property (`constructor(private s: Set<T>)`).\n */\nexport const annotatesMutatedBinding = (\n typeRef: ASTNode,\n mutators: ReadonlyArray<string>,\n sourceCode: SourceCode,\n): boolean => {\n const annotation = typeRef.parent\n if (annotation?.type !== \"TSTypeAnnotation\" || annotation.typeAnnotation !== typeRef) return false\n const owner = annotation.parent\n if (owner?.type === \"Identifier\") return isIdentifierBindingMutated(owner, mutators, sourceCode)\n if (owner?.type === \"PropertyDefinition\") {\n const name = fieldName(owner.key)\n return name !== null && isFieldMutated(owner, name, mutators)\n }\n return false\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ASTNode } from "../types/ast.js";
|
|
2
|
+
//#region src/utils/wire-types.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* `Wire<T>` declares a value in its serialization-safe shape — a DB row, an HTTP body,
|
|
5
|
+
* a JSONB payload (#325 B). Everything inside its type argument is the wire shape by declaration: a
|
|
6
|
+
* `ReadonlyArray` there is not a missed `List`, and a `T | null` there is not a missed `Option`. Rules
|
|
7
|
+
* that prefer the functype shape skip it, so the boundary is stated once instead of suppressed at every
|
|
8
|
+
* field. Names are configurable (`wireTypes`) for consumers with their own boundary alias.
|
|
9
|
+
*/
|
|
10
|
+
export declare const DEFAULT_WIRE_TYPES: ReadonlyArray<string>;
|
|
11
|
+
export declare const WIRE_TYPES_SCHEMA: {
|
|
12
|
+
readonly type: "array";
|
|
13
|
+
readonly items: {
|
|
14
|
+
readonly type: "string";
|
|
15
|
+
};
|
|
16
|
+
readonly default: readonly string[];
|
|
17
|
+
};
|
|
18
|
+
/** Is `node` inside the type argument of a `Wire<…>` (or other configured wire type) reference? */
|
|
19
|
+
export declare const isInsideWireType: (node: ASTNode, wireTypes: ReadonlyArray<string>) => boolean;
|
|
20
|
+
//#endregion
|
|
21
|
+
//# sourceMappingURL=wire-types.d.ts.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=[`Wire`],t={type:`array`,items:{type:`string`},default:[...e]},n=e=>e?.type===`Identifier`?e.name:e?.type===`TSQualifiedName`&&e.right?.type===`Identifier`?e.right.name:null,r=e=>e.type===`TSTypeReference`?n(e.typeName):e.type===`TSImportType`?n(e.qualifier):null,i=(e,t)=>{if(t.length===0)return!1;let n=e=>{let i=e?.parent;if(!i)return!1;if(i.type===`TSTypeParameterInstantiation`&&i.parent){let e=r(i.parent);if(e!==null&&t.includes(e))return!0}return n(i)};return n(e)};export{e as DEFAULT_WIRE_TYPES,t as WIRE_TYPES_SCHEMA,i as isInsideWireType};
|
|
2
|
+
//# sourceMappingURL=wire-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wire-types.js","names":["DEFAULT_WIRE_TYPES","WIRE_TYPES_SCHEMA","entityName","name","referenceName","typeRef","isInsideWireType","wireTypes","walk","parent","current","node"],"sources":["../../src/utils/wire-types.ts"],"sourcesContent":["import type { ASTNode } from \"../types/ast\"\n\n/**\n * `Wire<T>` declares a value in its serialization-safe shape — a DB row, an HTTP body,\n * a JSONB payload (#325 B). Everything inside its type argument is the wire shape by declaration: a\n * `ReadonlyArray` there is not a missed `List`, and a `T | null` there is not a missed `Option`. Rules\n * that prefer the functype shape skip it, so the boundary is stated once instead of suppressed at every\n * field. Names are configurable (`wireTypes`) for consumers with their own boundary alias.\n */\n\nexport const DEFAULT_WIRE_TYPES: ReadonlyArray<string> = [\"Wire\"]\n\nexport const WIRE_TYPES_SCHEMA = {\n type: \"array\",\n items: { type: \"string\" },\n default: [...DEFAULT_WIRE_TYPES],\n} as const\n\n/** The last segment of an entity name: `Wire` from `Wire` or `functype.Wire`. */\nconst entityName = (name: ASTNode): string | null => {\n if (name?.type === \"Identifier\") return name.name\n if (name?.type === \"TSQualifiedName\" && name.right?.type === \"Identifier\") return name.right.name\n return null\n}\n\n/** `Wire` from `Wire<…>`, `functype.Wire<…>` or `import(\"functype\").Wire<…>`; null otherwise. */\nconst referenceName = (typeRef: ASTNode): string | null => {\n if (typeRef.type === \"TSTypeReference\") return entityName(typeRef.typeName)\n if (typeRef.type === \"TSImportType\") return entityName(typeRef.qualifier)\n return null\n}\n\n/** Is `node` inside the type argument of a `Wire<…>` (or other configured wire type) reference? */\nexport const isInsideWireType = (node: ASTNode, wireTypes: ReadonlyArray<string>): boolean => {\n if (wireTypes.length === 0) return false\n const walk = (current: ASTNode | null | undefined): boolean => {\n const parent = current?.parent\n if (!parent) return false\n if (parent.type === \"TSTypeParameterInstantiation\" && parent.parent) {\n const name = referenceName(parent.parent)\n if (name !== null && wireTypes.includes(name)) return true\n }\n return walk(parent)\n }\n return walk(node)\n}\n"],"mappings":"AAUA,MAAaA,EAA4C,CAAC,MAAM,EAEnDC,EAAoB,CAC/B,KAAM,QACN,MAAO,CAAE,KAAM,QAAS,EACxB,QAAS,CAAC,GAAGD,CAAkB,CACjC,EAGME,EAAc,GACdC,GAAM,OAAS,aAAqBA,EAAK,KACzCA,GAAM,OAAS,mBAAqBA,EAAK,OAAO,OAAS,aAAqBA,EAAK,MAAM,KACtF,KAIHC,EAAiB,GACjBC,EAAQ,OAAS,kBAA0BH,EAAWG,EAAQ,QAAQ,EACtEA,EAAQ,OAAS,eAAuBH,EAAWG,EAAQ,SAAS,EACjE,KAIIC,GAAoB,EAAe,IAA8C,CAC5F,GAAIC,EAAU,SAAW,EAAG,MAAO,GACnC,IAAMC,EAAQ,GAAiD,CAC7D,IAAMC,EAASC,GAAS,OACxB,GAAI,CAACD,EAAQ,MAAO,GACpB,GAAIA,EAAO,OAAS,gCAAkCA,EAAO,OAAQ,CACnE,IAAMN,EAAOC,EAAcK,EAAO,MAAM,EACxC,GAAIN,IAAS,MAAQI,EAAU,SAASJ,CAAI,EAAG,MAAO,EACxD,CACA,OAAOK,EAAKC,CAAM,CACpB,EACA,OAAOD,EAAKG,CAAI,CAClB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-functype",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.110.0",
|
|
4
4
|
"description": "Custom ESLint rules for functional TypeScript programming with functype library patterns including Do notation (ESLint 10+)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -39,12 +39,12 @@
|
|
|
39
39
|
"eslint": "^10.2.1"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@types/node": "^24.
|
|
43
|
-
"@typescript-eslint/rule-tester": "^8.
|
|
42
|
+
"@types/node": "^24.19.0",
|
|
43
|
+
"@typescript-eslint/rule-tester": "^8.71.0",
|
|
44
44
|
"eslint-config-prettier": "^10.1.8",
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
45
|
+
"functype": "^1.10.0",
|
|
46
|
+
"ts-builds": "^3.4.3",
|
|
47
|
+
"tsdown": "^0.23.0"
|
|
48
48
|
},
|
|
49
49
|
"publishConfig": {
|
|
50
50
|
"access": "public",
|