corsa-oxlint 0.41.1 → 0.42.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/context.js CHANGED
@@ -15,7 +15,11 @@ const DEFAULT_TS_CONFIG = { compilerOptions: {
15
15
  strict: true
16
16
  } };
17
17
  function defaultCorsaExecutable(rootDir, platform = process.platform) {
18
- return resolveNativePreviewExecutable(rootDir) ?? resolve(rootDir, platform === "win32" ? ".cache/corsa.exe" : ".cache/corsa");
18
+ const nativePreview = resolveNativePreviewExecutable(rootDir);
19
+ if (nativePreview) return nativePreview;
20
+ const fallback = resolve(rootDir, platform === "win32" ? ".cache/corsa.exe" : ".cache/corsa");
21
+ if (existsSync(fallback)) return fallback;
22
+ throw new Error(["corsa-oxlint could not locate a Corsa runtime executable.", "Install `@typescript/native-preview`, set `CORSA_EXECUTABLE`, or configure `parserOptions.corsa.executable`."].join(" "));
19
23
  }
20
24
  function resolveProjectConfig(context) {
21
25
  const filename = resolve(context.filename);
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","names":[],"sources":["../ts/context.ts"],"sourcesContent":["import { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { dirname, resolve } from \"node:path\";\n\nimport type {\n ContextWithParserOptions,\n CorsaOxlintSettings,\n ProjectServiceOptions,\n ResolvedProjectConfig,\n ResolvedRuntimeOptions,\n TypeAwareParserOptions,\n} from \"./types\";\n\nconst DEFAULT_CACHE_LIFETIME_MS = 250;\nconst DEFAULT_PROJECT_PATTERNS = [\"*.ts\", \"*.tsx\", \"*.js\", \"*.jsx\"];\nconst DEFAULT_TS_CONFIG = {\n compilerOptions: {\n module: \"esnext\",\n target: \"es2022\",\n strict: true,\n },\n};\n\nexport function defaultCorsaExecutable(rootDir: string, platform = process.platform): string {\n return (\n resolveNativePreviewExecutable(rootDir) ??\n resolve(rootDir, platform === \"win32\" ? \".cache/corsa.exe\" : \".cache/corsa\")\n );\n}\n\nexport function resolveProjectConfig(context: ContextWithParserOptions): ResolvedProjectConfig {\n const filename = resolve(context.filename);\n const parserOptions = resolveTypeAwareParserOptions(context);\n const rootDir = resolve(parserOptions.tsconfigRootDir ?? context.cwd);\n const runtime = resolveRuntimeOptions(rootDir, parserOptions);\n const configPath =\n resolveExplicitProject(rootDir, parserOptions) ??\n discoverTsconfig(filename, rootDir) ??\n resolveDefaultProject(rootDir, filename, parserOptions.projectService);\n if (!configPath) {\n throw new Error(`corsa oxlint could not resolve a tsconfig for ${filename}`);\n }\n return { filename, rootDir, configPath, runtime };\n}\n\n/**\n * Resolves the type-aware parser options visible to a rule.\n *\n * Oxlint exposes a fixed `context.languageOptions.parserOptions` object at\n * runtime, so `corsa oxlint` stores its richer configuration under\n * `settings.corsaOxlint` and rehydrates the rule-facing parser options\n * shape from there.\n *\n * @example\n * ```ts\n * const parserOptions = resolveTypeAwareParserOptions(context);\n * parserOptions.corsa?.mode;\n * ```\n */\nexport function resolveTypeAwareParserOptions(\n context: ContextWithParserOptions,\n defaults: TypeAwareParserOptionDefaults = {},\n): TypeAwareParserOptions {\n const parserOptions = mergeTypeAwareParserOptions(\n resolveSettingsParserOptions(context.settings?.corsaOxlint),\n mergeTypeAwareParserOptions(context.parserOptions, context.languageOptions?.parserOptions),\n );\n const rootDir = resolve(parserOptions.tsconfigRootDir ?? context.cwd);\n return applyTypeAwareParserOptionDefaults(parserOptions, defaults, rootDir);\n}\n\ntype TypeAwareParserOptionDefaults = {\n readonly corsa?: boolean;\n readonly projectService?: boolean;\n};\n\nfunction resolveRuntimeOptions(\n rootDir: string,\n parserOptions: TypeAwareParserOptions,\n): ResolvedRuntimeOptions {\n const runtime = parserOptions.corsa;\n return {\n executable: resolve(\n runtime?.executable ?? process.env.CORSA_EXECUTABLE ?? defaultCorsaExecutable(rootDir),\n ),\n cwd: resolve(runtime?.cwd ?? rootDir),\n mode: runtime?.mode ?? \"msgpack\",\n cacheLifetimeMs: runtime?.cacheLifetimeMs ?? DEFAULT_CACHE_LIFETIME_MS,\n };\n}\n\nfunction resolveExplicitProject(\n rootDir: string,\n parserOptions: TypeAwareParserOptions,\n): string | undefined {\n const projects = asArray(parserOptions.project).map((project) => {\n return resolve(rootDir, project);\n });\n return projects.find(existsSync);\n}\n\nfunction discoverTsconfig(filename: string, rootDir: string): string | undefined {\n let current = dirname(filename);\n const boundary = resolve(rootDir);\n while (current.startsWith(boundary)) {\n const candidate = resolve(current, \"tsconfig.json\");\n if (existsSync(candidate)) {\n return candidate;\n }\n const parent = dirname(current);\n if (parent === current) {\n break;\n }\n current = parent;\n }\n return undefined;\n}\n\nfunction resolveDefaultProject(\n rootDir: string,\n filename: string,\n projectService: boolean | ProjectServiceOptions | undefined,\n): string | undefined {\n if (!projectService) {\n return undefined;\n }\n if (projectService !== true && projectService.defaultProject) {\n return resolve(rootDir, projectService.defaultProject);\n }\n if (!matchesDefaultProject(filename, projectService as true | ProjectServiceOptions)) {\n return undefined;\n }\n const id = Buffer.from(filename).toString(\"hex\").slice(0, 24);\n const cacheDir = resolve(rootDir, \".cache/corsa_oxlint/default\");\n const configPath = resolve(cacheDir, `${id}.tsconfig.json`);\n if (!existsSync(configPath)) {\n mkdirSync(cacheDir, { recursive: true });\n writeFileSync(\n configPath,\n JSON.stringify(\n {\n ...DEFAULT_TS_CONFIG,\n files: [filename],\n },\n null,\n 2,\n ),\n );\n }\n return configPath;\n}\n\nfunction matchesDefaultProject(\n filename: string,\n projectService: true | ProjectServiceOptions,\n): boolean {\n const patterns =\n (projectService === true ? undefined : projectService.allowDefaultProject) ??\n DEFAULT_PROJECT_PATTERNS;\n return patterns.some((pattern: string) => globMatch(filename, pattern));\n}\n\nfunction globMatch(value: string, pattern: string): boolean {\n const escaped = pattern.replaceAll(\".\", \"\\\\.\").replaceAll(\"*\", \".*\");\n return new RegExp(`${escaped}$`).test(value);\n}\n\nfunction asArray(value: string | string[] | undefined): string[] {\n return value ? (Array.isArray(value) ? value : [value]) : [];\n}\n\nfunction resolveNativePreviewExecutable(rootDir: string): string | undefined {\n const requireFromRoot = createRequire(resolve(rootDir, \"package.json\"));\n const packageJsonPath = resolveOptional(\n requireFromRoot,\n \"@typescript/native-preview/package.json\",\n );\n if (packageJsonPath) {\n const binPath = nativePreviewBinPath(packageJsonPath);\n if (binPath && existsSync(binPath)) {\n return binPath;\n }\n }\n const packageEntry = resolveOptional(requireFromRoot, \"@typescript/native-preview\");\n return packageEntry && existsSync(packageEntry) ? packageEntry : undefined;\n}\n\nfunction resolveOptional(requireFromRoot: NodeJS.Require, specifier: string): string | undefined {\n try {\n return requireFromRoot.resolve(specifier);\n } catch {\n return undefined;\n }\n}\n\nfunction nativePreviewBinPath(packageJsonPath: string): string | undefined {\n try {\n const packageJson = JSON.parse(readFileSync(packageJsonPath, \"utf8\")) as {\n readonly bin?: string | Record<string, string>;\n };\n const bin =\n typeof packageJson.bin === \"string\"\n ? packageJson.bin\n : (packageJson.bin?.tsgo ?? Object.values(packageJson.bin ?? {})[0]);\n return bin ? resolve(dirname(packageJsonPath), bin) : undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction resolveSettingsParserOptions(\n settings: CorsaOxlintSettings | undefined,\n): TypeAwareParserOptions {\n if (!settings) {\n return {};\n }\n const { parserOptions, ...inline } = settings;\n return mergeTypeAwareParserOptions(inline, parserOptions);\n}\n\nfunction applyTypeAwareParserOptionDefaults(\n parserOptions: TypeAwareParserOptions,\n defaults: TypeAwareParserOptionDefaults,\n rootDir: string,\n): TypeAwareParserOptions {\n let resolved = parserOptions;\n if (\n defaults.projectService === true &&\n parserOptions.projectService === undefined &&\n parserOptions.project === undefined\n ) {\n resolved = {\n ...resolved,\n projectService: true,\n };\n }\n if (defaults.corsa === true && resolved.corsa?.executable === undefined) {\n resolved = mergeTypeAwareParserOptions(resolved, {\n corsa: {\n executable: process.env.CORSA_EXECUTABLE ?? defaultCorsaExecutable(rootDir),\n },\n });\n }\n return resolved;\n}\n\nexport function mergeTypeAwareParserOptions(\n base: TypeAwareParserOptions | undefined,\n override: TypeAwareParserOptions | undefined,\n): TypeAwareParserOptions {\n if (!base) {\n return normalizeTypeAwareParserOptions(override ?? {});\n }\n if (!override) {\n return normalizeTypeAwareParserOptions(base);\n }\n const runtime = {\n ...base.corsa,\n ...override.corsa,\n };\n return {\n ...base,\n ...override,\n project: override.project ?? base.project,\n projectService: mergeProjectService(base.projectService, override.projectService),\n tsconfigRootDir: override.tsconfigRootDir ?? base.tsconfigRootDir,\n ...(Object.keys(runtime).length > 0 ? { corsa: runtime } : {}),\n };\n}\n\nfunction normalizeTypeAwareParserOptions(options: TypeAwareParserOptions): TypeAwareParserOptions {\n const runtime = options.corsa;\n if (!runtime) {\n return options;\n }\n return {\n ...options,\n corsa: runtime,\n };\n}\n\nfunction mergeProjectService(\n base: boolean | ProjectServiceOptions | undefined,\n override: boolean | ProjectServiceOptions | undefined,\n): boolean | ProjectServiceOptions | undefined {\n if (override === undefined) {\n return base;\n }\n if (typeof override === \"boolean\") {\n return override;\n }\n if (base === undefined || typeof base === \"boolean\") {\n return override;\n }\n return {\n ...base,\n ...override,\n allowDefaultProject: override.allowDefaultProject ?? base.allowDefaultProject,\n defaultProject: override.defaultProject ?? base.defaultProject,\n };\n}\n"],"mappings":";;;;AAaA,MAAM,4BAA4B;AAClC,MAAM,2BAA2B;CAAC;CAAQ;CAAS;CAAQ;CAAQ;AACnE,MAAM,oBAAoB,EACxB,iBAAiB;CACf,QAAQ;CACR,QAAQ;CACR,QAAQ;CACT,EACF;AAED,SAAgB,uBAAuB,SAAiB,WAAW,QAAQ,UAAkB;CAC3F,OACE,+BAA+B,QAAQ,IACvC,QAAQ,SAAS,aAAa,UAAU,qBAAqB,eAAe;;AAIhF,SAAgB,qBAAqB,SAA0D;CAC7F,MAAM,WAAW,QAAQ,QAAQ,SAAS;CAC1C,MAAM,gBAAgB,8BAA8B,QAAQ;CAC5D,MAAM,UAAU,QAAQ,cAAc,mBAAmB,QAAQ,IAAI;CACrE,MAAM,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SAAyD;CAChG,MAAM,UAAU,QAAQ;CACxB,IAAI,CAAC,SACH,OAAO;CAET,OAAO;EACL,GAAG;EACH,OAAO;EACR;;AAGH,SAAS,oBACP,MACA,UAC6C;CAC7C,IAAI,aAAa,KAAA,GACf,OAAO;CAET,IAAI,OAAO,aAAa,WACtB,OAAO;CAET,IAAI,SAAS,KAAA,KAAa,OAAO,SAAS,WACxC,OAAO;CAET,OAAO;EACL,GAAG;EACH,GAAG;EACH,qBAAqB,SAAS,uBAAuB,KAAK;EAC1D,gBAAgB,SAAS,kBAAkB,KAAK;EACjD"}
1
+ {"version":3,"file":"context.js","names":[],"sources":["../ts/context.ts"],"sourcesContent":["import { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { dirname, resolve } from \"node:path\";\n\nimport type {\n ContextWithParserOptions,\n CorsaOxlintSettings,\n ProjectServiceOptions,\n ResolvedProjectConfig,\n ResolvedRuntimeOptions,\n TypeAwareParserOptions,\n} from \"./types\";\n\nconst DEFAULT_CACHE_LIFETIME_MS = 250;\nconst DEFAULT_PROJECT_PATTERNS = [\"*.ts\", \"*.tsx\", \"*.js\", \"*.jsx\"];\nconst DEFAULT_TS_CONFIG = {\n compilerOptions: {\n module: \"esnext\",\n target: \"es2022\",\n strict: true,\n },\n};\n\nexport function defaultCorsaExecutable(rootDir: string, platform = process.platform): string {\n const nativePreview = resolveNativePreviewExecutable(rootDir);\n if (nativePreview) {\n return nativePreview;\n }\n const fallback = resolve(rootDir, platform === \"win32\" ? \".cache/corsa.exe\" : \".cache/corsa\");\n if (existsSync(fallback)) {\n return fallback;\n }\n throw new Error(\n [\n \"corsa-oxlint could not locate a Corsa runtime executable.\",\n \"Install `@typescript/native-preview`, set `CORSA_EXECUTABLE`, or configure `parserOptions.corsa.executable`.\",\n ].join(\" \"),\n );\n}\n\nexport function resolveProjectConfig(context: ContextWithParserOptions): ResolvedProjectConfig {\n const filename = resolve(context.filename);\n const parserOptions = resolveTypeAwareParserOptions(context);\n const rootDir = resolve(parserOptions.tsconfigRootDir ?? context.cwd);\n const runtime = resolveRuntimeOptions(rootDir, parserOptions);\n const configPath =\n resolveExplicitProject(rootDir, parserOptions) ??\n discoverTsconfig(filename, rootDir) ??\n resolveDefaultProject(rootDir, filename, parserOptions.projectService);\n if (!configPath) {\n throw new Error(`corsa oxlint could not resolve a tsconfig for ${filename}`);\n }\n return { filename, rootDir, configPath, runtime };\n}\n\n/**\n * Resolves the type-aware parser options visible to a rule.\n *\n * Oxlint exposes a fixed `context.languageOptions.parserOptions` object at\n * runtime, so `corsa oxlint` stores its richer configuration under\n * `settings.corsaOxlint` and rehydrates the rule-facing parser options\n * shape from there.\n *\n * @example\n * ```ts\n * const parserOptions = resolveTypeAwareParserOptions(context);\n * parserOptions.corsa?.mode;\n * ```\n */\nexport function resolveTypeAwareParserOptions(\n context: ContextWithParserOptions,\n defaults: TypeAwareParserOptionDefaults = {},\n): TypeAwareParserOptions {\n const parserOptions = mergeTypeAwareParserOptions(\n resolveSettingsParserOptions(context.settings?.corsaOxlint),\n mergeTypeAwareParserOptions(context.parserOptions, context.languageOptions?.parserOptions),\n );\n const rootDir = resolve(parserOptions.tsconfigRootDir ?? context.cwd);\n return applyTypeAwareParserOptionDefaults(parserOptions, defaults, rootDir);\n}\n\ntype TypeAwareParserOptionDefaults = {\n readonly corsa?: boolean;\n readonly projectService?: boolean;\n};\n\nfunction resolveRuntimeOptions(\n rootDir: string,\n parserOptions: TypeAwareParserOptions,\n): ResolvedRuntimeOptions {\n const runtime = parserOptions.corsa;\n return {\n executable: resolve(\n runtime?.executable ?? process.env.CORSA_EXECUTABLE ?? defaultCorsaExecutable(rootDir),\n ),\n cwd: resolve(runtime?.cwd ?? rootDir),\n mode: runtime?.mode ?? \"msgpack\",\n cacheLifetimeMs: runtime?.cacheLifetimeMs ?? DEFAULT_CACHE_LIFETIME_MS,\n };\n}\n\nfunction resolveExplicitProject(\n rootDir: string,\n parserOptions: TypeAwareParserOptions,\n): string | undefined {\n const projects = asArray(parserOptions.project).map((project) => {\n return resolve(rootDir, project);\n });\n return projects.find(existsSync);\n}\n\nfunction discoverTsconfig(filename: string, rootDir: string): string | undefined {\n let current = dirname(filename);\n const boundary = resolve(rootDir);\n while (current.startsWith(boundary)) {\n const candidate = resolve(current, \"tsconfig.json\");\n if (existsSync(candidate)) {\n return candidate;\n }\n const parent = dirname(current);\n if (parent === current) {\n break;\n }\n current = parent;\n }\n return undefined;\n}\n\nfunction resolveDefaultProject(\n rootDir: string,\n filename: string,\n projectService: boolean | ProjectServiceOptions | undefined,\n): string | undefined {\n if (!projectService) {\n return undefined;\n }\n if (projectService !== true && projectService.defaultProject) {\n return resolve(rootDir, projectService.defaultProject);\n }\n if (!matchesDefaultProject(filename, projectService as true | ProjectServiceOptions)) {\n return undefined;\n }\n const id = Buffer.from(filename).toString(\"hex\").slice(0, 24);\n const cacheDir = resolve(rootDir, \".cache/corsa_oxlint/default\");\n const configPath = resolve(cacheDir, `${id}.tsconfig.json`);\n if (!existsSync(configPath)) {\n mkdirSync(cacheDir, { recursive: true });\n writeFileSync(\n configPath,\n JSON.stringify(\n {\n ...DEFAULT_TS_CONFIG,\n files: [filename],\n },\n null,\n 2,\n ),\n );\n }\n return configPath;\n}\n\nfunction matchesDefaultProject(\n filename: string,\n projectService: true | ProjectServiceOptions,\n): boolean {\n const patterns =\n (projectService === true ? undefined : projectService.allowDefaultProject) ??\n DEFAULT_PROJECT_PATTERNS;\n return patterns.some((pattern: string) => globMatch(filename, pattern));\n}\n\nfunction globMatch(value: string, pattern: string): boolean {\n const escaped = pattern.replaceAll(\".\", \"\\\\.\").replaceAll(\"*\", \".*\");\n return new RegExp(`${escaped}$`).test(value);\n}\n\nfunction asArray(value: string | string[] | undefined): string[] {\n return value ? (Array.isArray(value) ? value : [value]) : [];\n}\n\nfunction resolveNativePreviewExecutable(rootDir: string): string | undefined {\n const requireFromRoot = createRequire(resolve(rootDir, \"package.json\"));\n const packageJsonPath = resolveOptional(\n requireFromRoot,\n \"@typescript/native-preview/package.json\",\n );\n if (packageJsonPath) {\n const binPath = nativePreviewBinPath(packageJsonPath);\n if (binPath && existsSync(binPath)) {\n return binPath;\n }\n }\n const packageEntry = resolveOptional(requireFromRoot, \"@typescript/native-preview\");\n return packageEntry && existsSync(packageEntry) ? packageEntry : undefined;\n}\n\nfunction resolveOptional(requireFromRoot: NodeJS.Require, specifier: string): string | undefined {\n try {\n return requireFromRoot.resolve(specifier);\n } catch {\n return undefined;\n }\n}\n\nfunction nativePreviewBinPath(packageJsonPath: string): string | undefined {\n try {\n const packageJson = JSON.parse(readFileSync(packageJsonPath, \"utf8\")) as {\n readonly bin?: string | Record<string, string>;\n };\n const bin =\n typeof packageJson.bin === \"string\"\n ? packageJson.bin\n : (packageJson.bin?.tsgo ?? Object.values(packageJson.bin ?? {})[0]);\n return bin ? resolve(dirname(packageJsonPath), bin) : undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction resolveSettingsParserOptions(\n settings: CorsaOxlintSettings | undefined,\n): TypeAwareParserOptions {\n if (!settings) {\n return {};\n }\n const { parserOptions, ...inline } = settings;\n return mergeTypeAwareParserOptions(inline, parserOptions);\n}\n\nfunction applyTypeAwareParserOptionDefaults(\n parserOptions: TypeAwareParserOptions,\n defaults: TypeAwareParserOptionDefaults,\n rootDir: string,\n): TypeAwareParserOptions {\n let resolved = parserOptions;\n if (\n defaults.projectService === true &&\n parserOptions.projectService === undefined &&\n parserOptions.project === undefined\n ) {\n resolved = {\n ...resolved,\n projectService: true,\n };\n }\n if (defaults.corsa === true && resolved.corsa?.executable === undefined) {\n resolved = mergeTypeAwareParserOptions(resolved, {\n corsa: {\n executable: process.env.CORSA_EXECUTABLE ?? defaultCorsaExecutable(rootDir),\n },\n });\n }\n return resolved;\n}\n\nexport function mergeTypeAwareParserOptions(\n base: TypeAwareParserOptions | undefined,\n override: TypeAwareParserOptions | undefined,\n): TypeAwareParserOptions {\n if (!base) {\n return normalizeTypeAwareParserOptions(override ?? {});\n }\n if (!override) {\n return normalizeTypeAwareParserOptions(base);\n }\n const runtime = {\n ...base.corsa,\n ...override.corsa,\n };\n return {\n ...base,\n ...override,\n project: override.project ?? base.project,\n projectService: mergeProjectService(base.projectService, override.projectService),\n tsconfigRootDir: override.tsconfigRootDir ?? base.tsconfigRootDir,\n ...(Object.keys(runtime).length > 0 ? { corsa: runtime } : {}),\n };\n}\n\nfunction normalizeTypeAwareParserOptions(options: TypeAwareParserOptions): TypeAwareParserOptions {\n const runtime = options.corsa;\n if (!runtime) {\n return options;\n }\n return {\n ...options,\n corsa: runtime,\n };\n}\n\nfunction mergeProjectService(\n base: boolean | ProjectServiceOptions | undefined,\n override: boolean | ProjectServiceOptions | undefined,\n): boolean | ProjectServiceOptions | undefined {\n if (override === undefined) {\n return base;\n }\n if (typeof override === \"boolean\") {\n return override;\n }\n if (base === undefined || typeof base === \"boolean\") {\n return override;\n }\n return {\n ...base,\n ...override,\n allowDefaultProject: override.allowDefaultProject ?? base.allowDefaultProject,\n defaultProject: override.defaultProject ?? base.defaultProject,\n };\n}\n"],"mappings":";;;;AAaA,MAAM,4BAA4B;AAClC,MAAM,2BAA2B;CAAC;CAAQ;CAAS;CAAQ;CAAQ;AACnE,MAAM,oBAAoB,EACxB,iBAAiB;CACf,QAAQ;CACR,QAAQ;CACR,QAAQ;CACT,EACF;AAED,SAAgB,uBAAuB,SAAiB,WAAW,QAAQ,UAAkB;CAC3F,MAAM,gBAAgB,+BAA+B,QAAQ;CAC7D,IAAI,eACF,OAAO;CAET,MAAM,WAAW,QAAQ,SAAS,aAAa,UAAU,qBAAqB,eAAe;CAC7F,IAAI,WAAW,SAAS,EACtB,OAAO;CAET,MAAM,IAAI,MACR,CACE,6DACA,+GACD,CAAC,KAAK,IAAI,CACZ;;AAGH,SAAgB,qBAAqB,SAA0D;CAC7F,MAAM,WAAW,QAAQ,QAAQ,SAAS;CAC1C,MAAM,gBAAgB,8BAA8B,QAAQ;CAC5D,MAAM,U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AAO,SAAS,GAAG,EAAE;EAC9D;;AAGH,SAAS,gCAAgC,SAAyD;CAChG,MAAM,UAAU,QAAQ;CACxB,IAAI,CAAC,SACH,OAAO;CAET,OAAO;EACL,GAAG;EACH,OAAO;EACR;;AAGH,SAAS,oBACP,MACA,UAC6C;CAC7C,IAAI,aAAa,KAAA,GACf,OAAO;CAET,IAAI,OAAO,aAAa,WACtB,OAAO;CAET,IAAI,SAAS,KAAA,KAAa,OAAO,SAAS,WACxC,OAAO;CAET,OAAO;EACL,GAAG;EACH,GAAG;EACH,qBAAqB,SAAS,uBAAuB,KAAK;EAC1D,gBAAgB,SAAS,kBAAkB,KAAK;EACjD"}
package/dist/index.d.ts CHANGED
@@ -15,14 +15,196 @@ import { stylistic_d_exports } from "./stylistic.js";
15
15
  import { ESTree as ESTree$1 } from "@oxlint/plugins";
16
16
 
17
17
  //#region src/bindings/nodejs/corsa_oxlint/ts/index.d.ts
18
- type ESTree = {
19
- NewExpression: ESTree$1.NewExpression;
20
- BindingIdentifier: Omit<ESTree$1.BindingIdentifier, "typeAnnotation"> & {
21
- typeAnnotation?: ESTree$1.TSTypeAnnotation | null;
18
+ type CorsaAstNodeType = keyof typeof AST_NODE_TYPES;
19
+ type ESTree = ESTree.NodeTypes;
20
+ declare namespace ESTree {
21
+ export type Node = ESTree$1.Node;
22
+ type NarrowNode<Candidate, Kind extends string> = Candidate extends {
23
+ readonly type: infer CandidateKind;
24
+ } ? Kind extends CandidateKind ? Candidate & {
25
+ readonly type: Kind;
26
+ } : never : never;
27
+ export type NodeByType<Kind extends string> = NarrowNode<Node, Kind>;
28
+ export type AccessorProperty = NodeByType<"AccessorProperty">;
29
+ export type ArrayExpression = NodeByType<"ArrayExpression">;
30
+ export type ArrayPattern = NodeByType<"ArrayPattern">;
31
+ export type ArrowFunctionExpression = NodeByType<"ArrowFunctionExpression">;
32
+ export type AssignmentExpression = NodeByType<"AssignmentExpression">;
33
+ export type AssignmentPattern = NodeByType<"AssignmentPattern">;
34
+ export type AwaitExpression = NodeByType<"AwaitExpression">;
35
+ export type BinaryExpression = NodeByType<"BinaryExpression">;
36
+ export type BlockStatement = NodeByType<"BlockStatement">;
37
+ export type BreakStatement = NodeByType<"BreakStatement">;
38
+ export type CallExpression = NodeByType<"CallExpression">;
39
+ export type CatchClause = NodeByType<"CatchClause">;
40
+ export type ChainExpression = NodeByType<"ChainExpression">;
41
+ export type ClassBody = NodeByType<"ClassBody">;
42
+ export type ClassDeclaration = NodeByType<"ClassDeclaration">;
43
+ export type ClassExpression = NodeByType<"ClassExpression">;
44
+ export type ConditionalExpression = NodeByType<"ConditionalExpression">;
45
+ export type ContinueStatement = NodeByType<"ContinueStatement">;
46
+ export type DebuggerStatement = NodeByType<"DebuggerStatement">;
47
+ export type Decorator = NodeByType<"Decorator">;
48
+ export type DoWhileStatement = NodeByType<"DoWhileStatement">;
49
+ export type EmptyStatement = NodeByType<"EmptyStatement">;
50
+ export type ExportAllDeclaration = NodeByType<"ExportAllDeclaration">;
51
+ export type ExportDefaultDeclaration = NodeByType<"ExportDefaultDeclaration">;
52
+ export type ExportNamedDeclaration = NodeByType<"ExportNamedDeclaration">;
53
+ export type ExportSpecifier = NodeByType<"ExportSpecifier">;
54
+ export type ExpressionStatement = NodeByType<"ExpressionStatement">;
55
+ export type ForInStatement = NodeByType<"ForInStatement">;
56
+ export type ForOfStatement = NodeByType<"ForOfStatement">;
57
+ export type ForStatement = NodeByType<"ForStatement">;
58
+ export type FunctionDeclaration = NodeByType<"FunctionDeclaration">;
59
+ export type FunctionExpression = NodeByType<"FunctionExpression">;
60
+ export type Identifier = NodeByType<"Identifier"> | BindingIdentifier;
61
+ export type IfStatement = NodeByType<"IfStatement">;
62
+ export type ImportAttribute = NodeByType<"ImportAttribute">;
63
+ export type ImportDeclaration = NodeByType<"ImportDeclaration">;
64
+ export type ImportDefaultSpecifier = NodeByType<"ImportDefaultSpecifier">;
65
+ export type ImportExpression = NodeByType<"ImportExpression">;
66
+ export type ImportNamespaceSpecifier = NodeByType<"ImportNamespaceSpecifier">;
67
+ export type ImportSpecifier = NodeByType<"ImportSpecifier">;
68
+ export type JSXAttribute = NodeByType<"JSXAttribute">;
69
+ export type JSXClosingElement = NodeByType<"JSXClosingElement">;
70
+ export type JSXClosingFragment = NodeByType<"JSXClosingFragment">;
71
+ export type JSXElement = NodeByType<"JSXElement">;
72
+ export type JSXEmptyExpression = NodeByType<"JSXEmptyExpression">;
73
+ export type JSXExpressionContainer = NodeByType<"JSXExpressionContainer">;
74
+ export type JSXFragment = NodeByType<"JSXFragment">;
75
+ export type JSXIdentifier = NodeByType<"JSXIdentifier">;
76
+ export type JSXMemberExpression = NodeByType<"JSXMemberExpression">;
77
+ export type JSXNamespacedName = NodeByType<"JSXNamespacedName">;
78
+ export type JSXOpeningElement = NodeByType<"JSXOpeningElement">;
79
+ export type JSXOpeningFragment = NodeByType<"JSXOpeningFragment">;
80
+ export type JSXSpreadAttribute = NodeByType<"JSXSpreadAttribute">;
81
+ export type JSXSpreadChild = NodeByType<"JSXSpreadChild">;
82
+ export type JSXText = NodeByType<"JSXText">;
83
+ export type LabeledStatement = NodeByType<"LabeledStatement">;
84
+ export type Literal = NodeByType<"Literal">;
85
+ export type LogicalExpression = NodeByType<"LogicalExpression">;
86
+ export type MemberExpression = NodeByType<"MemberExpression">;
87
+ export type MetaProperty = NodeByType<"MetaProperty">;
88
+ export type MethodDefinition = NodeByType<"MethodDefinition">;
89
+ export type NewExpression = NodeByType<"NewExpression">;
90
+ export type ObjectExpression = NodeByType<"ObjectExpression">;
91
+ export type ObjectPattern = NodeByType<"ObjectPattern">;
92
+ export type PrivateIdentifier = NodeByType<"PrivateIdentifier">;
93
+ export type Program = NodeByType<"Program">;
94
+ export type Property = NodeByType<"Property">;
95
+ export type PropertyDefinition = NodeByType<"PropertyDefinition">;
96
+ export type RestElement = NodeByType<"RestElement">;
97
+ export type ReturnStatement = NodeByType<"ReturnStatement">;
98
+ export type SequenceExpression = NodeByType<"SequenceExpression">;
99
+ export type SpreadElement = NodeByType<"SpreadElement">;
100
+ export type StaticBlock = NodeByType<"StaticBlock">;
101
+ export type Super = NodeByType<"Super">;
102
+ export type SwitchCase = NodeByType<"SwitchCase">;
103
+ export type SwitchStatement = NodeByType<"SwitchStatement">;
104
+ export type TaggedTemplateExpression = NodeByType<"TaggedTemplateExpression">;
105
+ export type TemplateElement = NodeByType<"TemplateElement">;
106
+ export type TemplateLiteral = NodeByType<"TemplateLiteral">;
107
+ export type ThisExpression = NodeByType<"ThisExpression">;
108
+ export type ThrowStatement = NodeByType<"ThrowStatement">;
109
+ export type TryStatement = NodeByType<"TryStatement">;
110
+ export type UnaryExpression = NodeByType<"UnaryExpression">;
111
+ export type UpdateExpression = NodeByType<"UpdateExpression">;
112
+ export type VariableDeclaration = NodeByType<"VariableDeclaration">;
113
+ export type VariableDeclarator = NodeByType<"VariableDeclarator">;
114
+ export type WhileStatement = NodeByType<"WhileStatement">;
115
+ export type WithStatement = NodeByType<"WithStatement">;
116
+ export type YieldExpression = NodeByType<"YieldExpression">;
117
+ export type TSAbstractAccessorProperty = NodeByType<"TSAbstractAccessorProperty">;
118
+ export type TSAbstractKeyword = NodeByType<"TSAbstractKeyword">;
119
+ export type TSAbstractMethodDefinition = NodeByType<"TSAbstractMethodDefinition">;
120
+ export type TSAbstractPropertyDefinition = NodeByType<"TSAbstractPropertyDefinition">;
121
+ export type TSAnyKeyword = NodeByType<"TSAnyKeyword">;
122
+ export type TSArrayType = NodeByType<"TSArrayType">;
123
+ export type TSAsExpression = NodeByType<"TSAsExpression">;
124
+ export type TSAsyncKeyword = NodeByType<"TSAsyncKeyword">;
125
+ export type TSBigIntKeyword = NodeByType<"TSBigIntKeyword">;
126
+ export type TSBooleanKeyword = NodeByType<"TSBooleanKeyword">;
127
+ export type TSCallSignatureDeclaration = NodeByType<"TSCallSignatureDeclaration">;
128
+ export type TSClassImplements = NodeByType<"TSClassImplements">;
129
+ export type TSConditionalType = NodeByType<"TSConditionalType">;
130
+ export type TSConstructorType = NodeByType<"TSConstructorType">;
131
+ export type TSConstructSignatureDeclaration = NodeByType<"TSConstructSignatureDeclaration">;
132
+ export type TSDeclareFunction = NodeByType<"TSDeclareFunction">;
133
+ export type TSDeclareKeyword = NodeByType<"TSDeclareKeyword">;
134
+ export type TSEmptyBodyFunctionExpression = NodeByType<"TSEmptyBodyFunctionExpression">;
135
+ export type TSEnumBody = NodeByType<"TSEnumBody">;
136
+ export type TSEnumDeclaration = NodeByType<"TSEnumDeclaration">;
137
+ export type TSEnumMember = NodeByType<"TSEnumMember">;
138
+ export type TSExportAssignment = NodeByType<"TSExportAssignment">;
139
+ export type TSExportKeyword = NodeByType<"TSExportKeyword">;
140
+ export type TSExpressionWithTypeArguments = NodeByType<"TSExpressionWithTypeArguments">;
141
+ export type TSExternalModuleReference = NodeByType<"TSExternalModuleReference">;
142
+ export type TSFunctionType = NodeByType<"TSFunctionType">;
143
+ export type TSImportEqualsDeclaration = NodeByType<"TSImportEqualsDeclaration">;
144
+ export type TSImportType = NodeByType<"TSImportType">;
145
+ export type TSIndexedAccessType = NodeByType<"TSIndexedAccessType">;
146
+ export type TSIndexSignature = NodeByType<"TSIndexSignature">;
147
+ export type TSInferType = NodeByType<"TSInferType">;
148
+ export type TSInstantiationExpression = NodeByType<"TSInstantiationExpression">;
149
+ export type TSInterfaceBody = NodeByType<"TSInterfaceBody">;
150
+ export type TSInterfaceDeclaration = NodeByType<"TSInterfaceDeclaration">;
151
+ export type TSInterfaceHeritage = NodeByType<"TSInterfaceHeritage">;
152
+ export type TSIntersectionType = NodeByType<"TSIntersectionType">;
153
+ export type TSIntrinsicKeyword = NodeByType<"TSIntrinsicKeyword">;
154
+ export type TSLiteralType = NodeByType<"TSLiteralType">;
155
+ export type TSMappedType = NodeByType<"TSMappedType">;
156
+ export type TSMethodSignature = NodeByType<"TSMethodSignature">;
157
+ export type TSModuleBlock = NodeByType<"TSModuleBlock">;
158
+ export type TSModuleDeclaration = NodeByType<"TSModuleDeclaration">;
159
+ export type TSNamedTupleMember = NodeByType<"TSNamedTupleMember">;
160
+ export type TSNamespaceExportDeclaration = NodeByType<"TSNamespaceExportDeclaration">;
161
+ export type TSNeverKeyword = NodeByType<"TSNeverKeyword">;
162
+ export type TSNonNullExpression = NodeByType<"TSNonNullExpression">;
163
+ export type TSNullKeyword = NodeByType<"TSNullKeyword">;
164
+ export type TSNumberKeyword = NodeByType<"TSNumberKeyword">;
165
+ export type TSObjectKeyword = NodeByType<"TSObjectKeyword">;
166
+ export type TSOptionalType = NodeByType<"TSOptionalType">;
167
+ export type TSParameterProperty = NodeByType<"TSParameterProperty">;
168
+ export type TSPrivateKeyword = NodeByType<"TSPrivateKeyword">;
169
+ export type TSPropertySignature = NodeByType<"TSPropertySignature">;
170
+ export type TSProtectedKeyword = NodeByType<"TSProtectedKeyword">;
171
+ export type TSPublicKeyword = NodeByType<"TSPublicKeyword">;
172
+ export type TSQualifiedName = NodeByType<"TSQualifiedName">;
173
+ export type TSReadonlyKeyword = NodeByType<"TSReadonlyKeyword">;
174
+ export type TSRestType = NodeByType<"TSRestType">;
175
+ export type TSSatisfiesExpression = NodeByType<"TSSatisfiesExpression">;
176
+ export type TSStaticKeyword = NodeByType<"TSStaticKeyword">;
177
+ export type TSStringKeyword = NodeByType<"TSStringKeyword">;
178
+ export type TSSymbolKeyword = NodeByType<"TSSymbolKeyword">;
179
+ export type TSTemplateLiteralType = NodeByType<"TSTemplateLiteralType">;
180
+ export type TSThisType = NodeByType<"TSThisType">;
181
+ export type TSTupleType = NodeByType<"TSTupleType">;
182
+ export type TSTypeAliasDeclaration = NodeByType<"TSTypeAliasDeclaration">;
183
+ export type TSTypeAnnotation = NodeByType<"TSTypeAnnotation">;
184
+ export type TSTypeAssertion = NodeByType<"TSTypeAssertion">;
185
+ export type TSTypeLiteral = NodeByType<"TSTypeLiteral">;
186
+ export type TSTypeOperator = NodeByType<"TSTypeOperator">;
187
+ export type TSTypeParameter = NodeByType<"TSTypeParameter">;
188
+ export type TSTypeParameterDeclaration = NodeByType<"TSTypeParameterDeclaration">;
189
+ export type TSTypeParameterInstantiation = NodeByType<"TSTypeParameterInstantiation">;
190
+ export type TSTypePredicate = NodeByType<"TSTypePredicate">;
191
+ export type TSTypeQuery = NodeByType<"TSTypeQuery">;
192
+ export type TSTypeReference = NodeByType<"TSTypeReference">;
193
+ export type TSUndefinedKeyword = NodeByType<"TSUndefinedKeyword">;
194
+ export type TSUnionType = NodeByType<"TSUnionType">;
195
+ export type TSUnknownKeyword = NodeByType<"TSUnknownKeyword">;
196
+ export type TSVoidKeyword = NodeByType<"TSVoidKeyword">;
197
+ export type BindingIdentifier = Omit<ESTree$1.BindingIdentifier, "typeAnnotation"> & {
198
+ typeAnnotation?: TSTypeAnnotation | null;
22
199
  };
23
- TSTypeAnnotation: ESTree$1.TSTypeAnnotation;
24
- [key: string]: unknown;
25
- };
200
+ export type NodeTypes = { [Kind in CorsaAstNodeType]: NodeByType<Kind> } & {
201
+ BindingIdentifier: BindingIdentifier;
202
+ Identifier: Identifier | BindingIdentifier;
203
+ NewExpression: NewExpression;
204
+ TSTypeAnnotation: TSTypeAnnotation;
205
+ };
206
+ export {};
207
+ }
26
208
  //#endregion
27
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, RuleCreator, 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 };
28
210
  //# sourceMappingURL=index.d.ts.map
