biomejs / biome

A toolchain for web projects, aimed to provide functionalities to maintain them. Biome offers formatter and linter, usable via CLI and LSP.
https://biomejs.dev
Apache License 2.0
13.95k stars 423 forks source link

🐛 configuration file error #3518

Open franck-paul opened 1 month ago

franck-paul commented 1 month ago

Environment information

I use this config file (biome.json):

{
  "organizeImports": { "enabled": true },
  "linter": {
    "enabled": true,
    "rules": {
      "recommended": true,
      "suspicious": {
        "noRedundantUseStrict": "off"
      }
    }
  }
}

With Biome 1.8.2 (SublimeText 4) everything is fine, with 1.8.3 (VSCode) Biome says: The configuration file has errors. Biome will report only parsing errors until the configuration is fixed.

Could you tell me how to fix this?

What happened?

I got an error message with 1.8.3 as soon as I open a JS file in VSC

Expected result

No error maybe, or tell me how to fix this.

Code of Conduct

dyc3 commented 1 month ago

I'm unable to reproduce this with the CLI. Try manually specifying the config path with --config-path to make sure you're loading the config you're expecting to.

Are you using the CLI or LSP?

franck-paul commented 1 month ago

I'm using LSP in both

ematipico commented 1 month ago

The configuration file is valid. It's probably something related to the IDE. Can you please share a reproduction with us?

franck-paul commented 1 month ago

I would like but how sharing it? May be this, below, is enough for you to reproduce it?

It's the last release of VSCode (1.91.1) installed on MacOS (M2 Pro, Sonoma 14.5), with biomejs.biome extension installed (using bundled biome 1.8.3).

I have a biome.json configuration file (see above) in the main folder and a js file in a sub-folder.

The js file begins with:

/*global dotclear */
'use strict';

dotclear.ready(() => {
  // DOM ready and content loaded

  // Give focus to user field
  /**
   * @type {HTMLInputElement|null}
   */
  const uid = document.querySelector('input[name=user_id]');
  if (uid) uid?.focus();
...
davearel commented 1 month ago

I'm experiencing this same error — same version of VSCode and Biome

Screenshot 2024-07-28 at 7 23 59 PM
The configuration file has errors. Biome will report only parsing errors until the configuration is fixed.

I ended up noticing an incorrect glob pattern in my files.include array.

To reproduce, try using this biome.json. I was able to trigger an inline error one time on the glob pattern. But most of the time, it just triggered the modal error above.

{
  "$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
  "files": {
     "include": ["**.ts"]
  }
}

Perhaps the error itself could be more descriptive? I assume this glob pattern is valid within the file because its only validating against the JSON Schema? May not be a glob pattern issue for the OP but similar valid JSON Schema but error in biome?

davearel commented 1 month ago

(Also— Perhaps this is best suited for biomejs/biome-vscode?)

dyc3 commented 1 month ago

@franck-paul You can share a reproduction with us by creating a minimal git repo that triggers the issue, and providing any steps necessary to trigger the issue. That would make it much quicker to track down the root cause of whatever the issue is.

@davearel That looks like a separate issue. Biome's globs require ** to be in it's own path segment. To fix it, replace the glob with **/*.ts. I believe the CLI should already emit better diagnostics for this, but it might not be properly conveyed via the LSP.

davearel commented 1 month ago

@dyc3 right, I got that, but the underlying issue for @franck-paul is similar in that VS Code is giving a generic error message for potentially a very specific issue like mine and no error is provided within the config itself.

I fixed my issue before posting, I'm just providing an example of how to reproduce a similar issue. The error message isn't helpful. Perhaps the LSP can list the set of configuration status errors?

ematipico commented 1 month ago

@davearel @franck-paul

If you see that warning and you open the configuration file, Biome should tell you what the error is.

Plus, you can Biome logs for more grained information: https://biomejs.dev/guides/editors/create-a-plugin/#daemon-logs

Perhaps the error itself could be more descriptive?

That's a generic warning emitted when the configuration file contains errors. Errors specific to a file are usually emitted and slowed to the file.

But if there aren't errors in the configuration file, then maybe there's an issue lurking around, and that's why we asked for a reproduction, which hasn't been provided yet.

franck-paul commented 1 month ago

Ok I will setup a minimal git repo… here: https://github.com/franck-paul/biomejs-strict

But unfortunately the error is not thrown with this repo in VSC, very weird.

davearel commented 1 month ago

@ematipico @dyc3 Makes sense. And yeah, the generic message is fine as long as it shows up in the config, but it wasn't for me. Can you try my configuration example above? thats my minimal example of the issue. I was seeing no error inside of the config, but consistently getting the generic modal error.

While I was debugging this issue, VSC underlined the glob pattern once. Which tells me it may work, but inconsistently. That may also explain why @franck-paul is seeing the issue in his original codebase, but not in the minimal example he just provided.

I also tried @franck-paul's original config myself, and didn't get any error at all. If either of you try my provided config and DO see the error in-line, there's something else going on.

update: fixed the last line ^

ematipico commented 1 month ago

@franck-paul I just tried your reproduction and it works as expected. I tried the bundled version and the global version installed via homebrew.

The only time I got the warning, was when my IDE accidentally added an additional ", causing the file to have a parsing error. Maybe that's what happened?

@davearel I could replicate your issue, and indeed we emit and error in the "Output" tab

[Error - 09:42:16] Couldn't parse the **.ts, reason: recursive wildcards must form a single path component

But we don't emit a diagnostic, which is a bug for us. Thank you for the reproduction!

davearel commented 1 month ago

@ematipico ah, I missed the error in the output initially, but I do see it now.

Glad I could help!

franck-paul commented 1 month ago

@franck-paul I just tried your reproduction and it works as expected. I tried the bundled version and the global version installed via homebrew.

The only time I got the warning, was when my IDE accidentally added an additional ", causing the file to have a parsing error. Maybe that's what happened?

I don't remember having put a couple of ", but maybe, we never be 100% sure about PBCAK ;-)