corsa-oxlint 0.44.0 → 0.46.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +19 -4
- package/dist/oxlint_utils.d.ts +4 -6
- package/dist/oxlint_utils.js.map +1 -1
- package/dist/plugin.d.ts +14 -2
- package/dist/plugin.js.map +1 -1
- package/dist/rule_tester.js +53 -25
- package/dist/rule_tester.js.map +1 -1
- package/dist/session.d.ts +7 -0
- package/dist/session.js +68 -6
- package/dist/session.js.map +1 -1
- package/package.json +9 -4
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { oxlintCompat, oxlint_compat_d_exports } from "./oxlint_compat.js";
|
|
|
6
6
|
import { ts_utils_d_exports } from "./ts_utils.js";
|
|
7
7
|
import { utils_d_exports } from "./utils.js";
|
|
8
8
|
import { getParserServices } from "./parser_services.js";
|
|
9
|
-
import { Plugin, Rule, RuleContext, RuleDefinition, RuleDiagnostic, RuleMetaWithMessages, compatPlugin, definePlugin, defineRule } from "./plugin.js";
|
|
9
|
+
import { Plugin, Rule, RuleContext, RuleDefinition, RuleDiagnostic, RuleDocs, RuleMetaWithMessages, compatPlugin, definePlugin, defineRule } from "./plugin.js";
|
|
10
10
|
import { ESLintUtils, OxlintUtils, RuleCreator } from "./oxlint_utils.js";
|
|
11
11
|
import { RuleTester, RuleTesterConfig } from "./rule_tester.js";
|
|
12
12
|
import { TSESLint } from "./ts_eslint.js";
|
|
@@ -18,13 +18,14 @@ import { ESTree as ESTree$1 } from "@oxlint/plugins";
|
|
|
18
18
|
type CorsaAstNodeType = keyof typeof AST_NODE_TYPES;
|
|
19
19
|
type ESTree = ESTree.NodeTypes;
|
|
20
20
|
declare namespace ESTree {
|
|
21
|
-
|
|
21
|
+
type OxlintNode = ESTree$1.Node;
|
|
22
22
|
type NarrowNode<Candidate, Kind extends string> = Candidate extends {
|
|
23
23
|
readonly type: infer CandidateKind;
|
|
24
24
|
} ? Kind extends CandidateKind ? Candidate & {
|
|
25
25
|
readonly type: Kind;
|
|
26
26
|
} : never : never;
|
|
27
|
-
export type NodeByType<Kind extends string> = NarrowNode<
|
|
27
|
+
export type NodeByType<Kind extends string> = Kind extends string ? NarrowNode<OxlintNode, Kind> : never;
|
|
28
|
+
export type Node = { [Kind in CorsaAstNodeType]: NodeByType<Kind> }[CorsaAstNodeType] | BindingIdentifier;
|
|
28
29
|
export type AccessorProperty = NodeByType<"AccessorProperty">;
|
|
29
30
|
export type ArrayExpression = NodeByType<"ArrayExpression">;
|
|
30
31
|
export type ArrayPattern = NodeByType<"ArrayPattern">;
|
|
@@ -197,6 +198,20 @@ declare namespace ESTree {
|
|
|
197
198
|
export type BindingIdentifier = Omit<ESTree$1.BindingIdentifier, "typeAnnotation"> & {
|
|
198
199
|
typeAnnotation?: TSTypeAnnotation | null;
|
|
199
200
|
};
|
|
201
|
+
export type BindingPattern = BindingIdentifier | ObjectPattern | ArrayPattern | AssignmentPattern;
|
|
202
|
+
export type Class = ClassDeclaration | ClassExpression;
|
|
203
|
+
export type Function = FunctionDeclaration | FunctionExpression | TSDeclareFunction | TSEmptyBodyFunctionExpression;
|
|
204
|
+
export type Declaration = VariableDeclaration | Function | Class | TSTypeAliasDeclaration | TSInterfaceDeclaration | TSEnumDeclaration | TSModuleDeclaration | TSImportEqualsDeclaration;
|
|
205
|
+
export type ModuleDeclaration = ImportDeclaration | ExportAllDeclaration | ExportDefaultDeclaration | ExportNamedDeclaration | TSExportAssignment | TSNamespaceExportDeclaration;
|
|
206
|
+
export type Statement = BlockStatement | BreakStatement | ContinueStatement | DebuggerStatement | DoWhileStatement | EmptyStatement | ExpressionStatement | ForInStatement | ForOfStatement | ForStatement | IfStatement | LabeledStatement | ReturnStatement | SwitchStatement | ThrowStatement | TryStatement | WhileStatement | WithStatement | Declaration | ModuleDeclaration;
|
|
207
|
+
export type Expression = Literal | TemplateLiteral | Identifier | MetaProperty | Super | ArrayExpression | ArrowFunctionExpression | AssignmentExpression | AwaitExpression | BinaryExpression | CallExpression | ChainExpression | Class | ConditionalExpression | Function | ImportExpression | LogicalExpression | NewExpression | ObjectExpression | SequenceExpression | TaggedTemplateExpression | ThisExpression | UnaryExpression | UpdateExpression | YieldExpression | JSXElement | JSXFragment | TSAsExpression | TSSatisfiesExpression | TSTypeAssertion | TSNonNullExpression | TSInstantiationExpression | MemberExpression;
|
|
208
|
+
export type SimpleAssignmentTarget = Identifier | TSAsExpression | TSSatisfiesExpression | TSNonNullExpression | TSTypeAssertion | MemberExpression;
|
|
209
|
+
export type AssignmentTarget = SimpleAssignmentTarget | ArrayPattern | ObjectPattern;
|
|
210
|
+
export type ChainElement = CallExpression | TSNonNullExpression | MemberExpression;
|
|
211
|
+
export type FormalParameter = BindingPattern;
|
|
212
|
+
export type FormalParameterRest = RestElement;
|
|
213
|
+
export type ParamPattern = FormalParameter | TSParameterProperty | FormalParameterRest;
|
|
214
|
+
export type ClassElement = StaticBlock | MethodDefinition | TSAbstractMethodDefinition | PropertyDefinition | TSAbstractPropertyDefinition | AccessorProperty | TSAbstractAccessorProperty | TSIndexSignature;
|
|
200
215
|
export type NodeTypes = { [Kind in CorsaAstNodeType]: NodeByType<Kind> } & {
|
|
201
216
|
BindingIdentifier: BindingIdentifier;
|
|
202
217
|
Identifier: Identifier | BindingIdentifier;
|
|
@@ -206,5 +221,5 @@ declare namespace ESTree {
|
|
|
206
221
|
export {};
|
|
207
222
|
}
|
|
208
223
|
//#endregion
|
|
209
|
-
export { ast_utils_d_exports as ASTUtils, AST_NODE_TYPES, AST_TOKEN_TYPES, type ContextWithParserOptions, type CorsaNode, type CorsaOxlintSettings, type CorsaProgramShape, type CorsaRuntimeOptions, type CorsaSignature, type CorsaStylisticSettings, type CorsaSymbol, type CorsaType, type CorsaTypeCheckerShape, ESLintUtils, ESTree, json_schema_d_exports as JSONSchema, oxlint_compat_d_exports as OxlintCompat, OxlintUtils, type ParserServices, type ParserServicesWithTypeInformation, type Plugin, type ProjectServiceOptions, type Rule, type RuleContext, RuleCreator, type RuleDefinition, type RuleDiagnostic, type RuleMetaWithMessages, RuleTester, type RuleTesterConfig, SignatureKind, TSESLint, TSESTree, ts_utils_d_exports as TSUtils, type TypeAwareParserOptions, utils_d_exports as Utils, compatPlugin, definePlugin, defineRule, getParserServices, oxlintCompat, index_d_exports as rules, stylistic_d_exports as stylistic };
|
|
224
|
+
export { ast_utils_d_exports as ASTUtils, AST_NODE_TYPES, AST_TOKEN_TYPES, type ContextWithParserOptions, type CorsaNode, type CorsaOxlintSettings, type CorsaProgramShape, type CorsaRuntimeOptions, type CorsaSignature, type CorsaStylisticSettings, type CorsaSymbol, type CorsaType, type CorsaTypeCheckerShape, ESLintUtils, ESTree, json_schema_d_exports as JSONSchema, oxlint_compat_d_exports as OxlintCompat, OxlintUtils, type ParserServices, type ParserServicesWithTypeInformation, type Plugin, type ProjectServiceOptions, type Rule, type RuleContext, RuleCreator, type RuleDefinition, type RuleDiagnostic, type RuleDocs, type RuleMetaWithMessages, RuleTester, type RuleTesterConfig, SignatureKind, TSESLint, TSESTree, ts_utils_d_exports as TSUtils, type TypeAwareParserOptions, utils_d_exports as Utils, compatPlugin, definePlugin, defineRule, getParserServices, oxlintCompat, index_d_exports as rules, stylistic_d_exports as stylistic };
|
|
210
225
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/oxlint_utils.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ContextWithParserOptions, ParserServices } from "./types.js";
|
|
2
2
|
import { getParserServices } from "./parser_services.js";
|
|
3
|
-
import { Rule as Rule$1 } from "./plugin.js";
|
|
4
|
-
import {
|
|
3
|
+
import { Rule as Rule$1, RuleMetaWithMessages } from "./plugin.js";
|
|
4
|
+
import { Visitor } from "@oxlint/plugins";
|
|
5
5
|
|
|
6
6
|
//#region src/bindings/nodejs/corsa_oxlint/ts/oxlint_utils.d.ts
|
|
7
7
|
type RuleCreatorRule<TOptions extends readonly unknown[] = readonly unknown[], TMessageIds extends string = string> = {
|
|
@@ -10,10 +10,8 @@ type RuleCreatorRule<TOptions extends readonly unknown[] = readonly unknown[], T
|
|
|
10
10
|
readonly defaultOptions?: TOptions;
|
|
11
11
|
readonly create: (context: ContextWithParserOptions) => Visitor;
|
|
12
12
|
};
|
|
13
|
-
type RuleCreatorMeta<TMessageIds extends string = string> =
|
|
14
|
-
|
|
15
|
-
};
|
|
16
|
-
type RuleCreatorCreatedRule<TOptions extends readonly unknown[] = readonly [], TMeta extends RuleMeta = RuleMeta> = Rule$1 & {
|
|
13
|
+
type RuleCreatorMeta<TMessageIds extends string = string> = RuleMetaWithMessages<TMessageIds>;
|
|
14
|
+
type RuleCreatorCreatedRule<TOptions extends readonly unknown[] = readonly [], TMeta extends RuleMetaWithMessages = RuleMetaWithMessages> = Rule$1 & {
|
|
17
15
|
readonly defaultOptions: TOptions;
|
|
18
16
|
readonly meta: TMeta & {
|
|
19
17
|
readonly docs: NonNullable<TMeta["docs"]> & {
|
package/dist/oxlint_utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oxlint_utils.js","names":[],"sources":["../ts/oxlint_utils.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"oxlint_utils.js","names":[],"sources":["../ts/oxlint_utils.ts"],"sourcesContent":["import type { Visitor } from \"@oxlint/plugins\";\n\nimport { getParserServices } from \"./parser_services\";\nimport { decorateRule } from \"./plugin\";\nimport type { Rule, RuleMetaWithMessages } from \"./plugin\";\nimport type { ContextWithParserOptions } from \"./types\";\n\nexport type RuleCreatorRule<\n TOptions extends readonly unknown[] = readonly unknown[],\n TMessageIds extends string = string,\n> = {\n readonly name: string;\n readonly meta: RuleCreatorMeta<TMessageIds>;\n readonly defaultOptions?: TOptions;\n readonly create: (context: ContextWithParserOptions) => Visitor;\n};\n\nexport type RuleCreatorMeta<TMessageIds extends string = string> =\n RuleMetaWithMessages<TMessageIds>;\n\nexport type RuleCreatorCreatedRule<\n TOptions extends readonly unknown[] = readonly [],\n TMeta extends RuleMetaWithMessages = RuleMetaWithMessages,\n> = Rule & {\n readonly defaultOptions: TOptions;\n readonly meta: TMeta & {\n readonly docs: NonNullable<TMeta[\"docs\"]> & {\n readonly url: string;\n };\n };\n};\n\ntype RuleCreatorInput<\n TOptions extends readonly unknown[],\n TMessageIds extends string,\n TMeta extends RuleCreatorMeta<TMessageIds>,\n> = Omit<RuleCreatorRule<TOptions, TMessageIds>, \"defaultOptions\" | \"meta\"> & {\n readonly defaultOptions?: TOptions;\n readonly meta: TMeta;\n};\n\nexport interface RuleCreatorFactory {\n <\n TOptions extends readonly unknown[],\n TMessageIds extends string,\n TMeta extends RuleCreatorMeta<TMessageIds>,\n >(\n rule: RuleCreatorInput<TOptions, TMessageIds, TMeta> & {\n readonly defaultOptions: TOptions;\n },\n ): RuleCreatorCreatedRule<TOptions, TMeta>;\n <TMessageIds extends string, TMeta extends RuleCreatorMeta<TMessageIds>>(\n rule: RuleCreatorInput<readonly [], TMessageIds, TMeta> & {\n readonly defaultOptions?: undefined;\n },\n ): RuleCreatorCreatedRule<readonly [], TMeta>;\n}\n\n/**\n * Self-hosted type-aware utilities for Oxlint rules backed by Corsa.\n */\nexport const OxlintUtils = Object.freeze({\n RuleCreator(urlCreator: (ruleName: string) => string): RuleCreatorFactory {\n return ((rule: RuleCreatorRule) => {\n const docs = rule.meta?.docs;\n return decorateRule({\n ...rule,\n meta: {\n ...rule.meta,\n docs: {\n ...docs,\n url: urlCreator(rule.name),\n },\n },\n defaultOptions: rule.defaultOptions ?? [],\n } as unknown as Rule) as never;\n }) as RuleCreatorFactory;\n },\n getParserServices(context: ContextWithParserOptions, allowWithoutFullTypeInformation = false) {\n return getParserServices(context, allowWithoutFullTypeInformation);\n },\n});\n\nexport const NullThrowsReasons = Object.freeze({\n MissingParent: \"Expected node to have a parent.\",\n MissingToken: (token: string, thing: string) => `Expected to find a ${token} for the ${thing}.`,\n});\n\nexport const RuleCreator = Object.assign(OxlintUtils.RuleCreator, {\n withoutDocs<TRule extends Omit<RuleCreatorRule, \"name\">>(\n rule: TRule,\n ): Rule & {\n readonly defaultOptions: TRule extends { readonly defaultOptions: infer TOptions }\n ? TOptions\n : readonly [];\n } {\n return decorateRule({\n ...rule,\n defaultOptions: rule.defaultOptions ?? [],\n } as unknown as Rule) as never;\n },\n});\nexport { getParserServices } from \"./parser_services\";\n\nexport function applyDefault<User extends readonly unknown[], Defaults extends readonly unknown[]>(\n defaultOptions: Defaults,\n userOptions: User | null | undefined,\n): readonly unknown[] {\n const options = structuredClone(defaultOptions) as unknown as unknown[];\n if (userOptions == null) {\n return options;\n }\n options.forEach((option, index) => {\n if (userOptions[index] === undefined) {\n return;\n }\n const userOption = userOptions[index];\n options[index] =\n isObjectNotArray(option) && isObjectNotArray(userOption)\n ? deepMerge(option, userOption)\n : userOption;\n });\n return options;\n}\n\nexport function deepMerge<T>(base: T, override: unknown): T {\n if (isObject(base) && isObject(override)) {\n return Object.fromEntries(\n [...new Set([...Object.keys(base), ...Object.keys(override)])].map((key) => [\n key,\n key in base && key in override\n ? deepMerge((base as any)[key], (override as any)[key])\n : key in base\n ? (base as any)[key]\n : (override as any)[key],\n ]),\n ) as T;\n }\n return (override === undefined ? base : override) as T;\n}\n\nexport function nullThrows<T>(\n value: T | null | undefined,\n message = \"Expected value to be present\",\n): T {\n if (value == null) {\n throw new Error(`Non-null Assertion Failed: ${message}`);\n }\n return value;\n}\n\nexport function isObjectNotArray(value: unknown): value is Record<string, unknown> {\n return isObject(value);\n}\n\nexport const ESLintUtils = Object.freeze({\n NullThrowsReasons,\n RuleCreator,\n applyDefault,\n deepMerge,\n getParserServices,\n isObjectNotArray,\n nullThrows,\n});\n\nfunction isObject(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n"],"mappings":";;;;;;AA6DA,MAAa,cAAc,OAAO,OAAO;CACvC,YAAY,YAA8D;EACxE,SAAS,SAA0B;GACjC,MAAM,OAAO,KAAK,MA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gB,WACd,OACA,UAAU,gCACP;CACH,IAAI,SAAS,MACX,MAAM,IAAI,MAAM,8BAA8B,SAAS;CAEzD,OAAO;AACT;AAEA,SAAgB,iBAAiB,OAAkD;CACjF,OAAO,SAAS,KAAK;AACvB;AAEA,MAAa,cAAc,OAAO,OAAO;CACvC;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAS,SAAS,OAAkD;CAClE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E"}
|
package/dist/plugin.d.ts
CHANGED
|
@@ -13,7 +13,19 @@ type RuleContext<MessageId extends string = string, Options extends readonly unk
|
|
|
13
13
|
readonly options: Readonly<Options>;
|
|
14
14
|
report(this: void, diagnostic: RuleDiagnostic<MessageId>): void;
|
|
15
15
|
};
|
|
16
|
-
type
|
|
16
|
+
type RuleDocs = {
|
|
17
|
+
readonly description?: string;
|
|
18
|
+
readonly recommended?: unknown;
|
|
19
|
+
readonly url?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Enables corsa-oxlint's type-aware parser service defaults for this rule.
|
|
22
|
+
*
|
|
23
|
+
* @default false
|
|
24
|
+
*/
|
|
25
|
+
readonly requiresTypeChecking?: boolean;
|
|
26
|
+
};
|
|
27
|
+
type RuleMetaWithMessages<MessageId extends string = string> = Omit<RuleMeta, "docs" | "messages"> & {
|
|
28
|
+
readonly docs?: RuleDocs;
|
|
17
29
|
readonly messages?: Record<MessageId, string>;
|
|
18
30
|
};
|
|
19
31
|
type RuleDefinition<MessageId extends string = string, Options extends readonly unknown[] = readonly unknown[]> = Record<string, unknown> & {
|
|
@@ -45,5 +57,5 @@ declare function defineRule<MessageId extends string = string, const Options ext
|
|
|
45
57
|
declare function compatPlugin(plugin: Plugin): Plugin;
|
|
46
58
|
declare function decorateRule(rule: Rule): Rule;
|
|
47
59
|
//#endregion
|
|
48
|
-
export { Plugin, Rule, RuleContext, RuleDefinition, RuleDiagnostic, RuleMetaWithMessages, compatPlugin, decorateRule, definePlugin, defineRule };
|
|
60
|
+
export { Plugin, Rule, RuleContext, RuleDefinition, RuleDiagnostic, RuleDocs, RuleMetaWithMessages, compatPlugin, decorateRule, definePlugin, defineRule };
|
|
49
61
|
//# sourceMappingURL=plugin.d.ts.map
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","names":[],"sources":["../ts/plugin.ts"],"sourcesContent":["import * as oxlintPluginApi from \"@oxlint/plugins\";\nimport type {\n Context as OxlintContext,\n Diagnostic,\n Plugin as OxlintPlugin,\n Rule as OxlintRule,\n RuleMeta,\n Visitor,\n VisitorWithHooks,\n} from \"@oxlint/plugins\";\n\nimport { resolveTypeAwareParserOptions } from \"./context\";\nimport { getParserServices } from \"./parser_services\";\nimport type { ContextWithParserOptions, ParserServices } from \"./types\";\n\nexport type Plugin = Omit<OxlintPlugin, \"rules\"> & {\n readonly rules: Record<string, Rule>;\n} & Record<string, unknown>;\nexport type Rule = OxlintRule & Record<string, unknown>;\nexport type RuleDiagnostic<MessageId extends string = string> = Diagnostic & {\n readonly messageId?: MessageId | null | undefined;\n};\nexport type RuleContext<\n MessageId extends string = string,\n Options extends readonly unknown[] = readonly unknown[],\n> = Omit<ContextWithParserOptions, \"options\" | \"report\"> & {\n readonly options: Readonly<Options>;\n report(this: void, diagnostic: RuleDiagnostic<MessageId>): void;\n};\nexport type RuleMetaWithMessages<MessageId extends string = string> =
|
|
1
|
+
{"version":3,"file":"plugin.js","names":[],"sources":["../ts/plugin.ts"],"sourcesContent":["import * as oxlintPluginApi from \"@oxlint/plugins\";\nimport type {\n Context as OxlintContext,\n Diagnostic,\n Plugin as OxlintPlugin,\n Rule as OxlintRule,\n RuleMeta as OxlintRuleMeta,\n Visitor,\n VisitorWithHooks,\n} from \"@oxlint/plugins\";\n\nimport { resolveTypeAwareParserOptions } from \"./context\";\nimport { getParserServices } from \"./parser_services\";\nimport type { ContextWithParserOptions, ParserServices } from \"./types\";\n\nexport type Plugin = Omit<OxlintPlugin, \"rules\"> & {\n readonly rules: Record<string, Rule>;\n} & Record<string, unknown>;\nexport type Rule = OxlintRule & Record<string, unknown>;\nexport type RuleDiagnostic<MessageId extends string = string> = Diagnostic & {\n readonly messageId?: MessageId | null | undefined;\n};\nexport type RuleContext<\n MessageId extends string = string,\n Options extends readonly unknown[] = readonly unknown[],\n> = Omit<ContextWithParserOptions, \"options\" | \"report\"> & {\n readonly options: Readonly<Options>;\n report(this: void, diagnostic: RuleDiagnostic<MessageId>): void;\n};\nexport type RuleDocs = {\n readonly description?: string;\n readonly recommended?: unknown;\n readonly url?: string;\n /**\n * Enables corsa-oxlint's type-aware parser service defaults for this rule.\n *\n * @default false\n */\n readonly requiresTypeChecking?: boolean;\n};\nexport type RuleMetaWithMessages<MessageId extends string = string> = Omit<\n OxlintRuleMeta,\n \"docs\" | \"messages\"\n> & {\n readonly docs?: RuleDocs;\n readonly messages?: Record<MessageId, string>;\n};\nexport type RuleDefinition<\n MessageId extends string = string,\n Options extends readonly unknown[] = readonly unknown[],\n> = Record<string, unknown> & {\n readonly defaultOptions?: Options;\n readonly meta?: RuleMetaWithMessages<MessageId>;\n} & (\n | {\n readonly create: (context: RuleContext<MessageId, Options>) => Visitor;\n readonly createOnce?: never;\n }\n | {\n readonly create?: (context: RuleContext<MessageId, Options>) => Visitor;\n readonly createOnce: (context: RuleContext<MessageId, Options>) => VisitorWithHooks;\n }\n );\n\nconst defineOxlintPlugin = oxlintPluginApi.definePlugin;\nconst defineOxlintRule = oxlintPluginApi.defineRule;\nconst baseCompatPlugin = Reflect.get(\n oxlintPluginApi as object,\n [\"es\", \"lintCompatPlugin\"].join(\"\"),\n) as typeof oxlintPluginApi.definePlugin;\n\nexport function definePlugin(plugin: Plugin): Plugin {\n return defineOxlintPlugin({\n ...plugin,\n rules: wrapRules(plugin.rules ?? {}),\n } as OxlintPlugin) as Plugin;\n}\n\n/**\n * Defines a single Oxlint rule with type-aware parser services.\n *\n * @example\n * ```ts\n * export default defineRule({\n * meta: { schema: [], messages: { demo: \"demo\" } },\n * create(context) {\n * const services = context.parserServices;\n * return {};\n * },\n * });\n * ```\n */\nexport function defineRule<\n MessageId extends string = string,\n const Options extends readonly unknown[] = readonly unknown[],\n>(rule: RuleDefinition<MessageId, Options>): Rule;\nexport function defineRule(rule: Rule): Rule {\n return defineOxlintRule(decorateRule(rule) as OxlintRule) as Rule;\n}\n\nexport function compatPlugin(plugin: Plugin): Plugin {\n return baseCompatPlugin(definePlugin(plugin)) as Plugin;\n}\n\nexport function decorateRule(rule: Rule): Rule {\n if (rule.create) {\n return {\n ...rule,\n create(context) {\n return rule.create!(decorateContext(context, rule));\n },\n } as Rule;\n }\n if (\"createOnce\" in rule && typeof (rule as any).createOnce === \"function\") {\n return {\n ...rule,\n createOnce(context) {\n return (rule as any).createOnce(decorateContext(context, rule));\n },\n } as Rule;\n }\n return rule;\n}\n\nfunction wrapRules(rules: Record<string, Rule>): Record<string, Rule> {\n return Object.fromEntries(\n Object.entries(rules).map(([name, rule]) => [name, decorateRule(rule)]),\n );\n}\n\nfunction decorateContext(context: ContextWithParserOptions, rule: Rule): ContextWithParserOptions {\n const typeAware = requiresTypeChecking(rule);\n const parserOptions = Object.freeze(\n resolveTypeAwareParserOptions(context, {\n corsa: typeAware,\n projectService: typeAware,\n }),\n );\n const baseLanguageOptions = context.languageOptions;\n const languageOptions = Object.freeze({\n ...baseLanguageOptions,\n parserOptions,\n });\n return Object.create(context as OxlintContext, {\n languageOptions: {\n configurable: true,\n enumerable: true,\n get() {\n return languageOptions;\n },\n },\n parserOptions: {\n configurable: true,\n enumerable: false,\n get() {\n return parserOptions;\n },\n },\n parserServices: {\n configurable: true,\n enumerable: false,\n get(): ParserServices {\n return getParserServices(context);\n },\n },\n }) as ContextWithParserOptions;\n}\n\nfunction requiresTypeChecking(rule: Rule): boolean {\n return (\n (rule.meta as { readonly docs?: { readonly requiresTypeChecking?: unknown } } | undefined)?.docs\n ?.requires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,OAAO;GACT;EACF;EACA,eAAe;GACb,cAAc;GACd,YAAY;GACZ,MAAM;IACJ,OAAO;GACT;EACF;EACA,gBAAgB;GACd,cAAc;GACd,YAAY;GACZ,MAAsB;IACpB,OAAO,kBAAkB,OAAO;GAClC;EACF;CACF,CAAC;AACH;AAEA,SAAS,qBAAqB,MAAqB;CACjD,OACG,KAAK,MAAsF,MACxF,yBAAyB;AAEjC"}
|
package/dist/rule_tester.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defaultCorsaExecutable, mergeTypeAwareParserOptions } from "./context.js";
|
|
2
2
|
import { decorateRule } from "./plugin.js";
|
|
3
3
|
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
4
|
-
import { dirname, join, resolve } from "node:path";
|
|
4
|
+
import { dirname, isAbsolute, join, resolve } from "node:path";
|
|
5
5
|
import { tmpdir } from "node:os";
|
|
6
6
|
import { RuleTester as RuleTester$1 } from "oxlint/plugins-dev";
|
|
7
7
|
//#region src/bindings/nodejs/corsa_oxlint/ts/rule_tester.ts
|
|
@@ -44,56 +44,65 @@ var RuleTester = class {
|
|
|
44
44
|
this.#inner = new RuleTester$1(config);
|
|
45
45
|
}
|
|
46
46
|
run(ruleName, rule, tests) {
|
|
47
|
+
const workspace = createWorkspace();
|
|
48
|
+
writeWorkspaceConfig(workspace);
|
|
47
49
|
const transformed = {
|
|
48
|
-
valid: tests.valid.map((test, index) => prepareTestCase(
|
|
49
|
-
invalid: tests.invalid.map((test, index) => prepareTestCase(
|
|
50
|
+
valid: tests.valid.map((test, index) => prepareTestCase(workspace, test, this.#config, "valid", index)),
|
|
51
|
+
invalid: tests.invalid.map((test, index) => prepareTestCase(workspace, test, this.#config, "invalid", index))
|
|
50
52
|
};
|
|
51
|
-
|
|
53
|
+
try {
|
|
54
|
+
this.#inner.run(ruleName, decorateRule(rule), transformed);
|
|
55
|
+
} finally {
|
|
56
|
+
cleanupWorkspace(workspace);
|
|
57
|
+
}
|
|
52
58
|
}
|
|
53
59
|
};
|
|
54
60
|
function createWorkspace() {
|
|
55
|
-
const workspace = mkdtempSync(join(tmpdir(), "corsa-oxlint-"));
|
|
61
|
+
const workspace = mkdtempSync(join(process.env.CORSA_OXLINT_RULE_TESTER_TMPDIR ?? tmpdir(), "corsa-oxlint-"));
|
|
56
62
|
registerCleanup(workspace);
|
|
57
63
|
return workspace;
|
|
58
64
|
}
|
|
59
65
|
function prepareTestCase(workspace, test, config, group, index) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
writeFixture(filename, test.code);
|
|
66
|
+
const caseWorkspace = resolve(workspace, `${group}-${index}`);
|
|
67
|
+
const normalized = typeof test === "string" ? { code: test } : test;
|
|
68
|
+
const filename = resolveCaseFilename(caseWorkspace, normalized.filename, "case.ts");
|
|
69
|
+
const projectRoot = isAbsolute(normalized.filename ?? "") ? dirname(filename) : workspace;
|
|
70
|
+
writeFixture(filename, normalized.code, projectRoot);
|
|
66
71
|
const testerConfig = config;
|
|
67
72
|
const baseSettings = testerConfig?.settings?.corsaOxlint;
|
|
68
|
-
const caseSettings =
|
|
73
|
+
const caseSettings = normalized.settings?.corsaOxlint;
|
|
69
74
|
const parserOptionsWithRuntime = applyRuleTesterRuntimeDefaults(mergeTypeAwareParserOptions(mergeTypeAwareParserOptions(mergeTypeAwareParserOptions(mergeTypeAwareParserOptions(baseSettings, baseSettings?.parserOptions), mergeTypeAwareParserOptions(caseSettings, caseSettings?.parserOptions)), {
|
|
70
|
-
tsconfigRootDir:
|
|
75
|
+
tsconfigRootDir: projectRoot,
|
|
71
76
|
projectService: { allowDefaultProject: [
|
|
72
77
|
"*.ts",
|
|
73
78
|
"*.tsx",
|
|
74
79
|
"*.js",
|
|
75
80
|
"*.jsx"
|
|
76
81
|
] }
|
|
77
|
-
}), mergeTypeAwareParserOptions(config?.languageOptions?.parserOptions,
|
|
82
|
+
}), mergeTypeAwareParserOptions(config?.languageOptions?.parserOptions, normalized.languageOptions?.parserOptions)), normalized, config);
|
|
78
83
|
return {
|
|
79
|
-
...
|
|
84
|
+
...normalized,
|
|
80
85
|
filename,
|
|
81
86
|
settings: {
|
|
82
87
|
...testerConfig?.settings,
|
|
83
|
-
...
|
|
88
|
+
...normalized.settings,
|
|
84
89
|
corsaOxlint: {
|
|
85
90
|
...testerConfig?.settings?.corsaOxlint,
|
|
86
|
-
...
|
|
91
|
+
...normalized.settings?.corsaOxlint,
|
|
87
92
|
parserOptions: parserOptionsWithRuntime
|
|
88
93
|
}
|
|
89
94
|
},
|
|
90
95
|
languageOptions: {
|
|
91
96
|
...config?.languageOptions,
|
|
92
|
-
...
|
|
97
|
+
...normalized.languageOptions,
|
|
93
98
|
parserOptions: { ...parserOptionsWithRuntime }
|
|
94
99
|
}
|
|
95
100
|
};
|
|
96
101
|
}
|
|
102
|
+
function resolveCaseFilename(caseWorkspace, filename, fallback) {
|
|
103
|
+
if (!filename) return resolve(caseWorkspace, fallback);
|
|
104
|
+
return isAbsolute(filename) ? filename : resolve(caseWorkspace, filename);
|
|
105
|
+
}
|
|
97
106
|
function applyRuleTesterRuntimeDefaults(parserOptions, test, config) {
|
|
98
107
|
if (parserOptions.corsa?.executable !== void 0) return parserOptions;
|
|
99
108
|
const rootDir = resolve(test.cwd ?? config?.cwd ?? process.cwd());
|
|
@@ -108,10 +117,17 @@ function optionalDefaultCorsaExecutable(rootDir) {
|
|
|
108
117
|
return;
|
|
109
118
|
}
|
|
110
119
|
}
|
|
111
|
-
function
|
|
120
|
+
function writeWorkspaceConfig(workspace) {
|
|
121
|
+
writeProjectConfig(resolve(workspace, "tsconfig.json"));
|
|
122
|
+
}
|
|
123
|
+
function writeFixture(filename, code, projectRoot) {
|
|
112
124
|
mkdirSync(dirname(filename), { recursive: true });
|
|
113
125
|
writeFileSync(filename, code);
|
|
114
|
-
|
|
126
|
+
writeProjectConfig(resolve(projectRoot, "tsconfig.json"));
|
|
127
|
+
}
|
|
128
|
+
function writeProjectConfig(configPath) {
|
|
129
|
+
mkdirSync(dirname(configPath), { recursive: true });
|
|
130
|
+
writeFileSync(configPath, JSON.stringify({
|
|
115
131
|
compilerOptions: {
|
|
116
132
|
module: "esnext",
|
|
117
133
|
target: "es2022",
|
|
@@ -122,15 +138,27 @@ function writeFixture(filename, code) {
|
|
|
122
138
|
}
|
|
123
139
|
function registerCleanup(workspace) {
|
|
124
140
|
cleanupDirs.add(workspace);
|
|
141
|
+
const afterAll = lifecycleCleanup();
|
|
142
|
+
if (afterAll) afterAll(() => cleanupWorkspace(workspace));
|
|
125
143
|
if (cleanupInstalled) return;
|
|
126
144
|
cleanupInstalled = true;
|
|
127
|
-
process.
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
145
|
+
process.once("beforeExit", cleanupAllWorkspaces);
|
|
146
|
+
process.once("exit", cleanupAllWorkspaces);
|
|
147
|
+
}
|
|
148
|
+
function lifecycleCleanup() {
|
|
149
|
+
const testGlobal = globalThis;
|
|
150
|
+
return typeof testGlobal.afterAll === "function" ? testGlobal.afterAll : typeof testGlobal.after === "function" ? testGlobal.after : void 0;
|
|
151
|
+
}
|
|
152
|
+
function cleanupWorkspace(workspace) {
|
|
153
|
+
if (!cleanupDirs.delete(workspace)) return;
|
|
154
|
+
rmSync(workspace, {
|
|
155
|
+
force: true,
|
|
156
|
+
recursive: true
|
|
132
157
|
});
|
|
133
158
|
}
|
|
159
|
+
function cleanupAllWorkspaces() {
|
|
160
|
+
for (const dir of cleanupDirs) cleanupWorkspace(dir);
|
|
161
|
+
}
|
|
134
162
|
//#endregion
|
|
135
163
|
export { RuleTester };
|
|
136
164
|
|
package/dist/rule_tester.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rule_tester.js","names":["OxlintRuleTester","#inner","#config"],"sources":["../ts/rule_tester.ts"],"sourcesContent":["import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport { dirname, join, resolve } from \"node:path\";\n\nimport { RuleTester as OxlintRuleTester } from \"oxlint/plugins-dev\";\n\nimport { defaultCorsaExecutable, mergeTypeAwareParserOptions } from \"./context\";\nimport { decorateRule } from \"./plugin\";\nimport type { CorsaOxlintSettings, TypeAwareParserOptions } from \"./types\";\n\ntype TesterConfig = import(\"oxlint/plugins-dev\").RuleTester.Config;\ntype TestCase = import(\"oxlint/plugins-dev\").RuleTester.ValidTestCase &\n Partial<import(\"oxlint/plugins-dev\").RuleTester.InvalidTestCase>;\ntype TestCases = import(\"oxlint/plugins-dev\").RuleTester.TestCases;\nexport type RuleTesterConfig = TesterConfig & {\n readonly settings?: {\n readonly corsaOxlint?: CorsaOxlintSettings;\n readonly [key: string]: unknown;\n };\n};\n\nconst cleanupDirs = new Set<string>();\nlet cleanupInstalled = false;\n\nexport class RuleTester {\n /**\n * A thin Oxlint `RuleTester` wrapper that injects\n * `settings.corsaOxlint`\n * settings, temporary fixtures, and a default project service.\n *\n * @example\n * ```ts\n * const tester = new RuleTester();\n * tester.run(\"demo\", rule, {\n * valid: [{ code: \"const answer = 42;\" }],\n * invalid: [],\n * });\n * ```\n */\n static get describe() {\n return OxlintRuleTester.describe;\n }\n\n static set describe(value) {\n OxlintRuleTester.describe = value;\n }\n\n static get it() {\n return OxlintRuleTester.it;\n }\n\n static set it(value) {\n OxlintRuleTester.it = value;\n }\n\n static only(item: string | TestCase): TestCase {\n return OxlintRuleTester.only(item);\n }\n\n readonly #inner: OxlintRuleTester;\n readonly #config?: RuleTesterConfig;\n\n constructor(config?: RuleTesterConfig) {\n this.#config = config;\n this.#inner = new OxlintRuleTester(config);\n }\n\n run(ruleName: string, rule: Record<string, unknown>, tests: TestCases): void {\n const transformed = {\n valid: tests.valid.map((test, index) =>\n prepareTestCase(createWorkspace(), test, this.#config, \"valid\", index),\n ),\n invalid: tests.invalid.map((test, index) =>\n prepareTestCase(createWorkspace(), test, this.#config, \"invalid\", index),\n ),\n };\n this.#inner.run(ruleName, decorateRule(rule as never) as never, transformed as TestCases);\n }\n}\n\nfunction createWorkspace(): string {\n const workspace = mkdtempSync(join(tmpdir(), \"corsa-oxlint-\"));\n registerCleanup(workspace);\n return workspace;\n}\n\nfunction prepareTestCase(\n workspace: string,\n test: string | TestCase,\n config: RuleTesterConfig | undefined,\n group: \"valid\" | \"invalid\",\n index: number,\n): string | TestCase {\n if (typeof test === \"string\") {\n const filename = resolve(workspace, `${group}-${index}.ts`);\n writeFixture(filename, test);\n return test;\n }\n const filename = resolve(workspace, test.filename ?? `${group}-${index}.ts`);\n writeFixture(filename, test.code);\n const testerConfig = config;\n const baseSettings = testerConfig?.settings?.corsaOxlint;\n const caseSettings = (\n test.settings as {\n corsaOxlint?: CorsaOxlintSettings;\n }\n )?.corsaOxlint;\n const parserOptions = mergeTypeAwareParserOptions(\n mergeTypeAwareParserOptions(\n mergeTypeAwareParserOptions(\n mergeTypeAwareParserOptions(baseSettings, baseSettings?.parserOptions),\n mergeTypeAwareParserOptions(caseSettings, caseSettings?.parserOptions),\n ),\n {\n tsconfigRootDir: workspace,\n projectService: {\n allowDefaultProject: [\"*.ts\", \"*.tsx\", \"*.js\", \"*.jsx\"],\n },\n },\n ),\n mergeTypeAwareParserOptions(\n config?.languageOptions?.parserOptions as TypeAwareParserOptions | undefined,\n test.languageOptions?.parserOptions as TypeAwareParserOptions | undefined,\n ),\n );\n const parserOptionsWithRuntime = applyRuleTesterRuntimeDefaults(parserOptions, test, config);\n return {\n ...test,\n filename,\n settings: {\n ...testerConfig?.settings,\n ...test.settings,\n corsaOxlint: {\n ...testerConfig?.settings?.corsaOxlint,\n ...(test.settings as { corsaOxlint?: CorsaOxlintSettings })?.corsaOxlint,\n parserOptions: parserOptionsWithRuntime,\n },\n } as never,\n languageOptions: {\n ...config?.languageOptions,\n ...test.languageOptions,\n parserOptions: {\n ...parserOptionsWithRuntime,\n } as never,\n },\n };\n}\n\nfunction applyRuleTesterRuntimeDefaults(\n parserOptions: TypeAwareParserOptions,\n test: TestCase,\n config: RuleTesterConfig | undefined,\n): TypeAwareParserOptions {\n if (parserOptions.corsa?.executable !== undefined) {\n return parserOptions;\n }\n const rootDir = resolve(test.cwd ?? config?.cwd ?? process.cwd());\n const executable = process.env.CORSA_EXECUTABLE ?? optionalDefaultCorsaExecutable(rootDir);\n if (!executable) {\n return parserOptions;\n }\n return mergeTypeAwareParserOptions(parserOptions, {\n corsa: {\n executable,\n },\n });\n}\n\nfunction optionalDefaultCorsaExecutable(rootDir: string): string | undefined {\n try {\n return defaultCorsaExecutable(rootDir);\n } catch {\n return undefined;\n }\n}\n\nfunction writeFixture(filename: string, code: string): void {\n mkdirSync(dirname(filename), { recursive: true });\n writeFileSync(filename, code);\n const configPath = resolve(dirname(filename), \"tsconfig.json\");\n writeFileSync(\n configPath,\n JSON.stringify(\n {\n compilerOptions: {\n module: \"esnext\",\n target: \"es2022\",\n strict: true,\n },\n include: [\"**/*\"],\n },\n null,\n 2,\n ),\n );\n}\n\nfunction registerCleanup(workspace: string): void {\n cleanupDirs.add(workspace);\n if (cleanupInstalled) {\n return;\n }\n cleanupInstalled = true;\n process.on(\"exit\", () => {\n for (const dir of cleanupDirs) {\n rmSync(dir, { force: true, recursive: true });\n }\n });\n}\n"],"mappings":";;;;;;;AAqBA,MAAM,8BAAc,IAAI,IAAY;AACpC,IAAI,mBAAmB;AAEvB,IAAa,aAAb,MAAwB;;;;;;;;;;;;;;;CAetB,WAAW,WAAW;EACpB,OAAOA,aAAiB;CAC1B;CAEA,WAAW,SAAS,OAAO;EACzB,aAAiB,WAAW;CAC9B;CAEA,WAAW,KAAK;EACd,OAAOA,aAAiB;CAC1B;CAEA,WAAW,GAAG,OAAO;EACnB,aAAiB,KAAK;CACxB;CAEA,OAAO,KAAK,MAAmC;EAC7C,OAAOA,aAAiB,KAAK,IAAI;CACnC;CAEA;CACA;CAEA,YAAY,QAA2B;EACrC,KAAKE,UAAU;EACf,KAAKD,SAAS,IAAID,aAAiB,MAAM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ACjB;EACF;EACA,iBAAiB;GACf,GAAG,QAAQ;GACX,GAAG,KAAK;GACR,eAAe,EACb,GAAG,yBACL;EACF;CACF;AACF;AAEA,SAAS,+BACP,eACA,MACA,QACwB;CACxB,IAAI,cAAc,OAAO,eAAe,KAAA,GACtC,OAAO;CAET,MAAM,UAAU,QAAQ,KAAK,OAAO,QAAQ,OAAO,QAAQ,IAAI,CAAC;CAChE,MAAM,aAAa,QAAQ,IAAI,oBAAoB,+BAA+B,OAAO;CACzF,IAAI,CAAC,YACH,OAAO;CAET,OAAO,4BAA4B,eAAe,EAChD,OAAO,EACL,WACF,EACF,CAAC;AACH;AAEA,SAAS,+BAA+B,SAAqC;CAC3E,IAAI;EACF,OAAO,uBAAuB,OAAO;CACvC,QAAQ;EACN;CACF;AACF;AAEA,SAAS,aAAa,UAAkB,MAAoB;CAC1D,UAAU,QAAQ,QAAQ,GAAG,EAAE,WAAW,KAAK,CAAC;CAChD,cAAc,UAAU,IAAI;CAE5B,cADmB,QAAQ,QAAQ,QAAQ,GAAG,eAEnC,GACT,KAAK,UACH;EACE,iBAAiB;GACf,QAAQ;GACR,QAAQ;GACR,QAAQ;EACV;EACA,SAAS,CAAC,MAAM;CAClB,GACA,MACA,CACF,CACF;AACF;AAEA,SAAS,gBAAgB,WAAyB;CAChD,YAAY,IAAI,SAAS;CACzB,IAAI,kBACF;CAEF,mBAAmB;CACnB,QAAQ,GAAG,cAAc;EACvB,KAAK,MAAM,OAAO,aAChB,OAAO,KAAK;GAAE,OAAO;GAAM,WAAW;EAAK,CAAC;CAEhD,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"rule_tester.js","names":["OxlintRuleTester","#inner","#config"],"sources":["../ts/rule_tester.ts"],"sourcesContent":["import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport { dirname, isAbsolute, join, resolve } from \"node:path\";\n\nimport { RuleTester as OxlintRuleTester } from \"oxlint/plugins-dev\";\n\nimport { defaultCorsaExecutable, mergeTypeAwareParserOptions } from \"./context\";\nimport { decorateRule } from \"./plugin\";\nimport type { CorsaOxlintSettings, TypeAwareParserOptions } from \"./types\";\n\ntype TesterConfig = import(\"oxlint/plugins-dev\").RuleTester.Config;\ntype TestCase = import(\"oxlint/plugins-dev\").RuleTester.ValidTestCase &\n Partial<import(\"oxlint/plugins-dev\").RuleTester.InvalidTestCase>;\ntype TestCases = import(\"oxlint/plugins-dev\").RuleTester.TestCases;\nexport type RuleTesterConfig = TesterConfig & {\n readonly settings?: {\n readonly corsaOxlint?: CorsaOxlintSettings;\n readonly [key: string]: unknown;\n };\n};\ntype TestLifecycleGlobal = typeof globalThis & {\n after?: (callback: () => void) => unknown;\n afterAll?: (callback: () => void) => unknown;\n};\n\nconst cleanupDirs = new Set<string>();\nlet cleanupInstalled = false;\n\nexport class RuleTester {\n /**\n * A thin Oxlint `RuleTester` wrapper that injects\n * `settings.corsaOxlint`\n * settings, temporary fixtures, and a default project service.\n *\n * @example\n * ```ts\n * const tester = new RuleTester();\n * tester.run(\"demo\", rule, {\n * valid: [{ code: \"const answer = 42;\" }],\n * invalid: [],\n * });\n * ```\n */\n static get describe() {\n return OxlintRuleTester.describe;\n }\n\n static set describe(value) {\n OxlintRuleTester.describe = value;\n }\n\n static get it() {\n return OxlintRuleTester.it;\n }\n\n static set it(value) {\n OxlintRuleTester.it = value;\n }\n\n static only(item: string | TestCase): TestCase {\n return OxlintRuleTester.only(item);\n }\n\n readonly #inner: OxlintRuleTester;\n readonly #config?: RuleTesterConfig;\n\n constructor(config?: RuleTesterConfig) {\n this.#config = config;\n this.#inner = new OxlintRuleTester(config);\n }\n\n run(ruleName: string, rule: Record<string, unknown>, tests: TestCases): void {\n const workspace = createWorkspace();\n writeWorkspaceConfig(workspace);\n const transformed = {\n valid: tests.valid.map((test, index) =>\n prepareTestCase(workspace, test, this.#config, \"valid\", index),\n ),\n invalid: tests.invalid.map((test, index) =>\n prepareTestCase(workspace, test, this.#config, \"invalid\", index),\n ),\n };\n try {\n this.#inner.run(ruleName, decorateRule(rule as never) as never, transformed as TestCases);\n } finally {\n cleanupWorkspace(workspace);\n }\n }\n}\n\nfunction createWorkspace(): string {\n const root = process.env.CORSA_OXLINT_RULE_TESTER_TMPDIR ?? tmpdir();\n const workspace = mkdtempSync(join(root, \"corsa-oxlint-\"));\n registerCleanup(workspace);\n return workspace;\n}\n\nfunction prepareTestCase(\n workspace: string,\n test: string | TestCase,\n config: RuleTesterConfig | undefined,\n group: \"valid\" | \"invalid\",\n index: number,\n): TestCase {\n const caseWorkspace = resolve(workspace, `${group}-${index}`);\n const normalized = typeof test === \"string\" ? ({ code: test } as TestCase) : test;\n const filename = resolveCaseFilename(caseWorkspace, normalized.filename, \"case.ts\");\n const projectRoot = isAbsolute(normalized.filename ?? \"\") ? dirname(filename) : workspace;\n writeFixture(filename, normalized.code, projectRoot);\n const testerConfig = config;\n const baseSettings = testerConfig?.settings?.corsaOxlint;\n const caseSettings = (\n normalized.settings as {\n corsaOxlint?: CorsaOxlintSettings;\n }\n )?.corsaOxlint;\n const parserOptions = mergeTypeAwareParserOptions(\n mergeTypeAwareParserOptions(\n mergeTypeAwareParserOptions(\n mergeTypeAwareParserOptions(baseSettings, baseSettings?.parserOptions),\n mergeTypeAwareParserOptions(caseSettings, caseSettings?.parserOptions),\n ),\n {\n tsconfigRootDir: projectRoot,\n projectService: {\n allowDefaultProject: [\"*.ts\", \"*.tsx\", \"*.js\", \"*.jsx\"],\n },\n },\n ),\n mergeTypeAwareParserOptions(\n config?.languageOptions?.parserOptions as TypeAwareParserOptions | undefined,\n normalized.languageOptions?.parserOptions as TypeAwareParserOptions | undefined,\n ),\n );\n const parserOptionsWithRuntime = applyRuleTesterRuntimeDefaults(\n parserOptions,\n normalized,\n config,\n );\n return {\n ...normalized,\n filename,\n settings: {\n ...testerConfig?.settings,\n ...normalized.settings,\n corsaOxlint: {\n ...testerConfig?.settings?.corsaOxlint,\n ...(normalized.settings as { corsaOxlint?: CorsaOxlintSettings })?.corsaOxlint,\n parserOptions: parserOptionsWithRuntime,\n },\n } as never,\n languageOptions: {\n ...config?.languageOptions,\n ...normalized.languageOptions,\n parserOptions: {\n ...parserOptionsWithRuntime,\n } as never,\n },\n };\n}\n\nfunction resolveCaseFilename(\n caseWorkspace: string,\n filename: string | undefined,\n fallback: string,\n): string {\n if (!filename) {\n return resolve(caseWorkspace, fallback);\n }\n return isAbsolute(filename) ? filename : resolve(caseWorkspace, filename);\n}\n\nfunction applyRuleTesterRuntimeDefaults(\n parserOptions: TypeAwareParserOptions,\n test: TestCase,\n config: RuleTesterConfig | undefined,\n): TypeAwareParserOptions {\n if (parserOptions.corsa?.executable !== undefined) {\n return parserOptions;\n }\n const rootDir = resolve(test.cwd ?? config?.cwd ?? process.cwd());\n const executable = process.env.CORSA_EXECUTABLE ?? optionalDefaultCorsaExecutable(rootDir);\n if (!executable) {\n return parserOptions;\n }\n return mergeTypeAwareParserOptions(parserOptions, {\n corsa: {\n executable,\n },\n });\n}\n\nfunction optionalDefaultCorsaExecutable(rootDir: string): string | undefined {\n try {\n return defaultCorsaExecutable(rootDir);\n } catch {\n return undefined;\n }\n}\n\nfunction writeWorkspaceConfig(workspace: string): void {\n writeProjectConfig(resolve(workspace, \"tsconfig.json\"));\n}\n\nfunction writeFixture(filename: string, code: string, projectRoot: string): void {\n mkdirSync(dirname(filename), { recursive: true });\n writeFileSync(filename, code);\n writeProjectConfig(resolve(projectRoot, \"tsconfig.json\"));\n}\n\nfunction writeProjectConfig(configPath: string): void {\n mkdirSync(dirname(configPath), { recursive: true });\n writeFileSync(\n configPath,\n JSON.stringify(\n {\n compilerOptions: {\n module: \"esnext\",\n target: \"es2022\",\n strict: true,\n },\n include: [\"**/*\"],\n },\n null,\n 2,\n ),\n );\n}\n\nfunction registerCleanup(workspace: string): void {\n cleanupDirs.add(workspace);\n const afterAll = lifecycleCleanup();\n if (afterAll) {\n afterAll(() => cleanupWorkspace(workspace));\n }\n if (cleanupInstalled) {\n return;\n }\n cleanupInstalled = true;\n process.once(\"beforeExit\", cleanupAllWorkspaces);\n process.once(\"exit\", cleanupAllWorkspaces);\n}\n\nfunction lifecycleCleanup(): ((callback: () => void) => unknown) | undefined {\n const testGlobal = globalThis as TestLifecycleGlobal;\n return typeof testGlobal.afterAll === \"function\"\n ? testGlobal.afterAll\n : typeof testGlobal.after === \"function\"\n ? testGlobal.after\n : undefined;\n}\n\nfunction cleanupWorkspace(workspace: string): void {\n if (!cleanupDirs.delete(workspace)) {\n return;\n }\n rmSync(workspace, { force: true, recursive: true });\n}\n\nfunction cleanupAllWorkspaces(): void {\n for (const dir of cleanupDirs) {\n cleanupWorkspace(dir);\n }\n}\n"],"mappings":";;;;;;;AAyBA,MAAM,8BAAc,IAAI,IAAY;AACpC,IAAI,mBAAmB;AAEvB,IAAa,aAAb,MAAwB;;;;;;;;;;;;;;;CAetB,WAAW,WAAW;EACpB,OAAOA,aAAiB;CAC1B;CAEA,WAAW,SAAS,OAAO;EACzB,aAAiB,WAAW;CAC9B;CAEA,WAAW,KAAK;EACd,OAAOA,aAAiB;CAC1B;CAEA,WAAW,GAAG,OAAO;EACnB,aAAiB,KAAK;CACxB;CAEA,OAAO,KAAK,MAAmC;EAC7C,OAAOA,aAAiB,KAAK,IAAI;CACnC;CAEA;CACA;CAEA,YAAY,QAA2B;EACrC,KAAKE,UAAU;EACf,KAAKD,SAAS,IAAID,aAAiB,MAAM;CAC3C;CAEA,IAAI,UAAkB,MAA+B,OAAwB;EAC3E,MAAM,YAAY,gBAAgB;EAClC,qBAAqB,SAAS;EAC9B,MAAM,cAAc;GAClB,OAAO,MAAM,MAAM,KAAK,MAAM,UAC5B,gBAAgB,WAAW,MAAM,KAAKE,SAAS,SAAS,KAAK,CAC/D;GACA,SAAS,MAAM,QAAQ,KAAK,MAAM,UAChC,gBAAgB,WAAW,MAAM,KAAKA,SAAS,WAAW,KAAK,CACjE;EACF;EACA,IAAI;GACF,KAAKD,OAAO,IAAI,UAAU,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AAU,aAC1B,WAAW,QACX,KAAA;AACR;AAEA,SAAS,iBAAiB,WAAyB;CACjD,IAAI,CAAC,YAAY,OAAO,SAAS,GAC/B;CAEF,OAAO,WAAW;EAAE,OAAO;EAAM,WAAW;CAAK,CAAC;AACpD;AAEA,SAAS,uBAA6B;CACpC,KAAK,MAAM,OAAO,aAChB,iBAAiB,GAAG;AAExB"}
|
package/dist/session.d.ts
CHANGED
|
@@ -10,8 +10,11 @@ declare class CorsaProjectSession {
|
|
|
10
10
|
getCompilerOptions(): unknown;
|
|
11
11
|
getRootFileNames(): readonly string[];
|
|
12
12
|
getTypeAtPosition(fileName: string, position: number, sourceText?: string): CorsaType | undefined;
|
|
13
|
+
private getTypeAtPositionUnchecked;
|
|
13
14
|
getTypeAtSourceRange(fileName: string, start: number, end: number, sourceText: string | undefined, kind: string | undefined): CorsaType | undefined;
|
|
15
|
+
private getTypeAtSourceRangeUnchecked;
|
|
14
16
|
getSymbolAtPosition(fileName: string, position: number, sourceText?: string): CorsaSymbol | undefined;
|
|
17
|
+
private getSymbolAtPositionUnchecked;
|
|
15
18
|
getSymbol(symbol: string | CorsaSymbol): CorsaSymbol | undefined;
|
|
16
19
|
getSymbolOfType(type: CorsaType): CorsaSymbol | undefined;
|
|
17
20
|
getNode(node: string | CorsaNode): CorsaNode | undefined;
|
|
@@ -61,6 +64,10 @@ declare class CorsaProjectSession {
|
|
|
61
64
|
private clearHandleCaches;
|
|
62
65
|
private sourceSliceForHandle;
|
|
63
66
|
private sourceTextForPath;
|
|
67
|
+
private withTransportRecovery;
|
|
68
|
+
private resetClientAfterTransportFailure;
|
|
69
|
+
private tryReleaseHandle;
|
|
70
|
+
private tryCloseClient;
|
|
64
71
|
private client;
|
|
65
72
|
private config;
|
|
66
73
|
private fileState;
|
package/dist/session.js
CHANGED
|
@@ -34,16 +34,17 @@ var CorsaProjectSession = class {
|
|
|
34
34
|
#lastRefreshMs = 0;
|
|
35
35
|
#snapshotHasIssuedHandles = false;
|
|
36
36
|
#supportsOverlayChanges;
|
|
37
|
+
#fatalTransportError;
|
|
37
38
|
constructor(project, runtime) {
|
|
38
39
|
this.project = project;
|
|
39
40
|
this.runtime = runtime;
|
|
40
41
|
}
|
|
41
42
|
close() {
|
|
42
43
|
if (this.#snapshot) {
|
|
43
|
-
this
|
|
44
|
+
this.tryReleaseHandle(this.#snapshot);
|
|
44
45
|
this.#snapshot = void 0;
|
|
45
46
|
}
|
|
46
|
-
this
|
|
47
|
+
this.tryCloseClient();
|
|
47
48
|
this.#client = void 0;
|
|
48
49
|
this.#supportsOverlayChanges = void 0;
|
|
49
50
|
this.#files.clear();
|
|
@@ -51,12 +52,15 @@ var CorsaProjectSession = class {
|
|
|
51
52
|
this.#typeTextById.clear();
|
|
52
53
|
}
|
|
53
54
|
getCompilerOptions() {
|
|
54
|
-
return this.config().options;
|
|
55
|
+
return this.withTransportRecovery(() => this.config().options, "reading compiler options");
|
|
55
56
|
}
|
|
56
57
|
getRootFileNames() {
|
|
57
|
-
return this.config().fileNames;
|
|
58
|
+
return this.withTransportRecovery(() => this.config().fileNames, "reading root file names");
|
|
58
59
|
}
|
|
59
60
|
getTypeAtPosition(fileName, position, sourceText) {
|
|
61
|
+
return this.withTransportRecovery(() => this.getTypeAtPositionUnchecked(fileName, position, sourceText), "looking up a type");
|
|
62
|
+
}
|
|
63
|
+
getTypeAtPositionUnchecked(fileName, position, sourceText) {
|
|
60
64
|
const state = this.fileState(fileName, sourceText);
|
|
61
65
|
if (!state.typeByPosition.has(position)) state.typeByPosition.set(position, this.client().getTypeAtPosition(this.#snapshot, state.projectId, fileName, position));
|
|
62
66
|
const type = this.rememberType(state.typeByPosition.get(position));
|
|
@@ -68,7 +72,10 @@ var CorsaProjectSession = class {
|
|
|
68
72
|
return type;
|
|
69
73
|
}
|
|
70
74
|
getTypeAtSourceRange(fileName, start, end, sourceText, kind) {
|
|
71
|
-
|
|
75
|
+
return this.withTransportRecovery(() => this.getTypeAtSourceRangeUnchecked(fileName, start, end, sourceText, kind), "looking up a type");
|
|
76
|
+
}
|
|
77
|
+
getTypeAtSourceRangeUnchecked(fileName, start, end, sourceText, kind) {
|
|
78
|
+
if (!sourceText || end <= start) return this.getTypeAtPositionUnchecked(fileName, start, sourceText);
|
|
72
79
|
const state = this.fileState(fileName, sourceText);
|
|
73
80
|
const key = `${start}:${end}:${kind ?? ""}`;
|
|
74
81
|
if (!state.typeBySourceRange.has(key)) state.typeBySourceRange.set(key, this.client().getTypeAtSourceRange(this.#snapshot, state.projectId, fileName, start, end, sourceText, kind));
|
|
@@ -84,6 +91,9 @@ var CorsaProjectSession = class {
|
|
|
84
91
|
return type;
|
|
85
92
|
}
|
|
86
93
|
getSymbolAtPosition(fileName, position, sourceText) {
|
|
94
|
+
return this.withTransportRecovery(() => this.getSymbolAtPositionUnchecked(fileName, position, sourceText), "looking up a symbol");
|
|
95
|
+
}
|
|
96
|
+
getSymbolAtPositionUnchecked(fileName, position, sourceText) {
|
|
87
97
|
const state = this.fileState(fileName, sourceText);
|
|
88
98
|
if (!state.symbolByPosition.has(position)) state.symbolByPosition.set(position, this.client().getSymbolAtPosition(this.#snapshot, state.projectId, fileName, position));
|
|
89
99
|
return this.rememberSymbol(state.symbolByPosition.get(position));
|
|
@@ -398,6 +408,51 @@ var CorsaProjectSession = class {
|
|
|
398
408
|
for (const [fileName, cached] of this.#files) if (fileName === path || fileName.endsWith(path)) return cached.lintSourceText ?? cached.sourceText ?? readFileOrUndefined(fileName);
|
|
399
409
|
return readFileOrUndefined(path) ?? readFileOrUndefined(`${this.runtime.cwd}/${path}`);
|
|
400
410
|
}
|
|
411
|
+
withTransportRecovery(operation, action) {
|
|
412
|
+
if (this.#fatalTransportError) throw this.#fatalTransportError;
|
|
413
|
+
try {
|
|
414
|
+
return operation();
|
|
415
|
+
} catch (error) {
|
|
416
|
+
if (!isRecoverableTransportError(error)) throw error;
|
|
417
|
+
this.resetClientAfterTransportFailure();
|
|
418
|
+
try {
|
|
419
|
+
return operation();
|
|
420
|
+
} catch (retryError) {
|
|
421
|
+
if (!isRecoverableTransportError(retryError)) throw retryError;
|
|
422
|
+
const fatal = /* @__PURE__ */ new Error(`corsa type-aware backend exited while ${action}; restarted the session, but the retry failed`);
|
|
423
|
+
fatal.cause = retryError;
|
|
424
|
+
this.#fatalTransportError = fatal;
|
|
425
|
+
throw fatal;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
resetClientAfterTransportFailure() {
|
|
430
|
+
this.tryCloseClient();
|
|
431
|
+
this.#client = void 0;
|
|
432
|
+
this.#config = void 0;
|
|
433
|
+
this.#snapshot = void 0;
|
|
434
|
+
this.#projects = [];
|
|
435
|
+
this.#files.clear();
|
|
436
|
+
this.clearHandleCaches();
|
|
437
|
+
this.#typeTextById.clear();
|
|
438
|
+
this.#lastRefreshMs = 0;
|
|
439
|
+
this.#supportsOverlayChanges = void 0;
|
|
440
|
+
this.#fatalTransportError = void 0;
|
|
441
|
+
}
|
|
442
|
+
tryReleaseHandle(handle) {
|
|
443
|
+
try {
|
|
444
|
+
this.#client?.releaseHandle(handle);
|
|
445
|
+
} catch (error) {
|
|
446
|
+
if (!isRecoverableTransportError(error)) throw error;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
tryCloseClient() {
|
|
450
|
+
try {
|
|
451
|
+
this.#client?.close();
|
|
452
|
+
} catch (error) {
|
|
453
|
+
if (!isRecoverableTransportError(error)) throw error;
|
|
454
|
+
}
|
|
455
|
+
}
|
|
401
456
|
client() {
|
|
402
457
|
if (!this.#client) {
|
|
403
458
|
this.#client = CorsaApiClient.spawn({
|
|
@@ -460,7 +515,7 @@ var CorsaProjectSession = class {
|
|
|
460
515
|
this.#lastRefreshMs = now;
|
|
461
516
|
this.#files.clear();
|
|
462
517
|
this.clearHandleCaches();
|
|
463
|
-
if (previous && previous !== this.#snapshot) this.
|
|
518
|
+
if (previous && previous !== this.#snapshot) this.tryReleaseHandle(previous);
|
|
464
519
|
return prepared;
|
|
465
520
|
}
|
|
466
521
|
projectId() {
|
|
@@ -537,6 +592,13 @@ function parseNodeHandle(value) {
|
|
|
537
592
|
range: [pos, end]
|
|
538
593
|
};
|
|
539
594
|
}
|
|
595
|
+
function isRecoverableTransportError(error) {
|
|
596
|
+
const message = errorMessage(error);
|
|
597
|
+
return message.includes("process is closed:") || message.includes("Broken pipe") || message.includes("EPIPE") || message.includes("failed to fill whole buffer") || message.includes("msgpack worker") || message.includes("msgpack stdin") || message.includes("msgpack stdout") || message.includes("jsonrpc reader") || message.includes("jsonrpc writer") || message.includes("jsonrpc connection");
|
|
598
|
+
}
|
|
599
|
+
function errorMessage(error) {
|
|
600
|
+
return error instanceof Error ? error.message : String(error);
|
|
601
|
+
}
|
|
540
602
|
function readFileOrUndefined(path) {
|
|
541
603
|
try {
|
|
542
604
|
return readFileSync(path, "utf8");
|
package/dist/session.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.js","names":["#snapshot","#client","#supportsOverlayChanges","#files","#typeTextById","#typeLookupById","#symbolsById","#symbolTypeById","#nodesById","#typeSourceById","#snapshotHasIssuedHandles","#config","#lastRefreshMs","#projects"],"sources":["../ts/session.ts"],"sourcesContent":["import { readFileSync, statSync } from \"node:fs\";\n\nimport { type ProjectResponse, CorsaApiClient } from \"@corsa-bind/napi\";\n\nimport type {\n CorsaCallSignatureFacts,\n CorsaNode,\n CorsaSignature,\n CorsaSymbol,\n CorsaType,\n CorsaTypePredicate,\n} from \"./types\";\nimport type { ResolvedProjectConfig, ResolvedRuntimeOptions } from \"./types\";\n\ntype FileCache = {\n mtimeMs: number;\n lintSourceText?: string;\n sourceText?: string;\n projectId: string;\n typeByPosition: Map<number, CorsaType | undefined>;\n typeBySourceRange: Map<string, CorsaType | undefined>;\n symbolByPosition: Map<number, CorsaSymbol | undefined>;\n};\n\ntype PreparedFileState = {\n mtimeMs: number;\n lintSourceText?: string;\n sourceText?: string;\n};\n\ntype SourceSlice = {\n node: CorsaNode;\n text: string;\n};\n\ntype TypeLookup = {\n fileName: string;\n position: number;\n sourceText?: string;\n};\n\nconst typeFlags = {\n object: 1 << 20,\n index: 1 << 21,\n templateLiteral: 1 << 22,\n stringMapping: 1 << 23,\n substitution: 1 << 24,\n indexedAccess: 1 << 25,\n conditional: 1 << 26,\n union: 1 << 27,\n intersection: 1 << 28,\n} as const;\n\nconst objectFlags = {\n classOrInterface: (1 << 0) | (1 << 1),\n reference: 1 << 2,\n mapped: 1 << 5,\n} as const;\n\nexport class CorsaProjectSession {\n #client?: CorsaApiClient;\n #config?: { options: unknown; fileNames: string[] };\n #snapshot?: string;\n #projects: ProjectResponse[] = [];\n #files = new Map<string, FileCache>();\n #symbolsById = new Map<string, CorsaSymbol>();\n #symbolTypeById = new Map<string, string>();\n #nodesById = new Map<string, CorsaNode>();\n #typeLookupById = new Map<string, TypeLookup>();\n #typeSourceById = new Map<string, SourceSlice>();\n #typeTextById = new Map<string, string>();\n #lastRefreshMs = 0;\n #snapshotHasIssuedHandles = false;\n #supportsOverlayChanges?: boolean;\n\n constructor(\n readonly project: ResolvedProjectConfig,\n readonly runtime: ResolvedRuntimeOptions,\n ) {}\n\n close(): void {\n if (this.#snapshot) {\n this.#client?.releaseHandle(this.#snapshot);\n this.#snapshot = undefined;\n }\n this.#client?.close();\n this.#client = undefined;\n this.#supportsOverlayChanges = undefined;\n this.#files.clear();\n this.clearHandleCaches();\n this.#typeTextById.clear();\n }\n\n getCompilerOptions(): unknown {\n return this.config().options;\n }\n\n getRootFileNames(): readonly string[] {\n return this.config().fileNames;\n }\n\n getTypeAtPosition(\n fileName: string,\n position: number,\n sourceText?: string,\n ): CorsaType | undefined {\n const state = this.fileState(fileName, sourceText);\n if (!state.typeByPosition.has(position)) {\n state.typeByPosition.set(\n position,\n this.client().getTypeAtPosition(this.#snapshot!, state.projectId, fileName, position) as\n | CorsaType\n | undefined,\n );\n }\n const type = this.rememberType(state.typeByPosition.get(position));\n if (type) {\n this.#typeLookupById.set(type.id, { fileName, position, sourceText });\n }\n return type;\n }\n\n getTypeAtSourceRange(\n fileName: string,\n start: number,\n end: number,\n sourceText: string | undefined,\n kind: string | undefined,\n ): CorsaType | undefined {\n if (!sourceText || end <= start) {\n return this.getTypeAtPosition(fileName, start, sourceText);\n }\n const state = this.fileState(fileName, sourceText);\n const key = `${start}:${end}:${kind ?? \"\"}`;\n if (!state.typeBySourceRange.has(key)) {\n state.typeBySourceRange.set(\n key,\n this.client().getTypeAtSourceRange(\n this.#snapshot!,\n state.projectId,\n fileName,\n start,\n end,\n sourceText,\n kind,\n ) as CorsaType | undefined,\n );\n }\n const type = this.rememberType(state.typeBySourceRange.get(key));\n if (type) {\n this.#typeLookupById.set(type.id, { fileName, position: start, sourceText });\n if (kind !== \"Identifier\") {\n this.rememberTypeSourceRange(type, fileName, start, end, sourceText);\n }\n }\n return type;\n }\n\n getSymbolAtPosition(\n fileName: string,\n position: number,\n sourceText?: string,\n ): CorsaSymbol | undefined {\n const state = this.fileState(fileName, sourceText);\n if (!state.symbolByPosition.has(position)) {\n state.symbolByPosition.set(\n position,\n this.client().getSymbolAtPosition(this.#snapshot!, state.projectId, fileName, position) as\n | CorsaSymbol\n | undefined,\n );\n }\n return this.rememberSymbol(state.symbolByPosition.get(position));\n }\n\n getSymbol(symbol: string | CorsaSymbol): CorsaSymbol | undefined {\n if (typeof symbol !== \"string\") {\n return this.rememberSymbol(symbol);\n }\n const cached = this.#symbolsById.get(symbol);\n if (cached) {\n return cached;\n }\n const typeId = this.#symbolTypeById.get(symbol);\n if (!typeId || !this.#snapshot) {\n return undefined;\n }\n const resolved = this.client().getSymbolOfType(this.#snapshot, typeId) as CorsaSymbol | null;\n return resolved?.id === symbol ? this.rememberUsableSymbol(resolved) : undefined;\n }\n\n getSymbolOfType(type: CorsaType): CorsaSymbol | undefined {\n if (type.symbol) {\n const symbol = this.getSymbol(type.symbol);\n if (isUsableSymbol(symbol)) {\n return symbol;\n }\n }\n if (!this.#snapshot) {\n return undefined;\n }\n return this.rememberUsableSymbol(\n this.client().getSymbolOfType(this.#snapshot, type.id) as CorsaSymbol | null,\n );\n }\n\n getNode(node: string | CorsaNode): CorsaNode | undefined {\n if (typeof node !== \"string\") {\n return node;\n }\n return this.#nodesById.get(node) ?? this.rememberNode(node);\n }\n\n getSourceTextForPath(path: string): string | undefined {\n return this.sourceTextForPath(path);\n }\n\n getTypeOfSymbol(symbol: CorsaSymbol): CorsaType | undefined {\n const type = this.rememberType(this.tryGetSymbolType(symbol, \"getTypeOfSymbol\"));\n this.rememberTypeSource(type, symbol.valueDeclaration);\n return type;\n }\n\n getTypeOfSymbolById(id: string): CorsaType | undefined {\n return this.rememberType(this.tryGetSymbolTypeId(id, \"getTypeOfSymbol\"));\n }\n\n getDeclaredTypeOfSymbol(symbol: CorsaSymbol): CorsaType | undefined {\n const type = this.rememberType(this.tryGetSymbolType(symbol, \"getDeclaredTypeOfSymbol\"));\n this.rememberTypeSource(type, symbol.valueDeclaration);\n return type;\n }\n\n getDeclaredTypeOfSymbolById(id: string): CorsaType | undefined {\n return this.rememberType(this.tryGetSymbolTypeId(id, \"getDeclaredTypeOfSymbol\"));\n }\n\n typeToString(type: CorsaType, flags?: number): string {\n try {\n const text = this.client().typeToString(\n this.#snapshot!,\n this.projectId(),\n type.id,\n undefined,\n flags,\n );\n if (flags === undefined) {\n this.#typeTextById.set(type.id, text);\n }\n return text;\n } catch (error) {\n const cached = flags === undefined ? this.#typeTextById.get(type.id) : undefined;\n if (cached !== undefined) {\n return cached;\n }\n throw error;\n }\n }\n\n getBaseTypeOfLiteralType(type: CorsaType): CorsaType | undefined {\n return this.rememberType(\n this.client().callJson(\"getBaseTypeOfLiteralType\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n type: type.id,\n }),\n );\n }\n\n getPropertiesOfType(type: CorsaType): readonly CorsaSymbol[] {\n return this.rememberSymbols(\n this.client().callJson(\"getPropertiesOfType\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n type: type.id,\n }) ?? [],\n );\n }\n\n getSignaturesOfType(type: CorsaType, kind: number): readonly CorsaSignature[] {\n const source = this.sourceContextForType(type);\n return this.rememberSignatures(\n this.client().callJson(\"getSignaturesOfType\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n type: type.id,\n kind,\n ...source,\n }) ?? [],\n );\n }\n\n getCallSignatureFacts(\n type: CorsaType,\n kind: number,\n argumentTypeTexts: readonly (readonly string[])[],\n explicitTypeArgumentTexts: readonly string[],\n ): CorsaCallSignatureFacts {\n const source = this.sourceContextForType(type);\n const facts = this.client().callJson<CorsaCallSignatureFacts>(\"getCallSignatureFacts\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n type: type.id,\n kind,\n ...source,\n argumentTypeTexts,\n explicitTypeArgumentTexts,\n });\n if (facts?.signature) {\n this.rememberSignature(facts.signature);\n }\n return facts ?? {};\n }\n\n getReturnTypeOfSignature(signature: CorsaSignature): CorsaType | undefined {\n return this.rememberType(\n this.client().callJson(\"getReturnTypeOfSignature\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n signature: signature.id,\n }),\n );\n }\n\n getTypePredicateOfSignature(signature: CorsaSignature): CorsaTypePredicate | undefined {\n const predicate = this.client().callJson<CorsaTypePredicate | undefined>(\n \"getTypePredicateOfSignature\",\n {\n snapshot: this.#snapshot,\n project: this.projectId(),\n signature: signature.id,\n },\n );\n if (predicate?.type) {\n this.rememberType(predicate.type);\n }\n return predicate;\n }\n\n getBaseTypes(type: CorsaType): readonly CorsaType[] {\n if (isArrayOrTupleLikeType(this, type)) {\n return [];\n }\n return this.rememberTypes(\n this.client().callJson(\"getBaseTypes\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n type: type.id,\n texts: this.typeTexts(type),\n }) ?? [],\n );\n }\n\n getTypeArguments(type: CorsaType): readonly CorsaType[] {\n const source = this.sourceSliceForType(type);\n return this.rememberTypes(\n source\n ? (this.client().getTypeArgumentsAtSourceRange(\n this.#snapshot!,\n this.projectId(),\n type.id,\n type.objectFlags,\n source.node.fileName,\n source.node.pos,\n source.node.end,\n this.sourceTextForPath(source.node.fileName) ?? \"\",\n ) as unknown as readonly CorsaType[])\n : (this.client().getTypeArguments(\n this.#snapshot!,\n this.projectId(),\n type.id,\n type.objectFlags,\n ) as unknown as readonly CorsaType[]),\n );\n }\n\n getTypesOfType(type: CorsaType): readonly CorsaType[] {\n if (\n (type.flags & (typeFlags.union | typeFlags.intersection | typeFlags.templateLiteral)) ===\n 0\n ) {\n return [];\n }\n return this.callTypeArray(\"getTypesOfType\", type);\n }\n\n getTargetOfType(type: CorsaType): CorsaType | undefined {\n if (\n (type.flags & (typeFlags.index | typeFlags.stringMapping)) === 0 &&\n ((type.objectFlags ?? 0) & (objectFlags.reference | objectFlags.mapped)) === 0\n ) {\n return undefined;\n }\n const target = this.callType(\"getTargetOfType\", type);\n this.cacheTypeText(target);\n return target;\n }\n\n getTypeParametersOfType(type: CorsaType): readonly CorsaType[] {\n const flags = type.objectFlags ?? 0;\n if ((type.flags & typeFlags.object) === 0 || (flags & objectFlags.classOrInterface) === 0) {\n return [];\n }\n return this.callTypeArray(\"getTypeParametersOfType\", type);\n }\n\n getOuterTypeParametersOfType(type: CorsaType): readonly CorsaType[] {\n const flags = type.objectFlags ?? 0;\n if ((type.flags & typeFlags.object) === 0 || (flags & objectFlags.classOrInterface) === 0) {\n return [];\n }\n return this.callTypeArray(\"getOuterTypeParametersOfType\", type);\n }\n\n getLocalTypeParametersOfType(type: CorsaType): readonly CorsaType[] {\n const flags = type.objectFlags ?? 0;\n if ((type.flags & typeFlags.object) === 0 || (flags & objectFlags.classOrInterface) === 0) {\n return [];\n }\n return this.callTypeArray(\"getLocalTypeParametersOfType\", type);\n }\n\n getObjectTypeOfType(type: CorsaType): CorsaType | undefined {\n return (type.flags & typeFlags.indexedAccess) !== 0\n ? this.callType(\"getObjectTypeOfType\", type)\n : undefined;\n }\n\n getIndexTypeOfType(type: CorsaType): CorsaType | undefined {\n return (type.flags & typeFlags.indexedAccess) !== 0\n ? this.callType(\"getIndexTypeOfType\", type)\n : undefined;\n }\n\n getCheckTypeOfType(type: CorsaType): CorsaType | undefined {\n return (type.flags & typeFlags.conditional) !== 0\n ? this.callType(\"getCheckTypeOfType\", type)\n : undefined;\n }\n\n getExtendsTypeOfType(type: CorsaType): CorsaType | undefined {\n return (type.flags & typeFlags.conditional) !== 0\n ? this.callType(\"getExtendsTypeOfType\", type)\n : undefined;\n }\n\n getBaseTypeOfType(type: CorsaType): CorsaType | undefined {\n return (type.flags & typeFlags.substitution) !== 0\n ? this.callType(\"getBaseTypeOfType\", type)\n : undefined;\n }\n\n getConstraintOfType(type: CorsaType): CorsaType | undefined {\n return this.rememberType(\n this.client().getConstraintOfType(this.#snapshot!, this.projectId(), type.id) as\n | CorsaType\n | undefined,\n );\n }\n\n private callType(method: string, type: CorsaType): CorsaType | undefined {\n return this.rememberType(\n this.client().callJson<CorsaType | null>(method, {\n snapshot: this.#snapshot,\n type: type.id,\n }) ?? undefined,\n );\n }\n\n private callTypeArray(method: string, type: CorsaType): readonly CorsaType[] {\n return this.rememberTypes(\n this.client().callJson<readonly CorsaType[] | null>(method, {\n snapshot: this.#snapshot,\n type: type.id,\n }) ?? [],\n );\n }\n\n private tryGetSymbolType(\n symbol: CorsaSymbol,\n method: \"getTypeOfSymbol\" | \"getDeclaredTypeOfSymbol\",\n ): CorsaType | undefined {\n return this.tryGetSymbolTypeId(symbol.id, method);\n }\n\n private tryGetSymbolTypeId(\n id: string,\n method: \"getTypeOfSymbol\" | \"getDeclaredTypeOfSymbol\",\n ): CorsaType | undefined {\n try {\n return this.client()[method](this.#snapshot!, this.projectId(), id) as CorsaType | undefined;\n } catch {\n return undefined;\n }\n }\n\n private sourceSliceForType(type: CorsaType): SourceSlice | undefined {\n const cached = this.#typeSourceById.get(type.id);\n if (cached) {\n return cached;\n }\n const lookup = this.#typeLookupById.get(type.id);\n if (lookup) {\n const symbol = this.getSymbolAtPosition(lookup.fileName, lookup.position, lookup.sourceText);\n this.rememberTypeSource(type, symbol?.valueDeclaration);\n const fromLookup = this.#typeSourceById.get(type.id);\n if (fromLookup) {\n return fromLookup;\n }\n }\n if (type.symbol) {\n const symbol = this.getSymbol(type.symbol);\n this.rememberTypeSource(type, symbol?.valueDeclaration);\n }\n return this.#typeSourceById.get(type.id);\n }\n\n private rememberType<T extends CorsaType | undefined>(type: T): T {\n if (type) {\n this.#snapshotHasIssuedHandles = true;\n }\n if (type?.symbol) {\n this.#symbolTypeById.set(type.symbol, type.id);\n }\n if (type?.texts?.[0]) {\n this.#typeTextById.set(type.id, type.texts[0]);\n }\n return type;\n }\n\n private rememberTypes<T extends readonly CorsaType[]>(types: T): T {\n for (const type of types) {\n this.rememberType(type);\n }\n return types;\n }\n\n private rememberTypeSource(type: CorsaType | undefined, handle: string | undefined): void {\n if (!type || !handle || this.#typeSourceById.has(type.id)) {\n return;\n }\n const source = this.sourceSliceForHandle(handle);\n if (source) {\n this.#typeSourceById.set(type.id, source);\n }\n }\n\n private rememberTypeSourceRange(\n type: CorsaType,\n fileName: string,\n start: number,\n end: number,\n sourceText: string | undefined,\n ): void {\n if (\n this.#typeSourceById.has(type.id) ||\n !sourceText ||\n start < 0 ||\n end > sourceText.length ||\n start >= end\n ) {\n return;\n }\n const node = {\n fileName,\n pos: start,\n end,\n range: [start, end] as const,\n };\n this.#typeSourceById.set(type.id, {\n node,\n text: sourceText.slice(start, end),\n });\n }\n\n private cacheTypeText(type: CorsaType | undefined): void {\n if (!type || this.#typeTextById.has(type.id)) {\n return;\n }\n try {\n this.#typeTextById.set(\n type.id,\n this.client().typeToString(this.#snapshot!, this.projectId(), type.id),\n );\n } catch {\n // Some upstream handles are only renderable before a later relation query.\n }\n }\n\n private typeTexts(type: CorsaType): readonly string[] {\n if (Array.isArray(type.texts) && type.texts.length > 0) {\n return type.texts;\n }\n const cached = this.#typeTextById.get(type.id);\n return cached === undefined ? [] : [cached];\n }\n\n private sourceContextForType(type: CorsaType): { file?: string; sourceText?: string } {\n const lookup = this.#typeLookupById.get(type.id);\n if (lookup) {\n const sourceText = lookup.sourceText ?? this.sourceTextForPath(lookup.fileName);\n return sourceText ? { file: lookup.fileName, sourceText } : {};\n }\n const source = this.#typeSourceById.get(type.id);\n if (source) {\n const sourceText = this.sourceTextForPath(source.node.fileName);\n return sourceText ? { file: source.node.fileName, sourceText } : {};\n }\n return {};\n }\n\n private rememberSymbol<T extends CorsaSymbol | undefined>(symbol: T): T {\n if (!symbol) {\n return symbol;\n }\n this.#snapshotHasIssuedHandles = true;\n this.#symbolsById.set(symbol.id, symbol);\n for (const declaration of symbol.declarations ?? []) {\n this.rememberNode(declaration);\n }\n if (symbol.valueDeclaration) {\n this.rememberNode(symbol.valueDeclaration);\n }\n return symbol;\n }\n\n private rememberUsableSymbol(symbol: CorsaSymbol | null | undefined): CorsaSymbol | undefined {\n return isUsableSymbol(symbol) ? this.rememberSymbol(symbol) : undefined;\n }\n\n private rememberSymbols<T extends readonly CorsaSymbol[]>(symbols: T): T {\n for (const symbol of symbols) {\n this.rememberSymbol(symbol);\n }\n return symbols;\n }\n\n private rememberSignatures<T extends readonly CorsaSignature[]>(signatures: T): T {\n for (const signature of signatures) {\n this.rememberSignature(signature);\n }\n return signatures;\n }\n\n private rememberSignature(signature: CorsaSignature): CorsaSignature {\n if (signature.declaration) {\n this.rememberNode(signature.declaration);\n }\n for (const symbol of signature.parameterSymbols ?? []) {\n this.rememberSymbol(symbol);\n }\n if (signature.thisParameterSymbol) {\n this.rememberSymbol(signature.thisParameterSymbol);\n }\n return signature;\n }\n\n private rememberNode(handle: string): CorsaNode | undefined {\n const parsed = parseNodeHandle(handle);\n if (!parsed) {\n return undefined;\n }\n this.#nodesById.set(handle, parsed);\n return parsed;\n }\n\n private clearHandleCaches(): void {\n this.#symbolsById.clear();\n this.#symbolTypeById.clear();\n this.#nodesById.clear();\n this.#typeLookupById.clear();\n this.#typeSourceById.clear();\n this.#snapshotHasIssuedHandles = false;\n }\n\n private sourceSliceForHandle(handle: string): SourceSlice | undefined {\n const node = this.getNode(handle);\n if (!node) {\n return undefined;\n }\n const sourceText = this.sourceTextForPath(node.fileName);\n if (!sourceText || node.pos < 0 || node.end > sourceText.length || node.pos >= node.end) {\n return undefined;\n }\n return {\n node,\n text: sourceText.slice(node.pos, node.end),\n };\n }\n\n private sourceTextForPath(path: string): string | undefined {\n for (const [fileName, cached] of this.#files) {\n if (fileName === path || fileName.endsWith(path)) {\n return cached.lintSourceText ?? cached.sourceText ?? readFileOrUndefined(fileName);\n }\n }\n return readFileOrUndefined(path) ?? readFileOrUndefined(`${this.runtime.cwd}/${path}`);\n }\n\n private client(): CorsaApiClient {\n if (!this.#client) {\n this.#client = CorsaApiClient.spawn({\n executable: this.runtime.executable,\n cwd: this.runtime.cwd,\n mode: this.runtime.mode,\n });\n this.#client.initialize();\n }\n return this.#client;\n }\n\n private config(): { options: unknown; fileNames: string[] } {\n if (!this.#config) {\n this.#config = this.client().parseConfigFile(this.project.configPath);\n }\n const config = this.#config;\n if (!config) {\n throw new Error(`corsa oxlint could not parse a Corsa config for ${this.project.configPath}`);\n }\n return config;\n }\n\n private fileState(fileName: string, sourceText?: string): FileCache {\n const prepared = this.refreshIfNeeded(fileName, sourceText);\n const current = this.#files.get(fileName);\n if (current) {\n return current;\n }\n const project = this.client().callJson<ProjectResponse | null>(\"getDefaultProjectForFile\", {\n snapshot: this.#snapshot,\n file: fileName,\n });\n const state: FileCache = {\n mtimeMs: prepared.mtimeMs,\n lintSourceText: prepared.lintSourceText,\n sourceText: prepared.sourceText,\n projectId: project?.id ?? this.projectId(),\n typeByPosition: new Map(),\n typeBySourceRange: new Map(),\n symbolByPosition: new Map(),\n };\n this.#files.set(fileName, state);\n return state;\n }\n\n private refreshIfNeeded(fileName: string, sourceText?: string): PreparedFileState {\n const now = Date.now();\n const expired = now - this.#lastRefreshMs > this.runtime.cacheLifetimeMs;\n const cached = this.#files.get(fileName);\n const mtimeMs = statMtimeMs(fileName);\n const overlayText = this.supportedOverlayText(fileName, sourceText, mtimeMs, cached);\n const mtimeChanged = cached !== undefined && mtimeMs !== cached.mtimeMs;\n const textChanged = overlayText !== cached?.sourceText;\n const prepared = {\n mtimeMs,\n lintSourceText: sourceText,\n sourceText: overlayText,\n };\n const stale =\n !this.#snapshot ||\n mtimeChanged ||\n textChanged ||\n (expired && !this.#snapshotHasIssuedHandles);\n if (!stale) {\n return prepared;\n }\n const previous = this.#snapshot;\n const overlayChanges = this.overlayChanges(fileName, overlayText, cached);\n const response = this.client().updateSnapshot({\n ...(previous\n ? { fileChanges: { changed: [fileName] } }\n : { openProject: this.project.configPath }),\n ...(overlayChanges === undefined ? {} : { overlayChanges }),\n });\n this.#snapshot = response.snapshot;\n this.#projects = response.projects;\n this.#lastRefreshMs = now;\n this.#files.clear();\n this.clearHandleCaches();\n if (previous && previous !== this.#snapshot) {\n this.client().releaseHandle(previous);\n }\n return prepared;\n }\n\n private projectId(): string {\n const id = this.#projects[0]?.id;\n if (!id) {\n throw new Error(\n `corsa oxlint could not resolve a Corsa project for ${this.project.filename}`,\n );\n }\n return id;\n }\n\n private supportedOverlayText(\n fileName: string,\n sourceText: string | undefined,\n mtimeMs: number,\n cached?: FileCache,\n ): string | undefined {\n if (sourceText === undefined || !this.supportsOverlayChanges()) {\n return undefined;\n }\n if (cached?.lintSourceText === sourceText && cached.mtimeMs === mtimeMs) {\n return cached.sourceText;\n }\n return overlayTextFor(fileName, sourceText);\n }\n\n private overlayChanges(\n fileName: string,\n overlayText: string | undefined,\n cached?: FileCache,\n ):\n | {\n upsert?: { document: string; text: string; languageId: string }[];\n delete?: string[];\n }\n | undefined {\n if (!this.supportsOverlayChanges()) {\n return undefined;\n }\n if (overlayText !== undefined) {\n return {\n upsert: [\n {\n document: fileName,\n text: overlayText,\n languageId: languageIdFor(fileName),\n },\n ],\n };\n }\n if (cached?.sourceText !== undefined) {\n return { delete: [fileName] };\n }\n return undefined;\n }\n\n private supportsOverlayChanges(): boolean {\n if (this.#supportsOverlayChanges !== undefined) {\n return this.#supportsOverlayChanges;\n }\n try {\n const capabilities = this.client().callJson<{\n overlay?: { updateSnapshotOverlayChanges?: boolean };\n }>(\"describeCapabilities\");\n this.#supportsOverlayChanges = capabilities?.overlay?.updateSnapshotOverlayChanges === true;\n } catch {\n this.#supportsOverlayChanges = false;\n }\n return this.#supportsOverlayChanges;\n }\n}\n\nfunction isArrayOrTupleLikeType(session: CorsaProjectSession, type: CorsaType): boolean {\n const texts =\n Array.isArray(type.texts) && type.texts.length > 0 ? type.texts : [session.typeToString(type)];\n return texts.some((text) => {\n const normalized = text.trimStart();\n return (\n normalized.startsWith(\"readonly [\") || normalized.startsWith(\"[\") || normalized.endsWith(\"[]\")\n );\n });\n}\n\nfunction isUsableSymbol(symbol: CorsaSymbol | null | undefined): symbol is CorsaSymbol {\n return symbol != null && !symbol.name.includes(\"\\ufffd\");\n}\n\nfunction overlayTextFor(fileName: string, sourceText?: string): string | undefined {\n if (sourceText === undefined) {\n return undefined;\n }\n try {\n return readFileSync(fileName, \"utf8\") === sourceText ? undefined : sourceText;\n } catch {\n return sourceText;\n }\n}\n\nfunction statMtimeMs(fileName: string): number {\n try {\n return statSync(fileName).mtimeMs;\n } catch {\n return 0;\n }\n}\n\nfunction languageIdFor(fileName: string): string {\n if (fileName.endsWith(\".tsx\")) {\n return \"typescriptreact\";\n }\n if (fileName.endsWith(\".jsx\")) {\n return \"javascriptreact\";\n }\n if (fileName.endsWith(\".js\")) {\n return \"javascript\";\n }\n return \"typescript\";\n}\n\nfunction parseNodeHandle(value: string): CorsaNode | undefined {\n const [posText, endText, _kindText, ...pathParts] = value.split(\".\");\n const pos = Number(posText);\n const end = Number(endText);\n const fileName = pathParts.join(\".\");\n if (!Number.isFinite(pos) || !Number.isFinite(end) || !fileName) {\n return undefined;\n }\n return { id: value, fileName, pos, end, range: [pos, end] };\n}\n\nfunction readFileOrUndefined(path: string): string | undefined {\n try {\n return readFileSync(path, \"utf8\");\n } catch {\n return undefined;\n }\n}\n"],"mappings":";;;AAyC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GACjB;CAEF,IAAI;EACF,OAAO,aAAa,UAAU,MAAM,MAAM,aAAa,KAAA,IAAY;CACrE,QAAQ;EACN,OAAO;CACT;AACF;AAEA,SAAS,YAAY,UAA0B;CAC7C,IAAI;EACF,OAAO,SAAS,QAAQ,EAAE;CAC5B,QAAQ;EACN,OAAO;CACT;AACF;AAEA,SAAS,cAAc,UAA0B;CAC/C,IAAI,SAAS,SAAS,MAAM,GAC1B,OAAO;CAET,IAAI,SAAS,SAAS,MAAM,GAC1B,OAAO;CAET,IAAI,SAAS,SAAS,KAAK,GACzB,OAAO;CAET,OAAO;AACT;AAEA,SAAS,gBAAgB,OAAsC;CAC7D,MAAM,CAAC,SAAS,SAAS,WAAW,GAAG,aAAa,MAAM,MAAM,GAAG;CACnE,MAAM,MAAM,OAAO,OAAO;CAC1B,MAAM,MAAM,OAAO,OAAO;CAC1B,MAAM,WAAW,UAAU,KAAK,GAAG;CACnC,IAAI,CAAC,OAAO,SAAS,GAAG,KAAK,CAAC,OAAO,SAAS,GAAG,KAAK,CAAC,UACrD;CAEF,OAAO;EAAE,IAAI;EAAO;EAAU;EAAK;EAAK,OAAO,CAAC,KAAK,GAAG;CAAE;AAC5D;AAEA,SAAS,oBAAoB,MAAkC;CAC7D,IAAI;EACF,OAAO,aAAa,MAAM,MAAM;CAClC,QAAQ;EACN;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"session.js","names":["#snapshot","#client","#supportsOverlayChanges","#files","#typeTextById","#typeLookupById","#symbolsById","#symbolTypeById","#nodesById","#typeSourceById","#snapshotHasIssuedHandles","#fatalTransportError","#config","#projects","#lastRefreshMs"],"sources":["../ts/session.ts"],"sourcesContent":["import { readFileSync, statSync } from \"node:fs\";\n\nimport { type ProjectResponse, CorsaApiClient } from \"@corsa-bind/napi\";\n\nimport type {\n CorsaCallSignatureFacts,\n CorsaNode,\n CorsaSignature,\n CorsaSymbol,\n CorsaType,\n CorsaTypePredicate,\n} from \"./types\";\nimport type { ResolvedProjectConfig, ResolvedRuntimeOptions } from \"./types\";\n\ntype FileCache = {\n mtimeMs: number;\n lintSourceText?: string;\n sourceText?: string;\n projectId: string;\n typeByPosition: Map<number, CorsaType | undefined>;\n typeBySourceRange: Map<string, CorsaType | undefined>;\n symbolByPosition: Map<number, CorsaSymbol | undefined>;\n};\n\ntype PreparedFileState = {\n mtimeMs: number;\n lintSourceText?: string;\n sourceText?: string;\n};\n\ntype SourceSlice = {\n node: CorsaNode;\n text: string;\n};\n\ntype TypeLookup = {\n fileName: string;\n position: number;\n sourceText?: string;\n};\n\nconst typeFlags = {\n object: 1 << 20,\n index: 1 << 21,\n templateLiteral: 1 << 22,\n stringMapping: 1 << 23,\n substitution: 1 << 24,\n indexedAccess: 1 << 25,\n conditional: 1 << 26,\n union: 1 << 27,\n intersection: 1 << 28,\n} as const;\n\nconst objectFlags = {\n classOrInterface: (1 << 0) | (1 << 1),\n reference: 1 << 2,\n mapped: 1 << 5,\n} as const;\n\nexport class CorsaProjectSession {\n #client?: CorsaApiClient;\n #config?: { options: unknown; fileNames: string[] };\n #snapshot?: string;\n #projects: ProjectResponse[] = [];\n #files = new Map<string, FileCache>();\n #symbolsById = new Map<string, CorsaSymbol>();\n #symbolTypeById = new Map<string, string>();\n #nodesById = new Map<string, CorsaNode>();\n #typeLookupById = new Map<string, TypeLookup>();\n #typeSourceById = new Map<string, SourceSlice>();\n #typeTextById = new Map<string, string>();\n #lastRefreshMs = 0;\n #snapshotHasIssuedHandles = false;\n #supportsOverlayChanges?: boolean;\n #fatalTransportError?: Error;\n\n constructor(\n readonly project: ResolvedProjectConfig,\n readonly runtime: ResolvedRuntimeOptions,\n ) {}\n\n close(): void {\n if (this.#snapshot) {\n this.tryReleaseHandle(this.#snapshot);\n this.#snapshot = undefined;\n }\n this.tryCloseClient();\n this.#client = undefined;\n this.#supportsOverlayChanges = undefined;\n this.#files.clear();\n this.clearHandleCaches();\n this.#typeTextById.clear();\n }\n\n getCompilerOptions(): unknown {\n return this.withTransportRecovery(() => this.config().options, \"reading compiler options\");\n }\n\n getRootFileNames(): readonly string[] {\n return this.withTransportRecovery(() => this.config().fileNames, \"reading root file names\");\n }\n\n getTypeAtPosition(\n fileName: string,\n position: number,\n sourceText?: string,\n ): CorsaType | undefined {\n return this.withTransportRecovery(\n () => this.getTypeAtPositionUnchecked(fileName, position, sourceText),\n \"looking up a type\",\n );\n }\n\n private getTypeAtPositionUnchecked(\n fileName: string,\n position: number,\n sourceText?: string,\n ): CorsaType | undefined {\n const state = this.fileState(fileName, sourceText);\n if (!state.typeByPosition.has(position)) {\n state.typeByPosition.set(\n position,\n this.client().getTypeAtPosition(this.#snapshot!, state.projectId, fileName, position) as\n | CorsaType\n | undefined,\n );\n }\n const type = this.rememberType(state.typeByPosition.get(position));\n if (type) {\n this.#typeLookupById.set(type.id, { fileName, position, sourceText });\n }\n return type;\n }\n\n getTypeAtSourceRange(\n fileName: string,\n start: number,\n end: number,\n sourceText: string | undefined,\n kind: string | undefined,\n ): CorsaType | undefined {\n return this.withTransportRecovery(\n () => this.getTypeAtSourceRangeUnchecked(fileName, start, end, sourceText, kind),\n \"looking up a type\",\n );\n }\n\n private getTypeAtSourceRangeUnchecked(\n fileName: string,\n start: number,\n end: number,\n sourceText: string | undefined,\n kind: string | undefined,\n ): CorsaType | undefined {\n if (!sourceText || end <= start) {\n return this.getTypeAtPositionUnchecked(fileName, start, sourceText);\n }\n const state = this.fileState(fileName, sourceText);\n const key = `${start}:${end}:${kind ?? \"\"}`;\n if (!state.typeBySourceRange.has(key)) {\n state.typeBySourceRange.set(\n key,\n this.client().getTypeAtSourceRange(\n this.#snapshot!,\n state.projectId,\n fileName,\n start,\n end,\n sourceText,\n kind,\n ) as CorsaType | undefined,\n );\n }\n const type = this.rememberType(state.typeBySourceRange.get(key));\n if (type) {\n this.#typeLookupById.set(type.id, { fileName, position: start, sourceText });\n if (kind !== \"Identifier\") {\n this.rememberTypeSourceRange(type, fileName, start, end, sourceText);\n }\n }\n return type;\n }\n\n getSymbolAtPosition(\n fileName: string,\n position: number,\n sourceText?: string,\n ): CorsaSymbol | undefined {\n return this.withTransportRecovery(\n () => this.getSymbolAtPositionUnchecked(fileName, position, sourceText),\n \"looking up a symbol\",\n );\n }\n\n private getSymbolAtPositionUnchecked(\n fileName: string,\n position: number,\n sourceText?: string,\n ): CorsaSymbol | undefined {\n const state = this.fileState(fileName, sourceText);\n if (!state.symbolByPosition.has(position)) {\n state.symbolByPosition.set(\n position,\n this.client().getSymbolAtPosition(this.#snapshot!, state.projectId, fileName, position) as\n | CorsaSymbol\n | undefined,\n );\n }\n return this.rememberSymbol(state.symbolByPosition.get(position));\n }\n\n getSymbol(symbol: string | CorsaSymbol): CorsaSymbol | undefined {\n if (typeof symbol !== \"string\") {\n return this.rememberSymbol(symbol);\n }\n const cached = this.#symbolsById.get(symbol);\n if (cached) {\n return cached;\n }\n const typeId = this.#symbolTypeById.get(symbol);\n if (!typeId || !this.#snapshot) {\n return undefined;\n }\n const resolved = this.client().getSymbolOfType(this.#snapshot, typeId) as CorsaSymbol | null;\n return resolved?.id === symbol ? this.rememberUsableSymbol(resolved) : undefined;\n }\n\n getSymbolOfType(type: CorsaType): CorsaSymbol | undefined {\n if (type.symbol) {\n const symbol = this.getSymbol(type.symbol);\n if (isUsableSymbol(symbol)) {\n return symbol;\n }\n }\n if (!this.#snapshot) {\n return undefined;\n }\n return this.rememberUsableSymbol(\n this.client().getSymbolOfType(this.#snapshot, type.id) as CorsaSymbol | null,\n );\n }\n\n getNode(node: string | CorsaNode): CorsaNode | undefined {\n if (typeof node !== \"string\") {\n return node;\n }\n return this.#nodesById.get(node) ?? this.rememberNode(node);\n }\n\n getSourceTextForPath(path: string): string | undefined {\n return this.sourceTextForPath(path);\n }\n\n getTypeOfSymbol(symbol: CorsaSymbol): CorsaType | undefined {\n const type = this.rememberType(this.tryGetSymbolType(symbol, \"getTypeOfSymbol\"));\n this.rememberTypeSource(type, symbol.valueDeclaration);\n return type;\n }\n\n getTypeOfSymbolById(id: string): CorsaType | undefined {\n return this.rememberType(this.tryGetSymbolTypeId(id, \"getTypeOfSymbol\"));\n }\n\n getDeclaredTypeOfSymbol(symbol: CorsaSymbol): CorsaType | undefined {\n const type = this.rememberType(this.tryGetSymbolType(symbol, \"getDeclaredTypeOfSymbol\"));\n this.rememberTypeSource(type, symbol.valueDeclaration);\n return type;\n }\n\n getDeclaredTypeOfSymbolById(id: string): CorsaType | undefined {\n return this.rememberType(this.tryGetSymbolTypeId(id, \"getDeclaredTypeOfSymbol\"));\n }\n\n typeToString(type: CorsaType, flags?: number): string {\n try {\n const text = this.client().typeToString(\n this.#snapshot!,\n this.projectId(),\n type.id,\n undefined,\n flags,\n );\n if (flags === undefined) {\n this.#typeTextById.set(type.id, text);\n }\n return text;\n } catch (error) {\n const cached = flags === undefined ? this.#typeTextById.get(type.id) : undefined;\n if (cached !== undefined) {\n return cached;\n }\n throw error;\n }\n }\n\n getBaseTypeOfLiteralType(type: CorsaType): CorsaType | undefined {\n return this.rememberType(\n this.client().callJson(\"getBaseTypeOfLiteralType\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n type: type.id,\n }),\n );\n }\n\n getPropertiesOfType(type: CorsaType): readonly CorsaSymbol[] {\n return this.rememberSymbols(\n this.client().callJson(\"getPropertiesOfType\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n type: type.id,\n }) ?? [],\n );\n }\n\n getSignaturesOfType(type: CorsaType, kind: number): readonly CorsaSignature[] {\n const source = this.sourceContextForType(type);\n return this.rememberSignatures(\n this.client().callJson(\"getSignaturesOfType\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n type: type.id,\n kind,\n ...source,\n }) ?? [],\n );\n }\n\n getCallSignatureFacts(\n type: CorsaType,\n kind: number,\n argumentTypeTexts: readonly (readonly string[])[],\n explicitTypeArgumentTexts: readonly string[],\n ): CorsaCallSignatureFacts {\n const source = this.sourceContextForType(type);\n const facts = this.client().callJson<CorsaCallSignatureFacts>(\"getCallSignatureFacts\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n type: type.id,\n kind,\n ...source,\n argumentTypeTexts,\n explicitTypeArgumentTexts,\n });\n if (facts?.signature) {\n this.rememberSignature(facts.signature);\n }\n return facts ?? {};\n }\n\n getReturnTypeOfSignature(signature: CorsaSignature): CorsaType | undefined {\n return this.rememberType(\n this.client().callJson(\"getReturnTypeOfSignature\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n signature: signature.id,\n }),\n );\n }\n\n getTypePredicateOfSignature(signature: CorsaSignature): CorsaTypePredicate | undefined {\n const predicate = this.client().callJson<CorsaTypePredicate | undefined>(\n \"getTypePredicateOfSignature\",\n {\n snapshot: this.#snapshot,\n project: this.projectId(),\n signature: signature.id,\n },\n );\n if (predicate?.type) {\n this.rememberType(predicate.type);\n }\n return predicate;\n }\n\n getBaseTypes(type: CorsaType): readonly CorsaType[] {\n if (isArrayOrTupleLikeType(this, type)) {\n return [];\n }\n return this.rememberTypes(\n this.client().callJson(\"getBaseTypes\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n type: type.id,\n texts: this.typeTexts(type),\n }) ?? [],\n );\n }\n\n getTypeArguments(type: CorsaType): readonly CorsaType[] {\n const source = this.sourceSliceForType(type);\n return this.rememberTypes(\n source\n ? (this.client().getTypeArgumentsAtSourceRange(\n this.#snapshot!,\n this.projectId(),\n type.id,\n type.objectFlags,\n source.node.fileName,\n source.node.pos,\n source.node.end,\n this.sourceTextForPath(source.node.fileName) ?? \"\",\n ) as unknown as readonly CorsaType[])\n : (this.client().getTypeArguments(\n this.#snapshot!,\n this.projectId(),\n type.id,\n type.objectFlags,\n ) as unknown as readonly CorsaType[]),\n );\n }\n\n getTypesOfType(type: CorsaType): readonly CorsaType[] {\n if (\n (type.flags & (typeFlags.union | typeFlags.intersection | typeFlags.templateLiteral)) ===\n 0\n ) {\n return [];\n }\n return this.callTypeArray(\"getTypesOfType\", type);\n }\n\n getTargetOfType(type: CorsaType): CorsaType | undefined {\n if (\n (type.flags & (typeFlags.index | typeFlags.stringMapping)) === 0 &&\n ((type.objectFlags ?? 0) & (objectFlags.reference | objectFlags.mapped)) === 0\n ) {\n return undefined;\n }\n const target = this.callType(\"getTargetOfType\", type);\n this.cacheTypeText(target);\n return target;\n }\n\n getTypeParametersOfType(type: CorsaType): readonly CorsaType[] {\n const flags = type.objectFlags ?? 0;\n if ((type.flags & typeFlags.object) === 0 || (flags & objectFlags.classOrInterface) === 0) {\n return [];\n }\n return this.callTypeArray(\"getTypeParametersOfType\", type);\n }\n\n getOuterTypeParametersOfType(type: CorsaType): readonly CorsaType[] {\n const flags = type.objectFlags ?? 0;\n if ((type.flags & typeFlags.object) === 0 || (flags & objectFlags.classOrInterface) === 0) {\n return [];\n }\n return this.callTypeArray(\"getOuterTypeParametersOfType\", type);\n }\n\n getLocalTypeParametersOfType(type: CorsaType): readonly CorsaType[] {\n const flags = type.objectFlags ?? 0;\n if ((type.flags & typeFlags.object) === 0 || (flags & objectFlags.classOrInterface) === 0) {\n return [];\n }\n return this.callTypeArray(\"getLocalTypeParametersOfType\", type);\n }\n\n getObjectTypeOfType(type: CorsaType): CorsaType | undefined {\n return (type.flags & typeFlags.indexedAccess) !== 0\n ? this.callType(\"getObjectTypeOfType\", type)\n : undefined;\n }\n\n getIndexTypeOfType(type: CorsaType): CorsaType | undefined {\n return (type.flags & typeFlags.indexedAccess) !== 0\n ? this.callType(\"getIndexTypeOfType\", type)\n : undefined;\n }\n\n getCheckTypeOfType(type: CorsaType): CorsaType | undefined {\n return (type.flags & typeFlags.conditional) !== 0\n ? this.callType(\"getCheckTypeOfType\", type)\n : undefined;\n }\n\n getExtendsTypeOfType(type: CorsaType): CorsaType | undefined {\n return (type.flags & typeFlags.conditional) !== 0\n ? this.callType(\"getExtendsTypeOfType\", type)\n : undefined;\n }\n\n getBaseTypeOfType(type: CorsaType): CorsaType | undefined {\n return (type.flags & typeFlags.substitution) !== 0\n ? this.callType(\"getBaseTypeOfType\", type)\n : undefined;\n }\n\n getConstraintOfType(type: CorsaType): CorsaType | undefined {\n return this.rememberType(\n this.client().getConstraintOfType(this.#snapshot!, this.projectId(), type.id) as\n | CorsaType\n | undefined,\n );\n }\n\n private callType(method: string, type: CorsaType): CorsaType | undefined {\n return this.rememberType(\n this.client().callJson<CorsaType | null>(method, {\n snapshot: this.#snapshot,\n type: type.id,\n }) ?? undefined,\n );\n }\n\n private callTypeArray(method: string, type: CorsaType): readonly CorsaType[] {\n return this.rememberTypes(\n this.client().callJson<readonly CorsaType[] | null>(method, {\n snapshot: this.#snapshot,\n type: type.id,\n }) ?? [],\n );\n }\n\n private tryGetSymbolType(\n symbol: CorsaSymbol,\n method: \"getTypeOfSymbol\" | \"getDeclaredTypeOfSymbol\",\n ): CorsaType | undefined {\n return this.tryGetSymbolTypeId(symbol.id, method);\n }\n\n private tryGetSymbolTypeId(\n id: string,\n method: \"getTypeOfSymbol\" | \"getDeclaredTypeOfSymbol\",\n ): CorsaType | undefined {\n try {\n return this.client()[method](this.#snapshot!, this.projectId(), id) as CorsaType | undefined;\n } catch {\n return undefined;\n }\n }\n\n private sourceSliceForType(type: CorsaType): SourceSlice | undefined {\n const cached = this.#typeSourceById.get(type.id);\n if (cached) {\n return cached;\n }\n const lookup = this.#typeLookupById.get(type.id);\n if (lookup) {\n const symbol = this.getSymbolAtPosition(lookup.fileName, lookup.position, lookup.sourceText);\n this.rememberTypeSource(type, symbol?.valueDeclaration);\n const fromLookup = this.#typeSourceById.get(type.id);\n if (fromLookup) {\n return fromLookup;\n }\n }\n if (type.symbol) {\n const symbol = this.getSymbol(type.symbol);\n this.rememberTypeSource(type, symbol?.valueDeclaration);\n }\n return this.#typeSourceById.get(type.id);\n }\n\n private rememberType<T extends CorsaType | undefined>(type: T): T {\n if (type) {\n this.#snapshotHasIssuedHandles = true;\n }\n if (type?.symbol) {\n this.#symbolTypeById.set(type.symbol, type.id);\n }\n if (type?.texts?.[0]) {\n this.#typeTextById.set(type.id, type.texts[0]);\n }\n return type;\n }\n\n private rememberTypes<T extends readonly CorsaType[]>(types: T): T {\n for (const type of types) {\n this.rememberType(type);\n }\n return types;\n }\n\n private rememberTypeSource(type: CorsaType | undefined, handle: string | undefined): void {\n if (!type || !handle || this.#typeSourceById.has(type.id)) {\n return;\n }\n const source = this.sourceSliceForHandle(handle);\n if (source) {\n this.#typeSourceById.set(type.id, source);\n }\n }\n\n private rememberTypeSourceRange(\n type: CorsaType,\n fileName: string,\n start: number,\n end: number,\n sourceText: string | undefined,\n ): void {\n if (\n this.#typeSourceById.has(type.id) ||\n !sourceText ||\n start < 0 ||\n end > sourceText.length ||\n start >= end\n ) {\n return;\n }\n const node = {\n fileName,\n pos: start,\n end,\n range: [start, end] as const,\n };\n this.#typeSourceById.set(type.id, {\n node,\n text: sourceText.slice(start, end),\n });\n }\n\n private cacheTypeText(type: CorsaType | undefined): void {\n if (!type || this.#typeTextById.has(type.id)) {\n return;\n }\n try {\n this.#typeTextById.set(\n type.id,\n this.client().typeToString(this.#snapshot!, this.projectId(), type.id),\n );\n } catch {\n // Some upstream handles are only renderable before a later relation query.\n }\n }\n\n private typeTexts(type: CorsaType): readonly string[] {\n if (Array.isArray(type.texts) && type.texts.length > 0) {\n return type.texts;\n }\n const cached = this.#typeTextById.get(type.id);\n return cached === undefined ? [] : [cached];\n }\n\n private sourceContextForType(type: CorsaType): { file?: string; sourceText?: string } {\n const lookup = this.#typeLookupById.get(type.id);\n if (lookup) {\n const sourceText = lookup.sourceText ?? this.sourceTextForPath(lookup.fileName);\n return sourceText ? { file: lookup.fileName, sourceText } : {};\n }\n const source = this.#typeSourceById.get(type.id);\n if (source) {\n const sourceText = this.sourceTextForPath(source.node.fileName);\n return sourceText ? { file: source.node.fileName, sourceText } : {};\n }\n return {};\n }\n\n private rememberSymbol<T extends CorsaSymbol | undefined>(symbol: T): T {\n if (!symbol) {\n return symbol;\n }\n this.#snapshotHasIssuedHandles = true;\n this.#symbolsById.set(symbol.id, symbol);\n for (const declaration of symbol.declarations ?? []) {\n this.rememberNode(declaration);\n }\n if (symbol.valueDeclaration) {\n this.rememberNode(symbol.valueDeclaration);\n }\n return symbol;\n }\n\n private rememberUsableSymbol(symbol: CorsaSymbol | null | undefined): CorsaSymbol | undefined {\n return isUsableSymbol(symbol) ? this.rememberSymbol(symbol) : undefined;\n }\n\n private rememberSymbols<T extends readonly CorsaSymbol[]>(symbols: T): T {\n for (const symbol of symbols) {\n this.rememberSymbol(symbol);\n }\n return symbols;\n }\n\n private rememberSignatures<T extends readonly CorsaSignature[]>(signatures: T): T {\n for (const signature of signatures) {\n this.rememberSignature(signature);\n }\n return signatures;\n }\n\n private rememberSignature(signature: CorsaSignature): CorsaSignature {\n if (signature.declaration) {\n this.rememberNode(signature.declaration);\n }\n for (const symbol of signature.parameterSymbols ?? []) {\n this.rememberSymbol(symbol);\n }\n if (signature.thisParameterSymbol) {\n this.rememberSymbol(signature.thisParameterSymbol);\n }\n return signature;\n }\n\n private rememberNode(handle: string): CorsaNode | undefined {\n const parsed = parseNodeHandle(handle);\n if (!parsed) {\n return undefined;\n }\n this.#nodesById.set(handle, parsed);\n return parsed;\n }\n\n private clearHandleCaches(): void {\n this.#symbolsById.clear();\n this.#symbolTypeById.clear();\n this.#nodesById.clear();\n this.#typeLookupById.clear();\n this.#typeSourceById.clear();\n this.#snapshotHasIssuedHandles = false;\n }\n\n private sourceSliceForHandle(handle: string): SourceSlice | undefined {\n const node = this.getNode(handle);\n if (!node) {\n return undefined;\n }\n const sourceText = this.sourceTextForPath(node.fileName);\n if (!sourceText || node.pos < 0 || node.end > sourceText.length || node.pos >= node.end) {\n return undefined;\n }\n return {\n node,\n text: sourceText.slice(node.pos, node.end),\n };\n }\n\n private sourceTextForPath(path: string): string | undefined {\n for (const [fileName, cached] of this.#files) {\n if (fileName === path || fileName.endsWith(path)) {\n return cached.lintSourceText ?? cached.sourceText ?? readFileOrUndefined(fileName);\n }\n }\n return readFileOrUndefined(path) ?? readFileOrUndefined(`${this.runtime.cwd}/${path}`);\n }\n\n private withTransportRecovery<T>(operation: () => T, action: string): T {\n if (this.#fatalTransportError) {\n throw this.#fatalTransportError;\n }\n try {\n return operation();\n } catch (error) {\n if (!isRecoverableTransportError(error)) {\n throw error;\n }\n this.resetClientAfterTransportFailure();\n try {\n return operation();\n } catch (retryError) {\n if (!isRecoverableTransportError(retryError)) {\n throw retryError;\n }\n const fatal = new Error(\n `corsa type-aware backend exited while ${action}; restarted the session, but the retry failed`,\n );\n (fatal as Error & { cause?: unknown }).cause = retryError;\n this.#fatalTransportError = fatal;\n throw fatal;\n }\n }\n }\n\n private resetClientAfterTransportFailure(): void {\n this.tryCloseClient();\n this.#client = undefined;\n this.#config = undefined;\n this.#snapshot = undefined;\n this.#projects = [];\n this.#files.clear();\n this.clearHandleCaches();\n this.#typeTextById.clear();\n this.#lastRefreshMs = 0;\n this.#supportsOverlayChanges = undefined;\n this.#fatalTransportError = undefined;\n }\n\n private tryReleaseHandle(handle: string): void {\n try {\n this.#client?.releaseHandle(handle);\n } catch (error) {\n if (!isRecoverableTransportError(error)) {\n throw error;\n }\n }\n }\n\n private tryCloseClient(): void {\n try {\n this.#client?.close();\n } catch (error) {\n if (!isRecoverableTransportError(error)) {\n throw error;\n }\n }\n }\n\n private client(): CorsaApiClient {\n if (!this.#client) {\n this.#client = CorsaApiClient.spawn({\n executable: this.runtime.executable,\n cwd: this.runtime.cwd,\n mode: this.runtime.mode,\n });\n this.#client.initialize();\n }\n return this.#client;\n }\n\n private config(): { options: unknown; fileNames: string[] } {\n if (!this.#config) {\n this.#config = this.client().parseConfigFile(this.project.configPath);\n }\n const config = this.#config;\n if (!config) {\n throw new Error(`corsa oxlint could not parse a Corsa config for ${this.project.configPath}`);\n }\n return config;\n }\n\n private fileState(fileName: string, sourceText?: string): FileCache {\n const prepared = this.refreshIfNeeded(fileName, sourceText);\n const current = this.#files.get(fileName);\n if (current) {\n return current;\n }\n const project = this.client().callJson<ProjectResponse | null>(\"getDefaultProjectForFile\", {\n snapshot: this.#snapshot,\n file: fileName,\n });\n const state: FileCache = {\n mtimeMs: prepared.mtimeMs,\n lintSourceText: prepared.lintSourceText,\n sourceText: prepared.sourceText,\n projectId: project?.id ?? this.projectId(),\n typeByPosition: new Map(),\n typeBySourceRange: new Map(),\n symbolByPosition: new Map(),\n };\n this.#files.set(fileName, state);\n return state;\n }\n\n private refreshIfNeeded(fileName: string, sourceText?: string): PreparedFileState {\n const now = Date.now();\n const expired = now - this.#lastRefreshMs > this.runtime.cacheLifetimeMs;\n const cached = this.#files.get(fileName);\n const mtimeMs = statMtimeMs(fileName);\n const overlayText = this.supportedOverlayText(fileName, sourceText, mtimeMs, cached);\n const mtimeChanged = cached !== undefined && mtimeMs !== cached.mtimeMs;\n const textChanged = overlayText !== cached?.sourceText;\n const prepared = {\n mtimeMs,\n lintSourceText: sourceText,\n sourceText: overlayText,\n };\n const stale =\n !this.#snapshot ||\n mtimeChanged ||\n textChanged ||\n (expired && !this.#snapshotHasIssuedHandles);\n if (!stale) {\n return prepared;\n }\n const previous = this.#snapshot;\n const overlayChanges = this.overlayChanges(fileName, overlayText, cached);\n const response = this.client().updateSnapshot({\n ...(previous\n ? { fileChanges: { changed: [fileName] } }\n : { openProject: this.project.configPath }),\n ...(overlayChanges === undefined ? {} : { overlayChanges }),\n });\n this.#snapshot = response.snapshot;\n this.#projects = response.projects;\n this.#lastRefreshMs = now;\n this.#files.clear();\n this.clearHandleCaches();\n if (previous && previous !== this.#snapshot) {\n this.tryReleaseHandle(previous);\n }\n return prepared;\n }\n\n private projectId(): string {\n const id = this.#projects[0]?.id;\n if (!id) {\n throw new Error(\n `corsa oxlint could not resolve a Corsa project for ${this.project.filename}`,\n );\n }\n return id;\n }\n\n private supportedOverlayText(\n fileName: string,\n sourceText: string | undefined,\n mtimeMs: number,\n cached?: FileCache,\n ): string | undefined {\n if (sourceText === undefined || !this.supportsOverlayChanges()) {\n return undefined;\n }\n if (cached?.lintSourceText === sourceText && cached.mtimeMs === mtimeMs) {\n return cached.sourceText;\n }\n return overlayTextFor(fileName, sourceText);\n }\n\n private overlayChanges(\n fileName: string,\n overlayText: string | undefined,\n cached?: FileCache,\n ):\n | {\n upsert?: { document: string; text: string; languageId: string }[];\n delete?: string[];\n }\n | undefined {\n if (!this.supportsOverlayChanges()) {\n return undefined;\n }\n if (overlayText !== undefined) {\n return {\n upsert: [\n {\n document: fileName,\n text: overlayText,\n languageId: languageIdFor(fileName),\n },\n ],\n };\n }\n if (cached?.sourceText !== undefined) {\n return { delete: [fileName] };\n }\n return undefined;\n }\n\n private supportsOverlayChanges(): boolean {\n if (this.#supportsOverlayChanges !== undefined) {\n return this.#supportsOverlayChanges;\n }\n try {\n const capabilities = this.client().callJson<{\n overlay?: { updateSnapshotOverlayChanges?: boolean };\n }>(\"describeCapabilities\");\n this.#supportsOverlayChanges = capabilities?.overlay?.updateSnapshotOverlayChanges === true;\n } catch {\n this.#supportsOverlayChanges = false;\n }\n return this.#supportsOverlayChanges;\n }\n}\n\nfunction isArrayOrTupleLikeType(session: CorsaProjectSession, type: CorsaType): boolean {\n const texts =\n Array.isArray(type.texts) && type.texts.length > 0 ? type.texts : [session.typeToString(type)];\n return texts.some((text) => {\n const normalized = text.trimStart();\n return (\n normalized.startsWith(\"readonly [\") || normalized.startsWith(\"[\") || normalized.endsWith(\"[]\")\n );\n });\n}\n\nfunction isUsableSymbol(symbol: CorsaSymbol | null | undefined): symbol is CorsaSymbol {\n return symbol != null && !symbol.name.includes(\"\\ufffd\");\n}\n\nfunction overlayTextFor(fileName: string, sourceText?: string): string | undefined {\n if (sourceText === undefined) {\n return undefined;\n }\n try {\n return readFileSync(fileName, \"utf8\") === sourceText ? undefined : sourceText;\n } catch {\n return sourceText;\n }\n}\n\nfunction statMtimeMs(fileName: string): number {\n try {\n return statSync(fileName).mtimeMs;\n } catch {\n return 0;\n }\n}\n\nfunction languageIdFor(fileName: string): string {\n if (fileName.endsWith(\".tsx\")) {\n return \"typescriptreact\";\n }\n if (fileName.endsWith(\".jsx\")) {\n return \"javascriptreact\";\n }\n if (fileName.endsWith(\".js\")) {\n return \"javascript\";\n }\n return \"typescript\";\n}\n\nfunction parseNodeHandle(value: string): CorsaNode | undefined {\n const [posText, endText, _kindText, ...pathParts] = value.split(\".\");\n const pos = Number(posText);\n const end = Number(endText);\n const fileName = pathParts.join(\".\");\n if (!Number.isFinite(pos) || !Number.isFinite(end) || !fileName) {\n return undefined;\n }\n return { id: value, fileName, pos, end, range: [pos, end] };\n}\n\nfunction isRecoverableTransportError(error: unknown): boolean {\n const message = errorMessage(error);\n return (\n message.includes(\"process is closed:\") ||\n message.includes(\"Broken pipe\") ||\n message.includes(\"EPIPE\") ||\n message.includes(\"failed to fill whole buffer\") ||\n message.includes(\"msgpack worker\") ||\n message.includes(\"msgpack stdin\") ||\n message.includes(\"msgpack stdout\") ||\n message.includes(\"jsonrpc reader\") ||\n message.includes(\"jsonrpc writer\") ||\n message.includes(\"jsonrpc connection\")\n );\n}\n\nfunction errorMessage(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\nfunction readFileOrUndefined(path: string): string | undefined {\n try {\n return readFileSync(path, \"utf8\");\n } catch {\n return undefined;\n }\n}\n"],"mappings":";;;AAyCA,MAAM,YAAY;CAChB,QAAQ,KAAK;CACb,OAAO,KAAK;CACZ,iBAAiB,KAAK;CACtB,eAAe,KAAK;CACpB,cAAc,KAAK;CACnB,eAAe,KAAK;CACpB,aAAa,KAAK;CAClB,OAAO,KAAK;CACZ,cAAc,KAAK;AACrB;AAEA,MAAM,cAAc;CAClB,kBAAkB;CAClB,WAAW;CACX,QAAQ;AACV;AAEA,IAAa,sBAAb,MAAiC;CAkBpB;CACA;CAlBX;CACA;CACA;CACA,YAA+B,CAAC;CAChC,yBAAS,IAAI,IAAuB;CACpC,+BAAe,IAAI,IAAyB;CAC5C,kCAAkB,IAAI,IAAoB;CAC1C,6BAAa,IAAI,IAAuB;CACxC,kCAAkB,IAAI,IAAwB;CAC9C,kCAAkB,IAAI,IAAyB;CAC/C,gCAAgB,IAAI,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AAS,SAAS,WAAW,GAAG,aAAa,MAAM,MAAM,GAAG;CACnE,MAAM,MAAM,OAAO,OAAO;CAC1B,MAAM,MAAM,OAAO,OAAO;CAC1B,MAAM,WAAW,UAAU,KAAK,GAAG;CACnC,IAAI,CAAC,OAAO,SAAS,GAAG,KAAK,CAAC,OAAO,SAAS,GAAG,KAAK,CAAC,UACrD;CAEF,OAAO;EAAE,IAAI;EAAO;EAAU;EAAK;EAAK,OAAO,CAAC,KAAK,GAAG;CAAE;AAC5D;AAEA,SAAS,4BAA4B,OAAyB;CAC5D,MAAM,UAAU,aAAa,KAAK;CAClC,OACE,QAAQ,SAAS,oBAAoB,KACrC,QAAQ,SAAS,aAAa,KAC9B,QAAQ,SAAS,OAAO,KACxB,QAAQ,SAAS,6BAA6B,KAC9C,QAAQ,SAAS,gBAAgB,KACjC,QAAQ,SAAS,eAAe,KAChC,QAAQ,SAAS,gBAAgB,KACjC,QAAQ,SAAS,gBAAgB,KACjC,QAAQ,SAAS,gBAAgB,KACjC,QAAQ,SAAS,oBAAoB;AAEzC;AAEA,SAAS,aAAa,OAAwB;CAC5C,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAC9D;AAEA,SAAS,oBAAoB,MAAkC;CAC7D,IAAI;EACF,OAAO,aAAa,MAAM,MAAM;CAClC,QAAQ;EACN;CACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "corsa-oxlint",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.46.0",
|
|
4
4
|
"description": "Type-aware Oxlint helpers powered by Corsa",
|
|
5
5
|
"homepage": "https://github.com/ubugeeei-prod/corsa-bind/tree/main/src/bindings/nodejs/corsa_oxlint",
|
|
6
6
|
"bugs": {
|
|
@@ -101,12 +101,17 @@
|
|
|
101
101
|
"./package.json": "./package.json"
|
|
102
102
|
},
|
|
103
103
|
"dependencies": {
|
|
104
|
+
"@corsa-bind/napi": "0.46.0"
|
|
105
|
+
},
|
|
106
|
+
"devDependencies": {
|
|
104
107
|
"@oxlint/plugins": "1.69.0",
|
|
108
|
+
"@typescript-eslint/utils": "8.61.0",
|
|
105
109
|
"oxlint": "1.69.0",
|
|
106
|
-
"
|
|
110
|
+
"oxlint-tsgolint": "0.23.0"
|
|
107
111
|
},
|
|
108
|
-
"
|
|
109
|
-
"@
|
|
112
|
+
"peerDependencies": {
|
|
113
|
+
"@oxlint/plugins": "^1.69.0",
|
|
114
|
+
"oxlint": "^1.69.0"
|
|
110
115
|
},
|
|
111
116
|
"engines": {
|
|
112
117
|
"bun": ">=1.2",
|