-
Notifications
You must be signed in to change notification settings - Fork 2
[#162] oxfmt-config 패키지 추가 #163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| --- | ||
| '@naverpay/code-style-cli': patch | ||
| --- | ||
|
|
||
| [#162] code-style-cli 에 oxfmt-config 지원 추가 | ||
|
|
||
| oxfmt 항목을 `@naverpay/oxfmt-config` 설치 + `oxfmt.config.ts` scaffold 방식으로 변경. (oxfmt 는 `extends` 가 없어 `oxfmt.config.ts` 에서 `import config from '@naverpay/oxfmt-config' with {type: 'json'}` 로 사용) | ||
|
|
||
| > `@naverpay/oxfmt-config` 패키지(0.0.1)는 첫 배포라 OIDC 가 없어 로컬에서 수동 배포했습니다. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| { | ||
| "singleQuote": true, | ||
| "semi": false, | ||
| "useTabs": false, | ||
| "tabWidth": 4, | ||
| "endOfLine": "lf", | ||
| "bracketSpacing": false, | ||
| "arrowParens": "always", | ||
| "bracketSameLine": false, | ||
| "printWidth": 120, | ||
| "trailingComma": "all" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| # @naverpay/oxfmt-config | ||
|
|
||
| ## 0.0.1 | ||
|
|
||
| ### Patch Changes | ||
|
|
||
| - [#162] oxfmt-config 패키지 추가 (prettier/biome 와 동일한 포매팅 규칙 제공) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| # CLAUDE.md — @naverpay/oxfmt-config | ||
|
|
||
| NaverPay's [oxfmt](https://oxc.rs/docs/guide/usage/formatter) config (the oxc Rust-based formatter). | ||
| **Config-only** — the package is `.oxfmtrc.json` (`main`/`exports`). No build, no tests. Peer dep: | ||
| `oxfmt@>=0.50.0`. | ||
|
|
||
| ## Scope: formatter only | ||
|
|
||
| By design this **replaces Prettier**, mirroring `@naverpay/prettier-config` and | ||
| `@naverpay/biome-config`: 4-space indent, `printWidth: 120`, `endOfLine: "lf"`, single quotes, | ||
| `semi: false`, `trailingComma: "all"`, `bracketSpacing: false`, `arrowParens: "always"`, | ||
| `bracketSameLine: false`, `useTabs: false`. Keep these in sync with the Prettier/Biome/editorconfig | ||
| packages when changing the house style. The `.oxfmtrc.json` values are exactly what | ||
| `oxfmt --migrate prettier` produces from `@naverpay/prettier-config`. | ||
|
|
||
| ## Consumption — no `extends`, JS-config import | ||
|
|
||
| oxfmt has **no `extends` key** — the maintainers explicitly declined to add one | ||
| ([oxc#16394](https://github.com/oxc-project/oxc/issues/16394)), pointing to JS/TS config files as | ||
| the composition mechanism. oxfmt auto-discovers `.oxfmtrc.json`, `.oxfmtrc.jsonc`, and | ||
| `oxfmt.config.ts` (verified: only `oxfmt.config.ts` among the JS/TS forms auto-loads in 0.56.0; | ||
| others like `oxfmt.config.js`/`.mjs` and `.oxfmtrc.ts` do **not**). | ||
|
|
||
| So the package is consumed by importing its JSON into an `oxfmt.config.ts`: | ||
|
|
||
| ```ts | ||
| import {defineConfig} from 'oxfmt' | ||
| import config from '@naverpay/oxfmt-config' with {type: 'json'} | ||
|
|
||
| export default defineConfig(config) // or {...config, <overrides>} | ||
| ``` | ||
|
|
||
| This is why the package keeps `exports: {".": "./.oxfmtrc.json"}` — the `with {type: 'json'}` import | ||
| resolves through it. The raw file path | ||
| (`./node_modules/@naverpay/oxfmt-config/.oxfmtrc.json`) also works as a `-c`/`--config` argument for | ||
| JSON-only setups (no local overrides possible that way). | ||
|
|
||
| ## Gotchas | ||
|
|
||
| - The package ships **no `ignorePatterns`** — oxfmt defaults to honoring `.gitignore` / | ||
| `.prettierignore`; consumers add `ignorePatterns` in their `oxfmt.config.ts` override. | ||
| - The CLI catalog (`@naverpay/code-style-cli` → `configs.js`) scaffolds an `oxfmt.config.ts` that | ||
| imports this package; the house-style values live only here. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| # @naverpay/oxfmt-config | ||
|
|
||
| 네이버페이 스타일 가이드에 맞게 [oxfmt](https://oxc.rs/docs/guide/usage/formatter) formatter 설정을 커스텀하여 제공합니다. | ||
|
|
||
| > oxfmt는 oxc(Rust 기반) 포매터로, prettier 를 대체하는 빠른 포매터입니다. | ||
| > `@naverpay/oxfmt-config`는 `@naverpay/prettier-config` · `@naverpay/biome-config`와 동일한 포매팅 규칙을 제공합니다. | ||
|
|
||
| ## 설치 방법 | ||
|
|
||
| ```bash | ||
| npm install @naverpay/oxfmt-config oxfmt -D | ||
| ``` | ||
|
|
||
| ## 사용 방법 | ||
|
|
||
| > **Note:** oxfmt 는 `extends` 키가 없습니다. ([oxc#16394](https://github.com/oxc-project/oxc/issues/16394)) 대신 메인테이너 권장 방식인 `oxfmt.config.ts` 에서 공유 설정을 import 해서 사용합니다. | ||
|
|
||
| 프로젝트 루트에 `oxfmt.config.ts` 파일을 생성하고 `@naverpay/oxfmt-config` 를 import 합니다. | ||
|
|
||
| ```ts | ||
| // oxfmt.config.ts | ||
| import {defineConfig} from 'oxfmt' | ||
| import config from '@naverpay/oxfmt-config' with {type: 'json'} | ||
|
|
||
| export default defineConfig(config) | ||
| ``` | ||
|
|
||
| > `defineConfig` 는 선택사항이지만 타입 체크/자동완성을 제공합니다. `with {type: 'json'}` import attribute 로 패키지의 `.oxfmtrc.json` 을 그대로 가져옵니다. | ||
| > | ||
| > 프로젝트 `package.json` 에 `"type": "module"` 이 없으면 Node 가 성능 경고를 출력할 수 있습니다(동작에는 영향 없음). `"type": "module"` 을 추가하면 사라집니다. | ||
|
|
||
| ### 일부 규칙만 덮어쓰기 | ||
|
|
||
| 공유 설정을 펼친 뒤 원하는 값만 덮어씁니다. | ||
|
|
||
| ```ts | ||
| // oxfmt.config.ts | ||
| import {defineConfig, type OxfmtConfig} from 'oxfmt' | ||
| import config from '@naverpay/oxfmt-config' with {type: 'json'} | ||
|
|
||
| export default defineConfig({ | ||
| ...(config as OxfmtConfig), | ||
| printWidth: 80, | ||
| ignorePatterns: ['dist', 'node_modules'], | ||
| }) | ||
| ``` | ||
|
|
||
| > ignore 는 기본적으로 `.gitignore` · `.prettierignore` 를 따르며, 추가로 제외할 경로는 `ignorePatterns` 로 지정합니다. | ||
|
|
||
| ## CLI | ||
|
|
||
| `oxfmt` 는 `oxfmt.config.ts` 를 자동으로 탐색하므로 별도 옵션 없이 실행합니다. | ||
|
|
||
| ```jsonc | ||
| // package.json | ||
| { | ||
| "scripts": { | ||
| "format": "oxfmt --check .", | ||
| "format:fix": "oxfmt ." | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| > 기본 동작은 파일을 직접 수정(`--write`)하는 것이며, `--check` 는 포매팅 여부만 검사합니다. | ||
|
|
||
| ### JSON 설정만 쓰고 싶다면 (대안) | ||
|
|
||
| TS 설정 파일 대신 JSON 만 쓰고 싶다면, `-c`(`--config`) 로 패키지의 설정 파일 경로를 직접 가리킬 수 있습니다. (이 경우 로컬 override 는 불가합니다.) | ||
|
|
||
| ```jsonc | ||
| // package.json | ||
| { | ||
| "scripts": { | ||
| "format": "oxfmt -c ./node_modules/@naverpay/oxfmt-config/.oxfmtrc.json --check ." | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| > [lefthook](https://github.com/evilmartians/lefthook)을 사용해서 commit 또는 push 전에 스타일 확인을 자동화할 것을 권장합니다. | ||
|
|
||
| ## Integrating with IDE | ||
|
|
||
| - code-style에서는 **Formatting을 위해 oxfmt** 를, **Code-quality를 위해 oxlint/ESLint** 를 사용할 수 있습니다. | ||
| - IDE에서 autofix 하기 위해 아래 설정이 필요합니다. | ||
|
|
||
| ### VSCode | ||
|
|
||
| 1. [oxc Extension](https://marketplace.visualstudio.com/items?itemName=oxc.oxc-vscode)을 설치합니다. | ||
| 2. IDE에서 Command Palette(CMD/CTRL + Shift + P)를 열고 `settings.json`을 입력하여 설정파일을 오픈합니다. | ||
| 3. 아래 설정을 추가하면 파일 저장시 oxfmt config에 맞게 autofix 할 수 있습니다. | ||
|
|
||
| ```json | ||
| { | ||
| "oxc.enable": true, | ||
| "oxc.fmt.experimental": true, | ||
| "editor.defaultFormatter": "oxc.oxc-vscode", | ||
| "editor.formatOnSave": true, | ||
| "[typescript]": { | ||
| "editor.defaultFormatter": "oxc.oxc-vscode" | ||
| }, | ||
| "[javascript]": { | ||
| "editor.defaultFormatter": "oxc.oxc-vscode" | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ### WebStorm | ||
|
|
||
| [oxc-intellij-plugin](https://plugins.jetbrains.com/plugin/27061-oxc)을 설치하여 사용할 수 있습니다. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| { | ||
| "name": "@naverpay/oxfmt-config", | ||
| "version": "0.0.1", | ||
| "description": "oxfmt configuration for NaverPay projects", | ||
| "keywords": [ | ||
| "oxfmt", | ||
| "oxc", | ||
| "config", | ||
| "formatter", | ||
| "naverpay" | ||
| ], | ||
| "homepage": "https://github.com/NaverPayDev/code-style", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/NaverPayDev/code-style.git", | ||
| "directory": "packages/oxfmt-config" | ||
| }, | ||
| "license": "MIT", | ||
| "author": "@NaverPayDev/frontend", | ||
| "type": "module", | ||
| "exports": { | ||
| ".": "./.oxfmtrc.json" | ||
| }, | ||
| "main": ".oxfmtrc.json", | ||
| "files": [ | ||
| ".oxfmtrc.json" | ||
| ], | ||
| "devDependencies": { | ||
| "oxfmt": "^0.56.0" | ||
| }, | ||
| "peerDependencies": { | ||
| "oxfmt": ">=0.50.0" | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
리드미도 업데이트 필요한가용
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/NaverPayDev/code-style/tree/main/packages/code-style-cli 요기 말씀이시져? 아 이전으로 작성되어 있는거 확인하여 변경하겠습니다!