## ็ต็ทฏ
[[Biome]]ใใกใใฃใจๆฐใซใชใฃใฆใใใฎใงใ่ปฝใ่งฆใฃใฆใฟใใใกใใฃใจ[[TypeScript]]ๆธใใใใจใใฏ[[Bun]]ใซ่ป้
ไธใใใ ใใใใฉใ[[Node.js]]็ฐๅขใงๅใใใชใใใฐใใใชใใจใใฏไพฟๅฉใใใชใฎใงใ
## ใคใณในใใผใซใจ่จญๅฎ
```console
mkdir biome-sandbox
cd biome-sandbox
npm i -D typescript @tsconfig/recommended @biomejs/biome
cat > tsconfig.json << EOF
{
"extends": "@tsconfig/recommended/tsconfig.json"
}
EOF
```
`index.ts`ใไฝๆใ
```ts
function sum(x: number, y: number): number {
return x + y;
}
function main() {
var total = sum(1, 100);
console.log(`total: ${total}`);
}
```
## ๅฎ่ก
[[ใใฉใผใใใฟใผ]]ใจ[[ใชใณใฟใผ]]ใใใใใซๅฏพใใฆไฟฎๆญฃ็นใ่กจ็คบใใใใ
```console
$ npx biome check .
./index.ts:6:3 lint/style/noVar FIXABLE โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Use let or const instead of var.
5 โ function main() {
> 6 โ var total = sum(1, 100);
โ ^^^^^^^^^^^^^^^^^^^^^^^
7 โ console.log(`total: ${total}`);
8 โ }
โน A variable declared with var is accessible in the whole body of the function. Thus, the variable can be accessed before its initialization and outsi
de the block where it is declared.
โน See MDN web docs for more details.
โน Unsafe fix: Use 'const' instead.
4 4 โ
5 5 โ function main() {
6 โ - ยทยทvarยทtotalยท=ยทsum(1,ยท100);
6 โ + ยทยทconstยทtotalยท=ยทsum(1,ยท100);
7 7 โ console.log(`total: ${total}`);
8 8 โ }
./index.ts lint โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ The file contains diagnostics that needs to be addressed.
./index.ts format โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โน Formatter would have printed the following content:
1 1 โ function sum(x: number, y: number): number {
2 โ - ยทยทreturnยทxยท+ยทy;
2 โ + โ returnยทxยท+ยทy;
3 3 โ }
4 4 โ
5 5 โ function main() {
6 โ - ยทยทvarยทtotalยท=ยทsum(1,ยท100);
7 โ - ยทยทconsole.log(`total:ยท${total}`);
6 โ + โ varยทtotalยท=ยทsum(1,ยท100);
7 โ + โ console.log(`total:ยท${total}`);
8 8 โ }
9 9 โ
./index.ts check โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ The file contains diagnostics that needs to be addressed.
Checked 1 file(s) in 1263ยตs
Found 4 error(s)
check โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Some errors were emitted while running checks.
```
## Neovimใงๅใใ
[[coc-biome]]ใจใใใใฎใใใใฎใงใใใไฝฟใใ
<div class="link-card">
<div class="link-card-header">
<img src="https://biomejs.dev/img/favicon.svg" class="link-card-site-icon"/>
<span class="link-card-site-name">Biome</span>
</div>
<div class="link-card-body">
<div class="link-card-content">
<p class="link-card-title">Integrate Biome in your editor</p>
<p class="link-card-description">Learn how you can integrate Biome with editors and IDEs</p>
</div>
<img src="https://biomejs.dev/img/og.png?v=1" class="link-card-image" />
</div>
<a href="https://biomejs.dev/guides/integrate-in-editor/#third-party-plugins"></a>
</div>
ใคใณในใใผใซใใใใฎใฎๅใใชใ... ใฉใใใ `biome.json` ใๅฟ
่ฆใใใใ
```console
npx biome init
```
`biome.json`ใใงใใใ
```json
{
"$schema": "https://biomejs.dev/schemas/1.5.1/schema.json",
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
}
}
```
[[Neovim]]ใง็ขบ่ชใใใจใใจใใฃใฟไธใซใจใฉใผใ่กจ็คบใใใใ
## ใใฉใผใใใฟใผใๆๅนใซใชใใชใ
ใใฎใพใพใ ใจ[[ใใฉใผใใใฟใผ]]ใๆๅนใซใชใฃใฆใใชใใฎใงใ`formatter`ใ่ฟฝๅ ใใใ
```json
{
"$schema": "https://biomejs.dev/schemas/1.5.1/schema.json",
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
},
"formatter": {
"enabled": true
}
}
```
ใใใใใใใ ใใงใฏ[[Prettier]]ใฎๆนใๅชๅ
ใใใฆใใพใใ[[coc-settings.json]]ใง`prettier.enable: false`ใจใใใฐ[[Biome]]ใๅชๅ
ใใใใใ้ฝๅบฆๅคๆดใใใฎใฏๆต็ณใซ้ขๅใ
[[coc.nvimใง็พๅจใฎใใญใธใงใฏใ้
ไธใฎใฟๆๅนใช(ไธๆธใ)่จญๅฎ]]ใใใใใจใซใใ ใๆ็คบ็ใซ[[coc-prettier]]ใ็กๅนๅใใใ
`.vim/coc-settings.json`
```json
{
"prettier.enable": false
}
```
## ใคใณใใณใใในใใผในใซใใ
ใใใฉใซใใ ใจ[[Biome]]ใฎใคใณใใณใใฏใฟใใชใฎใงใในใใผในใซใใฆใฟใใ
```json
"formatter": {
"enabled": true,
"indentStyle": "space"
}
```
ใใๆใใซใชใฃใใ
## Bunใงใไฝฟใฃใฆใฟใ
ๅ
ใปใฉใพใงใฏ[[Node.js]]ใ ใฃใใใไปๅบฆใฏ[[Bun]]ใงใไฝฟใฃใฆใฟใใ
```console
mkdir bun-biome-sandbox
cd $_
bun init . -y
bun add -d @biomejs/biome
cat > .vim/coc-settings.json << 'EOF'
{
"prettier.enable": false
}
EOF
cat > biome.json << 'EOF'
{
"$schema": "https://biomejs.dev/schemas/1.5.1/schema.json",
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
},
"formatter": {
"enabled": true,
"indentStyle": "space"
}
}
EOF
```