src/content/docs/blog/biome-v1-5.md
Along with the Roadmap for 2024, the new logo and homepage, we also published a new version. This version has few features around the CLI and many fixes in our formatter. Our TypeScript, JSX and JavaScript formatting has surpassed the 97% compatibility rate with Prettier. Biome now provides over 190 lint rules.
Update Biome using the following commands:
npm install --save-dev --save-exact @biomejs/biome@latest
npx @biomejs/biome migrate
biome ci now prints diagnostics in GitHub PRs.biome explain.biome migrate updates the $schema.If you enable the integration with VCS, you can tell Biome to process only the files that were changed. As for now, this feature computes the files that were changed by using a VCS, so Biome doesn't know exactly which lines changed.
This feature practically makes some utilities such as lint-staged obsolete.
To take advantage of this feature, you have to tell Biome what's the default branch in the configuration file, and then you'll have to pass the option --changed via CLI:
{
"vcs": {
"enabled": true,
"clientKind": "git",
"defaultBranch": "main"
}
}
Once you modified some files, use the new option to the command you need, for example the format command:
biome format --changed --write
biome ci now prints diagnostics in GitHub PRsFor quite some time, users were confused by the difference between the commands check and cibecause, until now, their behaviours have been very similar. From this version, the command ci can detect the GitHub CI environment and print annotation in the PRs.
It's possible that you would need to change your permissions of your workflow files in case you don't see the annotations:
permissions:
pull-requests: write
biome explainThis command will serve as an "offline" documentation tool. In this release, the command supports the explanation of all the lint rules; for example you can request documentation for noAccumulatingSpread:
biome explain noAccumulatingSpread
Which will print the following Markdown:
# noAccumulatingSpread
No fix available.
This rule is recommended.
# Description
Disallow the use of spread (`...`) syntax on accumulators.
Spread syntax allows an iterable to be expanded into its individual elements.
Spread syntax should be avoided on accumulators (like those in `.reduce`)
because it causes a time complexity of `O(n^2)` instead of `O(n)`.
Source: https://prateeksurana.me/blog/why-using-object-spread-with-reduce-bad-idea/
## Examples
### Invalid
```js,expect_diagnostic
var a = ['a', 'b', 'c'];
a.reduce((acc, val) => [...acc, val], []);
```
```js,expect_diagnostic
var a = ['a', 'b', 'c'];
a.reduce((acc, val) => {return [...acc, val];}, []);
```
```js,expect_diagnostic
var a = ['a', 'b', 'c'];
a.reduce((acc, val) => ({...acc, [val]: val}), {});
```
## Valid
```js
var a = ['a', 'b', 'c'];
a.reduce((acc, val) => {acc.push(val); return acc}, []);
```
We plan to make this output more readable for terminals, as well as provide autocompletion for this command.
biome migrate updates the $schemaThe command biome migrate now updates the $schema value inside the configuration file biome.json if you avail of the online schema. Run this command as soon as you update to Biome v1.5.0:
{
"$schema": "https://biomejs.dev/schemas/1.4.1/schema.json"
"$schema": "https://biomejs.dev/schemas/1.5.0/schema.json"
}
interface I {
}
export {I};
import {A} from "./mod.js";
type TypeOfA = typeof A;
let a: A;
Enforces naming conventions for JavaScript and TypeScript filenames.
import fs from 'fs';
import fs from "fs";
import path from "node:path";
function f() {
console.log(x);
const x;
}
eval("var a = 0");
Object = null;
/^[Á]$/u;
const foo = {
then() {
}
};
const foo = {
get then() {
}
};
var a = x ? true : true;