Replace ESLint & Prettier with Biome.js

For years I have been using ESLint and Prettier on my Javascript projects. And for years I've been struggling to setting it up for new projects, defining the rules and installing the necessary plugins. Just making ESLint & Prettier work together is not that straightforward, what is handled by ESLint and what is handled by Prettier? In the end I always tweaked the multiple configs until it kind of worked.

Today I'm glad to have found a real solution to this problem, and it's called Biome.js.

Biome.js is a tool that replaces ESLint, Prettier and also does some code organisation.

Here's a quick summary of what I like about Biome.js:

  • 1 dependency instead of ESLint, Prettier and the myriad of plugins needed
  • Better performances, espacially for the formatting
  • Easy single-file configuration
  • Good defaults
  • Monorepo support

Replacing ESLint with Biome.js in a fresh Remix project

Here's what you need to do to replace ESLint with Biome.js in a fresh Remix project. The process is the same for any framework or library you are using.

1. Install Biome.js


_10
bun add --dev --exact @biomejs/biome

The --exact flag is important to avoid any version conflicts. When new versions are available, make sure to adapt rules as required.

2. Configure Biome.js

Next we'll initialize Biome.js which will generate a default biome.json file.


_10
bunx @biomejs/biome init

biome.json

_12
{
_12
"$schema": "https://biomejs.dev/schemas/1.6.0/schema.json",
_12
"organizeImports": {
_12
"enabled": false
_12
},
_12
"linter": {
_12
"enabled": true,
_12
"rules": {
_12
"recommended": true
_12
}
_12
}
_12
}

You can adapt this configuration as you see fit, here's an example config I use for my projects.

biome.json

_28
{
_28
"$schema": "https://biomejs.dev/schemas/1.6.0/schema.json",
_28
"vcs": {
_28
"enabled": true,
_28
"clientKind": "git",
_28
"useIgnoreFile": true,
_28
"defaultBranch": "main"
_28
},
_28
"organizeImports": {
_28
"enabled": true
_28
},
_28
"formatter": {
_28
"enabled": true,
_28
"indentStyle": "space",
_28
"indentWidth": 2
_28
},
_28
"linter": {
_28
"enabled": true,
_28
"rules": {
_28
"recommended": true,
_28
"correctness": {
_28
"noUnusedImports": "error",
_28
"noUnusedVariables": "error",
_28
"useExhaustiveDependencies": "warn"
_28
}
_28
}
_28
}
_28
}

3. Remove ESLint and Prettier

Remove the .eslintrc.cjs file. In package.json remove the eslint dependencies.

Here's what it looks on the Remix vite template:

package.json

_43
{
_43
"name": "remix-vite",
_43
"private": true,
_43
"sideEffects": false,
_43
"type": "module",
_43
"scripts": {
_43
"build": "remix vite:build",
_43
"dev": "remix vite:dev",
_43
- "lint": "eslint --ignore-path .gitignore --cache --cache-location ./node_modules/.cache/eslint .",
_43
+ "format": "bunx @biomejs/biome format ./ --write",
_43
+ "lint": "bunx @biomejs/biome lint ./ --apply",
_43
"start": "remix-serve ./build/server/index.js",
_43
"typecheck": "tsc"
_43
},
_43
"dependencies": {
_43
"@remix-run/node": "^2.8.1",
_43
"@remix-run/react": "^2.8.1",
_43
"@remix-run/serve": "^2.8.1",
_43
"isbot": "^4.1.0",
_43
"react": "^18.2.0",
_43
"react-dom": "^18.2.0"
_43
},
_43
"devDependencies": {
_43
+ "@biomejs/biome": "^1.6.0",
_43
"@remix-run/dev": "^2.8.1",
_43
"@types/react": "^18.2.20",
_43
"@types/react-dom": "^18.2.7",
_43
- "@typescript-eslint/eslint-plugin": "^6.7.4",
_43
- "@typescript-eslint/parser": "^6.7.4",
_43
- "eslint": "^8.38.0",
_43
- "eslint-import-resolver-typescript": "^3.6.1",
_43
- "eslint-plugin-import": "^2.28.1",
_43
- "eslint-plugin-jsx-a11y": "^6.7.1",
_43
- "eslint-plugin-react": "^7.33.2",
_43
- "eslint-plugin-react-hooks": "^4.6.0",
_43
"typescript": "^5.1.6",
_43
"vite": "^5.1.0",
_43
"vite-tsconfig-paths": "^4.2.1"
_43
},
_43
"engines": {
_43
"node": ">=18.0.0"
_43
}
_43
}

4. Format and lint your code

You're now ready to format and lint your code.

Run the following commands:


_10
bun format
_10
bun lint

5. VSCode integration

Now that you don't have ESLint and Prettier installed, you can remove the extensions from your VSCode. Biome.js also provides a VSCode extension, so you can install it and configure it to run when you save your files.

Here's my VSCode config for Biome.js

.vscode/settings.json

_10
{
_10
"editor.codeActionsOnSave": {
_10
"quickfix.biome": "explicit",
_10
"source.organizeImports.biome": "explicit"
_10
},
_10
"editor.defaultFormatter": "biomejs.biome",
_10
"editor.formatOnSave": true
_10
}