@r_masseater/oxlint-typed-rules 0.4.1 → 0.4.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.
Files changed (39) hide show
  1. package/README.md +77 -83
  2. package/dist/drizzle.d.mts +3 -3
  3. package/dist/drizzle.mjs +10 -10
  4. package/dist/drizzle.mjs.map +1 -1
  5. package/dist/{eslint-utils-BmbvsYwn.mjs → eslint-utils-ujGlgEMD.mjs} +9 -9
  6. package/dist/{eslint-utils-BmbvsYwn.mjs.map → eslint-utils-ujGlgEMD.mjs.map} +1 -1
  7. package/dist/{upstream-plugin-xn91RvOJ.d.mts → index-D1qDt581.d.mts} +4 -4
  8. package/dist/index.d.mts +4 -4
  9. package/dist/index.mjs +1 -1
  10. package/dist/react.d.mts +5 -5
  11. package/dist/react.mjs +171 -117
  12. package/dist/react.mjs.map +1 -1
  13. package/dist/remotion.d.mts +3 -3
  14. package/dist/remotion.mjs +4 -4
  15. package/dist/remotion.mjs.map +1 -1
  16. package/dist/tanstack-query.d.mts +3 -3
  17. package/dist/tanstack-query.mjs +6 -6
  18. package/dist/tanstack-query.mjs.map +1 -1
  19. package/dist/tanstack-router.d.mts +3 -3
  20. package/dist/tanstack-router.mjs +12 -12
  21. package/dist/tanstack-router.mjs.map +1 -1
  22. package/dist/tanstack-start.mjs +15 -15
  23. package/dist/tanstack-start.mjs.map +1 -1
  24. package/dist/{ts-compat-kqrVqnFj.mjs → ts-compat-CFDky9Ie.mjs} +3 -3
  25. package/dist/ts-compat-CFDky9Ie.mjs.map +1 -0
  26. package/dist/{typed-rule-DljA66d1.mjs → typed-rule-DFpV2XgE.mjs} +63 -63
  27. package/dist/typed-rule-DFpV2XgE.mjs.map +1 -0
  28. package/dist/{typescript-eslint-utils-DRyGbBR9.mjs → typescript-eslint-utils-C6OO2FjX.mjs} +3 -3
  29. package/dist/typescript-eslint-utils-C6OO2FjX.mjs.map +1 -0
  30. package/dist/{upstream-plugin-B_PNfSLV.mjs → upstream-plugin-D4Lz9A1H.mjs} +5 -4
  31. package/dist/upstream-plugin-D4Lz9A1H.mjs.map +1 -0
  32. package/package.json +19 -17
  33. package/skills/run-typed-eslint-rules/SKILL.md +85 -0
  34. package/dist/config-rules-CIyMUUvG.mjs +0 -6
  35. package/dist/config-rules-CIyMUUvG.mjs.map +0 -1
  36. package/dist/ts-compat-kqrVqnFj.mjs.map +0 -1
  37. package/dist/typed-rule-DljA66d1.mjs.map +0 -1
  38. package/dist/typescript-eslint-utils-DRyGbBR9.mjs.map +0 -1
  39. package/dist/upstream-plugin-B_PNfSLV.mjs.map +0 -1
@@ -1,10 +1,10 @@
1
1
  import { Array, BigInt, Cause, Effect, Exit, Layer, ManagedRuntime, Match, Option, Predicate, Record, String as String$1, pipe } from "effect";
2
- import { SyntaxKind } from "typescript/ast";
3
2
  import { FetchHttpClient } from "effect/http";
4
3
  import { OtlpSerialization, OtlpTracer } from "effect/observability";
5
4
  import { createFileSystemLayer } from "typescript/fs";
6
5
  import { API } from "typescript/sync";
7
- // src/memo.ts
6
+ import { SyntaxKind } from "typescript/ast";
7
+ // src/shared/lib/memo.ts
8
8
  const memoizeByKey = (compute) => {
9
9
  const cache = /* @__PURE__ */ new WeakMap();
10
10
  return (key) => Option.fromNullishOr(cache.get(key)).pipe(Option.getOrElse(() => {
@@ -23,62 +23,7 @@ const lazily = (compute) => {
23
23
  return computed;
24
24
  };
25
25
  };
26
- // src/parser-services.ts
27
- const covers = (node, [start, end]) => node.getStart() <= start && node.end >= end;
28
- const spans = (node, [start, end]) => node.getStart() === start && node.end === end;
29
- const innermostSpanning = (sourceFile, range) => {
30
- const visit = (node, found) => {
31
- if (!covers(node, range)) return found;
32
- const matched = Option.liftPredicate(node, (candidate) => spans(candidate, range)).pipe(Option.getOrElse(() => found));
33
- return Option.fromNullishOr(node.forEachChild((child) => Option.liftPredicate(visit(child, matched), (deeper) => deeper !== matched).pipe(Option.getOrUndefined))).pipe(Option.getOrElse(() => matched));
34
- };
35
- return visit(sourceFile, sourceFile);
36
- };
37
- const toMappedNode = ({ context }, node) => {
38
- const start = node.getStart();
39
- return {
40
- type: SyntaxKind[node.kind],
41
- range: [start, node.end],
42
- loc: {
43
- start: context.sourceCode.getLocFromIndex(start),
44
- end: context.sourceCode.getLocFromIndex(node.end)
45
- }
46
- };
47
- };
48
- const rangeKey = ([start, end]) => `${String(start)}:${String(end)}`;
49
- const isRangedNode = (value) => Predicate.hasProperty(value, "type") && Predicate.isString(value.type) && Predicate.hasProperty(value, "range") && Array.isArray(value.range);
50
- const childNodesOf = (node, keys) => pipe(keys, Array.flatMap((key) => {
51
- const child = Reflect.get(node, key);
52
- return Array.ensure(child);
53
- }), Array.filter(isRangedNode));
54
- const esTreeIndex = ({ context }) => {
55
- const index = /* @__PURE__ */ new Map();
56
- const { visitorKeys } = context.sourceCode;
57
- const visit = (node) => {
58
- const key = rangeKey(node.range);
59
- if (!index.has(key)) index.set(key, node);
60
- for (const child of childNodesOf(node, visitorKeys[node.type] ?? [])) visit(child);
61
- };
62
- visit(context.sourceCode.ast);
63
- return index;
64
- };
65
- const createParserServices = (file) => {
66
- const esTreeNodes = lazily(() => esTreeIndex(file));
67
- const toTSNode = memoizeByKey((node) => innermostSpanning(file.sourceFile, node.range));
68
- const checker = file.program.getTypeChecker();
69
- const toESTreeNode = (node) => {
70
- const key = rangeKey([node.getStart(), node.end]);
71
- return Option.fromNullishOr(esTreeNodes().get(key)).pipe(Option.getOrElse(() => toMappedNode(file, node)));
72
- };
73
- return {
74
- program: file.program,
75
- esTreeNodeToTSNodeMap: { get: toTSNode },
76
- getTypeAtLocation: (node) => checker.getTypeAtLocation(toTSNode(node)),
77
- getSymbolAtLocation: (node) => checker.getSymbolAtLocation(toTSNode(node)),
78
- tsNodeToESTreeNodeMap: { get: (node) => Option.liftPredicate(node, (candidate) => candidate.getSourceFile().fileName === file.sourceFile.fileName).pipe(Option.map(toESTreeNode), Option.getOrUndefined) }
79
- };
80
- };
81
- // src/compat-symbol.ts
26
+ // src/shared/lib/compat-symbol.ts
82
27
  const resolveAll = (project, handles) => pipe(handles, Array.flatMap((handle) => Option.fromNullishOr(handle.resolve(project)).pipe(Option.toArray)));
83
28
  var CompatSymbol = class CompatSymbol {
84
29
  static #interned = /* @__PURE__ */ new WeakMap();
@@ -114,7 +59,7 @@ var CompatSymbol = class CompatSymbol {
114
59
  return this.declarations;
115
60
  }
116
61
  };
117
- // src/compat-type.ts
62
+ // src/shared/lib/compat-type.ts
118
63
  const ZERO = 0n;
119
64
  const pseudoBigInt = (value) => ({
120
65
  negative: value < ZERO,
@@ -193,7 +138,7 @@ var CompatType = class CompatType {
193
138
  })));
194
139
  }
195
140
  };
