Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export type { JSON5ParseOptions, JSON5StringifyOptions } from "./json5";
export { parseJSONC, stringifyJSONC } from "./jsonc";
export type { JSONCParseError, JSONCParseOptions } from "./jsonc";

export { parseYAML, stringifyYAML } from "./yaml";
export { parseYAML, stringifyYAML, YAMLException } from "./yaml";
export type { YAMLParseOptions, YAMLStringifyOptions } from "./yaml";

export { parseJSON, stringifyJSON } from "./json";
Expand Down
21 changes: 3 additions & 18 deletions src/yaml.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { load, dump } from "js-yaml";
import { load, dump, YAMLException } from "js-yaml";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

PKG_FILE="$(fd '^package\.json$' | head -n 1)"
echo "Inspecting: ${PKG_FILE}"

jq -r '
{
  dependencies_js_yaml: .dependencies["js-yaml"],
  peerDependencies_js_yaml: .peerDependencies["js-yaml"],
  devDependencies_js_yaml: .devDependencies["js-yaml"]
}
' "${PKG_FILE}"

Repository: unjs/confbox

Length of output: 190


Move js-yaml from devDependencies to dependencies in package.json.

The code imports YAMLException as a value at Line 1 and re-exports it at Line 51. Since consumer code will use this export at runtime, js-yaml must be in dependencies, not devDependencies. Currently it is only in devDependencies.

Also applies to: 51-51

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/yaml.ts` at line 1, The project currently imports and re-exports
YAMLException from js-yaml (see the import line "import { load, dump,
YAMLException } from 'js-yaml';" and the export of YAMLException later), but
js-yaml is only in devDependencies; update package.json to move js-yaml from
devDependencies to dependencies so consumers can import the re-exported
YAMLException at runtime, then run npm/yarn install to update lockfile.

import { type FormatOptions, getFormat, storeFormat } from "./_format";

// Source: https://github.com/nodeca/js-yaml
Expand Down Expand Up @@ -48,6 +48,8 @@ export function stringifyYAML(value: any, options?: YAMLStringifyOptions): strin

// --- Types ---

export { YAMLException };

export interface YAMLParseOptions extends FormatOptions {
/** string to be used as a file path in error/warning messages. */
filename?: string | undefined;
Expand Down Expand Up @@ -95,20 +97,3 @@ export interface YAMLStringifyOptions extends FormatOptions {
replacer?: ((key: string, value: any) => any) | undefined;
}

interface Mark {
buffer: string;
column: number;
line: number;
name: string;
position: number;
snippet: string;
}

declare class YAMLException extends Error {
constructor(reason?: string, mark?: Mark);
toString(compact?: boolean): string;
name: string;
reason: string;
message: string;
mark: Mark;
}