@r_masseater/oxlint-typed-rules 0.3.0 → 0.4.1

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.
@@ -0,0 +1 @@
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,OAAO,gBAAgB,KAAK,CAC9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,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,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-DauzR3x9.mjs";
2
+ import { n as require_dist, t as require_eslint_utils } from "./eslint-utils-BmbvsYwn.mjs";
3
3
  // src/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-QnYasB-9.mjs.map
16
+ //# sourceMappingURL=typescript-eslint-utils-DRyGbBR9.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"typescript-eslint-utils-QnYasB-9.mjs","names":[],"sources":["../src/typescript-eslint-utils.ts"],"sourcesContent":["export { AST_NODE_TYPES, TSESTree } from \"@typescript-eslint/types\";\nexport * as ESLintUtils from \"@typescript-eslint/utils/eslint-utils\";\n"],"mappings":""}
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,5 +1,5 @@
1
1
  import { t as rulesOf } from "./config-rules-CIyMUUvG.mjs";
2
- import { Array, Option, Predicate, Record, Schema, String, pipe } from "effect";
2
+ import { Array, Function, Option, Predicate, Record, Schema, String, pipe } from "effect";
3
3
  // src/upstream-plugin.ts
4
4
  const Severities = Schema.Literals([
5
5
  "error",
@@ -10,11 +10,11 @@ const isRule = (rule) => Predicate.hasProperty(rule, "create") && Predicate.isFu
10
10
  const plainRules = Record.filter(isRule);
11
11
  const ruleIdOf = (key) => Array.lastNonEmpty(String.split(key, "/"));
12
12
  const configOf = (name) => (config) => ({ rules: pipe(Array.ensure(config), Array.flatMap((entry) => Option.toArray(rulesOf(entry))), Array.flatMap(Record.toEntries), Record.fromEntries, Record.filter(Schema.is(Severities)), Record.mapKeys((key) => `${name}/${ruleIdOf(key)}`)) });
13
- const upstreamPlugin = (name, upstream, rulesOfUpstream) => ({
13
+ const upstreamPlugin = Function.dual(3, (name, upstream, rulesOfUpstream) => ({
14
14
  meta: { name },
15
15
  configs: pipe(upstream.configs, Record.map(configOf(name))),
16
16
  rules: rulesOfUpstream(upstream.rules)
17
- });
17
+ }));
18
18
  export { upstreamPlugin as n, plainRules as t };
19
19
 
20
- //# sourceMappingURL=upstream-plugin-DqJEA6iy.mjs.map
20
+ //# sourceMappingURL=upstream-plugin-B_PNfSLV.mjs.map
@@ -0,0 +1 @@
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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@r_masseater/oxlint-typed-rules",
3
- "version": "0.3.0",
3
+ "version": "0.4.1",
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",
@@ -15,14 +15,14 @@
15
15
  "tanstack-start",
16
16
  "typescript"
17
17
  ],
18
- "homepage": "https://github.com/masseater/lint-kit/tree/main/libs/oxlint-typed-rules#readme",
18
+ "homepage": "https://github.com/masseater/masseater.dev/tree/main/libs/oxlint-typed-rules#readme",
19
19
  "bugs": {
20
- "url": "https://github.com/masseater/lint-kit/issues"
20
+ "url": "https://github.com/masseater/masseater.dev/issues"
21
21
  },
22
22
  "license": "MIT",
23
23
  "repository": {
24
24
  "type": "git",
25
- "url": "git+https://github.com/masseater/lint-kit.git",
25
+ "url": "git+https://github.com/masseater/masseater.dev.git",
26
26
  "directory": "libs/oxlint-typed-rules"
27
27
  },
28
28
  "files": [
@@ -30,6 +30,9 @@
30
30
  "LICENSE"
31
31
  ],
32
32
  "type": "module",
33
+ "imports": {
34
+ "#src/*": "./src/*"
35
+ },
33
36
  "exports": {
34
37
  ".": {
35
38
  "types": "./dist/index.d.mts",
@@ -65,62 +68,63 @@
65
68
  "access": "public",
66
69
  "provenance": true
67
70
  },
68
- "dependencies": {
69
- "effect": "4.1.2"
70
- },
71
+ "dependencies": {},
71
72
  "devDependencies": {
72
- "@effect/platform-node": "4.1.2",
73
- "@effect/vitest": "4.1.2",
74
- "@eslint-react/eslint-plugin": "5.28.8",
75
- "@r_masseater/vite-plus-adopt": "0.3.0",
76
- "@remotion/eslint-plugin": "4.0.541",
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",
77
78
  "@size-limit/file": "14.3.0",
78
- "@tanstack/eslint-plugin-query": "5.105.3",
79
+ "@tanstack/eslint-plugin-query": "5.107.1",
79
80
  "@tanstack/eslint-plugin-router": "1.162.0",
80
81
  "@tanstack/eslint-plugin-start": "0.1.0",
81
82
  "@tsconfig/strictest": "2.0.8",
82
83
  "@types/node": "26.6.6",
83
84
  "@types/react": "19.3.0",
84
- "@typescript-eslint/parser": "8.72.1",
85
- "@typescript-eslint/types": "8.72.1",
86
- "@typescript-eslint/typescript-estree": "8.72.1",
85
+ "@typescript-eslint/parser": "8.72.2",
86
+ "@typescript-eslint/types": "8.72.2",
87
+ "@typescript-eslint/typescript-estree": "8.72.2",
87
88
  "@typescript-eslint/utils": "^8.72.1",
88
89
  "combinate": "1.1.11",
89
90
  "dedent": "1.7.2",
91
+ "effect": "4.1.3",
92
+ "eslint": "10.14.0",
90
93
  "eslint-plugin-drizzle": "0.2.3",
91
94
  "publint": "0.3.25",
92
95
  "size-limit": "14.3.0",
93
96
  "typescript": "7.1.0-beta",
94
- "vite-plus": "1.5.0"
97
+ "vite-plus": "1.5.1"
95
98
  },
96
99
  "peerDependencies": {
100
+ "effect": "^4.1.2",
97
101
  "typescript": ">=7.1.0-beta"
98
102
  },
99
103
  "size-limit": [
100
104
  {
101
105
  "name": "react",
102
106
  "path": "dist/react.mjs",
103
- "limit": "169062 B"
107
+ "limit": "175360 B"
104
108
  },
105
109
  {
106
110
  "name": "tanstack-query",
107
111
  "path": "dist/tanstack-query.mjs",
108
- "limit": "11828 B"
112
+ "limit": "11833 B"
109
113
  },
110
114
  {
111
115
  "name": "tanstack-router",
112
116
  "path": "dist/tanstack-router.mjs",
113
- "limit": "3448 B"
117
+ "limit": "3427 B"
114
118
  },
115
119
  {
116
120
  "name": "drizzle",
117
121
  "path": "dist/drizzle.mjs",
118
- "limit": "2172 B"
122
+ "limit": "2170 B"
119
123
  },
120
124
  {
121
125
  "name": "remotion",
122
126
  "path": "dist/remotion.mjs",
123
- "limit": "5263 B"
127
+ "limit": "5405 B"
124
128
  },
125
129
  {
126
130
  "name": "core",
@@ -132,7 +136,7 @@
132
136
  "!dist/drizzle.mjs",
133
137
  "!dist/remotion.mjs"
134
138
  ],
135
- "limit": "30078 B"
139
+ "limit": "30068 B"
136
140
  }
137
141
  ],
138
142
  "engines": {
@@ -1 +0,0 @@
1
- {"version":3,"file":"typed-rule-DsbM82SI.mjs","names":["Arr","Arr","BigInt_","Arr","Arr","Str"],"sources":["../src/memo.ts","../src/parser-services.ts","../src/compat-symbol.ts","../src/compat-type.ts","../src/compat.ts","../src/program.ts","../src/typed-rule.ts"],"sourcesContent":["import { Option } from \"effect\";\n\nconst memoizeByKey = <Key extends WeakKey, Value>(\n compute: (key: Key) => Value,\n): ((key: Key) => Value) => {\n const cache = new WeakMap<Key, Value>();\n return (key) =>\n Option.fromNullishOr(cache.get(key)).pipe(\n Option.getOrElse(() => {\n const computed = compute(key);\n cache.set(key, computed);\n return computed;\n }),\n );\n};\n\nconst lazily = <Value>(compute: () => Value): (() => Value) => {\n const cell: { value?: Option.Option<Value> } = {};\n return () => {\n const cached = Option.flatten(Option.fromNullishOr(cell.value));\n if (Option.isSome(cached)) {\n return cached.value;\n }\n const computed = compute();\n cell.value = Option.some(computed);\n return computed;\n };\n};\n\nexport { lazily, memoizeByKey };\n","import { Array as Arr, Option, Predicate, pipe } from \"effect\";\nimport { SyntaxKind } from \"typescript/ast\";\nimport type { Node, SourceFile } from \"typescript/ast\";\nimport type { Context, Location, Range } from \"vite-plus/lint/plugins\";\n\nimport type { CompatSymbol } from \"./compat-symbol.ts\";\nimport type { CompatType } from \"./compat-type.ts\";\nimport type { CompatProgram } from \"./compat.ts\";\nimport { lazily, memoizeByKey } from \"./memo.ts\";\n\ninterface RangedNode {\n readonly range: Readonly<Range>;\n}\n\ninterface MappedNode {\n readonly type: string;\n readonly range: Readonly<Range>;\n readonly loc: Location;\n}\n\ninterface ParserServices {\n readonly program: CompatProgram;\n readonly esTreeNodeToTSNodeMap: { readonly get: (node: RangedNode) => Node };\n readonly tsNodeToESTreeNodeMap: {\n readonly get: (node: Node) => MappedNode | undefined;\n };\n readonly getTypeAtLocation: (node: RangedNode) => CompatType;\n readonly getSymbolAtLocation: (node: RangedNode) => CompatSymbol | undefined;\n}\n\ninterface FileProgram {\n readonly context: Context;\n readonly program: CompatProgram;\n readonly sourceFile: SourceFile;\n}\n\nconst covers = (node: Node, [start, end]: Readonly<Range>): boolean =>\n node.getStart() <= start && node.end >= end;\n\nconst spans = (node: Node, [start, end]: Readonly<Range>): boolean =>\n node.getStart() === start && node.end === end;\n\nconst innermostSpanning = (sourceFile: SourceFile, range: Readonly<Range>): Node => {\n const visit = (node: Node, found: Node): Node => {\n if (!covers(node, range)) {\n return found;\n }\n const matched = Option.liftPredicate(node, (candidate) => spans(candidate, range)).pipe(\n Option.getOrElse(() => found),\n );\n return Option.fromNullishOr(\n node.forEachChild((child) =>\n Option.liftPredicate(visit(child, matched), (deeper) => deeper !== matched).pipe(\n Option.getOrUndefined,\n ),\n ),\n ).pipe(Option.getOrElse(() => matched));\n };\n return visit(sourceFile, sourceFile);\n};\n\nconst toMappedNode = ({ context }: FileProgram, node: Node): MappedNode => {\n const start = node.getStart();\n return {\n type: SyntaxKind[node.kind],\n range: [start, node.end],\n loc: {\n start: context.sourceCode.getLocFromIndex(start),\n end: context.sourceCode.getLocFromIndex(node.end),\n },\n };\n};\n\nconst rangeKey = ([start, end]: Readonly<Range>): string => `${String(start)}:${String(end)}`;\n\nconst isRangedNode = (value: unknown): value is MappedNode =>\n Predicate.hasProperty(value, \"type\") &&\n Predicate.isString(value.type) &&\n Predicate.hasProperty(value, \"range\") &&\n Array.isArray(value.range);\n\nconst childNodesOf = (node: MappedNode, keys: readonly string[]): readonly MappedNode[] =>\n pipe(\n keys,\n Arr.flatMap((key) => {\n const child: unknown = Reflect.get(node, key);\n return Arr.ensure(child);\n }),\n Arr.filter(isRangedNode),\n );\n\nconst esTreeIndex = ({ context }: FileProgram): ReadonlyMap<string, MappedNode> => {\n const index = new Map<string, MappedNode>();\n const { visitorKeys } = context.sourceCode;\n const visit = (node: MappedNode): void => {\n const key = rangeKey(node.range);\n if (!index.has(key)) {\n index.set(key, node);\n }\n for (const child of childNodesOf(node, visitorKeys[node.type] ?? [])) {\n visit(child);\n }\n };\n visit(context.sourceCode.ast);\n return index;\n};\n\nconst createParserServices = (file: FileProgram): ParserServices => {\n const esTreeNodes = lazily(() => esTreeIndex(file));\n const toTSNode = memoizeByKey((node: RangedNode) =>\n innermostSpanning(file.sourceFile, node.range),\n );\n const checker = file.program.getTypeChecker();\n const toESTreeNode = (node: Node): MappedNode => {\n const key = rangeKey([node.getStart(), node.end]);\n return Option.fromNullishOr(esTreeNodes().get(key)).pipe(\n Option.getOrElse(() => toMappedNode(file, node)),\n );\n };\n return {\n program: file.program,\n esTreeNodeToTSNodeMap: { get: toTSNode },\n getTypeAtLocation: (node) => checker.getTypeAtLocation(toTSNode(node)),\n getSymbolAtLocation: (node) => checker.getSymbolAtLocation(toTSNode(node)),\n tsNodeToESTreeNodeMap: {\n get: (node) =>\n Option.liftPredicate(\n node,\n (candidate) => candidate.getSourceFile().fileName === file.sourceFile.fileName,\n ).pipe(Option.map(toESTreeNode), Option.getOrUndefined),\n },\n };\n};\n\nexport { createParserServices };\nexport type { FileProgram, MappedNode, ParserServices, RangedNode };\n","import { Array as Arr, Option, pipe } from \"effect\";\nimport type { Node } from \"typescript/ast\";\nimport type { NodeHandle, Project, Symbol as NativeSymbol, SymbolFlags } from \"typescript/sync\";\n\nconst resolveAll = (project: Project, handles: readonly NodeHandle[]): readonly Node[] =>\n pipe(\n handles,\n Arr.flatMap((handle) => Option.fromNullishOr(handle.resolve(project)).pipe(Option.toArray)),\n );\n\ninterface LegacySymbol {\n readonly getName: () => string;\n readonly getDeclarations: () => readonly Node[];\n}\n\nclass CompatSymbol implements LegacySymbol {\n static readonly #interned = new WeakMap<NativeSymbol, CompatSymbol>();\n\n public readonly native: NativeSymbol;\n\n public readonly flags: SymbolFlags;\n\n public readonly name: string;\n\n readonly #project: Project;\n\n #declarations: readonly Node[] | undefined;\n\n private constructor(project: Project, native: NativeSymbol) {\n this.#project = project;\n this.native = native;\n this.flags = native.flags;\n this.name = native.name;\n }\n\n public static intern(project: Project, native: NativeSymbol): CompatSymbol {\n return Option.fromNullishOr(CompatSymbol.#interned.get(native)).pipe(\n Option.getOrElse(() => {\n const created = new CompatSymbol(project, native);\n CompatSymbol.#interned.set(native, created);\n return created;\n }),\n );\n }\n\n public static optional(\n project: Project,\n native: NativeSymbol | undefined,\n ): CompatSymbol | undefined {\n return Option.fromNullishOr(native).pipe(\n Option.map((symbol) => CompatSymbol.intern(project, symbol)),\n Option.getOrUndefined,\n );\n }\n\n public get declarations(): readonly Node[] {\n this.#declarations ??= resolveAll(this.#project, this.native.declarations);\n return this.#declarations;\n }\n\n public getName(): string {\n return this.name;\n }\n\n public getDeclarations(): readonly Node[] {\n return this.declarations;\n }\n}\n\nexport type { LegacySymbol };\nexport { CompatSymbol };\n","import { Array as Arr, BigInt as BigInt_, Match, Option, Predicate, pipe } from \"effect\";\nimport type {\n Project,\n Signature as NativeSignature,\n Type as NativeType,\n TypeFlags,\n UnionOrIntersectionType,\n} from \"typescript/sync\";\n\nimport { CompatSymbol } from \"./compat-symbol.ts\";\n\ninterface PseudoBigInt {\n readonly negative: boolean;\n readonly base10Value: string;\n}\n\ntype LiteralValue = string | number | boolean | PseudoBigInt;\n\nconst ZERO = 0n;\n\nconst pseudoBigInt = (value: bigint): PseudoBigInt => ({\n negative: value < ZERO,\n base10Value: BigInt_.abs(value).toString(),\n});\n\nconst literalValueOf = (native: NativeType): Option.Option<LiteralValue> =>\n Option.liftPredicate(native, (type) => type.isLiteralType()).pipe(\n Option.map(({ value }) =>\n Match.value(value).pipe(\n Match.when(Predicate.isBigInt, pseudoBigInt),\n Match.orElse((primitive) => primitive),\n ),\n ),\n );\n\nconst isUnionOrIntersection = (type: NativeType): type is UnionOrIntersectionType =>\n type.isUnionType() || type.isIntersectionType();\n\nconst constituentsOf = (native: NativeType): readonly NativeType[] =>\n Option.liftPredicate(native, isUnionOrIntersection).pipe(\n Option.map((type) => type.getTypes()),\n Option.getOrElse((): readonly NativeType[] => []),\n );\n\ninterface CompatSignature {\n readonly native: NativeSignature;\n readonly getReturnType: () => CompatType;\n}\n\ninterface LegacyType {\n readonly symbol: CompatSymbol | undefined;\n readonly aliasSymbol: CompatSymbol | undefined;\n readonly types: readonly CompatType[];\n readonly getSymbol: () => CompatSymbol | undefined;\n readonly getProperty: (name: string) => CompatSymbol | undefined;\n readonly getProperties: () => readonly CompatSymbol[];\n readonly getCallSignatures: () => readonly CompatSignature[];\n}\n\nclass CompatType implements LegacyType {\n static readonly #interned = new WeakMap<NativeType, CompatType>();\n\n public readonly native: NativeType;\n\n public readonly flags: TypeFlags;\n\n public readonly intrinsicName: string | undefined;\n\n public readonly value: LiteralValue | undefined;\n\n public readonly isUnion: () => boolean;\n\n public readonly isLiteral: () => boolean;\n\n public readonly isStringLiteral: () => boolean;\n\n public readonly isNumberLiteral: () => boolean;\n\n readonly #project: Project;\n\n #symbol: Option.Option<CompatSymbol | undefined> = Option.none();\n\n #aliasSymbol: Option.Option<CompatSymbol | undefined> = Option.none();\n\n #types: readonly CompatType[] | undefined;\n\n private constructor(project: Project, native: NativeType) {\n this.#project = project;\n this.native = native;\n this.flags = native.flags;\n this.intrinsicName = Option.liftPredicate(native, (type) => type.isIntrinsicType()).pipe(\n Option.map(({ intrinsicName }) => intrinsicName),\n Option.getOrUndefined,\n );\n this.value = Option.getOrUndefined(literalValueOf(native));\n this.isUnion = native.isUnionType.bind(native);\n this.isLiteral = native.isLiteralType.bind(native);\n this.isStringLiteral = native.isStringLiteralType.bind(native);\n this.isNumberLiteral = native.isNumberLiteralType.bind(native);\n }\n\n public static intern(project: Project, native: NativeType): CompatType {\n return Option.fromNullishOr(CompatType.#interned.get(native)).pipe(\n Option.getOrElse(() => {\n const created = new CompatType(project, native);\n CompatType.#interned.set(native, created);\n return created;\n }),\n );\n }\n\n public static optional(project: Project, native: NativeType | undefined): CompatType | undefined {\n return Option.fromNullishOr(native).pipe(\n Option.map((type) => CompatType.intern(project, type)),\n Option.getOrUndefined,\n );\n }\n\n public get symbol(): CompatSymbol | undefined {\n const { native } = this;\n const project = this.#project;\n this.#symbol = Option.orElse(this.#symbol, () =>\n Option.some(CompatSymbol.optional(project, native.getSymbol())),\n );\n return Option.getOrUndefined(this.#symbol);\n }\n\n public get aliasSymbol(): CompatSymbol | undefined {\n const { native } = this;\n const project = this.#project;\n this.#aliasSymbol = Option.orElse(this.#aliasSymbol, () =>\n Option.some(CompatSymbol.optional(project, native.getAliasSymbol())),\n );\n return Option.getOrUndefined(this.#aliasSymbol);\n }\n\n public get types(): readonly CompatType[] {\n const project = this.#project;\n this.#types ??= pipe(\n constituentsOf(this.native),\n Arr.map((member) => CompatType.intern(project, member)),\n );\n return this.#types;\n }\n\n public getSymbol(): CompatSymbol | undefined {\n return this.symbol;\n }\n\n public getProperty(name: string): CompatSymbol | undefined {\n return CompatSymbol.optional(this.#project, this.native.getProperty(name));\n }\n\n public getProperties(): readonly CompatSymbol[] {\n const project = this.#project;\n return pipe(\n this.native.getProperties(),\n Arr.map((property) => CompatSymbol.intern(project, property)),\n );\n }\n\n public getCallSignatures(): readonly CompatSignature[] {\n const project = this.#project;\n return pipe(\n this.native.getCallSignatures(),\n Arr.map((signature): CompatSignature => ({\n native: signature,\n getReturnType: () => CompatType.intern(project, signature.getReturnType()),\n })),\n );\n }\n}\n\nexport type { CompatSignature, LegacyType, LiteralValue, PseudoBigInt };\nexport { CompatType };\n","import { Array as Arr, Option, pipe } from \"effect\";\nimport type { Node, SourceFile } from \"typescript/ast\";\nimport type { Checker, CompilerOptions, Program as NativeProgram, Project } from \"typescript/sync\";\n\nimport { CompatSymbol } from \"./compat-symbol.ts\";\nimport { CompatType } from \"./compat-type.ts\";\nimport { memoizeByKey } from \"./memo.ts\";\n\ninterface CompatChecker {\n readonly getSymbolAtLocation: (node: Node) => CompatSymbol | undefined;\n readonly getAliasedSymbol: (symbol: CompatSymbol) => CompatSymbol;\n readonly getTypeAtLocation: (node: Node) => CompatType;\n readonly getTypeOfSymbol: (symbol: CompatSymbol) => CompatType;\n readonly getBaseConstraintOfType: (type: CompatType) => CompatType | undefined;\n readonly getAwaitedType: (type: CompatType) => CompatType | undefined;\n readonly getFullyQualifiedName: (symbol: CompatSymbol) => string;\n readonly typeToString: (type: CompatType) => string;\n}\n\ninterface CompatProgram {\n readonly getSourceFile: (fileName: string) => SourceFile | undefined;\n readonly getSourceFiles: () => readonly SourceFile[];\n readonly getTypeChecker: () => CompatChecker;\n readonly getCompilerOptions: () => CompilerOptions;\n}\n\nconst compatChecker = (project: Project, checker: Checker): CompatChecker => ({\n getSymbolAtLocation: (node) => CompatSymbol.optional(project, checker.getSymbolAtLocation(node)),\n getAliasedSymbol: (symbol) =>\n CompatSymbol.intern(project, checker.getAliasedSymbol(symbol.native)),\n getTypeAtLocation: (node) => CompatType.intern(project, checker.getTypeAtLocation(node)),\n getTypeOfSymbol: (symbol) => CompatType.intern(project, checker.getTypeOfSymbol(symbol.native)),\n getBaseConstraintOfType: (type) =>\n CompatType.optional(project, checker.getBaseConstraintOfType(type.native)),\n getAwaitedType: (type) => CompatType.optional(project, checker.getAwaitedType(type.native)),\n getFullyQualifiedName: (symbol) => checker.getFullyQualifiedName(symbol.native),\n typeToString: (type) => checker.typeToString(type.native),\n});\n\nconst isOwnSourceFile = (fileName: string): boolean =>\n !fileName.includes(\"/node_modules/\") && !fileName.endsWith(\".d.ts\");\n\nconst ownSourceFiles = memoizeByKey((program: NativeProgram): readonly SourceFile[] =>\n pipe(\n program.getSourceFileNames(),\n Arr.filter(isOwnSourceFile),\n Arr.flatMap((fileName) =>\n Option.fromNullishOr(program.getSourceFile(fileName)).pipe(Option.toArray),\n ),\n ),\n);\n\nconst compatPrograms = new WeakMap<NativeProgram, CompatProgram>();\n\nconst internProgram = (project: Project): CompatProgram =>\n Option.fromNullishOr(compatPrograms.get(project.program)).pipe(\n Option.getOrElse(() => {\n const { program } = project;\n const checker = compatChecker(project, project.checker);\n const created: CompatProgram = {\n getSourceFile: program.getSourceFile.bind(program),\n getSourceFiles: () => ownSourceFiles(program),\n getTypeChecker: () => checker,\n getCompilerOptions: program.getCompilerOptions.bind(program),\n };\n compatPrograms.set(program, created);\n return created;\n }),\n );\n\nexport type { CompatChecker, CompatProgram };\nexport { internProgram };\n","import { Cause, Effect, Exit, Layer, ManagedRuntime, Option, String as Str } from \"effect\";\nimport { FetchHttpClient } from \"effect/http\";\nimport { OtlpSerialization, OtlpTracer } from \"effect/observability\";\nimport { createFileSystemLayer } from \"typescript/fs\";\nimport { API } from \"typescript/sync\";\nimport type { Project, Snapshot } from \"typescript/sync\";\n\nimport { internProgram } from \"./compat.ts\";\nimport type { CompatProgram } from \"./compat.ts\";\nimport { memoizeByKey } from \"./memo.ts\";\n\nconst tracing = OtlpTracer.layerFromConfig({\n resource: { serviceName: \"oxlint-typed-rules\" },\n}).pipe(Layer.provide(OtlpSerialization.layerJson), Layer.provide(FetchHttpClient.layer));\n\nconst runtime = ManagedRuntime.make(tracing);\n\ninterface Overlay {\n readonly fileName: string;\n readonly text: string;\n}\n\nconst startApi = (): API => {\n const started = new API();\n process.once(\"beforeExit\", () => {\n started.close();\n Effect.runFork(runtime.disposeEffect);\n });\n return started;\n};\n\nconst api = startApi();\n\nconst snapshots = new Map<API, Snapshot>([[api, api.createSnapshot()]]);\n\nconst currentSnapshot = (): Snapshot =>\n Option.fromNullishOr(snapshots.get(api)).pipe(\n Option.getOrElse(() => {\n const created = api.createSnapshot();\n snapshots.set(api, created);\n return created;\n }),\n );\n\nconst matchesText = (project: Project, overlay: Overlay): boolean =>\n Option.fromNullishOr(project.program.getSourceFile(overlay.fileName)).pipe(\n Option.exists((sourceFile) => sourceFile.text === overlay.text),\n );\n\nconst directoryOf = (fileName: string): string => Str.replace(/[\\\\/][^\\\\/]*$/u, \"\")(fileName);\n\nconst directoryProjects = memoizeByKey(\n (_snapshot: Snapshot): Map<string, Project> => new Map<string, Project>(),\n);\n\nconst defaultProject = (snapshot: Snapshot, fileName: string): Option.Option<Project> =>\n Option.fromNullishOr(snapshot.getDefaultProjectForFile(fileName)).pipe(\n Option.map((project) => {\n directoryProjects(snapshot).set(directoryOf(fileName), project);\n return project;\n }),\n );\n\nconst currentProject = (overlay: Overlay): Option.Option<Project> => {\n const snapshot = currentSnapshot();\n return Option.fromNullishOr(directoryProjects(snapshot).get(directoryOf(overlay.fileName))).pipe(\n Option.filter((project) => matchesText(project, overlay)),\n Option.orElse(() =>\n defaultProject(snapshot, overlay.fileName).pipe(\n Option.filter((project) => matchesText(project, overlay)),\n ),\n ),\n );\n};\n\nconst openFile = (overlay: Overlay): Effect.Effect<Option.Option<Project>> =>\n Effect.sync(() => {\n const updated = currentSnapshot().update({\n openFiles: [overlay.fileName],\n fileSystem: createFileSystemLayer([[overlay.fileName, overlay.text]]),\n });\n snapshots.set(api, updated);\n return defaultProject(updated, overlay.fileName);\n }).pipe(\n Effect.withSpan(\"oxlint-typed-rules.open-file\", {\n attributes: { fileName: overlay.fileName },\n }),\n );\n\nconst projectOfFile = (overlay: Overlay): Effect.Effect<Option.Option<Project>> =>\n Effect.suspend(() =>\n Option.match(currentProject(overlay), {\n onSome: Effect.succeedSome,\n onNone: () => openFile(overlay),\n }),\n );\n\nconst programFor = (overlay: Overlay): Option.Option<CompatProgram> =>\n Exit.match(runtime.runSyncExit(projectOfFile(overlay)), {\n onSuccess: Option.map(internProgram),\n onFailure: (cause) => {\n throw Cause.squash(cause);\n },\n });\n\nexport type { Overlay };\nexport { programFor };\n","import { Option, Predicate, Record, pipe } from \"effect\";\nimport type { Context, CreateRule, RuleMeta, Visitor } from \"vite-plus/lint/plugins\";\n\nimport { lazily } from \"./memo.ts\";\nimport { createParserServices } from \"./parser-services.ts\";\nimport type { ParserServices } from \"./parser-services.ts\";\nimport { programFor } from \"./program.ts\";\n\ntype TypedSourceCode = Context[\"sourceCode\"] & {\n readonly parserServices: ParserServices | undefined;\n};\n\ntype TypedContext = Omit<Context, \"sourceCode\"> & { readonly sourceCode: TypedSourceCode };\n\ninterface TypedRule {\n readonly meta: RuleMeta;\n readonly create: (context: TypedContext) => Visitor;\n}\n\nconst isTypedRule = <Rule>(rule: Rule): rule is Rule & TypedRule =>\n Predicate.hasProperty(rule, \"meta\") &&\n Predicate.hasProperty(rule, \"create\") &&\n Predicate.isFunction(rule.create);\n\nconst isTypedContext = (value: unknown): value is TypedContext =>\n Predicate.hasProperty(value, \"report\") &&\n Predicate.hasProperty(value, \"sourceCode\") &&\n Predicate.hasProperty(value.sourceCode, \"parserServices\");\n\nconst inheriting = (\n prototype: object,\n name: string,\n descriptor: Readonly<PropertyDescriptor>,\n): unknown => Object.create(prototype, { [name]: { ...descriptor, enumerable: true } });\n\nconst parserServicesOf = (context: Context): Option.Option<ParserServices> =>\n programFor({ fileName: context.filename, text: context.sourceCode.text }).pipe(\n Option.flatMap((program) =>\n Option.fromNullishOr(program.getSourceFile(context.filename)).pipe(\n Option.map((sourceFile) => createParserServices({ context, program, sourceFile })),\n ),\n ),\n );\n\nconst withParserServices = (\n context: Context,\n parserServices: () => ParserServices | undefined,\n): TypedContext => {\n const sourceCode = inheriting(context.sourceCode, \"parserServices\", { get: parserServices });\n return Option.liftPredicate(\n inheriting(context, \"sourceCode\", { value: sourceCode }),\n isTypedContext,\n ).pipe(Option.getOrThrowWith(() => new TypeError(\"The rule context has no source code.\")));\n};\n\nconst withTypeInformation = (rule: TypedRule): CreateRule => ({\n meta: rule.meta,\n create: (context) =>\n parserServicesOf(context).pipe(\n Option.map((parserServices) =>\n rule.create(withParserServices(context, () => parserServices)),\n ),\n Option.getOrElse(() => ({})),\n ),\n});\n\nconst withOptionalTypeInformation = (rule: TypedRule): CreateRule => ({\n meta: rule.meta,\n create: (context) =>\n rule.create(\n withParserServices(\n context,\n lazily(() => Option.getOrUndefined(parserServicesOf(context))),\n ),\n ),\n});\n\nconst typedRules = (\n rules: Record.ReadonlyRecord<string, unknown>,\n): Record.ReadonlyRecord<string, CreateRule> =>\n pipe(rules, Record.filter(isTypedRule), Record.map(withTypeInformation));\n\nconst optionallyTypedRules = (\n rules: Record.ReadonlyRecord<string, unknown>,\n): Record.ReadonlyRecord<string, CreateRule> =>\n pipe(rules, Record.filter(isTypedRule), Record.map(withOptionalTypeInformation));\n\nexport type { TypedContext, TypedRule, TypedSourceCode };\nexport {\n isTypedR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C,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":"upstream-plugin-DqJEA6iy.mjs","names":["Arr","Str"],"sources":["../src/upstream-plugin.ts"],"sourcesContent":["import { Array as Arr, Option, Predicate, Record, Schema, String as Str, pipe } from \"effect\";\nimport type { CreateRule, Plugin } from \"vite-plus/lint/plugins\";\n\nimport { rulesOf } from \"./config-rules.ts\";\n\nconst Severities: Schema.Literals<readonly [\"error\", \"warn\", \"off\"]> = Schema.Literals([\n \"error\",\n \"warn\",\n \"off\",\n]);\n\ntype Severity = typeof Severities.Type;\n\ninterface Config {\n readonly rules?: Readonly<Record<string, Severity>> | undefined;\n}\n\ntype UpstreamPlugin<ConfigName extends string> = Plugin & {\n readonly meta: { readonly name: string };\n readonly configs: Readonly<Record<ConfigName, Config>>;\n};\n\ninterface Upstream<ConfigName extends string> {\n readonly rules: Readonly<Record<string, unknown>>;\n readonly configs: Readonly<Record<ConfigName, unknown>>;\n}\n\ntype RulesOf = (rules: Readonly<Record<string, unknown>>) => Readonly<Record<string, CreateRule>>;\n\nconst isRule = (rule: unknown): rule is CreateRule =>\n Predicate.hasProperty(rule, \"create\") && Predicate.isFunction(rule.create);\n\nconst plainRules: RulesOf = Record.filter(isRule);\n\nconst ruleIdOf = (key: string): string => Arr.lastNonEmpty(Str.split(key, \"/\"));\n\nconst configOf =\n (name: string) =>\n (config: unknown): Config => ({\n rules: pipe(\n Arr.ensure(config),\n Arr.flatMap((entry) => Option.toArray(rulesOf(entry))),\n Arr.flatMap(Record.toEntries),\n Record.fromEntries,\n Record.filter(Schema.is(Severities)),\n Record.mapKeys((key) => `${name}/${ruleIdOf(key)}`),\n ),\n });\n\nconst upstreamPlugin = <ConfigName extends string>(\n name: string,\n upstream: Upstream<ConfigName>,\n rulesOfUpstream: RulesOf,\n): UpstreamPlugin<ConfigName> => ({\n meta: { name },\n configs: pipe(upstream.configs, Record.map(configOf(name))),\n rules: rulesOfUpstream(upstream.rules),\n});\n\nexport type { Config, RulesOf, Severity, Upstream, UpstreamPlugin };\nexport { plainRules, upstreamPlugin };\n"],"mappings":";;;AAKA,MAAM,aAAiE,OAAO,SAAS;CACrF;CACA;CACA;AACF,CAAC;AAoBD,MAAM,UAAU,SACd,UAAU,YAAY,MAAM,QAAQ,KAAK,UAAU,WAAW,KAAK,MAAM;AAE3E,MAAM,aAAsB,OAAO,OAAO,MAAM;AAEhD,MAAM,YAAY,QAAwBA,MAAI,aAAaC,OAAI,MAAM,KAAK,GAAG,CAAC;AAE9E,MAAM,YACH,UACA,YAA6B,EAC5B,OAAO,KACLD,MAAI,OAAO,MAAM,GACjBA,MAAI,SAAS,UAAU,OAAO,QAAQ,QAAQ,KAAK,CAAC,CAAC,GACrDA,MAAI,QAAQ,OAAO,SAAS,GAC5B,OAAO,aACP,OAAO,OAAO,OAAO,GAAG,UAAU,CAAC,GACnC,OAAO,SAAS,QAAQ,GAAG,KAAK,GAAG,SAAS,GAAG,GAAG,CACpD,EACF;AAEF,MAAM,kBACJ,MACA,UACA,qBACgC;CAChC,MAAM,EAAE,KAAK;CACb,SAAS,KAAK,SAAS,SAAS,OAAO,IAAI,SAAS,IAAI,CAAC,CAAC;CAC1D,OAAO,gBAAgB,SAAS,KAAK;AACvC"}