corsa-oxlint 0.41.0 → 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 +5 -1
- package/dist/context.js.map +1 -1
- package/dist/index.d.ts +189 -7
- package/dist/rule_tester.js +10 -1
- package/dist/rule_tester.js.map +1 -1
- package/dist/stylistic.js +75 -1
- package/dist/stylistic.js.map +1 -1
- package/package.json +2 -2
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
|
-
|
|
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);
|
package/dist/context.js.map
CHANGED
|
@@ -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,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AS,SAAS,WAAW,KAAK;EAClC,gBAAgB,oBAAoB,KAAK,gBAAgB,SAAS,eAAe;EACjF,iBAAiB,SAAS,mBAAmB,KAAK;EAClD,GAAI,OAAO,KAAK,QAAQ,CAAC,SAAS,IAAI,EAAE,OAAO,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"}
|
|
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;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R,GAAG,SAAS;EACb;CACD,OAAO;EACL,GAAG;EACH,GAAG;EACH,SAAS,SAAS,WAAW,KAAK;EAClC,gBAAgB,oBAAoB,KAAK,gBAAgB,SAAS,eAAe;EACjF,iBAAiB,SAAS,mBAAmB,KAAK;EAClD,GAAI,OAAO,KAAK,QAAQ,CAAC,SAAS,IAAI,EAAE,OAAO,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
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
24
|
-
|
|
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
|
package/dist/rule_tester.js
CHANGED
|
@@ -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
|
-
|
|
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 });
|
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 return mergeTypeAwareParserOptions(parserOptions, {\n corsa: {\n executable:
|
|
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,WAAW,WAAW;EACpB,OAAOA,aAAiB;;CAG1B,WAAW,SAAS,OAAO;EACzB,aAAiB,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sForRule(context, ruleName) {
|
|
|
107
107
|
}
|
|
108
108
|
const cached = sourceCache.get(key);
|
|
109
109
|
if (cached?.sourceText === sourceText) return cached.diagnostics;
|
|
110
|
-
const diagnostics = runNativeStylisticLint(sourceText, { rules: config });
|
|
110
|
+
const diagnostics = mapNativeDiagnosticRanges(runNativeStylisticLint(sourceText, { rules: config }), sourceText);
|
|
111
111
|
sourceCache.set(key, {
|
|
112
112
|
sourceText,
|
|
113
113
|
diagnostics
|
|
@@ -147,6 +147,80 @@ function rangeNode(program, range) {
|
|
|
147
147
|
function oxlintRange(range) {
|
|
148
148
|
return [range.start, range.end];
|
|
149
149
|
}
|
|
150
|
+
function mapNativeDiagnosticRanges(diagnostics, sourceText) {
|
|
151
|
+
const byteToUtf16 = createByteToUtf16Mapper(sourceText);
|
|
152
|
+
return diagnostics.map((diagnostic) => ({
|
|
153
|
+
...diagnostic,
|
|
154
|
+
range: mapNativeRange(diagnostic.range, byteToUtf16),
|
|
155
|
+
...diagnostic.suggestions?.length ? { suggestions: diagnostic.suggestions.map((suggestion) => mapNativeSuggestion(suggestion, byteToUtf16)) } : {}
|
|
156
|
+
}));
|
|
157
|
+
}
|
|
158
|
+
function mapNativeSuggestion(suggestion, byteToUtf16) {
|
|
159
|
+
return {
|
|
160
|
+
...suggestion,
|
|
161
|
+
fixes: suggestion.fixes.map((fix) => mapNativeFix(fix, byteToUtf16))
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
function mapNativeFix(fix, byteToUtf16) {
|
|
165
|
+
return {
|
|
166
|
+
...fix,
|
|
167
|
+
range: mapNativeRange(fix.range, byteToUtf16)
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
function mapNativeRange(range, byteToUtf16) {
|
|
171
|
+
return {
|
|
172
|
+
start: byteToUtf16(range.start),
|
|
173
|
+
end: byteToUtf16(range.end)
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
function createByteToUtf16Mapper(sourceText) {
|
|
177
|
+
const nonAsciiSpans = [];
|
|
178
|
+
let byteOffset = 0;
|
|
179
|
+
let utf16Offset = 0;
|
|
180
|
+
while (utf16Offset < sourceText.length) {
|
|
181
|
+
const codePoint = sourceText.codePointAt(utf16Offset);
|
|
182
|
+
if (codePoint === void 0) break;
|
|
183
|
+
const utf16Length = codePoint > 65535 ? 2 : 1;
|
|
184
|
+
const byteLength = utf8ByteLength(codePoint);
|
|
185
|
+
const byteEnd = byteOffset + byteLength;
|
|
186
|
+
const utf16End = utf16Offset + utf16Length;
|
|
187
|
+
if (byteLength !== utf16Length) nonAsciiSpans.push({
|
|
188
|
+
byteStart: byteOffset,
|
|
189
|
+
byteEnd,
|
|
190
|
+
utf16Start: utf16Offset,
|
|
191
|
+
deltaAfter: byteEnd - utf16End
|
|
192
|
+
});
|
|
193
|
+
byteOffset = byteEnd;
|
|
194
|
+
utf16Offset = utf16End;
|
|
195
|
+
}
|
|
196
|
+
if (nonAsciiSpans.length === 0) return (offset) => clampOffset(offset, sourceText.length);
|
|
197
|
+
const totalBytes = byteOffset;
|
|
198
|
+
return (offset) => {
|
|
199
|
+
const byteOffset = clampOffset(offset, totalBytes);
|
|
200
|
+
let low = 0;
|
|
201
|
+
let high = nonAsciiSpans.length;
|
|
202
|
+
while (low < high) {
|
|
203
|
+
const mid = Math.floor((low + high) / 2);
|
|
204
|
+
if (nonAsciiSpans[mid].byteEnd <= byteOffset) low = mid + 1;
|
|
205
|
+
else high = mid;
|
|
206
|
+
}
|
|
207
|
+
const nextSpan = nonAsciiSpans[low];
|
|
208
|
+
if (nextSpan && byteOffset >= nextSpan.byteStart && byteOffset < nextSpan.byteEnd) return nextSpan.utf16Start;
|
|
209
|
+
return clampOffset(byteOffset - (nonAsciiSpans[low - 1]?.deltaAfter ?? 0), sourceText.length);
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
function utf8ByteLength(codePoint) {
|
|
213
|
+
if (codePoint <= 127) return 1;
|
|
214
|
+
if (codePoint <= 2047) return 2;
|
|
215
|
+
if (codePoint <= 65535) return 3;
|
|
216
|
+
return 4;
|
|
217
|
+
}
|
|
218
|
+
function clampOffset(offset, max) {
|
|
219
|
+
if (!Number.isFinite(offset)) return 0;
|
|
220
|
+
if (offset <= 0) return 0;
|
|
221
|
+
if (offset >= max) return max;
|
|
222
|
+
return Math.trunc(offset);
|
|
223
|
+
}
|
|
150
224
|
function sourceTextForContext(context) {
|
|
151
225
|
const text = context.sourceCode.text;
|
|
152
226
|
if (typeof text === "string") return text;
|
package/dist/stylistic.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stylistic.js","names":[],"sources":["../ts/stylistic.ts"],"sourcesContent":["import {\n nativeStylisticRuleMetas,\n runNativeStylisticLint,\n type NativeLintDiagnostic,\n type NativeLintRange,\n type NativeLintRuleMeta,\n type NativeStylisticRuleConfig,\n} from \"@corsa-bind/napi\";\n\nimport { definePlugin, defineRule } from \"./plugin\";\nimport type { ContextWithParserOptions } from \"./types\";\n\ntype ProgramNode = {\n readonly type: string;\n readonly range?: readonly [number, number];\n};\n\nexport type CorsaStylisticRuleName =\n | \"eol-last\"\n | \"linebreak-style\"\n | \"no-multiple-empty-lines\"\n | \"no-tabs\"\n | \"no-trailing-spaces\"\n | \"quotes\"\n | \"unicode-bom\"\n | \"arrow-spacing\"\n | \"comma-spacing\"\n | \"semi-spacing\"\n | \"space-in-parens\"\n | \"template-curly-spacing\"\n | \"rest-spread-spacing\"\n | \"no-multi-spaces\"\n | \"no-whitespace-before-property\"\n | \"dot-location\"\n | \"spaced-comment\"\n | \"object-curly-spacing\"\n | \"array-bracket-spacing\"\n | \"computed-property-spacing\"\n | \"block-spacing\"\n | \"space-before-blocks\"\n | \"function-call-spacing\"\n | \"space-before-function-paren\"\n | \"no-floating-decimal\"\n | \"template-tag-spacing\"\n | \"yield-star-spacing\"\n | \"generator-star-spacing\"\n | \"comma-dangle\"\n | \"space-infix-ops\"\n | \"max-len\"\n | \"semi-style\"\n | \"comma-style\"\n | \"arrow-parens\"\n | \"switch-colon-spacing\"\n | \"no-extra-semi\"\n | \"new-parens\"\n | \"space-unary-ops\"\n | \"wrap-regex\"\n | \"implicit-arrow-linebreak\"\n | \"operator-linebreak\"\n | \"keyword-spacing\";\n\nexport type CorsaStylisticRuleOptions = readonly unknown[];\n\nexport interface CorsaStylisticSettings {\n /**\n * Rule options used by the native batch runner.\n *\n * Keep this in sync with enabled Oxlint rules when several stylistic rules\n * are active; the JS bridge can then perform one native scan and share the\n * diagnostics across individual rule reports.\n */\n readonly rules?: Partial<Record<CorsaStylisticRuleName, CorsaStylisticRuleOptions>>;\n}\n\nconst stylisticMetas = nativeStylisticRuleMetas();\nconst stylisticMetasByName = new Map(stylisticMetas.map((meta) => [meta.name, meta]));\ntype CachedStylisticDiagnostics = {\n readonly sourceText: string;\n readonly diagnostics: readonly NativeLintDiagnostic[];\n};\n\nconst diagnosticsCache = new WeakMap<object, Map<string, CachedStylisticDiagnostics>>();\n\n/**\n * Native stylistic rule names exported by `corsa-oxlint/stylistic`.\n */\nexport const implementedStylisticRuleNames = [\n \"eol-last\",\n \"linebreak-style\",\n \"no-multiple-empty-lines\",\n \"no-tabs\",\n \"no-trailing-spaces\",\n \"quotes\",\n \"unicode-bom\",\n \"arrow-spacing\",\n \"comma-spacing\",\n \"semi-spacing\",\n \"space-in-parens\",\n \"template-curly-spacing\",\n \"rest-spread-spacing\",\n \"no-multi-spaces\",\n \"no-whitespace-before-property\",\n \"dot-location\",\n \"spaced-comment\",\n \"object-curly-spacing\",\n \"array-bracket-spacing\",\n \"computed-property-spacing\",\n \"block-spacing\",\n \"space-before-blocks\",\n \"function-call-spacing\",\n \"space-before-function-paren\",\n \"no-floating-decimal\",\n \"template-tag-spacing\",\n \"yield-star-spacing\",\n \"generator-star-spacing\",\n \"comma-dangle\",\n \"space-infix-ops\",\n \"max-len\",\n \"semi-style\",\n \"comma-style\",\n \"arrow-parens\",\n \"switch-colon-spacing\",\n \"no-extra-semi\",\n \"new-parens\",\n \"space-unary-ops\",\n \"wrap-regex\",\n \"implicit-arrow-linebreak\",\n \"operator-linebreak\",\n \"keyword-spacing\",\n] as const satisfies readonly CorsaStylisticRuleName[];\n\n/**\n * Oxlint-compatible stylistic rules backed by the Rust source scanner.\n */\nexport const corsaStylisticRules = Object.freeze(\n Object.fromEntries(\n implementedStylisticRuleNames.map((ruleName) => [ruleName, createStylisticRule(ruleName)]),\n ),\n) as Readonly<Record<CorsaStylisticRuleName, ReturnType<typeof createStylisticRule>>>;\n\n/**\n * Oxlint plugin exposing Corsa's Rust-backed stylistic rules.\n *\n * Register it under any namespace, then enable rules such as\n * `stylistic/quotes` or `stylistic/no-trailing-spaces`.\n */\nexport const corsaStylisticPlugin = definePlugin({\n meta: { name: \"oxlint-plugin-corsa-stylistic\" },\n rules: corsaStylisticRules,\n});\n\nexport default corsaStylisticPlugin;\n\nfunction createStylisticRule(ruleName: CorsaStylisticRuleName) {\n const meta = stylisticRuleMeta(ruleName);\n return defineRule({\n defaultOptions: [],\n meta: {\n type: \"layout\",\n docs: {\n description: meta.docsDescription,\n requiresTypeChecking: false,\n url: `https://github.com/ubugeeei-prod/corsa-bind/tree/main/src/bindings/nodejs/corsa_oxlint/ts/stylistic.ts`,\n },\n fixable: \"whitespace\",\n hasSuggestions: meta.hasSuggestions,\n messages: meta.messages,\n schema: { type: \"array\" },\n },\n create(context: ContextWithParserOptions) {\n return {\n Program(node: ProgramNode) {\n reportStylisticDiagnostics(\n context,\n node,\n diagnosticsForRule(context, ruleName).filter(\n (diagnostic) => diagnostic.ruleName === ruleName,\n ),\n );\n },\n };\n },\n });\n}\n\nfunction diagnosticsForRule(\n context: ContextWithParserOptions,\n ruleName: CorsaStylisticRuleName,\n): readonly NativeLintDiagnostic[] {\n const sourceCode = context.sourceCode as unknown as object;\n const sourceText = sourceTextForContext(context);\n const config = stylisticRunConfig(context, ruleName);\n const key = JSON.stringify(config);\n let sourceCache = diagnosticsCache.get(sourceCode);\n if (!sourceCache) {\n sourceCache = new Map();\n diagnosticsCache.set(sourceCode, sourceCache);\n }\n\n const cached = sourceCache.get(key);\n if (cached?.sourceText === sourceText) {\n return cached.diagnostics;\n }\n\n const diagnostics = runNativeStylisticLint(sourceText, { rules: config });\n sourceCache.set(key, { sourceText, diagnostics });\n return diagnostics;\n}\n\nfunction stylisticRunConfig(\n context: ContextWithParserOptions,\n currentRuleName: CorsaStylisticRuleName,\n): readonly NativeStylisticRuleConfig[] {\n const settingsRules = context.settings?.corsaStylistic?.rules;\n const rules = new Map<CorsaStylisticRuleName, CorsaStylisticRuleOptions>();\n\n if (settingsRules) {\n for (const [name, options] of Object.entries(settingsRules)) {\n assertKnownStylisticRuleName(name);\n rules.set(name, normalizeOptions(options));\n }\n }\n\n const currentOptions = currentRuleOptions(context);\n if (!rules.has(currentRuleName) || currentOptions.length > 0) {\n rules.set(currentRuleName, currentOptions);\n }\n\n return implementedStylisticRuleNames\n .filter((ruleName) => rules.has(ruleName))\n .map((ruleName) => ({\n name: ruleName,\n options: rules.get(ruleName) ?? [],\n }));\n}\n\nfunction reportStylisticDiagnostics(\n context: ContextWithParserOptions,\n program: ProgramNode,\n diagnostics: readonly NativeLintDiagnostic[],\n): void {\n for (const diagnostic of diagnostics) {\n context.report({\n node: rangeNode(program, diagnostic.range),\n messageId: diagnostic.messageId,\n ...(diagnostic.suggestions?.length\n ? {\n suggest: diagnostic.suggestions.map((suggestion) => ({\n messageId: suggestion.messageId,\n fix: (fixer: any) =>\n suggestion.fixes.map((fix) =>\n fixer.replaceTextRange(oxlintRange(fix.range), fix.replacementText),\n ),\n })),\n }\n : {}),\n } as never);\n }\n}\n\nfunction rangeNode(program: ProgramNode, range: NativeLintRange): ProgramNode {\n return {\n ...program,\n range: oxlintRange(range),\n };\n}\n\nfunction oxlintRange(range: NativeLintRange): [number, number] {\n return [range.start, range.end];\n}\n\nfunction sourceTextForContext(context: ContextWithParserOptions): string {\n const text = (context.sourceCode as { text?: unknown }).text;\n if (typeof text === \"string\") {\n return text;\n }\n return context.sourceCode.getText({ type: \"Program\" } as never);\n}\n\nfunction currentRuleOptions(context: ContextWithParserOptions): CorsaStylisticRuleOptions {\n return normalizeOptions((context as { options?: unknown }).options);\n}\n\nfunction normalizeOptions(options: unknown): CorsaStylisticRuleOptions {\n if (Array.isArray(options)) {\n return options;\n }\n if (options == null) {\n return [];\n }\n return [options];\n}\n\nfunction assertKnownStylisticRuleName(name: string): asserts name is CorsaStylisticRuleName {\n if (!(implementedStylisticRuleNames as readonly string[]).includes(name)) {\n throw new Error(`unknown corsa stylistic rule: ${name}`);\n }\n}\n\nfunction stylisticRuleMeta(ruleName: CorsaStylisticRuleName): NativeLintRuleMeta {\n const meta = stylisticMetasByName.get(ruleName);\n if (!meta) {\n throw new Error(`corsa stylistic native Rust rule is not registered: ${ruleName}`);\n }\n return meta;\n}\n"],"mappings":";;;;;;;;;;AA0EA,MAAM,iBAAiB,0BAA0B;AACjD,MAAM,uBAAuB,IAAI,IAAI,eAAe,KAAK,SAAS,CAAC,KAAK,MAAM,KAAK,CAAC,CAAC;AAMrF,MAAM,mCAAmB,IAAI,SAA0D;;;;AAKvF,MAAa,gCAAgC;CAC3C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;;;;AAKD,MAAa,sBAAsB,OAAO,OACxC,OAAO,YACL,8BAA8B,KAAK,aAAa,CAAC,UAAU,oBAAoB,SAAS,CAAC,CAAC,CAC3F,CACF;;;;;;;AAQD,MAAa,uBAAuB,aAAa;CAC/C,MAAM,EAAE,MAAM,iCAAiC;CAC/C,OAAO;CACR,CAAC;AAIF,SAAS,oBAAoB,UAAkC;CAC7D,MAAM,OAAO,kBAAkB,SAAS;CACxC,OAAO,WAAW;EAChB,gBAAgB,EAAE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,"file":"stylistic.js","names":[],"sources":["../ts/stylistic.ts"],"sourcesContent":["import {\n nativeStylisticRuleMetas,\n runNativeStylisticLint,\n type NativeLintDiagnostic,\n type NativeLintFix,\n type NativeLintRange,\n type NativeLintRuleMeta,\n type NativeLintSuggestion,\n type NativeStylisticRuleConfig,\n} from \"@corsa-bind/napi\";\n\nimport { definePlugin, defineRule } from \"./plugin\";\nimport type { ContextWithParserOptions } from \"./types\";\n\ntype ProgramNode = {\n readonly type: string;\n readonly range?: readonly [number, number];\n};\n\nexport type CorsaStylisticRuleName =\n | \"eol-last\"\n | \"linebreak-style\"\n | \"no-multiple-empty-lines\"\n | \"no-tabs\"\n | \"no-trailing-spaces\"\n | \"quotes\"\n | \"unicode-bom\"\n | \"arrow-spacing\"\n | \"comma-spacing\"\n | \"semi-spacing\"\n | \"space-in-parens\"\n | \"template-curly-spacing\"\n | \"rest-spread-spacing\"\n | \"no-multi-spaces\"\n | \"no-whitespace-before-property\"\n | \"dot-location\"\n | \"spaced-comment\"\n | \"object-curly-spacing\"\n | \"array-bracket-spacing\"\n | \"computed-property-spacing\"\n | \"block-spacing\"\n | \"space-before-blocks\"\n | \"function-call-spacing\"\n | \"space-before-function-paren\"\n | \"no-floating-decimal\"\n | \"template-tag-spacing\"\n | \"yield-star-spacing\"\n | \"generator-star-spacing\"\n | \"comma-dangle\"\n | \"space-infix-ops\"\n | \"max-len\"\n | \"semi-style\"\n | \"comma-style\"\n | \"arrow-parens\"\n | \"switch-colon-spacing\"\n | \"no-extra-semi\"\n | \"new-parens\"\n | \"space-unary-ops\"\n | \"wrap-regex\"\n | \"implicit-arrow-linebreak\"\n | \"operator-linebreak\"\n | \"keyword-spacing\";\n\nexport type CorsaStylisticRuleOptions = readonly unknown[];\n\nexport interface CorsaStylisticSettings {\n /**\n * Rule options used by the native batch runner.\n *\n * Keep this in sync with enabled Oxlint rules when several stylistic rules\n * are active; the JS bridge can then perform one native scan and share the\n * diagnostics across individual rule reports.\n */\n readonly rules?: Partial<Record<CorsaStylisticRuleName, CorsaStylisticRuleOptions>>;\n}\n\nconst stylisticMetas = nativeStylisticRuleMetas();\nconst stylisticMetasByName = new Map(stylisticMetas.map((meta) => [meta.name, meta]));\ntype CachedStylisticDiagnostics = {\n readonly sourceText: string;\n readonly diagnostics: readonly NativeLintDiagnostic[];\n};\n\ntype ByteToUtf16Mapper = (offset: number) => number;\n\ntype NonAsciiSpan = {\n readonly byteStart: number;\n readonly byteEnd: number;\n readonly utf16Start: number;\n readonly deltaAfter: number;\n};\n\nconst diagnosticsCache = new WeakMap<object, Map<string, CachedStylisticDiagnostics>>();\n\n/**\n * Native stylistic rule names exported by `corsa-oxlint/stylistic`.\n */\nexport const implementedStylisticRuleNames = [\n \"eol-last\",\n \"linebreak-style\",\n \"no-multiple-empty-lines\",\n \"no-tabs\",\n \"no-trailing-spaces\",\n \"quotes\",\n \"unicode-bom\",\n \"arrow-spacing\",\n \"comma-spacing\",\n \"semi-spacing\",\n \"space-in-parens\",\n \"template-curly-spacing\",\n \"rest-spread-spacing\",\n \"no-multi-spaces\",\n \"no-whitespace-before-property\",\n \"dot-location\",\n \"spaced-comment\",\n \"object-curly-spacing\",\n \"array-bracket-spacing\",\n \"computed-property-spacing\",\n \"block-spacing\",\n \"space-before-blocks\",\n \"function-call-spacing\",\n \"space-before-function-paren\",\n \"no-floating-decimal\",\n \"template-tag-spacing\",\n \"yield-star-spacing\",\n \"generator-star-spacing\",\n \"comma-dangle\",\n \"space-infix-ops\",\n \"max-len\",\n \"semi-style\",\n \"comma-style\",\n \"arrow-parens\",\n \"switch-colon-spacing\",\n \"no-extra-semi\",\n \"new-parens\",\n \"space-unary-ops\",\n \"wrap-regex\",\n \"implicit-arrow-linebreak\",\n \"operator-linebreak\",\n \"keyword-spacing\",\n] as const satisfies readonly CorsaStylisticRuleName[];\n\n/**\n * Oxlint-compatible stylistic rules backed by the Rust source scanner.\n */\nexport const corsaStylisticRules = Object.freeze(\n Object.fromEntries(\n implementedStylisticRuleNames.map((ruleName) => [ruleName, createStylisticRule(ruleName)]),\n ),\n) as Readonly<Record<CorsaStylisticRuleName, ReturnType<typeof createStylisticRule>>>;\n\n/**\n * Oxlint plugin exposing Corsa's Rust-backed stylistic rules.\n *\n * Register it under any namespace, then enable rules such as\n * `stylistic/quotes` or `stylistic/no-trailing-spaces`.\n */\nexport const corsaStylisticPlugin = definePlugin({\n meta: { name: \"oxlint-plugin-corsa-stylistic\" },\n rules: corsaStylisticRules,\n});\n\nexport default corsaStylisticPlugin;\n\nfunction createStylisticRule(ruleName: CorsaStylisticRuleName) {\n const meta = stylisticRuleMeta(ruleName);\n return defineRule({\n defaultOptions: [],\n meta: {\n type: \"layout\",\n docs: {\n description: meta.docsDescription,\n requiresTypeChecking: false,\n url: `https://github.com/ubugeeei-prod/corsa-bind/tree/main/src/bindings/nodejs/corsa_oxlint/ts/stylistic.ts`,\n },\n fixable: \"whitespace\",\n hasSuggestions: meta.hasSuggestions,\n messages: meta.messages,\n schema: { type: \"array\" },\n },\n create(context: ContextWithParserOptions) {\n return {\n Program(node: ProgramNode) {\n reportStylisticDiagnostics(\n context,\n node,\n diagnosticsForRule(context, ruleName).filter(\n (diagnostic) => diagnostic.ruleName === ruleName,\n ),\n );\n },\n };\n },\n });\n}\n\nfunction diagnosticsForRule(\n context: ContextWithParserOptions,\n ruleName: CorsaStylisticRuleName,\n): readonly NativeLintDiagnostic[] {\n const sourceCode = context.sourceCode as unknown as object;\n const sourceText = sourceTextForContext(context);\n const config = stylisticRunConfig(context, ruleName);\n const key = JSON.stringify(config);\n let sourceCache = diagnosticsCache.get(sourceCode);\n if (!sourceCache) {\n sourceCache = new Map();\n diagnosticsCache.set(sourceCode, sourceCache);\n }\n\n const cached = sourceCache.get(key);\n if (cached?.sourceText === sourceText) {\n return cached.diagnostics;\n }\n\n const diagnostics = mapNativeDiagnosticRanges(\n runNativeStylisticLint(sourceText, { rules: config }),\n sourceText,\n );\n sourceCache.set(key, { sourceText, diagnostics });\n return diagnostics;\n}\n\nfunction stylisticRunConfig(\n context: ContextWithParserOptions,\n currentRuleName: CorsaStylisticRuleName,\n): readonly NativeStylisticRuleConfig[] {\n const settingsRules = context.settings?.corsaStylistic?.rules;\n const rules = new Map<CorsaStylisticRuleName, CorsaStylisticRuleOptions>();\n\n if (settingsRules) {\n for (const [name, options] of Object.entries(settingsRules)) {\n assertKnownStylisticRuleName(name);\n rules.set(name, normalizeOptions(options));\n }\n }\n\n const currentOptions = currentRuleOptions(context);\n if (!rules.has(currentRuleName) || currentOptions.length > 0) {\n rules.set(currentRuleName, currentOptions);\n }\n\n return implementedStylisticRuleNames\n .filter((ruleName) => rules.has(ruleName))\n .map((ruleName) => ({\n name: ruleName,\n options: rules.get(ruleName) ?? [],\n }));\n}\n\nfunction reportStylisticDiagnostics(\n context: ContextWithParserOptions,\n program: ProgramNode,\n diagnostics: readonly NativeLintDiagnostic[],\n): void {\n for (const diagnostic of diagnostics) {\n context.report({\n node: rangeNode(program, diagnostic.range),\n messageId: diagnostic.messageId,\n ...(diagnostic.suggestions?.length\n ? {\n suggest: diagnostic.suggestions.map((suggestion) => ({\n messageId: suggestion.messageId,\n fix: (fixer: any) =>\n suggestion.fixes.map((fix) =>\n fixer.replaceTextRange(oxlintRange(fix.range), fix.replacementText),\n ),\n })),\n }\n : {}),\n } as never);\n }\n}\n\nfunction rangeNode(program: ProgramNode, range: NativeLintRange): ProgramNode {\n return {\n ...program,\n range: oxlintRange(range),\n };\n}\n\nfunction oxlintRange(range: NativeLintRange): [number, number] {\n return [range.start, range.end];\n}\n\nfunction mapNativeDiagnosticRanges(\n diagnostics: readonly NativeLintDiagnostic[],\n sourceText: string,\n): readonly NativeLintDiagnostic[] {\n const byteToUtf16 = createByteToUtf16Mapper(sourceText);\n return diagnostics.map((diagnostic) => ({\n ...diagnostic,\n range: mapNativeRange(diagnostic.range, byteToUtf16),\n ...(diagnostic.suggestions?.length\n ? {\n suggestions: diagnostic.suggestions.map((suggestion) =>\n mapNativeSuggestion(suggestion, byteToUtf16),\n ),\n }\n : {}),\n }));\n}\n\nfunction mapNativeSuggestion(\n suggestion: NativeLintSuggestion,\n byteToUtf16: ByteToUtf16Mapper,\n): NativeLintSuggestion {\n return {\n ...suggestion,\n fixes: suggestion.fixes.map((fix) => mapNativeFix(fix, byteToUtf16)),\n };\n}\n\nfunction mapNativeFix(fix: NativeLintFix, byteToUtf16: ByteToUtf16Mapper): NativeLintFix {\n return {\n ...fix,\n range: mapNativeRange(fix.range, byteToUtf16),\n };\n}\n\nfunction mapNativeRange(range: NativeLintRange, byteToUtf16: ByteToUtf16Mapper): NativeLintRange {\n return {\n start: byteToUtf16(range.start),\n end: byteToUtf16(range.end),\n };\n}\n\nfunction createByteToUtf16Mapper(sourceText: string): ByteToUtf16Mapper {\n const nonAsciiSpans: NonAsciiSpan[] = [];\n let byteOffset = 0;\n let utf16Offset = 0;\n\n while (utf16Offset < sourceText.length) {\n const codePoint = sourceText.codePointAt(utf16Offset);\n if (codePoint === undefined) {\n break;\n }\n const utf16Length = codePoint > 0xffff ? 2 : 1;\n const byteLength = utf8ByteLength(codePoint);\n const byteEnd = byteOffset + byteLength;\n const utf16End = utf16Offset + utf16Length;\n if (byteLength !== utf16Length) {\n nonAsciiSpans.push({\n byteStart: byteOffset,\n byteEnd,\n utf16Start: utf16Offset,\n deltaAfter: byteEnd - utf16End,\n });\n }\n byteOffset = byteEnd;\n utf16Offset = utf16End;\n }\n\n if (nonAsciiSpans.length === 0) {\n return (offset) => clampOffset(offset, sourceText.length);\n }\n\n const totalBytes = byteOffset;\n return (offset) => {\n const byteOffset = clampOffset(offset, totalBytes);\n let low = 0;\n let high = nonAsciiSpans.length;\n while (low < high) {\n const mid = Math.floor((low + high) / 2);\n if (nonAsciiSpans[mid].byteEnd <= byteOffset) {\n low = mid + 1;\n } else {\n high = mid;\n }\n }\n\n const nextSpan = nonAsciiSpans[low];\n if (nextSpan && byteOffset >= nextSpan.byteStart && byteOffset < nextSpan.byteEnd) {\n return nextSpan.utf16Start;\n }\n\n const previousSpan = nonAsciiSpans[low - 1];\n const delta = previousSpan?.deltaAfter ?? 0;\n return clampOffset(byteOffset - delta, sourceText.length);\n };\n}\n\nfunction utf8ByteLength(codePoint: number): number {\n if (codePoint <= 0x7f) {\n return 1;\n }\n if (codePoint <= 0x7ff) {\n return 2;\n }\n if (codePoint <= 0xffff) {\n return 3;\n }\n return 4;\n}\n\nfunction clampOffset(offset: number, max: number): number {\n if (!Number.isFinite(offset)) {\n return 0;\n }\n if (offset <= 0) {\n return 0;\n }\n if (offset >= max) {\n return max;\n }\n return Math.trunc(offset);\n}\n\nfunction sourceTextForContext(context: ContextWithParserOptions): string {\n const text = (context.sourceCode as { text?: unknown }).text;\n if (typeof text === \"string\") {\n return text;\n }\n return context.sourceCode.getText({ type: \"Program\" } as never);\n}\n\nfunction currentRuleOptions(context: ContextWithParserOptions): CorsaStylisticRuleOptions {\n return normalizeOptions((context as { options?: unknown }).options);\n}\n\nfunction normalizeOptions(options: unknown): CorsaStylisticRuleOptions {\n if (Array.isArray(options)) {\n return options;\n }\n if (options == null) {\n return [];\n }\n return [options];\n}\n\nfunction assertKnownStylisticRuleName(name: string): asserts name is CorsaStylisticRuleName {\n if (!(implementedStylisticRuleNames as readonly string[]).includes(name)) {\n throw new Error(`unknown corsa stylistic rule: ${name}`);\n }\n}\n\nfunction stylisticRuleMeta(ruleName: CorsaStylisticRuleName): NativeLintRuleMeta {\n const meta = stylisticMetasByName.get(ruleName);\n if (!meta) {\n throw new Error(`corsa stylistic native Rust rule is not registered: ${ruleName}`);\n }\n return meta;\n}\n"],"mappings":";;;;;;;;;;AA4EA,MAAM,iBAAiB,0BAA0B;AACjD,MAAM,uBAAuB,IAAI,IAAI,eAAe,KAAK,SAAS,CAAC,KAAK,MAAM,KAAK,CAAC,CAAC;AAerF,MAAM,mCAAmB,IAAI,SAA0D;;;;AAKvF,MAAa,gCAAgC;CAC3C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;C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IAAI,YAAY,cAAc,SAAS,aAAa,aAAa,SAAS,SACxE,OAAO,SAAS;EAKlB,OAAO,YAAY,cAFE,cAAc,MAAM,IACb,cAAc,IACH,WAAW,OAAO;;;AAI7D,SAAS,eAAe,WAA2B;CACjD,IAAI,aAAa,KACf,OAAO;CAET,IAAI,aAAa,MACf,OAAO;CAET,IAAI,aAAa,OACf,OAAO;CAET,OAAO;;AAGT,SAAS,YAAY,QAAgB,KAAqB;CACxD,IAAI,CAAC,OAAO,SAAS,OAAO,EAC1B,OAAO;CAET,IAAI,UAAU,GACZ,OAAO;CAET,IAAI,UAAU,KACZ,OAAO;CAET,OAAO,KAAK,MAAM,OAAO;;AAG3B,SAAS,qBAAqB,SAA2C;CACvE,MAAM,OAAQ,QAAQ,WAAkC;CACxD,IAAI,OAAO,SAAS,UAClB,OAAO;CAET,OAAO,QAAQ,WAAW,QAAQ,EAAE,MAAM,WAAW,CAAU;;AAGjE,SAAS,mBAAmB,SAA8D;CACxF,OAAO,iBAAkB,QAAkC,QAAQ;;AAGrE,SAAS,iBAAiB,SAA6C;CACrE,IAAI,MAAM,QAAQ,QAAQ,EACxB,OAAO;CAET,IAAI,WAAW,MACb,OAAO,EAAE;CAEX,OAAO,CAAC,QAAQ;;AAGlB,SAAS,6BAA6B,MAAsD;CAC1F,IAAI,CAAE,8BAAoD,SAAS,KAAK,EACtE,MAAM,IAAI,MAAM,iCAAiC,OAAO;;AAI5D,SAAS,kBAAkB,UAAsD;CAC/E,MAAM,OAAO,qBAAqB,IAAI,SAAS;CAC/C,IAAI,CAAC,MACH,MAAM,IAAI,MAAM,uDAAuD,WAAW;CAEpF,OAAO"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "corsa-oxlint",
|
|
3
|
-
"version": "0.
|
|
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.
|
|
106
|
+
"@corsa-bind/napi": "0.42.0"
|
|
107
107
|
},
|
|
108
108
|
"devDependencies": {
|
|
109
109
|
"@typescript-eslint/utils": "8.59.3"
|