@@ -97,7 +97,16 @@ function prepareTestCase(workspace, test, config, group, index) {
97
97
  function applyRuleTesterRuntimeDefaults(parserOptions, test, config) {
98
98
  if (parserOptions.corsa?.executable !== void 0) return parserOptions;
99
99
  const rootDir = resolve(test.cwd ?? config?.cwd ?? process.cwd());
100
- return mergeTypeAwareParserOptions(parserOptions, { corsa: { executable: process.env.CORSA_EXECUTABLE ?? defaultCorsaExecutable(rootDir) } });
100
+ const executable = process.env.CORSA_EXECUTABLE ?? optionalDefaultCorsaExecutable(rootDir);
101
+ if (!executable) return parserOptions;
102
+ return mergeTypeAwareParserOptions(parserOptions, { corsa: { executable } });
103
+ }
104
+ function optionalDefaultCorsaExecutable(rootDir) {
105
+ try {
106
+ return defaultCorsaExecutable(rootDir);
107
+ } catch {
108
+ return;
109
+ }
101
110
  }
102
111
  function writeFixture(filename, code) {
103
112
  mkdirSync(dirname(filename), { recursive: true });
@@ -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 return mergeTypeAwareParserOptions(parserOptions, {\n corsa: {\n executable: process.env.CORSA_EXECUTABLE ?? defaultCorsaExecutable(rootDir),\n },\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,KAAa;AACrC,IAAI,mBAAmB;AAEvB,IAAa,aAAb,MAAwB;;;;;;;;;;;;;;;CAetB,WAAW,WAAW;EACpB,OAAOA,aAAiB;;CAG1B,WAAW,SAAS,OAAO;EACzB,aAAiB,WAAW;;CAG9B,WAAW,KAAK;EACd,OAAOA,aAAiB;;CAG1B,WAAW,GAAG,OAAO;EACnB,aAAiB,KAAK;;CAGxB,OAAO,KAAK,MAAmC;EAC7C,OAAOA,aAAiB,KAAK,KAAK;;CAGpC;CACA;CAEA,YAAY,QAA2B;EACrC,KAAKE,UAAU;EACf,KAAKD,SAAS,IAAID,aAAiB,OAAO;;CAG5C,IAAI,UAAkB,MAA+B,OAAwB;EAC3E,MAAM,cAAc;GAClB,OAAO,MAAM,MAAM,KAAK,MAAM,UAC5B,gBAAgB,iBAAiB,EAAE,MAAM,KAAKE,SAAS,SAAS,MAAM,CACvE;GACD,SAAS,MAAM,QAAQ,KAAK,MAAM,UAChC,gBAAgB,iBAAiB,EAAE,MAAM,KAAKA,SAAS,WAAW,MAAM,CACzE;GACF;EACD,KAAKD,OAAO,IAAI,UAAU,aAAa,KAAc,EAAW,YAAyB;;;AAI7F,SAAS,kBAA0B;CACjC,MAAM,YAAY,YAAY,KAAK,QAAQ,EAAE,gBAAgB,CAAC;CAC9D,gBAAgB,UAAU;CAC1B,OAAO;;AAGT,SAAS,gBACP,WACA,MACA,QACA,OACA,OACmB;CACnB,IAAI,OAAO,SAAS,UAAU;EAE5B,aADiB,QAAQ,WAAW,GAAG,MAAM,GAAG,MAAM,KACjC,EAAE,KAAK;EAC5B,OAAO;;CAET,MAAM,WAAW,QAAQ,WAAW,KAAK,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BAAgB,WAAyB;CAChD,YAAY,IAAI,UAAU;CAC1B,IAAI,kBACF;CAEF,mBAAmB;CACnB,QAAQ,GAAG,cAAc;EACvB,KAAK,MAAM,OAAO,aAChB,OAAO,KAAK;GAAE,OAAO;GAAM,WAAW;GAAM,CAAC;GAE/C"}
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,KAAa;AACrC,IAAI,mBAAmB;AAEvB,IAAa,aAAb,MAAwB;;;;;;;;;;;;;;;CAetB,WAA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CAAC;GAE/C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "corsa-oxlint",
3
- "version": "0.41.1",
3
+ "version": "0.42.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": {
@@ -103,7 +103,7 @@
103
103
  "dependencies": {
104
104
  "@oxlint/plugins": "1.66.0",
105
105
  "oxlint": "1.66.0",
106
- "@corsa-bind/napi": "0.41.1"
106
+ "@corsa-bind/napi": "0.42.0"
107
107
  },
108
108
  "devDependencies": {
109
109
  "@typescript-eslint/utils": "8.59.3"