{"id":42341,"library":"yaml-fmt","title":"yaml-fmt","description":"A configurable YAML formatter for Node.js (CLI & API) that sorts object keys and array values in YAML files. Currently at v0.0.8, with infrequent releases. Key differentiators include support for wildcard targets, property-specific sort configurations, and JSON-based config files. Provides ESM and CJS support, ships TypeScript types, and can be used as a CLI tool via `yaml-fmt fmt` or programmatically. Alternatives like prettier or yq offer broader functionality but less YAML-specific sorting control.","status":"active","version":"0.0.8","language":"javascript","source_language":"en","source_url":"https://github.com/tkow/yaml-fmt","tags":["javascript","yaml","sort","format","typescript"],"install":[{"cmd":"npm install yaml-fmt","lang":"bash","label":"npm"},{"cmd":"yarn add yaml-fmt","lang":"bash","label":"yarn"},{"cmd":"pnpm add yaml-fmt","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"YAML parsing and serialization","package":"js-yaml","optional":false},{"reason":"CLI argument parsing","package":"yargs","optional":true}],"imports":[{"note":"ESM-only since v0.0.8; CommonJS require() not supported.","wrong":"const format = require('yaml-fmt')","symbol":"format","correct":"import { format } from 'yaml-fmt'"},{"note":"TypeScript type only, use as import type.","symbol":"YamlFmtConfig","correct":"import type { YamlFmtConfig } from 'yaml-fmt'"},{"note":"Default export is a function; do not use require with .default.","wrong":"const yamlFmt = require('yaml-fmt').default","symbol":"yamlFmt (default)","correct":"import yamlFmt from 'yaml-fmt'"},{"note":"cli is a named export, not default.","wrong":"import cli from 'yaml-fmt'","symbol":"cli","correct":"import { cli } from 'yaml-fmt'"}],"quickstart":{"code":"import { format } from 'yaml-fmt';\nimport YAML from 'js-yaml';\n\nconst input = `name: Bob\nage: 30\n`;\nconst output = format(input, { indent: 2, all: true });\nconsole.log(output);\n// age: 30\n// name: Bob","lang":"typescript","description":"Demonstrates sorting all top-level keys alphabetically with indent 2."},"warnings":[{"fix":"Switch to import statements; use dynamic import if needed.","message":"v0.0.8 drops CommonJS support; only ESM imports work.","severity":"breaking","affected_versions":">=0.0.8"},{"fix":"Define array sort targets in config (e.g., \"properties.enumValue.enum.[]\": true).","message":"Array sorting requires explicit configuration; not applied by `all: true`.","severity":"gotcha","affected_versions":"*"},{"fix":"Use explicit paths for deep nesting.","message":"Wildcard targets only match same-depth properties; nested paths not supported.","severity":"gotcha","affected_versions":"*"},{"fix":"Move root sort config under 'targets' as 'root': true or array.","message":"Config file key 'root' is deprecated in favor of 'targets'.","severity":"deprecated","affected_versions":">=0.0.6"}],"env_vars":null,"search_vec":"'altern':69 'api':11 'array':17 'base':43 'broader':75 'cjs':49 'cli':10,60 'config':44 'configur':5,39 'control':83 'current':22 'differenti':29 'esm':47 'file':21,45 'fmt':3,65,66 'format':87 'formatt':7 'function':76 'includ':30 'infrequ':26 'javascript':84 'json':42 'json-bas':41 'key':15,28 'less':78 'like':70 'node.js':9 'object':14 'offer':74 'prettier':71 'programmat':68 'properti':36 'property-specif':35 'provid':46 'releas':27 'ship':51 'sort':13,38,82,86 'specif':37,81 'support':31,50 'target':34 'tool':61 'type':53 'typescript':52,88 'use':57 'v0.0.8':24 'valu':18 'via':62 'wildcard':33 'yaml':2,6,20,64,80,85 'yaml-fmt':1,63 'yaml-specif':79 'yq':73","created_at":"2026-06-04T18:56:47.310745+00:00","updated_at":"2026-06-04T18:56:47.310745+00:00","problems":[{"fix":"Run 'npm install yaml-fmt' and ensure Node.js >=12 (ESM support).","cause":"Missing npm install or incompatible Node.js version.","error":"Cannot find module 'yaml-fmt'"},{"fix":"Use import { format } from 'yaml-fmt' (ESM only).","cause":"Incorrect import (CommonJS require or wrong named import).","error":"TypeError: format is not a function"},{"fix":"Use -a (short flag) or ensure version >=0.0.6.","cause":"Using --all flag without value or in older version.","error":"yaml-fmt: error: unknown option `--all'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/tkow/yaml-fmt#readme","github":"https://github.com/tkow/yaml-fmt","docs":null,"changelog":null,"pypi":null,"npm":"yaml-fmt","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-04","next_check":"2026-09-02","install_tag":null}}