@r_masseater/oxlint-typed-rules 0.1.2 → 0.1.3
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/LICENSE +258 -0
- package/README.md +23 -0
- package/dist/config-rules-CIyMUUvG.mjs +6 -0
- package/dist/config-rules-CIyMUUvG.mjs.map +1 -0
- package/dist/drizzle.d.mts +5 -0
- package/dist/drizzle.mjs +232 -0
- package/dist/drizzle.mjs.map +1 -0
- package/dist/eslint-utils-DauzR3x9.mjs +489 -0
- package/dist/eslint-utils-DauzR3x9.mjs.map +1 -0
- package/dist/index.d.mts +12 -1
- package/dist/index.mjs +1 -1
- package/dist/react.d.mts +4 -2
- package/dist/react.mjs +9 -301
- package/dist/react.mjs.map +1 -1
- package/dist/rolldown-runtime-DQp2zzRu.mjs +41 -0
- package/dist/tanstack-query.d.mts +5 -0
- package/dist/tanstack-query.mjs +1379 -0
- package/dist/tanstack-query.mjs.map +1 -0
- package/dist/tanstack-router.d.mts +5 -0
- package/dist/tanstack-router.mjs +344 -0
- package/dist/tanstack-router.mjs.map +1 -0
- package/dist/tanstack-start.mjs +6 -4
- package/dist/tanstack-start.mjs.map +1 -1
- package/dist/ts-compat-kqrVqnFj.mjs +132 -0
- package/dist/ts-compat-kqrVqnFj.mjs.map +1 -0
- package/dist/{typed-rule-D8jasU_z.mjs → typed-rule-DsbM82SI.mjs} +20 -4
- package/dist/typed-rule-DsbM82SI.mjs.map +1 -0
- package/dist/typescript-eslint-utils-QnYasB-9.mjs +16 -0
- package/dist/typescript-eslint-utils-QnYasB-9.mjs.map +1 -0
- package/dist/upstream-plugin-DqJEA6iy.mjs +20 -0
- package/dist/upstream-plugin-DqJEA6iy.mjs.map +1 -0
- package/dist/upstream-plugin-xn91RvOJ.d.mts +15 -0
- package/package.json +43 -5
- package/dist/eslint-utils-CTNWAzIf.mjs +0 -352
- package/dist/eslint-utils-CTNWAzIf.mjs.map +0 -1
- package/dist/typed-rule-D8jasU_z.mjs.map +0 -1
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { r as __exportAll } from "./rolldown-runtime-DQp2zzRu.mjs";
|
|
2
|
+
import { Array, Function, Option, Predicate } from "effect";
|
|
3
|
+
import { SyntaxKind, SyntaxKind as SyntaxKind$1 } from "typescript/ast";
|
|
4
|
+
import { JsxEmit, JsxEmit as JsxEmit$1, SymbolFlags, SymbolFlags as SymbolFlags$1, TypeFlags, TypeFlags as TypeFlags$1 } from "typescript/sync";
|
|
5
|
+
import { isArrayBindingPattern, isArrayBindingPattern as isArrayBindingPattern$1, isArrowFunction, isArrowFunction as isArrowFunction$1, isBindingElement, isBindingElement as isBindingElement$1, isCallExpression, isCallExpression as isCallExpression$1, isClassDeclaration, isClassDeclaration as isClassDeclaration$1, isClassExpression, isClassExpression as isClassExpression$1, isEnumDeclaration, isEnumDeclaration as isEnumDeclaration$1, isEnumMember, isEnumMember as isEnumMember$1, isExpressionStatement, isExpressionStatement as isExpressionStatement$1, isFunctionDeclaration, isFunctionDeclaration as isFunctionDeclaration$1, isFunctionExpression, isFunctionExpression as isFunctionExpression$1, isIdentifier, isIdentifier as isIdentifier$1, isImportClause, isImportClause as isImportClause$1, isImportSpecifier, isImportSpecifier as isImportSpecifier$1, isInterfaceDeclaration, isInterfaceDeclaration as isInterfaceDeclaration$1, isIntersectionTypeNode, isIntersectionTypeNode as isIntersectionTypeNode$1, isJsxAttribute, isJsxAttribute as isJsxAttribute$1, isJsxExpression, isJsxExpression as isJsxExpression$1, isJsxOpeningElement, isJsxOpeningElement as isJsxOpeningElement$1, isJsxSelfClosingElement, isJsxSelfClosingElement as isJsxSelfClosingElement$1, isMappedTypeNode, isMappedTypeNode as isMappedTypeNode$1, isMethodDeclaration, isMethodDeclaration as isMethodDeclaration$1, isMethodSignatureDeclaration, isMethodSignatureDeclaration as isMethodSignature, isModuleDeclaration, isModuleDeclaration as isModuleDeclaration$1, isNamespaceExport, isNamespaceExport as isNamespaceExport$1, isNamespaceExportDeclaration, isNamespaceExportDeclaration as isNamespaceExportDeclaration$1, isNamespaceImport, isNamespaceImport as isNamespaceImport$1, isObjectBindingPattern, isObjectBindingPattern as isObjectBindingPattern$1, isObjectLiteralExpression, isObjectLiteralExpression as isObjectLiteralExpression$1, isParameterDeclaration, isParameterDeclaration as isParameter, isParenthesizedExpression, isParenthesizedExpression as isParenthesizedExpression$1, isPropertyAccessExpression, isPropertyAccessExpression as isPropertyAccessExpression$1, isPropertyAssignment, isPropertyAssignment as isPropertyAssignment$1, isPropertyDeclaration, isPropertyDeclaration as isPropertyDeclaration$1, isPropertySignatureDeclaration, isPropertySignatureDeclaration as isPropertySignature, isStringLiteral, isStringLiteral as isStringLiteral$1, isTypeAliasDeclaration, isTypeAliasDeclaration as isTypeAliasDeclaration$1, isTypeLiteralNode, isTypeLiteralNode as isTypeLiteralNode$1, isTypeParameterDeclaration, isTypeParameterDeclaration as isTypeParameterDeclaration$1, isTypeQueryNode, isTypeQueryNode as isTypeQueryNode$1, isTypeReferenceNode, isTypeReferenceNode as isTypeReferenceNode$1, isUnionTypeNode, isUnionTypeNode as isUnionTypeNode$1, isVariableDeclaration, isVariableDeclaration as isVariableDeclaration$1, isVariableStatement, isVariableStatement as isVariableStatement$1 } from "typescript/ast/is";
|
|
6
|
+
// src/ts-compat.ts
|
|
7
|
+
var ts_compat_exports = /* @__PURE__ */ __exportAll({
|
|
8
|
+
JsxEmit: () => JsxEmit$1,
|
|
9
|
+
SymbolFlags: () => SymbolFlags$1,
|
|
10
|
+
SyntaxKind: () => SyntaxKind$1,
|
|
11
|
+
TypeFlags: () => TypeFlags$1,
|
|
12
|
+
default: () => ts,
|
|
13
|
+
forEachChild: () => forEachChild,
|
|
14
|
+
isArrayBindingPattern: () => isArrayBindingPattern$1,
|
|
15
|
+
isArrowFunction: () => isArrowFunction$1,
|
|
16
|
+
isBindingElement: () => isBindingElement$1,
|
|
17
|
+
isCallExpression: () => isCallExpression$1,
|
|
18
|
+
isClassDeclaration: () => isClassDeclaration$1,
|
|
19
|
+
isClassExpression: () => isClassExpression$1,
|
|
20
|
+
isEnumDeclaration: () => isEnumDeclaration$1,
|
|
21
|
+
isEnumMember: () => isEnumMember$1,
|
|
22
|
+
isExpressionStatement: () => isExpressionStatement$1,
|
|
23
|
+
isFunctionDeclaration: () => isFunctionDeclaration$1,
|
|
24
|
+
isFunctionExpression: () => isFunctionExpression$1,
|
|
25
|
+
isFunctionLike: () => isFunctionLike,
|
|
26
|
+
isIdentifier: () => isIdentifier$1,
|
|
27
|
+
isImportClause: () => isImportClause$1,
|
|
28
|
+
isImportSpecifier: () => isImportSpecifier$1,
|
|
29
|
+
isInterfaceDeclaration: () => isInterfaceDeclaration$1,
|
|
30
|
+
isIntersectionTypeNode: () => isIntersectionTypeNode$1,
|
|
31
|
+
isJsxAttribute: () => isJsxAttribute$1,
|
|
32
|
+
isJsxExpression: () => isJsxExpression$1,
|
|
33
|
+
isJsxOpeningElement: () => isJsxOpeningElement$1,
|
|
34
|
+
isJsxSelfClosingElement: () => isJsxSelfClosingElement$1,
|
|
35
|
+
isMappedTypeNode: () => isMappedTypeNode$1,
|
|
36
|
+
isMethodDeclaration: () => isMethodDeclaration$1,
|
|
37
|
+
isMethodSignature: () => isMethodSignature,
|
|
38
|
+
isModuleDeclaration: () => isModuleDeclaration$1,
|
|
39
|
+
isNamespaceExport: () => isNamespaceExport$1,
|
|
40
|
+
isNamespaceExportDeclaration: () => isNamespaceExportDeclaration$1,
|
|
41
|
+
isNamespaceImport: () => isNamespaceImport$1,
|
|
42
|
+
isObjectBindingPattern: () => isObjectBindingPattern$1,
|
|
43
|
+
isObjectLiteralExpression: () => isObjectLiteralExpression$1,
|
|
44
|
+
isParameter: () => isParameter,
|
|
45
|
+
isParenthesizedExpression: () => isParenthesizedExpression$1,
|
|
46
|
+
isPropertyAccessExpression: () => isPropertyAccessExpression$1,
|
|
47
|
+
isPropertyAssignment: () => isPropertyAssignment$1,
|
|
48
|
+
isPropertyDeclaration: () => isPropertyDeclaration$1,
|
|
49
|
+
isPropertySignature: () => isPropertySignature,
|
|
50
|
+
isStringLiteral: () => isStringLiteral$1,
|
|
51
|
+
isTypeAliasDeclaration: () => isTypeAliasDeclaration$1,
|
|
52
|
+
isTypeLiteralNode: () => isTypeLiteralNode$1,
|
|
53
|
+
isTypeParameterDeclaration: () => isTypeParameterDeclaration$1,
|
|
54
|
+
isTypeQueryNode: () => isTypeQueryNode$1,
|
|
55
|
+
isTypeReferenceNode: () => isTypeReferenceNode$1,
|
|
56
|
+
isUnionTypeNode: () => isUnionTypeNode$1,
|
|
57
|
+
isVariableDeclaration: () => isVariableDeclaration$1,
|
|
58
|
+
isVariableStatement: () => isVariableStatement$1
|
|
59
|
+
});
|
|
60
|
+
const FUNCTION_LIKE_KINDS = /* @__PURE__ */ new Set([
|
|
61
|
+
SyntaxKind.FunctionDeclaration,
|
|
62
|
+
SyntaxKind.MethodDeclaration,
|
|
63
|
+
SyntaxKind.Constructor,
|
|
64
|
+
SyntaxKind.GetAccessor,
|
|
65
|
+
SyntaxKind.SetAccessor,
|
|
66
|
+
SyntaxKind.FunctionExpression,
|
|
67
|
+
SyntaxKind.ArrowFunction,
|
|
68
|
+
SyntaxKind.MethodSignature,
|
|
69
|
+
SyntaxKind.CallSignature,
|
|
70
|
+
SyntaxKind.JSDocSignature,
|
|
71
|
+
SyntaxKind.ConstructSignature,
|
|
72
|
+
SyntaxKind.IndexSignature,
|
|
73
|
+
SyntaxKind.FunctionType,
|
|
74
|
+
SyntaxKind.ConstructorType
|
|
75
|
+
]);
|
|
76
|
+
const isFunctionLike = (node) => Option.fromNullishOr(node).pipe(Option.exists(({ kind }) => FUNCTION_LIKE_KINDS.has(kind)));
|
|
77
|
+
const forEachChild = Function.dual((args) => Array.head(Array.fromIterable(args)).pipe(Option.exists(Predicate.not(Predicate.isFunction))), (node, visit) => node.forEachChild(visit));
|
|
78
|
+
const ts = {
|
|
79
|
+
forEachChild,
|
|
80
|
+
isArrayBindingPattern,
|
|
81
|
+
isArrowFunction,
|
|
82
|
+
isBindingElement,
|
|
83
|
+
isCallExpression,
|
|
84
|
+
isClassDeclaration,
|
|
85
|
+
isClassExpression,
|
|
86
|
+
isEnumDeclaration,
|
|
87
|
+
isEnumMember,
|
|
88
|
+
isExpressionStatement,
|
|
89
|
+
isFunctionDeclaration,
|
|
90
|
+
isFunctionExpression,
|
|
91
|
+
isFunctionLike,
|
|
92
|
+
isIdentifier,
|
|
93
|
+
isImportClause,
|
|
94
|
+
isImportSpecifier,
|
|
95
|
+
isInterfaceDeclaration,
|
|
96
|
+
isIntersectionTypeNode,
|
|
97
|
+
isJsxAttribute,
|
|
98
|
+
isJsxExpression,
|
|
99
|
+
isJsxOpeningElement,
|
|
100
|
+
isJsxSelfClosingElement,
|
|
101
|
+
isMappedTypeNode,
|
|
102
|
+
isMethodDeclaration,
|
|
103
|
+
isMethodSignature: isMethodSignatureDeclaration,
|
|
104
|
+
isModuleDeclaration,
|
|
105
|
+
isNamespaceExport,
|
|
106
|
+
isNamespaceExportDeclaration,
|
|
107
|
+
isNamespaceImport,
|
|
108
|
+
isObjectBindingPattern,
|
|
109
|
+
isObjectLiteralExpression,
|
|
110
|
+
isParameter: isParameterDeclaration,
|
|
111
|
+
isParenthesizedExpression,
|
|
112
|
+
isPropertyAccessExpression,
|
|
113
|
+
isPropertyAssignment,
|
|
114
|
+
isPropertyDeclaration,
|
|
115
|
+
isPropertySignature: isPropertySignatureDeclaration,
|
|
116
|
+
isStringLiteral,
|
|
117
|
+
isTypeAliasDeclaration,
|
|
118
|
+
isTypeLiteralNode,
|
|
119
|
+
isTypeParameterDeclaration,
|
|
120
|
+
isTypeQueryNode,
|
|
121
|
+
isTypeReferenceNode,
|
|
122
|
+
isUnionTypeNode,
|
|
123
|
+
isVariableDeclaration,
|
|
124
|
+
isVariableStatement,
|
|
125
|
+
JsxEmit,
|
|
126
|
+
SymbolFlags,
|
|
127
|
+
SyntaxKind,
|
|
128
|
+
TypeFlags
|
|
129
|
+
};
|
|
130
|
+
export { isCallExpression$1 as a, isIdentifier$1 as c, isObjectBindingPattern$1 as d, isParameter as f, ts_compat_exports as h, isBindingElement$1 as i, isJsxOpeningElement$1 as l, ts as m, forEachChild as n, isExpressionStatement$1 as o, isStringLiteral$1 as p, isArrayBindingPattern$1 as r, isFunctionLike as s, SymbolFlags$1 as t, isJsxSelfClosingElement$1 as u };
|
|
131
|
+
|
|
132
|
+
//# sourceMappingURL=ts-compat-kqrVqnFj.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ts-compat-kqrVqnFj.mjs","names":["Arr"],"sources":["../src/ts-compat.ts"],"sourcesContent":["import { Array as Arr, Function, Option, Predicate } from \"effect\";\nimport { SyntaxKind } from \"typescript/ast\";\nimport type { Node } from \"typescript/ast\";\nimport {\n isArrayBindingPattern,\n isArrowFunction,\n isBindingElement,\n isCallExpression,\n isClassDeclaration,\n isClassExpression,\n isEnumDeclaration,\n isEnumMember,\n isExpressionStatement,\n isFunctionDeclaration,\n isFunctionExpression,\n isIdentifier,\n isImportClause,\n isImportSpecifier,\n isInterfaceDeclaration,\n isIntersectionTypeNode,\n isJsxAttribute,\n isJsxExpression,\n isJsxOpeningElement,\n isJsxSelfClosingElement,\n isMappedTypeNode,\n isMethodDeclaration,\n isMethodSignatureDeclaration,\n isModuleDeclaration,\n isNamespaceExport,\n isNamespaceExportDeclaration,\n isNamespaceImport,\n isObjectBindingPattern,\n isObjectLiteralExpression,\n isParameterDeclaration,\n isParenthesizedExpression,\n isPropertyAccessExpression,\n isPropertyAssignment,\n isPropertyDeclaration,\n isPropertySignatureDeclaration,\n isStringLiteral,\n isTypeAliasDeclaration,\n isTypeLiteralNode,\n isTypeParameterDeclaration,\n isTypeQueryNode,\n isTypeReferenceNode,\n isUnionTypeNode,\n isVariableDeclaration,\n isVariableStatement,\n} from \"typescript/ast/is\";\nimport { JsxEmit, SymbolFlags, TypeFlags } from \"typescript/sync\";\n\nconst FUNCTION_LIKE_KINDS: ReadonlySet<SyntaxKind> = new Set([\n SyntaxKind.FunctionDeclaration,\n SyntaxKind.MethodDeclaration,\n SyntaxKind.Constructor,\n SyntaxKind.GetAccessor,\n SyntaxKind.SetAccessor,\n SyntaxKind.FunctionExpression,\n SyntaxKind.ArrowFunction,\n SyntaxKind.MethodSignature,\n SyntaxKind.CallSignature,\n SyntaxKind.JSDocSignature,\n SyntaxKind.ConstructSignature,\n SyntaxKind.IndexSignature,\n SyntaxKind.FunctionType,\n SyntaxKind.ConstructorType,\n]);\n\nconst isFunctionLike = (node: Node | null | undefined): boolean =>\n Option.fromNullishOr(node).pipe(Option.exists(({ kind }) => FUNCTION_LIKE_KINDS.has(kind)));\n\nconst forEachChild: {\n <Result>(visit: (child: Node) => Result | undefined): (node: Node) => Result | undefined;\n <Result>(node: Node, visit: (child: Node) => Result | undefined): Result | undefined;\n} = Function.dual(\n (args) =>\n Arr.head(Arr.fromIterable(args)).pipe(Option.exists(Predicate.not(Predicate.isFunction))),\n <Result>(node: Node, visit: (child: Node) => Result | undefined): Result | undefined =>\n node.forEachChild(visit),\n);\n\nconst ts = {\n forEachChild,\n isArrayBindingPattern,\n isArrowFunction,\n isBindingElement,\n isCallExpression,\n isClassDeclaration,\n isClassExpression,\n isEnumDeclaration,\n isEnumMember,\n isExpressionStatement,\n isFunctionDeclaration,\n isFunctionExpression,\n isFunctionLike,\n isIdentifier,\n isImportClause,\n isImportSpecifier,\n isInterfaceDeclaration,\n isIntersectionTypeNode,\n isJsxAttribute,\n isJsxExpression,\n isJsxOpeningElement,\n isJsxSelfClosingElement,\n isMappedTypeNode,\n isMethodDeclaration,\n isMethodSignature: isMethodSignatureDeclaration,\n isModuleDeclaration,\n isNamespaceExport,\n isNamespaceExportDeclaration,\n isNamespaceImport,\n isObjectBindingPattern,\n isObjectLiteralExpression,\n isParameter: isParameterDeclaration,\n isParenthesizedExpression,\n isPropertyAccessExpression,\n isPropertyAssignment,\n isPropertyDeclaration,\n isPropertySignature: isPropertySignatureDeclaration,\n isStringLiteral,\n isTypeAliasDeclaration,\n isTypeLiteralNode,\n isTypeParameterDeclaration,\n isTypeQueryNode,\n isTypeReferenceNode,\n isUnionTypeNode,\n isVariableDeclaration,\n isVariableStatement,\n JsxEmit,\n SymbolFlags,\n SyntaxKind,\n TypeFlags,\n} as const;\n\nexport { forEachChild, isFunctionLike };\nexport {\n isArrayBindingPattern,\n isArrowFunction,\n isBindingElement,\n isCallExpression,\n isClassDeclaration,\n isClassExpression,\n isEnumDeclaration,\n isEnumMember,\n isExpressionStatement,\n isFunctionDeclaration,\n isFunctionExpression,\n isIdentifier,\n isImportClause,\n isImportSpecifier,\n isInterfaceDeclaration,\n isIntersectionTypeNode,\n isJsxAttribute,\n isJsxExpression,\n isJsxOpeningElement,\n isJsxSelfClosingElement,\n isMappedTypeNode,\n isMethodDeclaration,\n isMethodSignatureDeclaration as isMethodSignature,\n isModuleDeclaration,\n isNamespaceExport,\n isNamespaceExportDeclaration,\n isNamespaceImport,\n isObjectBindingPattern,\n isObjectLiteralExpression,\n isParameterDeclaration as isParameter,\n isParenthesizedExpression,\n isPropertyAccessExpression,\n isPropertyAssignment,\n isPropertyDeclaration,\n isPropertySignatureDeclaration as isPropertySignature,\n isStringLiteral,\n isTypeAliasDeclaration,\n isTypeLiteralNode,\n isTypeParameterDeclaration,\n isTypeQueryNode,\n isTypeReferenceNode,\n isUnionTypeNode,\n isVariableDeclaration,\n isVariableStatement,\n} from \"typescript/ast/is\";\nexport { SyntaxKind } from \"typescript/ast\";\nexport { JsxEmit, SymbolFlags, TypeFlags } from \"typescript/sync\";\nexport default ts;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,MAAM,sCAA+C,IAAI,IAAI;CAC3D,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;AACb,CAAC;AAED,MAAM,kBAAkB,SACtB,OAAO,cAAc,IAAI,CAAC,CAAC,KAAK,OAAO,QAAQ,EAAE,WAAW,oBAAoB,IAAI,IAAI,CAAC,CAAC;AAE5F,MAAM,eAGF,SAAS,MACV,SACCA,MAAI,KAAKA,MAAI,aAAa,IAAI,CAAC,CAAC,CAAC,KAAK,OAAO,OAAO,UAAU,IAAI,UAAU,UAAU,CAAC,CAAC,IACjF,MAAY,UACnB,KAAK,aAAa,KAAK,CAC3B;AAEA,MAAM,KAAK;CACT;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA,mBAAmB;CACnB;CACA;CACA;CACA;CACA;CACA;CACA,aAAa;CACb;CACA;CACA;CACA;CACA,qBAAqB;CACrB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF"}
|
|
@@ -155,6 +155,9 @@ var CompatType = class CompatType {
|
|
|
155
155
|
return created;
|
|
156
156
|
}));
|
|
157
157
|
}
|
|
158
|
+
static optional(project, native) {
|
|
159
|
+
return Option.fromNullishOr(native).pipe(Option.map((type) => CompatType.intern(project, type)), Option.getOrUndefined);
|
|
160
|
+
}
|
|
158
161
|
get symbol() {
|
|
159
162
|
const { native } = this;
|
|
160
163
|
const project = this.#project;
|
|
@@ -172,6 +175,9 @@ var CompatType = class CompatType {
|
|
|
172
175
|
this.#types ??= pipe(constituentsOf(this.native), Array$1.map((member) => CompatType.intern(project, member)));
|
|
173
176
|
return this.#types;
|
|
174
177
|
}
|
|
178
|
+
getSymbol() {
|
|
179
|
+
return this.symbol;
|
|
180
|
+
}
|
|
175
181
|
getProperty(name) {
|
|
176
182
|
return CompatSymbol.optional(this.#project, this.native.getProperty(name));
|
|
177
183
|
}
|
|
@@ -179,6 +185,13 @@ var CompatType = class CompatType {
|
|
|
179
185
|
const project = this.#project;
|
|
180
186
|
return pipe(this.native.getProperties(), Array$1.map((property) => CompatSymbol.intern(project, property)));
|
|
181
187
|
}
|
|
188
|
+
getCallSignatures() {
|
|
189
|
+
const project = this.#project;
|
|
190
|
+
return pipe(this.native.getCallSignatures(), Array$1.map((signature) => ({
|
|
191
|
+
native: signature,
|
|
192
|
+
getReturnType: () => CompatType.intern(project, signature.getReturnType())
|
|
193
|
+
})));
|
|
194
|
+
}
|
|
182
195
|
};
|
|
183
196
|
// src/compat.ts
|
|
184
197
|
const compatChecker = (project, checker) => ({
|
|
@@ -186,8 +199,10 @@ const compatChecker = (project, checker) => ({
|
|
|
186
199
|
getAliasedSymbol: (symbol) => CompatSymbol.intern(project, checker.getAliasedSymbol(symbol.native)),
|
|
187
200
|
getTypeAtLocation: (node) => CompatType.intern(project, checker.getTypeAtLocation(node)),
|
|
188
201
|
getTypeOfSymbol: (symbol) => CompatType.intern(project, checker.getTypeOfSymbol(symbol.native)),
|
|
189
|
-
getBaseConstraintOfType: (type) =>
|
|
190
|
-
|
|
202
|
+
getBaseConstraintOfType: (type) => CompatType.optional(project, checker.getBaseConstraintOfType(type.native)),
|
|
203
|
+
getAwaitedType: (type) => CompatType.optional(project, checker.getAwaitedType(type.native)),
|
|
204
|
+
getFullyQualifiedName: (symbol) => checker.getFullyQualifiedName(symbol.native),
|
|
205
|
+
typeToString: (type) => checker.typeToString(type.native)
|
|
191
206
|
});
|
|
192
207
|
const isOwnSourceFile = (fileName) => !fileName.includes("/node_modules/") && !fileName.endsWith(".d.ts");
|
|
193
208
|
const ownSourceFiles = memoizeByKey((program) => pipe(program.getSourceFileNames(), Array$1.filter(isOwnSourceFile), Array$1.flatMap((fileName) => Option.fromNullishOr(program.getSourceFile(fileName)).pipe(Option.toArray))));
|
|
@@ -279,6 +294,7 @@ const withOptionalTypeInformation = (rule) => ({
|
|
|
279
294
|
create: (context) => rule.create(withParserServices(context, lazily(() => Option.getOrUndefined(parserServicesOf(context)))))
|
|
280
295
|
});
|
|
281
296
|
const typedRules = (rules) => pipe(rules, Record.filter(isTypedRule), Record.map(withTypeInformation));
|
|
282
|
-
|
|
297
|
+
const optionallyTypedRules = (rules) => pipe(rules, Record.filter(isTypedRule), Record.map(withOptionalTypeInformation));
|
|
298
|
+
export { withTypeInformation as a, withOptionalTypeInformation as i, optionallyTypedRules as n, typedRules as r, isTypedRule as t };
|
|
283
299
|
|
|
284
|
-
//# sourceMappingURL=typed-rule-
|
|
300
|
+
//# sourceMappingURL=typed-rule-DsbM82SI.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typed-rule-DsbM82SI.mjs","names":["Arr","Arr","BigInt_","Arr","Arr","Str"],"sources":["../src/memo.ts","../src/parser-services.ts","../src/compat-symbol.ts","../src/compat-type.ts","../src/compat.ts","../src/program.ts","../src/typed-rule.ts"],"sourcesContent":["import { Option } from \"effect\";\n\nconst memoizeByKey = <Key extends WeakKey, Value>(\n compute: (key: Key) => Value,\n): ((key: Key) => Value) => {\n const cache = new WeakMap<Key, Value>();\n return (key) =>\n Option.fromNullishOr(cache.get(key)).pipe(\n Option.getOrElse(() => {\n const computed = compute(key);\n cache.set(key, computed);\n return computed;\n }),\n );\n};\n\nconst lazily = <Value>(compute: () => Value): (() => Value) => {\n const cell: { value?: Option.Option<Value> } = {};\n return () => {\n const cached = Option.flatten(Option.fromNullishOr(cell.value));\n if (Option.isSome(cached)) {\n return cached.value;\n }\n const computed = compute();\n cell.value = Option.some(computed);\n return computed;\n };\n};\n\nexport { lazily, memoizeByKey };\n","import { Array as Arr, Option, Predicate, pipe } from \"effect\";\nimport { SyntaxKind } from \"typescript/ast\";\nimport type { Node, SourceFile } from \"typescript/ast\";\nimport type { Context, Location, Range } from \"vite-plus/lint/plugins\";\n\nimport type { CompatSymbol } from \"./compat-symbol.ts\";\nimport type { CompatType } from \"./compat-type.ts\";\nimport type { CompatProgram } from \"./compat.ts\";\nimport { lazily, memoizeByKey } from \"./memo.ts\";\n\ninterface RangedNode {\n readonly range: Readonly<Range>;\n}\n\ninterface MappedNode {\n readonly type: string;\n readonly range: Readonly<Range>;\n readonly loc: Location;\n}\n\ninterface ParserServices {\n readonly program: CompatProgram;\n readonly esTreeNodeToTSNodeMap: { readonly get: (node: RangedNode) => Node };\n readonly tsNodeToESTreeNodeMap: {\n readonly get: (node: Node) => MappedNode | undefined;\n };\n readonly getTypeAtLocation: (node: RangedNode) => CompatType;\n readonly getSymbolAtLocation: (node: RangedNode) => CompatSymbol | undefined;\n}\n\ninterface FileProgram {\n readonly context: Context;\n readonly program: CompatProgram;\n readonly sourceFile: SourceFile;\n}\n\nconst covers = (node: Node, [start, end]: Readonly<Range>): boolean =>\n node.getStart() <= start && node.end >= end;\n\nconst spans = (node: Node, [start, end]: Readonly<Range>): boolean =>\n node.getStart() === start && node.end === end;\n\nconst innermostSpanning = (sourceFile: SourceFile, range: Readonly<Range>): Node => {\n const visit = (node: Node, found: Node): Node => {\n if (!covers(node, range)) {\n return found;\n }\n const matched = Option.liftPredicate(node, (candidate) => spans(candidate, range)).pipe(\n Option.getOrElse(() => found),\n );\n return Option.fromNullishOr(\n node.forEachChild((child) =>\n Option.liftPredicate(visit(child, matched), (deeper) => deeper !== matched).pipe(\n Option.getOrUndefined,\n ),\n ),\n ).pipe(Option.getOrElse(() => matched));\n };\n return visit(sourceFile, sourceFile);\n};\n\nconst toMappedNode = ({ context }: FileProgram, node: Node): MappedNode => {\n const start = node.getStart();\n return {\n type: SyntaxKind[node.kind],\n range: [start, node.end],\n loc: {\n start: context.sourceCode.getLocFromIndex(start),\n end: context.sourceCode.getLocFromIndex(node.end),\n },\n };\n};\n\nconst rangeKey = ([start, end]: Readonly<Range>): string => `${String(start)}:${String(end)}`;\n\nconst isRangedNode = (value: unknown): value is MappedNode =>\n Predicate.hasProperty(value, \"type\") &&\n Predicate.isString(value.type) &&\n Predicate.hasProperty(value, \"range\") &&\n Array.isArray(value.range);\n\nconst childNodesOf = (node: MappedNode, keys: readonly string[]): readonly MappedNode[] =>\n pipe(\n keys,\n Arr.flatMap((key) => {\n const child: unknown = Reflect.get(node, key);\n return Arr.ensure(child);\n }),\n Arr.filter(isRangedNode),\n );\n\nconst esTreeIndex = ({ context }: FileProgram): ReadonlyMap<string, MappedNode> => {\n const index = new Map<string, MappedNode>();\n const { visitorKeys } = context.sourceCode;\n const visit = (node: MappedNode): void => {\n const key = rangeKey(node.range);\n if (!index.has(key)) {\n index.set(key, node);\n }\n for (const child of childNodesOf(node, visitorKeys[node.type] ?? [])) {\n visit(child);\n }\n };\n visit(context.sourceCode.ast);\n return index;\n};\n\nconst createParserServices = (file: FileProgram): ParserServices => {\n const esTreeNodes = lazily(() => esTreeIndex(file));\n const toTSNode = memoizeByKey((node: RangedNode) =>\n innermostSpanning(file.sourceFile, node.range),\n );\n const checker = file.program.getTypeChecker();\n const toESTreeNode = (node: Node): MappedNode => {\n const key = rangeKey([node.getStart(), node.end]);\n return Option.fromNullishOr(esTreeNodes().get(key)).pipe(\n Option.getOrElse(() => toMappedNode(file, node)),\n );\n };\n return {\n program: file.program,\n esTreeNodeToTSNodeMap: { get: toTSNode },\n getTypeAtLocation: (node) => checker.getTypeAtLocation(toTSNode(node)),\n getSymbolAtLocation: (node) => checker.getSymbolAtLocation(toTSNode(node)),\n tsNodeToESTreeNodeMap: {\n get: (node) =>\n Option.liftPredicate(\n node,\n (candidate) => candidate.getSourceFile().fileName === file.sourceFile.fileName,\n ).pipe(Option.map(toESTreeNode), Option.getOrUndefined),\n },\n };\n};\n\nexport { createParserServices };\nexport type { FileProgram, MappedNode, ParserServices, RangedNode };\n","import { Array as Arr, Option, pipe } from \"effect\";\nimport type { Node } from \"typescript/ast\";\nimport type { NodeHandle, Project, Symbol as NativeSymbol, SymbolFlags } from \"typescript/sync\";\n\nconst resolveAll = (project: Project, handles: readonly NodeHandle[]): readonly Node[] =>\n pipe(\n handles,\n Arr.flatMap((handle) => Option.fromNullishOr(handle.resolve(project)).pipe(Option.toArray)),\n );\n\ninterface LegacySymbol {\n readonly getName: () => string;\n readonly getDeclarations: () => readonly Node[];\n}\n\nclass CompatSymbol implements LegacySymbol {\n static readonly #interned = new WeakMap<NativeSymbol, CompatSymbol>();\n\n public readonly native: NativeSymbol;\n\n public readonly flags: SymbolFlags;\n\n public readonly name: string;\n\n readonly #project: Project;\n\n #declarations: readonly Node[] | undefined;\n\n private constructor(project: Project, native: NativeSymbol) {\n this.#project = project;\n this.native = native;\n this.flags = native.flags;\n this.name = native.name;\n }\n\n public static intern(project: Project, native: NativeSymbol): CompatSymbol {\n return Option.fromNullishOr(CompatSymbol.#interned.get(native)).pipe(\n Option.getOrElse(() => {\n const created = new CompatSymbol(project, native);\n CompatSymbol.#interned.set(native, created);\n return created;\n }),\n );\n }\n\n public static optional(\n project: Project,\n native: NativeSymbol | undefined,\n ): CompatSymbol | undefined {\n return Option.fromNullishOr(native).pipe(\n Option.map((symbol) => CompatSymbol.intern(project, symbol)),\n Option.getOrUndefined,\n );\n }\n\n public get declarations(): readonly Node[] {\n this.#declarations ??= resolveAll(this.#project, this.native.declarations);\n return this.#declarations;\n }\n\n public getName(): string {\n return this.name;\n }\n\n public getDeclarations(): readonly Node[] {\n return this.declarations;\n }\n}\n\nexport type { LegacySymbol };\nexport { CompatSymbol };\n","import { Array as Arr, BigInt as BigInt_, Match, Option, Predicate, pipe } from \"effect\";\nimport type {\n Project,\n Signature as NativeSignature,\n Type as NativeType,\n TypeFlags,\n UnionOrIntersectionType,\n} from \"typescript/sync\";\n\nimport { CompatSymbol } from \"./compat-symbol.ts\";\n\ninterface PseudoBigInt {\n readonly negative: boolean;\n readonly base10Value: string;\n}\n\ntype LiteralValue = string | number | boolean | PseudoBigInt;\n\nconst ZERO = 0n;\n\nconst pseudoBigInt = (value: bigint): PseudoBigInt => ({\n negative: value < ZERO,\n base10Value: BigInt_.abs(value).toString(),\n});\n\nconst literalValueOf = (native: NativeType): Option.Option<LiteralValue> =>\n Option.liftPredicate(native, (type) => type.isLiteralType()).pipe(\n Option.map(({ value }) =>\n Match.value(value).pipe(\n Match.when(Predicate.isBigInt, pseudoBigInt),\n Match.orElse((primitive) => primitive),\n ),\n ),\n );\n\nconst isUnionOrIntersection = (type: NativeType): type is UnionOrIntersectionType =>\n type.isUnionType() || type.isIntersectionType();\n\nconst constituentsOf = (native: NativeType): readonly NativeType[] =>\n Option.liftPredicate(native, isUnionOrIntersection).pipe(\n Option.map((type) => type.getTypes()),\n Option.getOrElse((): readonly NativeType[] => []),\n );\n\ninterface CompatSignature {\n readonly native: NativeSignature;\n readonly getReturnType: () => CompatType;\n}\n\ninterface LegacyType {\n readonly symbol: CompatSymbol | undefined;\n readonly aliasSymbol: CompatSymbol | undefined;\n readonly types: readonly CompatType[];\n readonly getSymbol: () => CompatSymbol | undefined;\n readonly getProperty: (name: string) => CompatSymbol | undefined;\n readonly getProperties: () => readonly CompatSymbol[];\n readonly getCallSignatures: () => readonly CompatSignature[];\n}\n\nclass CompatType implements LegacyType {\n static readonly #interned = new WeakMap<NativeType, CompatType>();\n\n public readonly native: NativeType;\n\n public readonly flags: TypeFlags;\n\n public readonly intrinsicName: string | undefined;\n\n public readonly value: LiteralValue | undefined;\n\n public readonly isUnion: () => boolean;\n\n public readonly isLiteral: () => boolean;\n\n public readonly isStringLiteral: () => boolean;\n\n public readonly isNumberLiteral: () => boolean;\n\n readonly #project: Project;\n\n #symbol: Option.Option<CompatSymbol | undefined> = Option.none();\n\n #aliasSymbol: Option.Option<CompatSymbol | undefined> = Option.none();\n\n #types: readonly CompatType[] | undefined;\n\n private constructor(project: Project, native: NativeType) {\n this.#project = project;\n this.native = native;\n this.flags = native.flags;\n this.intrinsicName = Option.liftPredicate(native, (type) => type.isIntrinsicType()).pipe(\n Option.map(({ intrinsicName }) => intrinsicName),\n Option.getOrUndefined,\n );\n this.value = Option.getOrUndefined(literalValueOf(native));\n this.isUnion = native.isUnionType.bind(native);\n this.isLiteral = native.isLiteralType.bind(native);\n this.isStringLiteral = native.isStringLiteralType.bind(native);\n this.isNumberLiteral = native.isNumberLiteralType.bind(native);\n }\n\n public static intern(project: Project, native: NativeType): CompatType {\n return Option.fromNullishOr(CompatType.#interned.get(native)).pipe(\n Option.getOrElse(() => {\n const created = new CompatType(project, native);\n CompatType.#interned.set(native, created);\n return created;\n }),\n );\n }\n\n public static optional(project: Project, native: NativeType | undefined): CompatType | undefined {\n return Option.fromNullishOr(native).pipe(\n Option.map((type) => CompatType.intern(project, type)),\n Option.getOrUndefined,\n );\n }\n\n public get symbol(): CompatSymbol | undefined {\n const { native } = this;\n const project = this.#project;\n this.#symbol = Option.orElse(this.#symbol, () =>\n Option.some(CompatSymbol.optional(project, native.getSymbol())),\n );\n return Option.getOrUndefined(this.#symbol);\n }\n\n public get aliasSymbol(): CompatSymbol | undefined {\n const { native } = this;\n const project = this.#project;\n this.#aliasSymbol = Option.orElse(this.#aliasSymbol, () =>\n Option.some(CompatSymbol.optional(project, native.getAliasSymbol())),\n );\n return Option.getOrUndefined(this.#aliasSymbol);\n }\n\n public get types(): readonly CompatType[] {\n const project = this.#project;\n this.#types ??= pipe(\n constituentsOf(this.native),\n Arr.map((member) => CompatType.intern(project, member)),\n );\n return this.#types;\n }\n\n public getSymbol(): CompatSymbol | undefined {\n return this.symbol;\n }\n\n public getProperty(name: string): CompatSymbol | undefined {\n return CompatSymbol.optional(this.#project, this.native.getProperty(name));\n }\n\n public getProperties(): readonly CompatSymbol[] {\n const project = this.#project;\n return pipe(\n this.native.getProperties(),\n Arr.map((property) => CompatSymbol.intern(project, property)),\n );\n }\n\n public getCallSignatures(): readonly CompatSignature[] {\n const project = this.#project;\n return pipe(\n this.native.getCallSignatures(),\n Arr.map((signature): CompatSignature => ({\n native: signature,\n getReturnType: () => CompatType.intern(project, signature.getReturnType()),\n })),\n );\n }\n}\n\nexport type { CompatSignature, LegacyType, LiteralValue, PseudoBigInt };\nexport { CompatType };\n","import { Array as Arr, Option, pipe } from \"effect\";\nimport type { Node, SourceFile } from \"typescript/ast\";\nimport type { Checker, CompilerOptions, Program as NativeProgram, Project } from \"typescript/sync\";\n\nimport { CompatSymbol } from \"./compat-symbol.ts\";\nimport { CompatType } from \"./compat-type.ts\";\nimport { memoizeByKey } from \"./memo.ts\";\n\ninterface CompatChecker {\n readonly getSymbolAtLocation: (node: Node) => CompatSymbol | undefined;\n readonly getAliasedSymbol: (symbol: CompatSymbol) => CompatSymbol;\n readonly getTypeAtLocation: (node: Node) => CompatType;\n readonly getTypeOfSymbol: (symbol: CompatSymbol) => CompatType;\n readonly getBaseConstraintOfType: (type: CompatType) => CompatType | undefined;\n readonly getAwaitedType: (type: CompatType) => CompatType | undefined;\n readonly getFullyQualifiedName: (symbol: CompatSymbol) => string;\n readonly typeToString: (type: CompatType) => string;\n}\n\ninterface CompatProgram {\n readonly getSourceFile: (fileName: string) => SourceFile | undefined;\n readonly getSourceFiles: () => readonly SourceFile[];\n readonly getTypeChecker: () => CompatChecker;\n readonly getCompilerOptions: () => CompilerOptions;\n}\n\nconst compatChecker = (project: Project, checker: Checker): CompatChecker => ({\n getSymbolAtLocation: (node) => CompatSymbol.optional(project, checker.getSymbolAtLocation(node)),\n getAliasedSymbol: (symbol) =>\n CompatSymbol.intern(project, checker.getAliasedSymbol(symbol.native)),\n getTypeAtLocation: (node) => CompatType.intern(project, checker.getTypeAtLocation(node)),\n getTypeOfSymbol: (symbol) => CompatType.intern(project, checker.getTypeOfSymbol(symbol.native)),\n getBaseConstraintOfType: (type) =>\n CompatType.optional(project, checker.getBaseConstraintOfType(type.native)),\n getAwaitedType: (type) => CompatType.optional(project, checker.getAwaitedType(type.native)),\n getFullyQualifiedName: (symbol) => checker.getFullyQualifiedName(symbol.native),\n typeToString: (type) => checker.typeToString(type.native),\n});\n\nconst isOwnSourceFile = (fileName: string): boolean =>\n !fileName.includes(\"/node_modules/\") && !fileName.endsWith(\".d.ts\");\n\nconst ownSourceFiles = memoizeByKey((program: NativeProgram): readonly SourceFile[] =>\n pipe(\n program.getSourceFileNames(),\n Arr.filter(isOwnSourceFile),\n Arr.flatMap((fileName) =>\n Option.fromNullishOr(program.getSourceFile(fileName)).pipe(Option.toArray),\n ),\n ),\n);\n\nconst compatPrograms = new WeakMap<NativeProgram, CompatProgram>();\n\nconst internProgram = (project: Project): CompatProgram =>\n Option.fromNullishOr(compatPrograms.get(project.program)).pipe(\n Option.getOrElse(() => {\n const { program } = project;\n const checker = compatChecker(project, project.checker);\n const created: CompatProgram = {\n getSourceFile: program.getSourceFile.bind(program),\n getSourceFiles: () => ownSourceFiles(program),\n getTypeChecker: () => checker,\n getCompilerOptions: program.getCompilerOptions.bind(program),\n };\n compatPrograms.set(program, created);\n return created;\n }),\n );\n\nexport type { CompatChecker, CompatProgram };\nexport { internProgram };\n","import { Cause, Effect, Exit, Layer, ManagedRuntime, Option, String as Str } from \"effect\";\nimport { FetchHttpClient } from \"effect/http\";\nimport { OtlpSerialization, OtlpTracer } from \"effect/observability\";\nimport { createFileSystemLayer } from \"typescript/fs\";\nimport { API } from \"typescript/sync\";\nimport type { Project, Snapshot } from \"typescript/sync\";\n\nimport { internProgram } from \"./compat.ts\";\nimport type { CompatProgram } from \"./compat.ts\";\nimport { memoizeByKey } from \"./memo.ts\";\n\nconst tracing = OtlpTracer.layerFromConfig({\n resource: { serviceName: \"oxlint-typed-rules\" },\n}).pipe(Layer.provide(OtlpSerialization.layerJson), Layer.provide(FetchHttpClient.layer));\n\nconst runtime = ManagedRuntime.make(tracing);\n\ninterface Overlay {\n readonly fileName: string;\n readonly text: string;\n}\n\nconst startApi = (): API => {\n const started = new API();\n process.once(\"beforeExit\", () => {\n started.close();\n Effect.runFork(runtime.disposeEffect);\n });\n return started;\n};\n\nconst api = startApi();\n\nconst snapshots = new Map<API, Snapshot>([[api, api.createSnapshot()]]);\n\nconst currentSnapshot = (): Snapshot =>\n Option.fromNullishOr(snapshots.get(api)).pipe(\n Option.getOrElse(() => {\n const created = api.createSnapshot();\n snapshots.set(api, created);\n return created;\n }),\n );\n\nconst matchesText = (project: Project, overlay: Overlay): boolean =>\n Option.fromNullishOr(project.program.getSourceFile(overlay.fileName)).pipe(\n Option.exists((sourceFile) => sourceFile.text === overlay.text),\n );\n\nconst directoryOf = (fileName: string): string => Str.replace(/[\\\\/][^\\\\/]*$/u, \"\")(fileName);\n\nconst directoryProjects = memoizeByKey(\n (_snapshot: Snapshot): Map<string, Project> => new Map<string, Project>(),\n);\n\nconst defaultProject = (snapshot: Snapshot, fileName: string): Option.Option<Project> =>\n Option.fromNullishOr(snapshot.getDefaultProjectForFile(fileName)).pipe(\n Option.map((project) => {\n directoryProjects(snapshot).set(directoryOf(fileName), project);\n return project;\n }),\n );\n\nconst currentProject = (overlay: Overlay): Option.Option<Project> => {\n const snapshot = currentSnapshot();\n return Option.fromNullishOr(directoryProjects(snapshot).get(directoryOf(overlay.fileName))).pipe(\n Option.filter((project) => matchesText(project, overlay)),\n Option.orElse(() =>\n defaultProject(snapshot, overlay.fileName).pipe(\n Option.filter((project) => matchesText(project, overlay)),\n ),\n ),\n );\n};\n\nconst openFile = (overlay: Overlay): Effect.Effect<Option.Option<Project>> =>\n Effect.sync(() => {\n const updated = currentSnapshot().update({\n openFiles: [overlay.fileName],\n fileSystem: createFileSystemLayer([[overlay.fileName, overlay.text]]),\n });\n snapshots.set(api, updated);\n return defaultProject(updated, overlay.fileName);\n }).pipe(\n Effect.withSpan(\"oxlint-typed-rules.open-file\", {\n attributes: { fileName: overlay.fileName },\n }),\n );\n\nconst projectOfFile = (overlay: Overlay): Effect.Effect<Option.Option<Project>> =>\n Effect.suspend(() =>\n Option.match(currentProject(overlay), {\n onSome: Effect.succeedSome,\n onNone: () => openFile(overlay),\n }),\n );\n\nconst programFor = (overlay: Overlay): Option.Option<CompatProgram> =>\n Exit.match(runtime.runSyncExit(projectOfFile(overlay)), {\n onSuccess: Option.map(internProgram),\n onFailure: (cause) => {\n throw Cause.squash(cause);\n },\n });\n\nexport type { Overlay };\nexport { programFor };\n","import { Option, Predicate, Record, pipe } from \"effect\";\nimport type { Context, CreateRule, RuleMeta, Visitor } from \"vite-plus/lint/plugins\";\n\nimport { lazily } from \"./memo.ts\";\nimport { createParserServices } from \"./parser-services.ts\";\nimport type { ParserServices } from \"./parser-services.ts\";\nimport { programFor } from \"./program.ts\";\n\ntype TypedSourceCode = Context[\"sourceCode\"] & {\n readonly parserServices: ParserServices | undefined;\n};\n\ntype TypedContext = Omit<Context, \"sourceCode\"> & { readonly sourceCode: TypedSourceCode };\n\ninterface TypedRule {\n readonly meta: RuleMeta;\n readonly create: (context: TypedContext) => Visitor;\n}\n\nconst isTypedRule = <Rule>(rule: Rule): rule is Rule & TypedRule =>\n Predicate.hasProperty(rule, \"meta\") &&\n Predicate.hasProperty(rule, \"create\") &&\n Predicate.isFunction(rule.create);\n\nconst isTypedContext = (value: unknown): value is TypedContext =>\n Predicate.hasProperty(value, \"report\") &&\n Predicate.hasProperty(value, \"sourceCode\") &&\n Predicate.hasProperty(value.sourceCode, \"parserServices\");\n\nconst inheriting = (\n prototype: object,\n name: string,\n descriptor: Readonly<PropertyDescriptor>,\n): unknown => Object.create(prototype, { [name]: { ...descriptor, enumerable: true } });\n\nconst parserServicesOf = (context: Context): Option.Option<ParserServices> =>\n programFor({ fileName: context.filename, text: context.sourceCode.text }).pipe(\n Option.flatMap((program) =>\n Option.fromNullishOr(program.getSourceFile(context.filename)).pipe(\n Option.map((sourceFile) => createParserServices({ context, program, sourceFile })),\n ),\n ),\n );\n\nconst withParserServices = (\n context: Context,\n parserServices: () => ParserServices | undefined,\n): TypedContext => {\n const sourceCode = inheriting(context.sourceCode, \"parserServices\", { get: parserServices });\n return Option.liftPredicate(\n inheriting(context, \"sourceCode\", { value: sourceCode }),\n isTypedContext,\n ).pipe(Option.getOrThrowWith(() => new TypeError(\"The rule context has no source code.\")));\n};\n\nconst withTypeInformation = (rule: TypedRule): CreateRule => ({\n meta: rule.meta,\n create: (context) =>\n parserServicesOf(context).pipe(\n Option.map((parserServices) =>\n rule.create(withParserServices(context, () => parserServices)),\n ),\n Option.getOrElse(() => ({})),\n ),\n});\n\nconst withOptionalTypeInformation = (rule: TypedRule): CreateRule => ({\n meta: rule.meta,\n create: (context) =>\n rule.create(\n withParserServices(\n context,\n lazily(() => Option.getOrUndefined(parserServicesOf(context))),\n ),\n ),\n});\n\nconst typedRules = (\n rules: Record.ReadonlyRecord<string, unknown>,\n): Record.ReadonlyRecord<string, CreateRule> =>\n pipe(rules, Record.filter(isTypedRule), Record.map(withTypeInformation));\n\nconst optionallyTypedRules = (\n rules: Record.ReadonlyRecord<string, unknown>,\n): Record.ReadonlyRecord<string, CreateRule> =>\n pipe(rules, Record.filter(isTypedRule), Record.map(withOptionalTypeInformation));\n\nexport type { TypedContext, TypedRule, TypedSourceCode };\nexport {\n isTypedRule,\n optionallyTypedRules,\n typedRules,\n withOptionalTypeInformation,\n withTypeInformation,\n};\n"],"mappings":";;;;;;;AAEA,MAAM,gBACJ,YAC0B;CAC1B,MAAM,wBAAQ,IAAI,QAAoB;CACtC,QAAQ,QACN,OAAO,cAAc,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,KACnC,OAAO,gBAAgB;EACrB,MAAM,WAAW,QAAQ,GAAG;EAC5B,MAAM,IAAI,KAAK,QAAQ;EACvB,OAAO;CACT,CAAC,CACH;AACJ;AAEA,MAAM,UAAiB,YAAwC;CAC7D,MAAM,OAAyC,CAAC;CAChD,aAAa;EACX,MAAM,SAAS,OAAO,QAAQ,OAAO,cAAc,KAAK,KAAK,CAAC;EAC9D,IAAI,OAAO,OAAO,MAAM,GACtB,OAAO,OAAO;EAEhB,MAAM,WAAW,QAAQ;EACzB,KAAK,QAAQ,OAAO,KAAK,QAAQ;EACjC,OAAO;CACT;AACF;;ACSA,MAAM,UAAU,MAAY,CAAC,OAAO,SAClC,KAAK,SAAS,KAAK,SAAS,KAAK,OAAO;AAE1C,MAAM,SAAS,MAAY,CAAC,OAAO,SACjC,KAAK,SAAS,MAAM,SAAS,KAAK,QAAQ;AAE5C,M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,CAAC;CAC3F,OAAO,OAAO,cACZ,WAAW,SAAS,cAAc,EAAE,OAAO,WAAW,CAAC,GACvD,cACF,CAAC,CAAC,KAAK,OAAO,qCAAqB,IAAI,UAAU,sCAAsC,CAAC,CAAC;AAC3F;AAEA,MAAM,uBAAuB,UAAiC;CAC5D,MAAM,KAAK;CACX,SAAS,YACP,iBAAiB,OAAO,CAAC,CAAC,KACxB,OAAO,KAAK,mBACV,KAAK,OAAO,mBAAmB,eAAe,cAAc,CAAC,CAC/D,GACA,OAAO,iBAAiB,CAAC,EAAE,CAC7B;AACJ;AAEA,MAAM,+BAA+B,UAAiC;CACpE,MAAM,KAAK;CACX,SAAS,YACP,KAAK,OACH,mBACE,SACA,aAAa,OAAO,eAAe,iBAAiB,OAAO,CAAC,CAAC,CAC/D,CACF;AACJ;AAEA,MAAM,cACJ,UAEA,KAAK,OAAO,OAAO,OAAO,WAAW,GAAG,OAAO,IAAI,mBAAmB,CAAC;AAEzE,MAAM,wBACJ,UAEA,KAAK,OAAO,OAAO,OAAO,WAAW,GAAG,OAAO,IAAI,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { a as __toESM, n as __esmMin, r as __exportAll } from "./rolldown-runtime-DQp2zzRu.mjs";
|
|
2
|
+
import { n as require_dist, t as require_eslint_utils } from "./eslint-utils-DauzR3x9.mjs";
|
|
3
|
+
// src/typescript-eslint-utils.ts
|
|
4
|
+
var typescript_eslint_utils_exports = /* @__PURE__ */ __exportAll({
|
|
5
|
+
AST_NODE_TYPES: () => import_dist.AST_NODE_TYPES,
|
|
6
|
+
ESLintUtils: () => import_eslint_utils,
|
|
7
|
+
TSESTree: () => import_dist.TSESTree
|
|
8
|
+
});
|
|
9
|
+
var import_dist, import_eslint_utils;
|
|
10
|
+
var init_typescript_eslint_utils = __esmMin((() => {
|
|
11
|
+
import_dist = require_dist();
|
|
12
|
+
import_eslint_utils = /* @__PURE__ */ __toESM(require_eslint_utils(), 1);
|
|
13
|
+
}));
|
|
14
|
+
export { typescript_eslint_utils_exports as i, import_eslint_utils as n, init_typescript_eslint_utils as r, import_dist as t };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=typescript-eslint-utils-QnYasB-9.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typescript-eslint-utils-QnYasB-9.mjs","names":[],"sources":["../src/typescript-eslint-utils.ts"],"sourcesContent":["export { AST_NODE_TYPES, TSESTree } from \"@typescript-eslint/types\";\nexport * as ESLintUtils from \"@typescript-eslint/utils/eslint-utils\";\n"],"mappings":""}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { t as rulesOf } from "./config-rules-CIyMUUvG.mjs";
|
|
2
|
+
import { Array, Option, Predicate, Record, Schema, String, pipe } from "effect";
|
|
3
|
+
// src/upstream-plugin.ts
|
|
4
|
+
const Severities = Schema.Literals([
|
|
5
|
+
"error",
|
|
6
|
+
"warn",
|
|
7
|
+
"off"
|
|
8
|
+
]);
|
|
9
|
+
const isRule = (rule) => Predicate.hasProperty(rule, "create") && Predicate.isFunction(rule.create);
|
|
10
|
+
const plainRules = Record.filter(isRule);
|
|
11
|
+
const ruleIdOf = (key) => Array.lastNonEmpty(String.split(key, "/"));
|
|
12
|
+
const configOf = (name) => (config) => ({ rules: pipe(Array.ensure(config), Array.flatMap((entry) => Option.toArray(rulesOf(entry))), Array.flatMap(Record.toEntries), Record.fromEntries, Record.filter(Schema.is(Severities)), Record.mapKeys((key) => `${name}/${ruleIdOf(key)}`)) });
|
|
13
|
+
const upstreamPlugin = (name, upstream, rulesOfUpstream) => ({
|
|
14
|
+
meta: { name },
|
|
15
|
+
configs: pipe(upstream.configs, Record.map(configOf(name))),
|
|
16
|
+
rules: rulesOfUpstream(upstream.rules)
|
|
17
|
+
});
|
|
18
|
+
export { upstreamPlugin as n, plainRules as t };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=upstream-plugin-DqJEA6iy.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upstream-plugin-DqJEA6iy.mjs","names":["Arr","Str"],"sources":["../src/upstream-plugin.ts"],"sourcesContent":["import { Array as Arr, Option, Predicate, Record, Schema, String as Str, pipe } from \"effect\";\nimport type { CreateRule, Plugin } from \"vite-plus/lint/plugins\";\n\nimport { rulesOf } from \"./config-rules.ts\";\n\nconst Severities: Schema.Literals<readonly [\"error\", \"warn\", \"off\"]> = Schema.Literals([\n \"error\",\n \"warn\",\n \"off\",\n]);\n\ntype Severity = typeof Severities.Type;\n\ninterface Config {\n readonly rules?: Readonly<Record<string, Severity>> | undefined;\n}\n\ntype UpstreamPlugin<ConfigName extends string> = Plugin & {\n readonly meta: { readonly name: string };\n readonly configs: Readonly<Record<ConfigName, Config>>;\n};\n\ninterface Upstream<ConfigName extends string> {\n readonly rules: Readonly<Record<string, unknown>>;\n readonly configs: Readonly<Record<ConfigName, unknown>>;\n}\n\ntype RulesOf = (rules: Readonly<Record<string, unknown>>) => Readonly<Record<string, CreateRule>>;\n\nconst isRule = (rule: unknown): rule is CreateRule =>\n Predicate.hasProperty(rule, \"create\") && Predicate.isFunction(rule.create);\n\nconst plainRules: RulesOf = Record.filter(isRule);\n\nconst ruleIdOf = (key: string): string => Arr.lastNonEmpty(Str.split(key, \"/\"));\n\nconst configOf =\n (name: string) =>\n (config: unknown): Config => ({\n rules: pipe(\n Arr.ensure(config),\n Arr.flatMap((entry) => Option.toArray(rulesOf(entry))),\n Arr.flatMap(Record.toEntries),\n Record.fromEntries,\n Record.filter(Schema.is(Severities)),\n Record.mapKeys((key) => `${name}/${ruleIdOf(key)}`),\n ),\n });\n\nconst upstreamPlugin = <ConfigName extends string>(\n name: string,\n upstream: Upstream<ConfigName>,\n rulesOfUpstream: RulesOf,\n): UpstreamPlugin<ConfigName> => ({\n meta: { name },\n configs: pipe(upstream.configs, Record.map(configOf(name))),\n rules: rulesOfUpstream(upstream.rules),\n});\n\nexport type { Config, RulesOf, Severity, Upstream, UpstreamPlugin };\nexport { plainRules, upstreamPlugin };\n"],"mappings":";;;AAKA,MAAM,aAAiE,OAAO,SAAS;CACrF;CACA;CACA;AACF,CAAC;AAoBD,MAAM,UAAU,SACd,UAAU,YAAY,MAAM,QAAQ,KAAK,UAAU,WAAW,KAAK,MAAM;AAE3E,MAAM,aAAsB,OAAO,OAAO,MAAM;AAEhD,MAAM,YAAY,QAAwBA,MAAI,aAAaC,OAAI,MAAM,KAAK,GAAG,CAAC;AAE9E,MAAM,YACH,UACA,YAA6B,EAC5B,OAAO,KACLD,MAAI,OAAO,MAAM,GACjBA,MAAI,SAAS,UAAU,OAAO,QAAQ,QAAQ,KAAK,CAAC,CAAC,GACrDA,MAAI,QAAQ,OAAO,SAAS,GAC5B,OAAO,aACP,OAAO,OAAO,OAAO,GAAG,UAAU,CAAC,GACnC,OAAO,SAAS,QAAQ,GAAG,KAAK,GAAG,SAAS,GAAG,GAAG,CACpD,EACF;AAEF,MAAM,kBACJ,MACA,UACA,qBACgC;CAChC,MAAM,EAAE,KAAK;CACb,SAAS,KAAK,SAAS,SAAS,OAAO,IAAI,SAAS,IAAI,CAAC,CAAC;CAC1D,OAAO,gBAAgB,SAAS,KAAK;AACvC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Record, Schema } from "effect";
|
|
2
|
+
import { CreateRule, Plugin } from "vite-plus/lint/plugins";
|
|
3
|
+
declare const Severities: Schema.Literals<readonly ["error", "warn", "off"]>;
|
|
4
|
+
type Severity = typeof Severities.Type;
|
|
5
|
+
interface Config {
|
|
6
|
+
readonly rules?: Readonly<Record<string, Severity>> | undefined;
|
|
7
|
+
}
|
|
8
|
+
type UpstreamPlugin<ConfigName extends string> = Plugin & {
|
|
9
|
+
readonly meta: {
|
|
10
|
+
readonly name: string;
|
|
11
|
+
};
|
|
12
|
+
readonly configs: Readonly<Record<ConfigName, Config>>;
|
|
13
|
+
};
|
|
14
|
+
export { UpstreamPlugin as t };
|
|
15
|
+
//# sourceMappingURL=upstream-plugin-xn91RvOJ.d.mts.map
|
package/package.json
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@r_masseater/oxlint-typed-rules",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Run ESLint rules that need type information as oxlint JS plugins on TypeScript 7, including TanStack Start's React Server Component rules and ESLint React.",
|
|
3
|
+
"version": "0.1.3",
|
|
4
|
+
"description": "Run ESLint rules that need type information as oxlint JS plugins on TypeScript 7, including TanStack Start's React Server Component rules, TanStack Query, TanStack Router, Drizzle and ESLint React.",
|
|
5
5
|
"keywords": [
|
|
6
|
+
"drizzle",
|
|
6
7
|
"eslint",
|
|
7
8
|
"eslint-react",
|
|
8
9
|
"oxlint",
|
|
9
10
|
"oxlint-plugin",
|
|
10
11
|
"react",
|
|
12
|
+
"tanstack-query",
|
|
13
|
+
"tanstack-router",
|
|
11
14
|
"tanstack-start",
|
|
12
15
|
"typescript"
|
|
13
16
|
],
|
|
@@ -31,10 +34,22 @@
|
|
|
31
34
|
"types": "./dist/index.d.mts",
|
|
32
35
|
"default": "./dist/index.mjs"
|
|
33
36
|
},
|
|
37
|
+
"./drizzle": {
|
|
38
|
+
"types": "./dist/drizzle.d.mts",
|
|
39
|
+
"default": "./dist/drizzle.mjs"
|
|
40
|
+
},
|
|
34
41
|
"./react": {
|
|
35
42
|
"types": "./dist/react.d.mts",
|
|
36
43
|
"default": "./dist/react.mjs"
|
|
37
44
|
},
|
|
45
|
+
"./tanstack-query": {
|
|
46
|
+
"types": "./dist/tanstack-query.d.mts",
|
|
47
|
+
"default": "./dist/tanstack-query.mjs"
|
|
48
|
+
},
|
|
49
|
+
"./tanstack-router": {
|
|
50
|
+
"types": "./dist/tanstack-router.d.mts",
|
|
51
|
+
"default": "./dist/tanstack-router.mjs"
|
|
52
|
+
},
|
|
38
53
|
"./tanstack-start": {
|
|
39
54
|
"types": "./dist/tanstack-start.d.mts",
|
|
40
55
|
"default": "./dist/tanstack-start.mjs"
|
|
@@ -54,14 +69,19 @@
|
|
|
54
69
|
"@effect/vitest": "4.1.2",
|
|
55
70
|
"@eslint-react/eslint-plugin": "5.28.8",
|
|
56
71
|
"@size-limit/file": "14.3.0",
|
|
72
|
+
"@tanstack/eslint-plugin-query": "5.105.3",
|
|
73
|
+
"@tanstack/eslint-plugin-router": "1.162.0",
|
|
57
74
|
"@tanstack/eslint-plugin-start": "0.1.0",
|
|
58
75
|
"@tsconfig/strictest": "2.0.8",
|
|
59
76
|
"@types/node": "26.6.6",
|
|
60
77
|
"@types/react": "19.3.0",
|
|
78
|
+
"@typescript-eslint/parser": "8.72.1",
|
|
61
79
|
"@typescript-eslint/types": "8.72.1",
|
|
62
80
|
"@typescript-eslint/typescript-estree": "8.72.1",
|
|
63
81
|
"@typescript-eslint/utils": "^8.72.1",
|
|
82
|
+
"combinate": "1.1.11",
|
|
64
83
|
"dedent": "1.7.2",
|
|
84
|
+
"eslint-plugin-drizzle": "0.2.3",
|
|
65
85
|
"publint": "0.3.25",
|
|
66
86
|
"size-limit": "14.3.0",
|
|
67
87
|
"typescript": "7.1.0-beta",
|
|
@@ -74,15 +94,33 @@
|
|
|
74
94
|
{
|
|
75
95
|
"name": "react",
|
|
76
96
|
"path": "dist/react.mjs",
|
|
77
|
-
"limit": "
|
|
97
|
+
"limit": "169062 B"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"name": "tanstack-query",
|
|
101
|
+
"path": "dist/tanstack-query.mjs",
|
|
102
|
+
"limit": "11828 B"
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"name": "tanstack-router",
|
|
106
|
+
"path": "dist/tanstack-router.mjs",
|
|
107
|
+
"limit": "3448 B"
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"name": "drizzle",
|
|
111
|
+
"path": "dist/drizzle.mjs",
|
|
112
|
+
"limit": "2172 B"
|
|
78
113
|
},
|
|
79
114
|
{
|
|
80
115
|
"name": "core",
|
|
81
116
|
"path": [
|
|
82
117
|
"dist/*.mjs",
|
|
83
|
-
"!dist/react.mjs"
|
|
118
|
+
"!dist/react.mjs",
|
|
119
|
+
"!dist/tanstack-query.mjs",
|
|
120
|
+
"!dist/tanstack-router.mjs",
|
|
121
|
+
"!dist/drizzle.mjs"
|
|
84
122
|
],
|
|
85
|
-
"limit": "
|
|
123
|
+
"limit": "30078 B"
|
|
86
124
|
}
|
|
87
125
|
],
|
|
88
126
|
"engines": {
|