Skip to content

📎 Use biome_glob for the Biome config file #4611

@Conaclos

Description

@Conaclos

Description

Biome currently uses a fork of the glob crate. This crate has known shortcomings that can be considered as bugs by users. See #2421 and #3345.
For instance the globs src/** and *.txt are currently interpreted as **/src/** and **/*.txt.
Also, we would like in the future to support convenient syntaxes such as #2986.

In the past months, several linter or assist rules required globs. Instead of using our glob fork, I introduced biome_glob::Glob (Previously known as RestrictedGlob). This currently encapsulates the globset crate and provides glob list with exceptions (negated globs).

Our current Biome configuration file uses globs in include and ignore fields.
Switching from our glob fork to biome_glob could cause breakage on users.
This is why I propose to keep the include and ignore fields bound to our fork of glob, to deprecate them, and to introduce a new
field includes (include with a trailing s).
includes will use a glob list with exceptions.

Also, to make top-level includes more accessible, to propose to place it directly at the root of the configuration (i.e. includes instead of files.include/files.ignore). See the migration example.

Tasks:

  • Introduce the new field includes
  • Deprecate include/ignore and provide an automated migration (using biome migrate) to ease migration from include/ignore to includes.

Implementation notes

Our file crawler currently doesn't traverse a directory if the directory is ignored in a ignore file.
I introduced a method biome_glob::CandidatePath::matches_directory_with_exceptions to preserve this behavior.

Migration example

The migration tool will have in charge of translating include/ignore patterns into includes.
For instance the globs src/** and *.txt have to be translated as **/src/** and **/*.txt.

  {
    "files": {
-     "include": ["src/**"],
-     "ignore": ["src/**/*.test.js"]
    },
+  "includes": [
+     "**/src/**",
+     "!**/src/**/*.test.js"
+  ],
    "linter": {
-     "ignore": ["**/test/**"],
+     "includes": ["!**/test/**"],
    },
    "overrides": [
      {
-       "include": ["test/**"],
+       "includes": ["**/test/**"],
      }
    ]
  }

Discussion

includes and include are really close (just a trailing s creates the difference). This could cause some confusion.
An alternative name could be files. Unfortunately this conflicts with the top-level files config.
If we want to use files we will have to deprecate the top-level files object and to find an alternative way of configuring the files options.
Maybe the confusion is ok because include will be deprecated anyway and eventually removed.

Metadata

Metadata

Labels

A-ProjectArea: projectS-Help-wantedStatus: you're familiar with the code base and want to help the project

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions