diff --git a/.changeset/silver-eagles-kneel.md b/.changeset/silver-eagles-kneel.md new file mode 100644 index 0000000..1af9c71 --- /dev/null +++ b/.changeset/silver-eagles-kneel.md @@ -0,0 +1,7 @@ +--- +"@naverpay/biome-config": patch +--- + +πŸš€ biome formatting + +PR: [πŸš€ biome formatting](https://github.com/NaverPayDev/code-style/pull/131) diff --git a/packages/biome-config/README.md b/packages/biome-config/README.md new file mode 100644 index 0000000..a72de76 --- /dev/null +++ b/packages/biome-config/README.md @@ -0,0 +1,88 @@ +# @naverpay/biome-config + +λ„€μ΄λ²„νŽ˜μ΄ μŠ€νƒ€μΌ κ°€μ΄λ“œμ— 맞게 Biome formatter 섀정을 μ»€μŠ€ν…€ν•˜μ—¬ μ œκ³΅ν•©λ‹ˆλ‹€. + +> eslint λ₯Ό λŒ€μ²΄ ν•˜κΈ°μ—λŠ” eslint ν”ŒλŸ¬κ·ΈμΈμ΄ λ„ˆλ¬΄ λ°©λŒ€ν•˜μ—¬, `@naverpay/biome-config`λŠ” formatting 역할을 ν•˜λŠ” prettier 만 λŒ€μ²΄ν•˜λ„λ‘ μ„€κ³„λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€. + +## μ„€μΉ˜ 방법 + +```bash +npm install @naverpay/biome-config @biomejs/biome -D +``` + +## μ‚¬μš© 방법 + +biome.json νŒŒμΌμ„ μƒμ„±ν•˜κ³  `@naverpay/biome-config` νŒ¨ν‚€μ§€λ₯Ό μΆ”κ°€ν•©λ‹ˆλ‹€. + +```json +{ + "$schema": "https://biomejs.dev/schemas/2.2.6/schema.json", + "extends": ["@naverpay/biome-config"], + "files": { + "includes": ["**", "!scripts/**", "!apps/web/public/**", "!apps/web/src/assets/lottie/applyCharge.json"] + } +} + +``` + +> ignore 섀정이 μ—†κΈ° λ•Œλ¬Έμ—, `includes`의 `!`둜 λ¬΄μ‹œν•˜κ³  싢은 νŒŒμΌμ„ μ„€μ •ν•΄μ£Όμ„Έμš”. + +## CLI + +package.json에 슀크립트λ₯Ό μΆ”κ°€ν•˜μ—¬ format 검사λ₯Ό ν•  수 μžˆμŠ΅λ‹ˆλ‹€. + +```jsonc +// package.json +{ + "scripts": { + "format": "biome check .", + "format:fix": "biome check --write ." + }, +} +``` + +> [lefthook](https://github.com/evilmartians/lefthook)을 μ‚¬μš©ν•΄μ„œ commit λ˜λŠ” push 전에 μŠ€νƒ€μΌ 확인을 μžλ™ν™”ν•  것을 ꢌμž₯ν•©λ‹ˆλ‹€. + +## 차이점 + +- [biome μ—μ„œ μ œκ³΅ν•˜λŠ” assist](https://biomejs.dev/assist/javascript/actions/) κ°€ 기본으둜 ν™œμ„±ν™” λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€. λ”°λΌμ„œ prettier λ₯Ό λŒ€μ²΄ν•œλ‹€λ©΄ jsx elements 의 μˆœμ„œκ°€ μ •λ ¬λ˜κ±°λ‚˜, js 객체의 ν‚€κ°€ 정렬될 수 μžˆμŠ΅λ‹ˆλ‹€. ν•΄λ‹Ή μ˜΅μ…˜μ„ μ›μΉ˜ μ•ŠλŠ”λ‹€λ©΄ λ°˜λ“œμ‹œ κΊΌμ£Όμ„Έμš”. + - [organizeImports](https://biomejs.dev/assist/actions/organize-imports/) κ·œμΉ™μ€ eslint 의 `import/order` 와 μΆ©λŒν•˜μ—¬ 기본적으둜 κΊΌμ ΈμžˆμŠ΅λ‹ˆλ‹€. λ‹€μŒ major 버전 λ•Œ biome 둜 λŒ€μ²΄λ  μ˜ˆμ •μž…λ‹ˆλ‹€. + +```jsonc +// biome.json +{ + "$schema": "https://biomejs.dev/schemas/2.2.6/schema.json", + "assist": { + "actions": { + "source": { + "organizeImports": "off" + } + } + } +} +``` + +## Integrating with IDE + +- code-styleμ—μ„œλŠ” **Formatting을 μœ„ν•΄ Biome**λ₯Ό, **Code-qualityλ₯Ό μœ„ν•΄ ESLint**λ₯Ό μ‚¬μš©ν•˜κ³  μžˆμŠ΅λ‹ˆλ‹€. +- IDEμ—μ„œ autofix ν•˜κΈ° μœ„ν•΄ μ•„λž˜ 섀정이 ν•„μš”ν•©λ‹ˆλ‹€. + +### VSCode + +1. [Biome Extension](https://marketplace.visualstudio.com/items?itemName=biomejs.biome)을 μ„€μΉ˜ν•©λ‹ˆλ‹€. +2. IDEμ—μ„œ Command Palette(CMD/CTRL + Shift + P)λ₯Ό μ—΄κ³  `settings.json`을 μž…λ ₯ν•˜μ—¬ μ„€μ •νŒŒμΌμ„ μ˜€ν”ˆν•©λ‹ˆλ‹€. +3. μ•„λž˜ 섀정을 μΆ”κ°€ν•˜λ©΄ 파일 μ €μž₯μ‹œ Biome config에 맞게 autofix ν•  수 μžˆμŠ΅λ‹ˆλ‹€. + +```json +{ + "editor.defaultFormatter": "biomejs.biome", + "editor.formatOnSave": true, + "editor.codeActionsOnSave": { + "source.fixAll.biome": "explicit" + } +} +``` + +### WebStorm + +Settings > Languages & Frameworks > JavaScript > Prettier μ—μ„œ Prettierλ₯Ό λΉ„ν™œμ„±ν™”ν•˜κ³ , [Biome Plugin](https://plugins.jetbrains.com/plugin/22761-biome)을 μ„€μΉ˜ν•˜μ—¬ μ‚¬μš©ν•  수 μžˆμŠ΅λ‹ˆλ‹€. diff --git a/packages/biome-config/biome.json b/packages/biome-config/biome.json new file mode 100644 index 0000000..460c5ae --- /dev/null +++ b/packages/biome-config/biome.json @@ -0,0 +1,36 @@ +{ + "$schema": "https://biomejs.dev/schemas/2.0.6/schema.json", + "formatter": { + "enabled": true, + "indentStyle": "space", + "indentWidth": 4, + "lineWidth": 120, + "lineEnding": "lf" + }, + "linter": { + "enabled": false + }, + "assist": { + "enabled": true, + "actions": { + "source": { + "organizeImports": "off" + } + } + }, + "javascript": { + "formatter": { + "quoteStyle": "single", + "semicolons": "asNeeded", + "trailingCommas": "all", + "bracketSpacing": false, + "bracketSameLine": false, + "arrowParentheses": "always" + } + }, + "json": { + "formatter": { + "trailingCommas": "none" + } + } +} diff --git a/packages/biome-config/package.json b/packages/biome-config/package.json new file mode 100644 index 0000000..3431109 --- /dev/null +++ b/packages/biome-config/package.json @@ -0,0 +1,33 @@ +{ + "name": "@naverpay/biome-config", + "version": "0.0.0", + "description": "Biome configuration for NaverPay projects", + "keywords": [ + "biome", + "config", + "formatter", + "linter", + "naverpay" + ], + "repository": { + "type": "git", + "url": "https://github.com/NaverPayDev/code-style.git", + "directory": "packages/biome-config" + }, + "license": "MIT", + "author": "NaverPay Frontend", + "type": "module", + "exports": { + ".": "./biome.json" + }, + "main": "biome.json", + "files": [ + "biome.json" + ], + "devDependencies": { + "@biomejs/biome": "^2.0.6" + }, + "peerDependencies": { + "@biomejs/biome": "^2.0.6" + } +} diff --git a/packages/eslint-config/node/rules/import.js b/packages/eslint-config/node/rules/import.js index 27ecb1b..9be24f3 100644 --- a/packages/eslint-config/node/rules/import.js +++ b/packages/eslint-config/node/rules/import.js @@ -9,6 +9,7 @@ export default { /** * Enforce a convention in the order of require() / import statements * @see https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/order.md + * @deprecated biome organizeImports 둜 λŒ€μ²΄ μ˜ˆμ • https://biomejs.dev/assist/actions/organize-imports/ */ 'import/order': importOrder(), diff --git a/packages/eslint-config/react/rules/import.js b/packages/eslint-config/react/rules/import.js index dde038c..42a5da2 100644 --- a/packages/eslint-config/react/rules/import.js +++ b/packages/eslint-config/react/rules/import.js @@ -10,6 +10,7 @@ export default { /** * Enforce a convention in the order of require() / import statements * @see https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/order.md + * @deprecated biome organizeImports 둜 λŒ€μ²΄ μ˜ˆμ • https://biomejs.dev/assist/actions/organize-imports/ */ 'import/order': importOrder(), diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6372612..3084ec7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -48,6 +48,12 @@ importers: specifier: ^6.3.5 version: 6.3.5(sass-embedded@1.85.1)(terser@5.36.0) + packages/biome-config: + devDependencies: + '@biomejs/biome': + specifier: ^2.0.6 + version: 2.2.6 + packages/editorconfig: {} packages/eslint-config: @@ -836,6 +842,59 @@ packages: '@bcoe/v8-coverage@0.2.3': resolution: {integrity: sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==} + '@biomejs/biome@2.2.6': + resolution: {integrity: sha512-yKTCNGhek0rL5OEW1jbLeZX8LHaM8yk7+3JRGv08my+gkpmtb5dDE+54r2ZjZx0ediFEn1pYBOJSmOdDP9xtFw==} + engines: {node: '>=14.21.3'} + hasBin: true + + '@biomejs/cli-darwin-arm64@2.2.6': + resolution: {integrity: sha512-UZPmn3M45CjTYulgcrFJFZv7YmK3pTxTJDrFYlNElT2FNnkkX4fsxjExTSMeWKQYoZjvekpH5cvrYZZlWu3yfA==} + engines: {node: '>=14.21.3'} + cpu: [arm64] + os: [darwin] + + '@biomejs/cli-darwin-x64@2.2.6': + resolution: {integrity: sha512-HOUIquhHVgh/jvxyClpwlpl/oeMqntlteL89YqjuFDiZ091P0vhHccwz+8muu3nTyHWM5FQslt+4Jdcd67+xWQ==} + engines: {node: '>=14.21.3'} + cpu: [x64] + os: [darwin] + + '@biomejs/cli-linux-arm64-musl@2.2.6': + resolution: {integrity: sha512-TjCenQq3N6g1C+5UT3jE1bIiJb5MWQvulpUngTIpFsL4StVAUXucWD0SL9MCW89Tm6awWfeXBbZBAhJwjyFbRQ==} + engines: {node: '>=14.21.3'} + cpu: [arm64] + os: [linux] + + '@biomejs/cli-linux-arm64@2.2.6': + resolution: {integrity: sha512-BpGtuMJGN+o8pQjvYsUKZ+4JEErxdSmcRD/JG3mXoWc6zrcA7OkuyGFN1mDggO0Q1n7qXxo/PcupHk8gzijt5g==} + engines: {node: '>=14.21.3'} + cpu: [arm64] + os: [linux] + + '@biomejs/cli-linux-x64-musl@2.2.6': + resolution: {integrity: sha512-1ZcBux8zVM3JhWN2ZCPaYf0+ogxXG316uaoXJdgoPZcdK/rmRcRY7PqHdAos2ExzvjIdvhQp72UcveI98hgOog==} + engines: {node: '>=14.21.3'} + cpu: [x64] + os: [linux] + + '@biomejs/cli-linux-x64@2.2.6': + resolution: {integrity: sha512-1HaM/dpI/1Z68zp8ZdT6EiBq+/O/z97a2AiHMl+VAdv5/ELckFt9EvRb8hDHpk8hUMoz03gXkC7VPXOVtU7faA==} + engines: {node: '>=14.21.3'} + cpu: [x64] + os: [linux] + + '@biomejs/cli-win32-arm64@2.2.6': + resolution: {integrity: sha512-h3A88G8PGM1ryTeZyLlSdfC/gz3e95EJw9BZmA6Po412DRqwqPBa2Y9U+4ZSGUAXCsnSQE00jLV8Pyrh0d+jQw==} + engines: {node: '>=14.21.3'} + cpu: [arm64] + os: [win32] + + '@biomejs/cli-win32-x64@2.2.6': + resolution: {integrity: sha512-yx0CqeOhPjYQ5ZXgPfu8QYkgBhVJyvWe36as7jRuPrKPO5ylVDfwVtPQ+K/mooNTADW0IhxOZm3aPu16dP8yNQ==} + engines: {node: '>=14.21.3'} + cpu: [x64] + os: [win32] + '@bufbuild/protobuf@2.2.3': resolution: {integrity: sha512-tFQoXHJdkEOSwj5tRIZSPNUuXK3RaR7T1nUrPgbYX1pUbvqqaaZAsfo+NXBPsz5rZMSKVFrgK1WL8Q/MSLvprg==} @@ -5713,6 +5772,41 @@ snapshots: '@bcoe/v8-coverage@0.2.3': {} + '@biomejs/biome@2.2.6': + optionalDependencies: + '@biomejs/cli-darwin-arm64': 2.2.6 + '@biomejs/cli-darwin-x64': 2.2.6 + '@biomejs/cli-linux-arm64': 2.2.6 + '@biomejs/cli-linux-arm64-musl': 2.2.6 + '@biomejs/cli-linux-x64': 2.2.6 + '@biomejs/cli-linux-x64-musl': 2.2.6 + '@biomejs/cli-win32-arm64': 2.2.6 + '@biomejs/cli-win32-x64': 2.2.6 + + '@biomejs/cli-darwin-arm64@2.2.6': + optional: true + + '@biomejs/cli-darwin-x64@2.2.6': + optional: true + + '@biomejs/cli-linux-arm64-musl@2.2.6': + optional: true + + '@biomejs/cli-linux-arm64@2.2.6': + optional: true + + '@biomejs/cli-linux-x64-musl@2.2.6': + optional: true + + '@biomejs/cli-linux-x64@2.2.6': + optional: true + + '@biomejs/cli-win32-arm64@2.2.6': + optional: true + + '@biomejs/cli-win32-x64@2.2.6': + optional: true + '@bufbuild/protobuf@2.2.3': {} '@changesets/apply-release-plan@7.0.0':