Skip to content

feat: support YAML format for flaglint.config.json (.flaglintrc.yml) #128

Description

@Krishan27

Summary

The config loader in src/config.ts currently only reads flaglint.config.json. Many teams prefer YAML for config files because it supports comments and is less noisy for arrays and nested objects. Supporting .flaglintrc.yml / .flaglintrc.yaml as an alternative to flaglint.config.json lowers the friction for adopting FlagLint in projects that already use YAML-based tooling.

Proposed lookup order

When no --config path is passed explicitly, the loader tries in order:

  1. flaglint.config.json (existing behaviour — unchanged)
  2. .flaglintrc.json
  3. .flaglintrc.yml
  4. .flaglintrc.yaml

The first file found wins. If none is found, defaults apply (also existing behaviour).

Acceptance criteria

  • .flaglintrc.yml and .flaglintrc.yaml are parsed and validated through the same Zod schema as JSON config
  • An explicit --config path/to/custom.yml also works for YAML files
  • A YAML config example is added to the docs config reference page
  • Tests cover: JSON config (existing), YAML config (new), explicit --config with YAML path
  • Error messages for invalid YAML config are clear (include the file path and the parse error)

Implementation notes

  • Use the js-yaml package (already extremely common; tiny footprint) or Node's --experimental-strip-types to avoid a new runtime dependency — confirm which fits the project's dep philosophy
  • Alternatively, a minimal YAML parser subset (just the types FlagLint uses: strings, numbers, booleans, arrays, objects) can be hand-rolled in ~50 lines to keep the dependency count at zero
  • The Zod validation layer does not change — YAML is parsed to a plain object first, then validated identically to JSON

Files likely touched

  • src/config.ts — extend loader to probe YAML filenames and parse YAML
  • src/config/tests/config.test.ts — add YAML config test cases
  • docs-src/ — update config reference page
  • package.json — add js-yaml if that route is chosen (needs ADR comment if a new runtime dep)

Metadata

Metadata

Assignees

No one assigned

    Labels

    cliCLI interface and user experienceenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions