@r_masseater/oxlint-typed-rules 0.4.2 → 0.5.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.
@@ -7,11 +7,7 @@ import { SyntaxKind } from "typescript/ast";
7
7
  // src/shared/lib/memo.ts
8
8
  const memoizeByKey = (compute) => {
9
9
  const cache = /* @__PURE__ */ new WeakMap();
10
- return (key) => Option.fromNullishOr(cache.get(key)).pipe(Option.getOrElse(() => {
11
- const computed = compute(key);
12
- cache.set(key, computed);
13
- return computed;
14
- }));
10
+ return (key) => cache.getOrInsertComputed(key, () => compute(key));
15
11
  };
16
12
  const lazily = (compute) => {
17
13
  const cell = {};
@@ -39,11 +35,7 @@ var CompatSymbol = class CompatSymbol {
39
35
  this.name = native.name;
40
36
  }
41
37
  static intern(project, native) {
42
- return Option.fromNullishOr(CompatSymbol.#interned.get(native)).pipe(Option.getOrElse(() => {
43
- const created = new CompatSymbol(project, native);
44
- CompatSymbol.#interned.set(native, created);
45
- return created;
46
- }));
38
+ return CompatSymbol.#interned.getOrInsertComputed(native, () => new CompatSymbol(project, native));
47
39
  }
48
40
  static optional(project, native) {
49
41
  return Option.fromNullishOr(native).pipe(Option.map((symbol) => CompatSymbol.intern(project, symbol)), Option.getOrUndefined);
@@ -52,12 +44,8 @@ var CompatSymbol = class CompatSymbol {
52
44
  this.#declarations ??= resolveAll(this.#project, this.native.declarations);
53
45
  return this.#declarations;
54
46
  }
55
- getName() {
56
- return this.name;
57
- }
58
- getDeclarations() {
59
- return this.declarations;
60
- }
47
+ getName = () => this.name;
48
+ getDeclarations = () => this.declarations;
61
49
  };
62
50
  // src/shared/lib/compat-type.ts
63
51
  const ZERO = 0n;
@@ -94,11 +82,7 @@ var CompatType = class CompatType {
94
82
  this.isNumberLiteral = native.isNumberLiteralType.bind(native);
95
83
  }
96
84
  static intern(project, native) {
97
- return Option.fromNullishOr(CompatType.#interned.get(native)).pipe(Option.getOrElse(() => {
98
- const created = new CompatType(project, native);
99
- CompatType.#interned.set(native, created);
100
- return created;
101
- }));
85
+ return CompatType.#interned.getOrInsertComputed(native, () => new CompatType(project, native));
102
86
  }
103
87
  static optional(project, native) {
104
88
  return Option.fromNullishOr(native).pipe(Option.map((type) => CompatType.intern(project, type)), Option.getOrUndefined);
@@ -120,23 +104,19 @@ var CompatType = class CompatType {
120
104
  this.#types ??= pipe(constituentsOf(this.native), Array.map((member) => CompatType.intern(project, member)));
121
105
  return this.#types;
122
106
  }
123
- getSymbol() {
124
- return this.symbol;
125
- }
126
- getProperty(name) {
127
- return CompatSymbol.optional(this.#project, this.native.getProperty(name));
128
- }
129
- getProperties() {
107
+ getSymbol = () => this.symbol;
108
+ getProperty = (name) => CompatSymbol.optional(this.#project, this.native.getProperty(name));
109
+ getProperties = () => {
130
110
  const project = this.#project;
131
111
  return pipe(this.native.getProperties(), Array.map((property) => CompatSymbol.intern(project, property)));
132
- }
133
- getCallSignatures() {
112
+ };
113
+ getCallSignatures = () => {
134
114
  const project = this.#project;
135
115
  return pipe(this.native.getCallSignatures(), Array.map((signature) => ({
136
116
  native: signature,
137
117
  getReturnType: () => CompatType.intern(project, signature.getReturnType())
138
118
  })));
139
- }
119
+ };
140
120
  };
141
121
  // src/shared/lib/compat.ts
142
122
  const compatChecker = (project, checker) => ({
@@ -156,6 +136,7 @@ const internProgram = (project) => Option.fromNullishOr(compatPrograms.get(proje
156
136
  const { program } = project;
157
137
  const checker = compatChecker(project, project.checker);
158
138
  const created = {
139
+ native: project,
159
140
  getSourceFile: program.getSourceFile.bind(program),
160
141
  getSourceFiles: () => ownSourceFiles(program),
161
142
  getTypeChecker: () => checker,
@@ -177,11 +158,7 @@ const startApi = () => {
177
158
  };
178
159
  const api = startApi();
179
160
  const snapshots = /* @__PURE__ */ new Map([[api, api.createSnapshot()]]);
180
- const currentSnapshot = () => Option.fromNullishOr(snapshots.get(api)).pipe(Option.getOrElse(() => {
181
- const created = api.createSnapshot();
182
- snapshots.set(api, created);
183
- return created;
184
- }));
161
+ const currentSnapshot = () => snapshots.getOrInsertComputed(api, () => api.createSnapshot());
185
162
  const matchesText = (project, overlay) => Option.fromNullishOr(project.program.getSourceFile(overlay.fileName)).pipe(Option.exists((sourceFile) => sourceFile.text === overlay.text));
186
163
  const directoryOf = (fileName) => String$1.replace(/[\\/][^\\/]*$/u, "")(fileName);
187
164
  const directoryProjects = memoizeByKey((_snapshot) => /* @__PURE__ */ new Map());
@@ -235,16 +212,16 @@ const toMappedNode = ({ context }, node) => {
235
212
  };
236
213
  const rangeKey = ([start, end]) => `${String(start)}:${String(end)}`;
237
214
  const isRangedNode = (value) => Predicate.hasProperty(value, "type") && Predicate.isString(value.type) && Predicate.hasProperty(value, "range") && Array.isArray(value.range);
238
- const childNodesOf = (node, keys) => pipe(keys, Array.flatMap((key) => {
239
- const child = Reflect.get(node, key);
240
- return Array.ensure(child);
241
- }), Array.filter(isRangedNode));
215
+ const childNodesOf = (node, keys) => pipe(keys, Array.flatMap((key) => pipe(Option.liftPredicate(node, Predicate.hasProperty(key)), Option.match({
216
+ onNone: () => [],
217
+ onSome: (found) => Array.ensure(found[key])
218
+ }))), Array.filter(isRangedNode));
242
219
  const esTreeIndex = ({ context }) => {
243
220
  const index = /* @__PURE__ */ new Map();
244
221
  const { visitorKeys } = context.sourceCode;
245
222
  const visit = (node) => {
246
223
  const key = rangeKey(node.range);
247
- if (!index.has(key)) index.set(key, node);
224
+ index.getOrInsert(key, node);
248
225
  for (const child of childNodesOf(node, visitorKeys[node.type] ?? [])) visit(child);
249
226
  };
250
227
  visit(context.sourceCode.ast);
@@ -297,4 +274,4 @@ const typedRules = (rules) => pipe(rules, Record.filter(isTypedRule), Record.map
297
274
  const optionallyTypedRules = (rules) => pipe(rules, Record.filter(isTypedRule), Record.map(withOptionalTypeInformation));
298
275
  export { withTypeInformation as a, withOptionalTypeInformation as i, optionallyTypedRules as n, typedRules as r, isTypedRule as t };
299
276
 
300
- //# sourceMappingURL=typed-rule-DFpV2XgE.mjs.map
277
+ //# sourceMappingURL=typed-rule-DmEliEEx.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typed-rule-DmEliEEx.mjs","names":["Arr","BigInt_","Arr","Str","Arr","Str","Arr"],"sources":["../src/shared/lib/memo.ts","../src/shared/lib/compat-symbol.ts","../src/shared/lib/compat-type.ts","../src/shared/lib/compat.ts","../src/shared/lib/program.ts","../src/entities/typed-rule/model/parser-services.ts","../src/entities/typed-rule/model/typed-rule.ts"],"sourcesContent":["import { Option } from \"effect\";\n\nexport const memoizeByKey = <Key extends WeakKey, Value>(\n compute: (key: Key) => Value,\n): ((key: Key) => Value) => {\n const cache = new WeakMap<Key, Value>();\n return (key) => cache.getOrInsertComputed(key, () => compute(key));\n};\n\nexport const 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","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\nexport interface LegacySymbol {\n readonly getName: () => string;\n readonly getDeclarations: () => readonly Node[];\n}\n\nexport class 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 CompatSymbol.#interned.getOrInsertComputed(\n native,\n () => new CompatSymbol(project, native),\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 readonly getName = (): string => this.name;\n\n public readonly getDeclarations = (): readonly Node[] => this.declarations;\n}\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\nexport interface PseudoBigInt {\n readonly negative: boolean;\n readonly base10Value: string;\n}\n\nexport type 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\nexport interface CompatSignature {\n readonly native: NativeSignature;\n readonly getReturnType: () => CompatType;\n}\n\nexport interface 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\nexport class 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 CompatType.#interned.getOrInsertComputed(native, () => new CompatType(project, native));\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 readonly getSymbol = (): CompatSymbol | undefined => this.symbol;\n\n public readonly getProperty = (name: string): CompatSymbol | undefined =>\n CompatSymbol.optional(this.#project, this.native.getProperty(name));\n\n public readonly 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 readonly 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","import { Array as Arr, Option, pipe, String as Str } 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\nexport interface 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\nexport interface CompatProgram {\n readonly native: Project;\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 !Str.includes(\"/node_modules/\")(fileName) && !Str.endsWith(\".d.ts\")(fileName);\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\nexport const 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 native: project,\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","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\nexport interface 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 snapshots.getOrInsertComputed(api, () => api.createSnapshot());\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\nexport const 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","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 \"#/shared/lib/compat-symbol.ts\";\nimport type { CompatType } from \"#/shared/lib/compat-type.ts\";\nimport type { CompatProgram } from \"#/shared/lib/compat.ts\";\nimport { lazily, memoizeByKey } from \"#/shared/lib/memo.ts\";\n\nexport interface RangedNode {\n readonly range: Readonly<Range>;\n}\n\nexport interface MappedNode {\n readonly type: string;\n readonly range: Readonly<Range>;\n readonly loc: Location;\n}\n\nexport interface 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\nexport interface 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 Arr.isArray(value.range);\n\nconst childNodesOf = (node: MappedNode, keys: readonly string[]): readonly MappedNode[] =>\n pipe(\n keys,\n Arr.flatMap((key) =>\n pipe(\n Option.liftPredicate(node, Predicate.hasProperty(key)),\n Option.match({ onNone: () => [], onSome: (found) => Arr.ensure(found[key]) }),\n ),\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 index.getOrInsert(key, node);\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\nexport const 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","import { Option, Predicate, Record, pipe } from \"effect\";\nimport type { Context, CreateRule, RuleMeta, Visitor } from \"vite-plus/lint/plugins\";\n\nimport { lazily } from \"#/shared/lib/memo.ts\";\nimport { programFor } from \"#/shared/lib/program.ts\";\n\nimport { createParserServices } from \"./parser-services.ts\";\nimport type { ParserServices } from \"./parser-services.ts\";\n\nexport type TypedSourceCode = Context[\"sourceCode\"] & {\n readonly parserServices: ParserServices | undefined;\n};\n\nexport type TypedContext = Omit<Context, \"sourceCode\"> & { readonly sourceCode: TypedSourceCode };\n\nexport interface TypedRule {\n readonly meta: RuleMeta;\n readonly create: (context: TypedContext) => Visitor;\n}\n\nexport const 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\nexport const 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\nexport const 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\nexport const typedRules = (\n rules: Record.ReadonlyRecord<string, unknown>,\n): Record.ReadonlyRecord<string, CreateRule> =>\n pipe(rules, Record.filter(isTypedRule), Record.map(withTypeInformation));\n\nexport const optionallyTypedRules = (\n rules: Record.ReadonlyRecord<string, unknown>,\n): Record.ReadonlyRecord<string, CreateRule> =>\n pipe(rules, Record.filter(isTypedRule), Record.map(withOptionalTypeInformation));\n"],"mappings":";;;;;;;AAEA,MAAa,gBACX,YAC0B;CAC1B,MAAM,wBAAQ,IAAI,QAAoB;CACtC,QAAQ,QAAQ,MAAM,oBAAoB,WAAW,QAAQ,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,MAAM,sBACJ,SACA,mBACiB;CACjB,MAAM,aAAa,WAAW,QAAQ,YAAY,kBAAkB,EAAE,KAAK,eAAe,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,MAAa,uBAAuB,UAAiC;CACnE,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,MAAa,+BAA+B,UAAiC;CAC3E,MAAM,KAAK;CACX,SAAS,YACP,KAAK,OACH,mBACE,SACA,aAAa,OAAO,eAAe,iBAAiB,OAAO,CAAC,CAAC,CAC/D,CACF;AACJ;AAEA,MAAa,cACX,UAEA,KAAK,OAAO,OAAO,OAAO,WAAW,GAAG,OAAO,IAAI,mBAAmB,CAAC;AAEzE,MAAa,wBACX,UAEA,KAAK,OAAO,OAAO,OAAO,WAAW,GAAG,OAAO,IAAI,2BAA2B,CAAC"}
@@ -1,5 +1,5 @@
1
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-BmbvsYwn.mjs";
2
+ import { n as require_dist, t as require_eslint_utils } from "./eslint-utils-wXfFnDTz.mjs";
3
3
  // src/shared/lib/typescript-eslint-utils.ts
4
4
  var typescript_eslint_utils_exports = /* @__PURE__ */ __exportAll({
5
5
  AST_NODE_TYPES: () => import_dist.AST_NODE_TYPES,
@@ -13,4 +13,4 @@ var init_typescript_eslint_utils = __esmMin((() => {
13
13
  }));
14
14
  export { typescript_eslint_utils_exports as i, import_eslint_utils as n, init_typescript_eslint_utils as r, import_dist as t };
15
15
 
16
- //# sourceMappingURL=typescript-eslint-utils-BMYUCcJU.mjs.map
16
+ //# sourceMappingURL=typescript-eslint-utils-CTZhVn8G.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"typescript-eslint-utils-BMYUCcJU.mjs","names":[],"sources":["../src/shared/lib/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":""}
1
+ {"version":3,"file":"typescript-eslint-utils-CTZhVn8G.mjs","names":[],"sources":["../src/shared/lib/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":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@r_masseater/oxlint-typed-rules",
3
- "version": "0.4.2",
3
+ "version": "0.5.0",
4
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, Remotion and ESLint React.",
5
5
  "keywords": [
6
6
  "drizzle",
@@ -72,31 +72,31 @@
72
72
  },
73
73
  "dependencies": {},
74
74
  "devDependencies": {
75
- "@effect/platform-node": "4.1.4",
76
- "@effect/vitest": "4.1.4",
77
- "@eslint-react/eslint-plugin": "5.30.2",
78
- "@r_masseater/vite-plus-adopt": "0.8.1",
79
- "@remotion/eslint-plugin": "4.0.543",
75
+ "@effect/platform-node": "4.1.5",
76
+ "@effect/vitest": "4.1.5",
77
+ "@eslint-react/eslint-plugin": "5.30.6",
78
+ "@r_masseater/vite-plus-adopt": "0.12.0",
79
+ "@remotion/eslint-plugin": "4.0.546",
80
80
  "@size-limit/file": "14.3.0",
81
- "@tanstack/eslint-plugin-query": "5.107.1",
81
+ "@tanstack/eslint-plugin-query": "5.108.4",
82
82
  "@tanstack/eslint-plugin-router": "1.162.0",
83
83
  "@tanstack/eslint-plugin-start": "0.1.0",
84
84
  "@tsconfig/strictest": "2.0.9",
85
85
  "@types/node": "26.6.6",
86
86
  "@types/react": "19.3.0",
87
- "@typescript-eslint/parser": "8.72.2",
88
- "@typescript-eslint/types": "8.72.2",
89
- "@typescript-eslint/typescript-estree": "8.72.2",
90
- "@typescript-eslint/utils": "^8.72.1",
87
+ "@typescript-eslint/parser": "8.74.0",
88
+ "@typescript-eslint/types": "8.74.0",
89
+ "@typescript-eslint/typescript-estree": "8.74.0",
90
+ "@typescript-eslint/utils": "8.74.0",
91
91
  "combinate": "1.1.11",
92
92
  "dedent": "1.7.2",
93
- "effect": "4.1.4",
94
- "eslint": "10.14.0",
93
+ "effect": "4.1.5",
94
+ "eslint": "10.15.0",
95
95
  "eslint-plugin-drizzle": "0.2.3",
96
96
  "publint": "0.3.25",
97
97
  "size-limit": "14.3.0",
98
98
  "typescript": "7.1.0-beta",
99
- "vite-plus": "1.6.0"
99
+ "vite-plus": "1.8.0"
100
100
  },
101
101
  "peerDependencies": {
102
102
  "effect": "^4.1.2",
@@ -106,7 +106,7 @@
106
106
  {
107
107
  "name": "react",
108
108
  "path": "dist/react.mjs",
109
- "limit": "175820 B"
109
+ "limit": "177355 B"
110
110
  },
111
111
  {
112
112
  "name": "tanstack-query",
@@ -116,17 +116,17 @@
116
116
  {
117
117
  "name": "tanstack-router",
118
118
  "path": "dist/tanstack-router.mjs",
119
- "limit": "3428 B"
119
+ "limit": "3430 B"
120
120
  },
121
121
  {
122
122
  "name": "drizzle",
123
123
  "path": "dist/drizzle.mjs",
124
- "limit": "2173 B"
124
+ "limit": "2174 B"
125
125
  },
126
126
  {
127
127
  "name": "remotion",
128
128
  "path": "dist/remotion.mjs",
129
- "limit": "5408 B"
129
+ "limit": "5411 B"
130
130
  },
131
131
  {
132
132
  "name": "core",
@@ -142,7 +142,7 @@
142
142
  }
143
143
  ],
144
144
  "engines": {
145
- "node": ">=26"
145
+ "node": "v26.13.1"
146
146
  },
147
147
  "scripts": {}
148
148
  }
@@ -4,11 +4,12 @@ description: >
4
4
  Use when running ESLint rules that need type information inside oxlint with
5
5
  @r_masseater/oxlint-typed-rules: the bundled TanStack Start, TanStack Query, TanStack Router,
6
6
  Drizzle, Remotion and ESLint React plugins, wrapping another typed ESLint plugin with typedRules,
7
- and choosing between this package and tsgolint.
7
+ writing a typed rule with withTypeInformation, and choosing between this package and
8
+ tsgolint.
8
9
  metadata:
9
10
  type: core
10
11
  library: "@r_masseater/oxlint-typed-rules"
11
- library_version: 0.4.2
12
+ library_version: 0.5.0
12
13
  sources:
13
14
  - src/app/**
14
15
  - src/entities/typed-rule/**
@@ -73,6 +74,34 @@ export default {
73
74
  };
74
75
  ```
75
76
 
77
+ ## Write a typed rule
78
+
79
+ `withTypeInformation(rule)` gives a rule of your own the same `parserServices`.
80
+ `parserServices.program.native` is the TypeScript 7 `Project` of the linted file. Read its `checker` and `program` for what the ESLint-shaped services do not answer.
81
+
82
+ ```ts
83
+ import { withTypeInformation } from "@r_masseater/oxlint-typed-rules";
84
+
85
+ export const noAnyParameter = withTypeInformation({
86
+ meta: { type: "problem", messages: { any: "Give the parameter a type." } },
87
+ create: (context) => {
88
+ const services = context.sourceCode.parserServices;
89
+ if (services === undefined) {
90
+ return {};
91
+ }
92
+ const { checker } = services.program.native;
93
+ return {
94
+ Identifier: (node) => {
95
+ const type = services.getTypeAtLocation(node).native;
96
+ if (checker.typeToString(type) === "any") {
97
+ context.report({ node, messageId: "any" });
98
+ }
99
+ },
100
+ };
101
+ },
102
+ });
103
+ ```
104
+
76
105
  ## Choose the tool
77
106
 
78
107
  A typescript-eslint rule that oxlint also has, such as `no-floating-promises`, runs faster in tsgolint.
@@ -1 +0,0 @@
1
- {"version":3,"file":"ts-compat-CFDky9Ie.mjs","names":["Arr"],"sources":["../src/shared/lib/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\nexport const isFunctionLike = (node: Node | null | undefined): boolean =>\n Option.fromNullishOr(node).pipe(Option.exists(({ kind }) => FUNCTION_LIKE_KINDS.has(kind)));\n\nexport const 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 {\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,MAAa,kBAAkB,SAC7B,OAAO,cAAc,IAAI,CAAC,CAAC,KAAK,OAAO,QAAQ,EAAE,WAAW,oBAAoB,IAAI,IAAI,CAAC,CAAC;AAE5F,MAAa,eAGT,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"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"typed-rule-DFpV2XgE.mjs","names":["Arr","BigInt_","Arr","Str","Arr","Str","Arr"],"sources":["../src/shared/lib/memo.ts","../src/shared/lib/compat-symbol.ts","../src/shared/lib/compat-type.ts","../src/shared/lib/compat.ts","../src/shared/lib/program.ts","../src/entities/typed-rule/model/parser-services.ts","../src/entities/typed-rule/model/typed-rule.ts"],"sourcesContent":["import { Option } from \"effect\";\n\nexport const 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\nexport const 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","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\nexport interface LegacySymbol {\n readonly getName: () => string;\n readonly getDeclarations: () => readonly Node[];\n}\n\nexport class 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","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\nexport interface PseudoBigInt {\n readonly negative: boolean;\n readonly base10Value: string;\n}\n\nexport type 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\nexport interface CompatSignature {\n readonly native: NativeSignature;\n readonly getReturnType: () => CompatType;\n}\n\nexport interface 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\nexport class 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","import { Array as Arr, Option, pipe, String as Str } 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\nexport interface 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\nexport interface 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 !Str.includes(\"/node_modules/\")(fileName) && !Str.endsWith(\".d.ts\")(fileName);\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\nexport const 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","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\nexport interface 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\nexport const 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","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 \"#/shared/lib/compat-symbol.ts\";\nimport type { CompatType } from \"#/shared/lib/compat-type.ts\";\nimport type { CompatProgram } from \"#/shared/lib/compat.ts\";\nimport { lazily, memoizeByKey } from \"#/shared/lib/memo.ts\";\n\nexport interface RangedNode {\n readonly range: Readonly<Range>;\n}\n\nexport interface MappedNode {\n readonly type: string;\n readonly range: Readonly<Range>;\n readonly loc: Location;\n}\n\nexport interface 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\nexport interface 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 Arr.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\nexport const 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","import { Option, Predicate, Record, pipe } from \"effect\";\nimport type { Context, CreateRule, RuleMeta, Visitor } from \"vite-plus/lint/plugins\";\n\nimport { lazily } from \"#/shared/lib/memo.ts\";\nimport { programFor } from \"#/shared/lib/program.ts\";\n\nimport { createParserServices } from \"./parser-services.ts\";\nimport type { ParserServices } from \"./parser-services.ts\";\n\nexport type TypedSourceCode = Context[\"sourceCode\"] & {\n readonly parserServices: ParserServices | undefined;\n};\n\nexport type TypedContext = Omit<Context, \"sourceCode\"> & { readonly sourceCode: TypedSourceCode };\n\nexport interface TypedRule {\n readonly meta: RuleMeta;\n readonly create: (context: TypedContext) => Visitor;\n}\n\nexport const 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\nexport const 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\nexport const 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\nexport const typedRules = (\n rules: Record.ReadonlyRecord<string, unknown>,\n): Record.ReadonlyRecord<string, CreateRule> =>\n pipe(rules, Record.filter(isTypedRule), Record.map(withTypeInformation));\n\nexport const optionallyTypedRules = (\n rules: Record.ReadonlyRecord<string, unknown>,\n): Record.ReadonlyRecord<string, CreateRule> =>\n pipe(rules, Record.filter(isTypedRule), Record.map(withOptionalTypeInformation));\n"],"mappings":";;;;;;;AAEA,MAAa,gBACX,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,MAAa,UAAiB,YAAwC;CACpE,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;;ACvBA,MAAM,cAAc,SAAkB,YACpC,KACE,SACAA,MAAI,SAAS,WAAW,OAAO,cAAc,OAAO,QAAQ,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,OAAO,CAAC,CAC5F;AAOF,IAAa,eAAb,MAAa,aAAqC;CAChD,OAAgB,4BAAY,IAAI,QAAoC;CAEpE;CAEA;CAEA;CAEA;CAEA;CAEA,YAAoB,SAAkB,QAAsB;EAC1D,KAAK,WAAW;EAChB,KAAK,SAAS;EACd,KAAK,QAAQ,OAAO;EACpB,KAAK,OAAO,OAAO;CACrB;CAEA,OAAc,OAAO,SAAkB,QAAoC;EACzE,OAAO,OAAO,cAAc,aAAa,UAAU,IAAI,MAAM,CAAC,CAAC,CAAC,KAC9D,OAAO,gBAAgB;GACrB,MAAM,UAAU,IAAI,aAAa,SAAS,MAAM;GAChD,aAAa,UAAU,IAAI,QAAQ,OAAO;GAC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