196
- // src/compat.ts
141
+ // src/shared/lib/compat.ts
197
142
  const compatChecker = (project, checker) => ({
198
143
  getSymbolAtLocation: (node) => CompatSymbol.optional(project, checker.getSymbolAtLocation(node)),
199
144
  getAliasedSymbol: (symbol) => CompatSymbol.intern(project, checker.getAliasedSymbol(symbol.native)),
@@ -219,7 +164,7 @@ const internProgram = (project) => Option.fromNullishOr(compatPrograms.get(proje
219
164
  compatPrograms.set(program, created);
220
165
  return created;
221
166
  }));
222
- // src/program.ts
167
+ // src/shared/lib/program.ts
223
168
  const tracing = OtlpTracer.layerFromConfig({ resource: { serviceName: "oxlint-typed-rules" } }).pipe(Layer.provide(OtlpSerialization.layerJson), Layer.provide(FetchHttpClient.layer));
224
169
  const runtime = ManagedRuntime.make(tracing);
225
170
  const startApi = () => {
@@ -266,7 +211,62 @@ const programFor = (overlay) => Exit.match(runtime.runSyncExit(projectOfFile(ove
266
211
  throw Cause.squash(cause);
267
212
  }
268
213
  });
269
- // src/typed-rule.ts
214
+ // src/entities/typed-rule/model/parser-services.ts
215
+ const covers = (node, [start, end]) => node.getStart() <= start && node.end >= end;
216
+ const spans = (node, [start, end]) => node.getStart() === start && node.end === end;
217
+ const innermostSpanning = (sourceFile, range) => {
218
+ const visit = (node, found) => {
219
+ if (!covers(node, range)) return found;
220
+ const matched = Option.liftPredicate(node, (candidate) => spans(candidate, range)).pipe(Option.getOrElse(() => found));
221
+ return Option.fromNullishOr(node.forEachChild((child) => Option.liftPredicate(visit(child, matched), (deeper) => deeper !== matched).pipe(Option.getOrUndefined))).pipe(Option.getOrElse(() => matched));
222
+ };
223
+ return visit(sourceFile, sourceFile);
224
+ };
225
+ const toMappedNode = ({ context }, node) => {
226
+ const start = node.getStart();
227
+ return {
228
+ type: SyntaxKind[node.kind],
229
+ range: [start, node.end],
230
+ loc: {
231
+ start: context.sourceCode.getLocFromIndex(start),
232
+ end: context.sourceCode.getLocFromIndex(node.end)
233
+ }
234
+ };
235
+ };
236
+ const rangeKey = ([start, end]) => `${String(start)}:${String(end)}`;
237
+ 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));
242
+ const esTreeIndex = ({ context }) => {
243
+ const index = /* @__PURE__ */ new Map();
244
+ const { visitorKeys } = context.sourceCode;
245
+ const visit = (node) => {
246
+ const key = rangeKey(node.range);
247
+ if (!index.has(key)) index.set(key, node);
248
+ for (const child of childNodesOf(node, visitorKeys[node.type] ?? [])) visit(child);
249
+ };
250
+ visit(context.sourceCode.ast);
251
+ return index;
252
+ };
253
+ const createParserServices = (file) => {
254
+ const esTreeNodes = lazily(() => esTreeIndex(file));
255
+ const toTSNode = memoizeByKey((node) => innermostSpanning(file.sourceFile, node.range));
256
+ const checker = file.program.getTypeChecker();
257
+ const toESTreeNode = (node) => {
258
+ const key = rangeKey([node.getStart(), node.end]);
259
+ return Option.fromNullishOr(esTreeNodes().get(key)).pipe(Option.getOrElse(() => toMappedNode(file, node)));
260
+ };
261
+ return {
262
+ program: file.program,
263
+ esTreeNodeToTSNodeMap: { get: toTSNode },
264
+ getTypeAtLocation: (node) => checker.getTypeAtLocation(toTSNode(node)),
265
+ getSymbolAtLocation: (node) => checker.getSymbolAtLocation(toTSNode(node)),
266
+ tsNodeToESTreeNodeMap: { get: (node) => Option.liftPredicate(node, (candidate) => candidate.getSourceFile().fileName === file.sourceFile.fileName).pipe(Option.map(toESTreeNode), Option.getOrUndefined) }
267
+ };
268
+ };
269
+ // src/entities/typed-rule/model/typed-rule.ts
270
270
  const isTypedRule = (rule) => Predicate.hasProperty(rule, "meta") && Predicate.hasProperty(rule, "create") && Predicate.isFunction(rule.create);
271
271
  const isTypedContext = (value) => Predicate.hasProperty(value, "report") && Predicate.hasProperty(value, "sourceCode") && Predicate.hasProperty(value.sourceCode, "parserServices");
