Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Error about insert_final_newline being set to true in .editorconfig, even if Biome's supported files shouldn't be affected #5165

Open
1 task done
jonasgeiler opened this issue Feb 20, 2025 · 5 comments
Labels
S-Bug-confirmed Status: report has been confirmed as a valid bug

Comments

@jonasgeiler
Copy link

Environment information

CLI:
  Version:                      1.9.4
  Color support:                true

Platform:
  CPU Architecture:             x86_64
  OS:                           linux

Environment:
  BIOME_LOG_PATH:               unset
  BIOME_LOG_PREFIX_NAME:        unset
  BIOME_CONFIG_PATH:            unset
  NO_COLOR:                     unset
  TERM:                         "xterm-256color"
  JS_RUNTIME_VERSION:           "v20.18.2"
  JS_RUNTIME_NAME:              "node"
  NODE_PACKAGE_MANAGER:         unset

Biome Configuration:
  Status:                       Loaded successfully
  Formatter disabled:           false
  Linter disabled:              false
  Organize imports disabled:    false
  VCS disabled:                 false

Workspace:
  Open Documents:               0

What happened?

Next to #5164, I also noticed this while using an .editorconfig file with Biome:

  1. I have the following .editorconfig file:

    [*]
    indent_style             = tab
    indent_size              = 4
    end_of_line              = lf
    charset                  = utf-8
    trim_trailing_whitespace = true
    insert_final_newline     = true
    max_line_length          = 80
    
    [*.{c,h}]
    insert_final_newline = false

    As you can see I only enabled insert_final_newline for Clang files, which shouldn't be affected or formatted by Biome anyway.

  2. I have set formatter/useEditorconfig to true in biome.json, so it uses the .editorconfig file above.

  3. Running biome check now shows the following error, but afterwards still runs as usual:

    configuration ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
    
      ✖ Key 'insert_final_newline' is incompatible with biome: Biome always inserts a final newline. Set this option to true.
    
  4. If I remove the line with insert_final_newline = false, this error doesn't show up anymore.

Expected result

I think that if a config like insert_final_newline in .editorconfig won't affect Biome and the files Biome is going to format, it should just ignore that config, and not show an error for f.e. Clang files' configuration.

Code of Conduct

  • I agree to follow Biome's Code of Conduct
@jonasgeiler jonasgeiler added the S-Needs triage Status: this issue needs to be triaged label Feb 20, 2025
@ematipico
Copy link
Member

I think that if a config like insert_final_newline in .editorconfig won't affect Biome and the files Biome is going to format, it should just ignore that config, and not show an error for f.e. Clang files' configuration.

We have a different vision. If a user sets insert_final_newline = false, it means that they don't want a newline at the end of the files, so that's what they expect. If Biome can't give what they expect, it should not function, otherwise Biome will do things that the user doesn't expect.

@dyc3
Copy link
Contributor

dyc3 commented Feb 20, 2025

This makes sense. I'm not sure it's feasible to cover every possible edge case here, but it should be reasonable to at least check the file extensions in the patterns before emitting diagnostics.

@dyc3 dyc3 added the S-Bug-confirmed Status: report has been confirmed as a valid bug label Feb 20, 2025
@github-actions github-actions bot removed the S-Needs triage Status: this issue needs to be triaged label Feb 20, 2025
@ematipico
Copy link
Member

@dyc3 I'm not sure why this is a bug? What's the actual fix?

@dyc3
Copy link
Contributor

dyc3 commented Feb 20, 2025

The issue is specifically about biome emitting a diagnostic for this:

[*.{c,h}]
insert_final_newline = false

Where the pattern only selects files that are not handled by biome. It would be better if we didn't emit a diagnostic in this case, because biome never touches those files.

This is more of a "nice to have" rather than something being broken.

@ematipico
Copy link
Member

I see. I didn't see the actual glob, thank you for clarifying

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-Bug-confirmed Status: report has been confirmed as a valid bug
Projects
None yet
Development

No branches or pull requests

3 participants