Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .changeset/oxfmt-config.md
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 가 없어 로컬에서 수동 배포했습니다.
3 changes: 2 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ and published. There are two kinds of packages:
dual CJS/ESM bundles under `dist/`. Their `package.json` `exports` point at `./dist/cjs/...`
and `./dist/esm/...`, so **the package must be built before its exports resolve**.
- **Config-only packages** (`prettier-config`, `stylelint-config`, `biome-config`,
`oxlint-config`, `editorconfig`, `markdown-lint`, `code-style-cli`) — ship raw config files
`oxlint-config`, `oxfmt-config`, `editorconfig`, `markdown-lint`, `code-style-cli`) — ship raw config files
(`.json`/`.js`) referenced directly by `main`/`exports`/`bin`. No build step, no `dist/`.

The repo **dogfoods its own packages**: the root `eslint.config.mjs` consumes
Expand All @@ -33,6 +33,7 @@ read the relevant one before working inside a package.
| `@naverpay/stylelint-config` | config (rule modules) | [packages/stylelint-config/CLAUDE.md](./packages/stylelint-config/CLAUDE.md) |
| `@naverpay/prettier-config` | config-only | [packages/prettier-config/CLAUDE.md](./packages/prettier-config/CLAUDE.md) |
| `@naverpay/biome-config` | config-only | [packages/biome-config/CLAUDE.md](./packages/biome-config/CLAUDE.md) |
| `@naverpay/oxfmt-config` | config-only | [packages/oxfmt-config/CLAUDE.md](./packages/oxfmt-config/CLAUDE.md) |
| `@naverpay/oxlint-config` | config-only | [packages/oxlint-config/CLAUDE.md](./packages/oxlint-config/CLAUDE.md) |
| `@naverpay/editorconfig` | config-only (copied) | [packages/editorconfig/CLAUDE.md](./packages/editorconfig/CLAUDE.md) |

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- [@naverpay/oxlint-config](./packages/oxlint-config/README.md): oxlint config 를 제공하는 패키지입니다.
- [@naverpay/prettier-config](./packages/prettier-config/README.md): Prettier config 를 제공하는 패키지입니다.
- [@naverpay/biome-config](./packages/biome-config/README.md): Biome config 를 제공하는 패키지입니다.
- [@naverpay/oxfmt-config](./packages/oxfmt-config/README.md): oxfmt config 를 제공하는 패키지입니다.
- [@naverpay/stylelint-config](./packages/stylelint-config/README.md): Stylelint config 를 제공하는 패키지입니다.
- [@naverpay/editorconfig](./packages/editorconfig/README.md): IDE 일관된 코딩 스타일로 작성할 수 있도록 `.editorconfig` 를 제공하는 패키지입니다.
- [@naverpay/markdown-lint](./packages/markdown-lint/README.md): 마크다운(Markdown) 파일의 스타일을 검사하는 패키지 입니다.
6 changes: 3 additions & 3 deletions packages/code-style-cli/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ A tool scaffolds its config file via exactly one of three modes:
## Adding an installable tool

Append an entry to `TOOLS` in `configs.js` with its npm `packages` and, if it needs a config file,
one of the three modes above. Note the catalog also offers `oxfmt` (a formatter config scaffold)
even though there is no `@naverpay/oxfmt` package — `TOOLS` entries are not limited to this repo's
packages.
one of the three modes above. `TOOLS` entries are not limited to this repo's packages — `packages`
may list any npm package (e.g. an entry can install a third-party tool alongside a `@naverpay/*`
config).
Comment on lines -29 to +31

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리드미도 업데이트 필요한가용

Copy link
Copy Markdown
Contributor Author

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 요기 말씀이시져? 아 이전으로 작성되어 있는거 확인하여 변경하겠습니다!

29 changes: 11 additions & 18 deletions packages/code-style-cli/configs.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,11 @@ function getBiomeContent() {
)
}

const OXFMTRC_CONTENT = JSON.stringify(
{
$schema: './node_modules/oxfmt/configuration_schema.json',
singleQuote: true,
semi: false,
useTabs: false,
tabWidth: 4,
endOfLine: 'lf',
bracketSpacing: false,
arrowParens: 'always',
bracketSameLine: false,
printWidth: 120,
trailingComma: 'all',
},
null,
4,
)
const OXFMT_CONFIG_CONTENT = `import {defineConfig} from 'oxfmt'
import config from '@naverpay/oxfmt-config' with {type: 'json'}

export default defineConfig(config)
`

// 패키지 목록
export const TOOLS = [
Expand Down Expand Up @@ -102,7 +90,12 @@ export const TOOLS = [
configFile: 'biome.json',
getContent: getBiomeContent,
},
{value: 'oxfmt', packages: ['oxfmt'], configFile: '.oxfmtrc.json', configContent: OXFMTRC_CONTENT},
{
value: 'oxfmt-config',
packages: ['@naverpay/oxfmt-config', 'oxfmt'],
configFile: 'oxfmt.config.ts',
configContent: OXFMT_CONFIG_CONTENT,
},
]

export const TOOLS_MAP = Object.fromEntries(TOOLS.map((t) => [t.value, t]))
Expand Down
12 changes: 12 additions & 0 deletions packages/oxfmt-config/.oxfmtrc.json
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"
}
7 changes: 7 additions & 0 deletions packages/oxfmt-config/CHANGELOG.md
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 와 동일한 포매팅 규칙 제공)
43 changes: 43 additions & 0 deletions packages/oxfmt-config/CLAUDE.md
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.
109 changes: 109 additions & 0 deletions packages/oxfmt-config/README.md
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} from 'oxfmt'
import config from '@naverpay/oxfmt-config' with {type: 'json'}

export default defineConfig({
...config,
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)을 설치하여 사용할 수 있습니다.
34 changes: 34 additions & 0 deletions packages/oxfmt-config/package.json
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"
}
}
Loading
Loading