272
272
  const inheriting = (prototype, name, descriptor) => Object.create(prototype, { [name]: {
@@ -297,4 +297,4 @@ const typedRules = (rules) => pipe(rules, Record.filter(isTypedRule), Record.map
297
297
  const optionallyTypedRules = (rules) => pipe(rules, Record.filter(isTypedRule), Record.map(withOptionalTypeInformation));
298
298
  export { withTypeInformation as a, withOptionalTypeInformation as i, optionallyTypedRules as n, typedRules as r, isTypedRule as t };
299
299
 
300
- //# sourceMappingURL=typed-rule-DljA66d1.mjs.map
300
+ //# sourceMappingURL=typed-rule-DFpV2XgE.mjs.map
@@ -0,0 +1 @@
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;E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QAAQ,WAAW;AAAK,CAAC,CAAC,CAAC,KACxE,OAAO,SAAS,YACd,OAAO,cAAc,QAAQ,cAAc,QAAQ,QAAQ,CAAC,CAAC,CAAC,KAC5D,OAAO,KAAK,eAAe,qBAAqB;CAAE;CAAS;CAAS;AAAW,CAAC,CAAC,CACnF,CACF,CACF;AAEF,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,6 +1,6 @@
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";
3
- // src/typescript-eslint-utils.ts
2
+ import { n as require_dist, t as require_eslint_utils } from "./eslint-utils-ujGlgEMD.mjs";
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,
6
6
  ESLintUtils: () => import_eslint_utils,
@@ -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-DRyGbBR9.mjs.map
16
+ //# sourceMappingURL=typescript-eslint-utils-C6OO2FjX.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typescript-eslint-utils-C6OO2FjX.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,6 +1,7 @@
1
- import { t as rulesOf } from "./config-rules-CIyMUUvG.mjs";
2
1
  import { Array, Function, Option, Predicate, Record, Schema, String, pipe } from "effect";
3
- // src/upstream-plugin.ts
2
+ // src/entities/upstream-plugin/model/config-rules.ts
3
+ const rulesOf = (config) => Option.liftPredicate(config, Predicate.hasProperty("rules")).pipe(Option.flatMap(({ rules }) => Option.liftPredicate(rules, Predicate.isReadonlyObject)));
4
+ // src/entities/upstream-plugin/model/upstream-plugin.ts
4
5
  const Severities = Schema.Literals([
5
6
  "error",
6
7
  "warn",
@@ -15,6 +16,6 @@ const upstreamPlugin = Function.dual(3, (name, upstream, rulesOfUpstream) => ({
15
16
  configs: pipe(upstream.configs, Record.map(configOf(name))),
16
17
  rules: rulesOfUpstream(upstream.rules)
17
18
  }));
18
- export { upstreamPlugin as n, plainRules as t };
19
+ export { upstreamPlugin as n, rulesOf as r, plainRules as t };
19
20
 
20
- //# sourceMappingURL=upstream-plugin-B_PNfSLV.mjs.map
21
+ //# sourceMappingURL=upstream-plugin-D4Lz9A1H.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upstream-plugin-D4Lz9A1H.mjs","names":["Arr","Str","Fn"],"sources":["../src/entities/upstream-plugin/model/config-rules.ts","../src/entities/upstream-plugin/model/upstream-plugin.ts"],"sourcesContent":["import { Option, Predicate } from \"effect\";\n\nexport const rulesOf = (config: unknown): Option.Option<Readonly<Record<string, unknown>>> =>\n Option.liftPredicate(config, Predicate.hasProperty(\"rules\")).pipe(\n Option.flatMap(({ rules }) => Option.liftPredicate(rules, Predicate.isReadonlyObject)),\n );\n","import {\n Array as Arr,\n Function as Fn,\n Option,\n Predicate,\n Record,\n Schema,\n String as Str,\n pipe,\n} 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\nexport type Severity = typeof Severities.Type;\n\nexport interface Config {\n readonly rules?: Readonly<Record<string, Severity>> | undefined;\n}\n\nexport type UpstreamPlugin<ConfigName extends string> = Plugin & {\n readonly meta: { readonly name: string };\n readonly configs: Readonly<Record<ConfigName, Config>>;\n};\n\nexport interface Upstream<ConfigName extends string> {\n readonly rules: Readonly<Record<string, unknown>>;\n readonly configs: Readonly<Record<ConfigName, unknown>>;\n}\n\nexport type RulesOf = (\n rules: Readonly<Record<string, unknown>>,\n) => Readonly<Record<string, CreateRule>>;\n\nconst isRule = (rule: unknown): rule is CreateRule =>\n Predicate.hasProperty(rule, \"create\") && Predicate.isFunction(rule.create);\n\nexport const 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 DATA_FIRST_ARITY_3 = 3;\n\nexport const upstreamPlugin: {\n <ConfigName extends string>(\n upstream: Upstream<ConfigName>,\n rulesOfUpstream: RulesOf,\n ): (name: string) => UpstreamPlugin<ConfigName>;\n <ConfigName extends string>(\n name: string,\n upstream: Upstream<ConfigName>,\n rulesOfUpstream: RulesOf,\n ): UpstreamPlugin<ConfigName>;\n} = Fn.dual(\n DATA_FIRST_ARITY_3,\n <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);\n"],"mappings":";;AAEA,MAAa,WAAW,WACtB,OAAO,cAAc,QAAQ,UAAU,YAAY,OAAO,CAAC,CAAC,CAAC,KAC3D,OAAO,SAAS,EAAE,YAAY,OAAO,cAAc,OAAO,UAAU,gBAAgB,CAAC,CACvF;;ACSF,MAAM,aAAiE,OAAO,SAAS;CACrF;CACA;CACA;AACF,CAAC;AAsBD,MAAM,UAAU,SACd,UAAU,YAAY,MAAM,QAAQ,KAAK,UAAU,WAAW,KAAK,MAAM;AAE3E,MAAa,aAAsB,OAAO,OAAO,MAAM;AAEvD,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;AAIF,MAAa,iBAUTE,SAAG,KACL,IAEE,MACA,UACA,qBACgC;CAChC,MAAM,EAAE,KAAK;CACb,SAAS,KAAK,SAAS,SAAS,OAAO,IAAI,SAAS,IAAI,CAAC,CAAC;CAC1D,OAAO,gBAAgB,SAAS,KAAK;AACvC,EACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@r_masseater/oxlint-typed-rules",
3
- "version": "0.4.1",
3
+ "version": "0.4.3",
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",
@@ -10,6 +10,7 @@
10
10
  "oxlint-plugin",
11
11
  "react",
12
12
  "remotion",
13
+ "tanstack-intent",
13
14
  "tanstack-query",
14
15
  "tanstack-router",
15
16
  "tanstack-start",
@@ -26,12 +27,13 @@
26
27
  "directory": "libs/oxlint-typed-rules"
27
28
  },
28
29
  "files": [
30
+ "LICENSE",
29
31
  "dist",
30
- "LICENSE"
32
+ "skills/run-typed-eslint-rules"
31
33
  ],
32
34
  "type": "module",
33
35
  "imports": {
34
- "#src/*": "./src/*"
36
+ "#/*": "./src/*"
35
37
  },
36
38
  "exports": {
37
39
  ".": {
@@ -70,16 +72,16 @@
70
72
  },
71
73
  "dependencies": {},
72
74
  "devDependencies": {
73
- "@effect/platform-node": "4.1.3",
74
- "@effect/vitest": "4.1.3",
75
- "@eslint-react/eslint-plugin": "5.30.1",
76
- "@r_masseater/vite-plus-adopt": "0.4.0",
77
- "@remotion/eslint-plugin": "4.0.542",
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.9.0",
79
+ "@remotion/eslint-plugin": "4.0.543",
78
80
  "@size-limit/file": "14.3.0",
79
81
  "@tanstack/eslint-plugin-query": "5.107.1",
80
82
  "@tanstack/eslint-plugin-router": "1.162.0",
81
83
  "@tanstack/eslint-plugin-start": "0.1.0",
82
- "@tsconfig/strictest": "2.0.8",
84
+ "@tsconfig/strictest": "2.0.9",
83
85
  "@types/node": "26.6.6",
84
86
  "@types/react": "19.3.0",
85
87
  "@typescript-eslint/parser": "8.72.2",
@@ -88,13 +90,13 @@
88
90
  "@typescript-eslint/utils": "^8.72.1",
89
91
  "combinate": "1.1.11",
90
92
  "dedent": "1.7.2",
91
- "effect": "4.1.3",
92
- "eslint": "10.14.0",
93
+ "effect": "4.1.4",
94
+ "eslint": "10.15.0",
93
95
  "eslint-plugin-drizzle": "0.2.3",
94
96
  "publint": "0.3.25",
95
97
  "size-limit": "14.3.0",
96
98
  "typescript": "7.1.0-beta",
97
- "vite-plus": "1.5.1"
99
+ "vite-plus": "1.6.0"
98
100
  },
99
101
  "peerDependencies": {
100
102
  "effect": "^4.1.2",
@@ -104,27 +106,27 @@
104
106
  {
105
107
  "name": "react",
106
108
  "path": "dist/react.mjs",
107
- "limit": "175360 B"
109
+ "limit": "175820 B"
108
110
  },
109
111
  {
110
112
  "name": "tanstack-query",
111
113
  "path": "dist/tanstack-query.mjs",
112
- "limit": "11833 B"
114
+ "limit": "11840 B"
113
115
  },
114
116
  {
115
117
  "name": "tanstack-router",
116
118
  "path": "dist/tanstack-router.mjs",
117
- "limit": "3427 B"
119
+ "limit": "3429 B"
118
120
  },
119
121
  {
120
122
  "name": "drizzle",
121
123
  "path": "dist/drizzle.mjs",
122
- "limit": "2170 B"
124
+ "limit": "2174 B"
123
125
  },
124
126
  {
125
127
  "name": "remotion",
126
128
  "path": "dist/remotion.mjs",
127
- "limit": "5405 B"
129
+ "limit": "5408 B"
128
130
  },
129
131
  {
130
132
  "name": "core",
@@ -0,0 +1,85 @@
1
+ ---
2
+ name: run-typed-eslint-rules
3
+ description: >
4
+ Use when running ESLint rules that need type information inside oxlint with
5
+ @r_masseater/oxlint-typed-rules: the bundled TanStack Start, TanStack Query, TanStack Router,
6
+ Drizzle, Remotion and ESLint React plugins, wrapping another typed ESLint plugin with typedRules,
7
+ and choosing between this package and tsgolint.
8
+ metadata:
9
+ type: core
10
+ library: "@r_masseater/oxlint-typed-rules"
11
+ library_version: 0.4.2
12
+ sources:
13
+ - src/app/**
14
+ - src/entities/typed-rule/**
15
+ - src/shared/lib/program.ts
16
+ - README.md
17
+ ---
18
+
19
+ # run-typed-eslint-rules
20
+
21
+ Oxlint's JS plugins receive no type information.
22
+ This package builds a TypeScript 7 program for each linted file.
23
+ It hands the rule the `parserServices` that typed ESLint rules read, without installing ESLint.
24
+
25
+ ## Setup
26
+
27
+ ```sh
28
+ npm i -D oxlint @r_masseater/oxlint-typed-rules effect typescript@7
29
+ ```
30
+
31
+ Load a bundled plugin through `jsPlugins` and turn its rules on by name.
32
+
33
+ ```ts
34
+ import { defineConfig } from "vite-plus";
35
+
36
+ export default defineConfig({
37
+ lint: {
38
+ jsPlugins: [
39
+ {
40
+ name: "tanstack-start",
41
+ specifier: "@r_masseater/oxlint-typed-rules/tanstack-start",
42
+ },
43
+ ],
44
+ rules: {
45
+ "tanstack-start/no-async-client-component": "error",
46
+ "tanstack-start/no-client-code-in-server-component": "error",
47
+ },
48
+ },
49
+ });
50
+ ```
51
+
52
+ | Entry | Holds |
53
+ | ------------------ | ------------------------------------------------------- |
54
+ | `/tanstack-start` | The two rules of @tanstack/eslint-plugin-start |
55
+ | `/tanstack-query` | Every rule and config of @tanstack/eslint-plugin-query |
56
+ | `/tanstack-router` | Every rule and config of @tanstack/eslint-plugin-router |
57
+ | `/drizzle` | Every rule and config of eslint-plugin-drizzle |
58
+ | `/remotion` | Every rule and config of @remotion/eslint-plugin |
59
+ | `/react` | Every rule and config of @eslint-react/eslint-plugin |
60
+
61
+ ## Wrap another typed plugin
62
+
63
+ `typedRules(plugin.rules)` keeps the rules that need type information and gives each one `parserServices`. Export the result as an Oxlint plugin with a `meta.name`.
64
+
65
+ ```ts
66
+ import { typedRules } from "@r_masseater/oxlint-typed-rules";
67
+
68
+ declare const upstream: { readonly rules: Readonly<Record<string, unknown>> };
69
+
70
+ export default {
71
+ meta: { name: "upstream" },
72
+ rules: typedRules(upstream.rules),
73
+ };
74
+ ```
75
+
76
+ ## Choose the tool
77
+
78
+ A typescript-eslint rule that oxlint also has, such as `no-floating-promises`, runs faster in tsgolint.
79
+ Use tsgolint for those, and this package for typed rules that tsgolint does not have.
80
+ Running both builds type information twice, so memory grows by that much.
81
+
82
+ ## Common mistakes
83
+
84
+ A file that no `tsconfig.json` includes gets no program, so the rule reports nothing for it.
85
+ ESLint configs do not load as they are. Turn the rules on in the oxlint config.
@@ -1,6 +0,0 @@
1
- import { Option, Predicate } from "effect";
2
- // src/config-rules.ts
3
- const rulesOf = (config) => Option.liftPredicate(config, Predicate.hasProperty("rules")).pipe(Option.flatMap(({ rules }) => Option.liftPredicate(rules, Predicate.isReadonlyObject)));
4
- export { rulesOf as t };
5
-
6
- //# sourceMappingURL=config-rules-CIyMUUvG.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config-rules-CIyMUUvG.mjs","names":[],"sources":["../src/config-rules.ts"],"sourcesContent":["import { Option, Predicate } from \"effect\";\n\nconst rulesOf = (config: unknown): Option.Option<Readonly<Record<string, unknown>>> =>\n Option.liftPredicate(config, Predicate.hasProperty(\"rules\")).pipe(\n Option.flatMap(({ rules }) => Option.liftPredicate(rules, Predicate.isReadonlyObject)),\n );\n\nexport { rulesOf };\n"],"mappings":";;AAEA,MAAM,WAAW,WACf,OAAO,cAAc,QAAQ,UAAU,YAAY,OAAO,CAAC,CAAC,CAAC,KAC3D,OAAO,SAAS,EAAE,YAAY,OAAO,cAAc,OAAO,UAAU,gBAAgB,CAAC,CACvF"}
@@ -1 +0,0 @@
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"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"typed-rule-DljA66d1.mjs","names":["Arr","Arr","BigInt_","Arr","Str","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 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\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, 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\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 !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\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,MAAM,qBAAqB,YAAwB,UAAiC;CAClF,MAAM,SAAS,MAAY,UAAsB;EAC/C,IAAI,CAAC,OAAO,MAAM,KAAK,GACrB,OAAO;EAET,MAAM,UAAU,OAAO,cAAc,OAAO,cAAc,MAAM,WAAW,KAAK,CAAC,CAAC,CAAC,KACjF,OA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3F;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"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"typescript-eslint-utils-DRyGbBR9.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":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"upstream-plugin-B_PNfSLV.mjs","names":["Arr","Str","Fn"],"sources":["../src/upstream-plugin.ts"],"sourcesContent":["import {\n Array as Arr,\n Function as Fn,\n Option,\n Predicate,\n Record,\n Schema,\n String as Str,\n pipe,\n} 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 DATA_FIRST_ARITY_3 = 3;\n\nconst upstreamPlugin: {\n <ConfigName extends string>(\n upstream: Upstream<ConfigName>,\n rulesOfUpstream: RulesOf,\n ): (name: string) => UpstreamPlugin<ConfigName>;\n <ConfigName extends string>(\n name: string,\n upstream: Upstream<ConfigName>,\n rulesOfUpstream: RulesOf,\n ): UpstreamPlugin<ConfigName>;\n} = Fn.dual(\n DATA_FIRST_ARITY_3,\n <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);\n\nexport type { Config, RulesOf, Severity, Upstream, UpstreamPlugin };\nexport { plainRules, upstreamPlugin };\n"],"mappings":";;;AAcA,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;AAIF,MAAM,iBAUFE,SAAG,KACL,IAEE,MACA,UACA,qBACgC;CAChC,MAAM,EAAE,KAAK;CACb,SAAS,KAAK,SAAS,SAAS,OAAO,IAAI,SAAS,IAAI,CAAC,CAAC;CAC1D,OAAO,gBAAgB,SAAS,KAAK;AACvC,EACF"}