## ็ตŒ็ทฏ [[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 ```