@alint-js/core 0.1.5 → 0.3.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.
@@ -372,9 +372,7 @@ function recordPatternNames(node, info) {
372
372
  for (const property of asNodeList(node.properties)) if (property.type === "RestElement") recordPatternNames(asAstNode(property.argument), info);
373
373
  else if (!property.shorthand) recordPatternNames(asAstNode(property.value), info);
374
374
  break;
375
- case "RestElement":
376
- recordPatternNames(asAstNode(node.argument), info);
377
- break;
375
+ case "RestElement": recordPatternNames(asAstNode(node.argument), info);
378
376
  }
379
377
  }
380
378
  function walk(node, info) {
@@ -428,9 +426,7 @@ function walk(node, info) {
428
426
  if (value) walk(value, info);
429
427
  return;
430
428
  }
431
- case "VariableDeclarator":
432
- recordPatternNames(asAstNode(node.id), info);
433
- break;
429
+ case "VariableDeclarator": recordPatternNames(asAstNode(node.id), info);
434
430
  }
435
431
  for (const child of childNodes(node)) walk(child, info);
436
432
  }
package/dist/index.d.mts CHANGED
@@ -50,6 +50,10 @@ declare function resolveLanguage(file: SourceFile, registry: LanguageRegistry, o
50
50
  declare function createBuiltInLanguageRegistry(): LanguageRegistry;
51
51
  //#endregion
52
52
  //#region src/core/types.d.ts
53
+ interface AlintFailureCause {
54
+ code?: string;
55
+ message: string;
56
+ }
53
57
  interface AlintFileFailure {
54
58
  file: {
55
59
  index: number;
@@ -59,6 +63,7 @@ interface AlintFileFailure {
59
63
  message: string;
60
64
  }
61
65
  interface AlintRuleFailure {
66
+ causes: AlintFailureCause[];
62
67
  job: ProgressJobRef;
63
68
  kind: 'cache-replay' | 'handler' | 'source-changed' | 'timeout';
64
69
  message: string;
@@ -374,4 +379,4 @@ declare function benchmarkModels(config: SetupConfig, options?: BenchmarkModelsO
374
379
  //#region src/models/resolve.d.ts
375
380
  declare function resolveModel(registry: SetupConfig, options?: ResolveModelOptions): ResolvedModel;
376
381
  //#endregion
377
- export { AlintAbortError, type AlintConfig, type AlintConfigExtends, type AlintConfigInput, type AlintConfigItem, type AlintFileFailure, type AlintLinterOptions, type AlintRuleFailure, AlintRunCancelledError, AlintRunError, type AlintRunFailure, type Awaitable, type BaseSourceFile, type BenchmarkModelsOptions, type CallSite, type ClassTarget, type Diagnostic, type DiagnosticDescriptor, type DiagnosticLocation, type DiagnosticProgressPayload, type DirectoryTarget, type EffectiveAlintConfig, type EnabledRule, type ExecutionCounts, type ExecutionProgressPayload, type FileReadyPayload, type FileTarget, type FunctionInfo, type FunctionTarget, type IgnoreConfig, type InferenceUsageRecord, type JobEndPayload, type JobQueuedPayload, type JobRetryPayload, type JobStartPayload, type LanguageContext, type LanguageDefinition, type LanguageRegistry, type LineRange, type ModelBenchmarkActive, type ModelBenchmarkMeasurement, type ModelBenchmarkProgress, type ModelBenchmarkRequest, type ModelBenchmarkResult, type ModelRequirement, type ModelSize, type PlannedSourceTarget, type PlannedSourceTargetOfKind, type PluginDefinition, type PrepareEndPayload, type PrepareStartPayload, type ProcessedSource, type ProcessedSourceOrigin, type ProcessorContext, type ProcessorDefinition, type ProcessorPostprocessContext, type ProgressJobRef, type ProgressReporter, type ProgressSnapshot, type ProgressTargetKind, type ProjectFileEntry, type ProjectTarget, type ProjectTargetEntry, type ProviderDefinition, type ProviderType, type ResolveConfigResult, type ResolveLanguageOptions, type ResolveModelOptions, type ResolvedModel, type ResolvedProvider, type RuleCacheConfig, type RuleConfigEntry, type RuleContext, type RuleDefinition, type RuleHandlers, type RuleInferenceUsageRecord, type RuleRegistry, type RuleSeverity, type RuleSpecializedHandlers, type RuleWithHandler, type RunEndPayload, type RunExecution, type RunOptions, type RunResult, type RunUsage, type RunUsageTotals, type RunnerConfig, type RunnerStatsConfig, type SetupConfig, type SetupModelDefinition, type SourceExtractOptions, type SourceFile, type SourceLocation, type SourceMetadataObject, type SourceMetadataValue, type SourcePosition, type SourceRange, type SourceRuntime, type SourceRuntimeOptions, type SourceTarget, type SourceTargetKind, type SourceTargetMetadata, type SourceTargetOfKind, type SourceTargetOrigin, type SourceText, type Target, type UsageProgressPayload, benchmarkModels, buildRuleRegistry, createBuiltInLanguageRegistry, createSourceExtractor, createSourceFile, createSourceRuntime, defineConfig, definePlugin, defineRule, hasDiscoveryFilePatterns, matchesDiscoveryFile, normalizeConfig, registerLanguage, resolveConfigForDirectory, resolveConfigForFile, resolveConfigForProject, resolveLanguage, resolveModel, runAlint, sliceLines, sliceRange, targetIdentity, withLanguage, withStableIdentities };
382
+ export { AlintAbortError, type AlintConfig, type AlintConfigExtends, type AlintConfigInput, type AlintConfigItem, type AlintFailureCause, type AlintFileFailure, type AlintLinterOptions, type AlintRuleFailure, AlintRunCancelledError, AlintRunError, type AlintRunFailure, type Awaitable, type BaseSourceFile, type BenchmarkModelsOptions, type CallSite, type ClassTarget, type Diagnostic, type DiagnosticDescriptor, type DiagnosticLocation, type DiagnosticProgressPayload, type DirectoryTarget, type EffectiveAlintConfig, type EnabledRule, type ExecutionCounts, type ExecutionProgressPayload, type FileReadyPayload, type FileTarget, type FunctionInfo, type FunctionTarget, type IgnoreConfig, type InferenceUsageRecord, type JobEndPayload, type JobQueuedPayload, type JobRetryPayload, type JobStartPayload, type LanguageContext, type LanguageDefinition, type LanguageRegistry, type LineRange, type ModelBenchmarkActive, type ModelBenchmarkMeasurement, type ModelBenchmarkProgress, type ModelBenchmarkRequest, type ModelBenchmarkResult, type ModelRequirement, type ModelSize, type PlannedSourceTarget, type PlannedSourceTargetOfKind, type PluginDefinition, type PrepareEndPayload, type PrepareStartPayload, type ProcessedSource, type ProcessedSourceOrigin, type ProcessorContext, type ProcessorDefinition, type ProcessorPostprocessContext, type ProgressJobRef, type ProgressReporter, type ProgressSnapshot, type ProgressTargetKind, type ProjectFileEntry, type ProjectTarget, type ProjectTargetEntry, type ProviderDefinition, type ProviderType, type ResolveConfigResult, type ResolveLanguageOptions, type ResolveModelOptions, type ResolvedModel, type ResolvedProvider, type RuleCacheConfig, type RuleConfigEntry, type RuleContext, type RuleDefinition, type RuleHandlers, type RuleInferenceUsageRecord, type RuleRegistry, type RuleSeverity, type RuleSpecializedHandlers, type RuleWithHandler, type RunEndPayload, type RunExecution, type RunOptions, type RunResult, type RunUsage, type RunUsageTotals, type RunnerConfig, type RunnerStatsConfig, type SetupConfig, type SetupModelDefinition, type SourceExtractOptions, type SourceFile, type SourceLocation, type SourceMetadataObject, type SourceMetadataValue, type SourcePosition, type SourceRange, type SourceRuntime, type SourceRuntimeOptions, type SourceTarget, type SourceTargetKind, type SourceTargetMetadata, type SourceTargetOfKind, type SourceTargetOrigin, type SourceText, type Target, type UsageProgressPayload, benchmarkModels, buildRuleRegistry, createBuiltInLanguageRegistry, createSourceExtractor, createSourceFile, createSourceRuntime, defineConfig, definePlugin, defineRule, hasDiscoveryFilePatterns, matchesDiscoveryFile, normalizeConfig, registerLanguage, resolveConfigForDirectory, resolveConfigForFile, resolveConfigForProject, resolveLanguage, resolveModel, runAlint, sliceLines, sliceRange, targetIdentity, withLanguage, withStableIdentities };
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { o as withAgentRetry, t as combineAbortSignals } from "./agent-B6GG68NX.mjs";
2
2
  import { n as definePlugin, r as defineRule, t as defineConfig } from "./define-Da342Fcx.mjs";
3
- import { a as createSourceFile, c as sliceRange, d as stableHash, i as SourceChangedError, l as withLanguage, n as targetIdentity, o as createSourceRuntime, r as withStableIdentities, s as sliceLines, t as extractJsSourceTargets, u as createStableHasher } from "./extract-BVbjWXMC.mjs";
3
+ import { a as createSourceFile, c as sliceRange, d as stableHash, i as SourceChangedError, l as withLanguage, n as targetIdentity, o as createSourceRuntime, r as withStableIdentities, s as sliceLines, t as extractJsSourceTargets, u as createStableHasher } from "./extract-DoHeLdG1.mjs";
4
4
  import { minimatch } from "minimatch";
5
5
  import { basename, extname, isAbsolute, relative, resolve } from "pathe";
6
6
  import { access, mkdir, open, readFile, rename, rm, writeFile } from "node:fs/promises";
@@ -149,7 +149,8 @@ function matchesInheritedScopes(filePath, item, cwd, targetKind) {
149
149
  }
150
150
  function matchesPattern(filePath, pattern, cwd, basePath, matchDirectoryRoot = false) {
151
151
  if (isPatternList(pattern)) return pattern.every((entry) => matchesPattern(filePath, entry, cwd, basePath, matchDirectoryRoot));
152
- const relativePath = relative(basePath ? resolve(cwd, basePath) : cwd, isAbsolute(filePath) ? filePath : resolve(cwd, filePath)).replaceAll("\\", "/");
152
+ const base = basePath ? resolve(cwd, basePath) : cwd;
153
+ const relativePath = relative(base, isAbsolute(filePath) ? filePath : resolve(cwd, filePath)).replaceAll("\\", "/");
153
154
  if (relativePath === ".." || relativePath.startsWith("../")) return false;
154
155
  return minimatch(relativePath, pattern, { dot: true }) || matchDirectoryRoot && minimatch(`${relativePath}/`, pattern, { dot: true });
155
156
  }
@@ -601,7 +602,7 @@ function recordMissingLanguages(into, rules, registry, path) {
601
602
  }
602
603
  //#endregion
603
604
  //#region package.json
604
- var version = "0.1.5";
605
+ var version = "0.3.0";
605
606
  //#endregion
606
607
  //#region src/core/cache/types.ts
607
608
  const CACHE_MAGIC = "ALINT_CACHE";
@@ -689,7 +690,8 @@ const CacheFileBodySchema = pipe(object({
689
690
  async function createCacheStore(options) {
690
691
  const location = resolveCacheLocation(options.cwd, options.location);
691
692
  if (!options.enabled) return createNoopCacheStore(location);
692
- const header = `${CACHE_MAGIC} 2 ${options.alintVersion ?? version}`;
693
+ const alintVersion = options.alintVersion ?? version;
694
+ const header = `${CACHE_MAGIC} 2 ${alintVersion}`;
693
695
  const body = await loadCacheBody(location, header, options.readOnly === true);
694
696
  if (options.readOnly) return createReadOnlyCacheStore(location, body, options.cwd);
695
697
  const fileExists = options.fileExists ?? defaultFileExists;
@@ -726,7 +728,8 @@ function createTargetIdentityResolver(targets) {
726
728
  };
727
729
  }
728
730
  function normalizeCachePath(cwd, filePath) {
729
- return relative$1(cwd, isAbsolute$1(filePath) ? resolve$1(filePath) : resolve$1(cwd, filePath)).split(sep).join("/") || ".";
731
+ const resolvedPath = isAbsolute$1(filePath) ? resolve$1(filePath) : resolve$1(cwd, filePath);
732
+ return relative$1(cwd, resolvedPath).split(sep).join("/") || ".";
730
733
  }
731
734
  function normalizeRunnerCacheConfig(cache, cwd) {
732
735
  if (cache === false) return {
@@ -985,6 +988,7 @@ function snapshotDiagnostics(diagnostics) {
985
988
  }
986
989
  function snapshotFailure(failure) {
987
990
  return {
991
+ causes: failure.causes.map((cause) => ({ ...cause })),
988
992
  job: snapshotProgressJobRef(failure.job),
989
993
  kind: failure.kind,
990
994
  message: failure.message
@@ -1156,13 +1160,51 @@ function createFingerprint(job, modelHash) {
1156
1160
  function createTargetHash(job) {
1157
1161
  return job.target.cacheTargetHash;
1158
1162
  }
1163
+ function errorCause(error) {
1164
+ if (error === null || typeof error !== "object") return void 0;
1165
+ try {
1166
+ return "cause" in error ? error.cause : void 0;
1167
+ } catch {
1168
+ return;
1169
+ }
1170
+ }
1171
+ function errorCode(error) {
1172
+ if (error === null || typeof error !== "object") return void 0;
1173
+ try {
1174
+ const code = "code" in error ? error.code : void 0;
1175
+ return typeof code === "string" || typeof code === "number" ? String(code) : void 0;
1176
+ } catch {
1177
+ return;
1178
+ }
1179
+ }
1159
1180
  function failure(cause, job, kind) {
1160
1181
  return {
1182
+ causes: failureCauses(cause),
1161
1183
  job: snapshotProgressJobRef(job.jobRef),
1162
1184
  kind,
1163
1185
  message: failureMessage$1(cause)
1164
1186
  };
1165
1187
  }
1188
+ function failureCauses(error) {
1189
+ const causes = [];
1190
+ const seen = /* @__PURE__ */ new Set();
1191
+ let current = error;
1192
+ if (current !== null && typeof current === "object") seen.add(current);
1193
+ while (true) {
1194
+ const cause = errorCause(current);
1195
+ if (cause === void 0) return causes;
1196
+ if (cause !== null && typeof cause === "object") {
1197
+ if (seen.has(cause)) return causes;
1198
+ seen.add(cause);
1199
+ }
1200
+ const code = errorCode(cause);
1201
+ causes.push({
1202
+ ...code === void 0 ? {} : { code },
1203
+ message: failureMessage$1(cause)
1204
+ });
1205
+ current = cause;
1206
+ }
1207
+ }
1166
1208
  function failureMessage$1(cause) {
1167
1209
  try {
1168
1210
  return errorMessageFrom(cause) ?? "Unknown rule failure.";
@@ -1,2 +1,2 @@
1
- import { t as extractJsSourceTargets } from "./extract-BVbjWXMC.mjs";
1
+ import { t as extractJsSourceTargets } from "./extract-DoHeLdG1.mjs";
2
2
  export { extractJsSourceTargets };
@@ -46,6 +46,7 @@ async function generateStructured(options) {
46
46
  try {
47
47
  options.signal?.throwIfAborted();
48
48
  response = await generateText({
49
+ ...options.model.params,
49
50
  abortSignal: options.signal,
50
51
  baseURL: options.model.provider.endpoint,
51
52
  headers: options.model.provider.headers,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@alint-js/core",
3
3
  "type": "module",
4
- "version": "0.1.5",
4
+ "version": "0.3.0",
5
5
  "exports": {
6
6
  ".": {
7
7
  "types": "./dist/index.d.mts",
@@ -35,15 +35,15 @@
35
35
  "@xsai/shared-chat": "^0.5.0-beta.7",
36
36
  "@xsai/stream-text": "^0.5.0-beta.7",
37
37
  "@xsai/tool": "^0.5.0-beta.7",
38
- "es-toolkit": "^1.49.0",
39
- "minimatch": "^10.2.5",
40
- "oxc-parser": "^0.140.0",
38
+ "es-toolkit": "^1.50.0",
39
+ "minimatch": "^10.2.6",
40
+ "oxc-parser": "^0.142.0",
41
41
  "pathe": "^2.0.3",
42
42
  "valibot": "^1.4.2"
43
43
  },
44
44
  "devDependencies": {
45
- "effect": "^3.22.0",
46
- "sury": "^11.0.0-alpha.10"
45
+ "effect": "^3.22.1",
46
+ "sury": "^11.0.0-rc.0"
47
47
  },
48
48
  "scripts": {
49
49
  "bench": "vitest bench --config vitest.config.ts",