Skip to content

📝 With --stdin-file-path + inherited config, biome only respects the root configuration #8233

Description

@cormacrelf

Please provide a clear and concise description of what the bug is.

There is a big divergence between what config is used by stdin mode, and what happens when formatting the whole repo. In stdin mode, biome is completely ignoring non-root configs. This prevents biome being usable with jj fix, which only supports stdin mode.

As I understood it, the entire point of the --stdin-file-path flag is to allow biome to do config discovery exactly as if you ran biome format THATFILENAME.js. It is in fact documented on the Check { stdin_file_path } flag in biome_cli that the provided path should determine which override configs are applied. I haven't got it to work with check either, for the record. I can't fathom writing a tool like this from scratch with two different config discovery pipelines, so this is probably from a big code path migration from v1 to v2 or something that was not completed.

See linked repository https://github.com/cormacrelf/biome-nested-config-repro, whose readme shows a breakdown of what works and what doesn't.

Surprise

Biome is in fact reading the subdirectory configuration. And then ignoring it!

; strace biome format --stdin-file-path=subdirectory/lib.js < subdirectory/lib.js 2>&1 1>/dev/null | rg 'openat.*biome'

openat(AT_FDCWD, "/home/user/newfolder/biome.json", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/home/user/newfolder/biome.jsonc", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/home/user/newfolder/biome.jsonc", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/home/user/newfolder/subdirectory/biome.jsonc/biome.json", O_RDONLY|O_CLOEXEC) = -1 ENOTDIR (Not a directory)
openat(AT_FDCWD, "/home/user/newfolder/subdirectory/biome.jsonc/biome.jsonc", O_RDONLY|O_CLOEXEC) = -1 ENOTDIR (Not a directory)
openat(AT_FDCWD, "/home/user/newfolder/subdirectory/biome.json", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/home/user/newfolder/subdirectory/biome.jsonc", O_RDONLY|O_CLOEXEC) = 3

Whereas when formatting a root js file:

strace biome format --stdin-file-path=app.js < app.js 2>&1 1>/dev/null | rg 'openat.*biome'

openat(AT_FDCWD, "/home/user/newfolder/biome.json", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/home/user/newfolder/biome.jsonc", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/home/user/newfolder/biome.jsonc", O_RDONLY|O_CLOEXEC) = 3

Environment information

CLI:
  Version:                      2.3.5
  Color support:                true

Platform:
  CPU Architecture:             x86_64
  OS:                           linux

Environment:
  BIOME_LOG_PATH:               unset
  BIOME_LOG_PREFIX_NAME:        unset
  BIOME_CONFIG_PATH:            unset
  BIOME_THREADS:                unset
  NO_COLOR:                     unset
  TERM:                         alacritty
  JS_RUNTIME_VERSION:           unset
  JS_RUNTIME_NAME:              unset
  NODE_PACKAGE_MANAGER:         unset

Biome Configuration:
  Status:                       Loaded successfully
  Path:                         biome.jsonc
  Formatter enabled:            true
  Linter enabled:               true
  Assist enabled:               true
  VCS enabled:                  false

Formatter:
  Format with errors:           unset
  Indent style:                 Space
  Indent width:                 4
  ...
  (everything else unset)

Configuration

{ "please": "see linked repository, this is about nested config",
  "also": "the bug report template is broken, there is no field for description" }

Playground link

https://github.com/cormacrelf/biome-nested-config-repro

Code of Conduct

  • I agree to follow Biome's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    S-Needs triageStatus: this issue needs to be triaged

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions