kimlimjustin / xplorer

Xplorer, a customizable, modern file manager
https://xplorer.space/
Apache License 2.0
4.04k stars 290 forks source link

chore!: add biome instead of prettier for formatting #303

Open curtisy1 opened 3 months ago

curtisy1 commented 3 months ago

This also sets up the preliminary work needed to use biome as a linter instead of eslint by running lint:biome

Motivation

Biome is an alternative to Prettier and ESLint, written in Rust. The main advantage of it besides speed is that it gives very useful error messages when using it as a linter, for example

src/Components/Functions/path/normalizeSlash.ts:8:5 lint/style/noParameterAssign ━━━━━━━━━━━━━━━━━━━

  ✖ Reassigning a function parameter is confusing.

     6 │ const NormalizeSlash = (path: string): string => {
     7 │     if (path === "\\" || path === "/") return "/";
   > 8 │     path = path.replace(/\\/g, "/");
       │     ^^^^
     9 │ 
    10 │     if (path.length === 2 && /.:/.test(path)) return `${path}/`;

  ℹ The parameter is declared here:

    4 │  * @returns {string}
    5 │  */
  > 6 │ const NormalizeSlash = (path: string): string => {
      │                         ^^^^^^^^^^^^
    7 │     if (path === "\\" || path === "/") return "/";
    8 │     path = path.replace(/\\/g, "/");

  ℹ Use a local variable instead.

This makes it easier for newcomers to understand what's happening and fix issues accordingly. It also aligns nicely with Rust's error messages

Changes

Added a biome.json files with the default ruleset and applied the prettier config on top. After that I ran yarn format on the code base to make biome format the whole code according to prettier specification

Additional Comments

Leaving this in Draft mode for now because I plan on using Biome as a linter as well, at least for everything that is not type-checking

vercel[bot] commented 3 months ago

@curtisy1 is attempting to deploy a commit to the Justin Maximillian Kimlim's projects Team on Vercel.

A member of the Team first needs to authorize it.

curtisy1 commented 3 months ago

I fixed most of the lint rules Biome provides. Some are too tedious to fix on a small note but they can be easily added and fixed gradually (and should be!)