Skip to content

Commit cb1bb63

Browse files
committed
feat: adopt load-oxfmt-config v0.5 API and add cli parity mode
1 parent 4fd14bb commit cb1bb63

33 files changed

Lines changed: 1424 additions & 1090 deletions

README.md

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,20 @@ export default [
7171
]
7272
```
7373

74+
For CLI-like ignore/config behavior, use `cliParity`:
75+
76+
```js
77+
// eslint.config.mjs
78+
import pluginOxfmt from 'eslint-plugin-oxfmt'
79+
80+
export default [
81+
{
82+
...pluginOxfmt.configs.cliParity,
83+
files: ['**/*.{js,ts,mjs,cjs,jsx,tsx,json,jsonc,yaml,yml}'],
84+
},
85+
]
86+
```
87+
7488
### Custom Configuration
7589

7690
You can customize the formatting options by configuring the rule:
@@ -157,10 +171,14 @@ All options are optional and default to sensible values.
157171

158172
### Plugin Options
159173

160-
| Option | Type | Default | Description |
161-
| ------------ | --------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
162-
| `useConfig` | `boolean` | `true` | Load `.oxfmtrc.json`, `.oxfmtrc.jsonc`, or `oxfmt.config.ts` via `load-oxfmt-config` (with `.editorconfig` merge support). Set to `false` to rely only on inline options. |
163-
| `configPath` | `string` || Custom path to an oxfmt config file. Resolved from ESLint `cwd` when set. |
174+
| Option | Type | Default | Description |
175+
| ---------------------------- | -------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------- |
176+
| `useConfig` | `boolean` | `true` | Load `.oxfmtrc.json`, `.oxfmtrc.jsonc`, or `oxfmt.config.*` via `load-oxfmt-config`. Set to `false` to rely only on inline options. |
177+
| `configPath` | `string` || Custom path to an oxfmt config file. Resolved from ESLint `cwd` when set. |
178+
| `ignorePath` | `string \| string[]` || Ignore file path(s) for CLI-style ignore resolution (same role as CLI `--ignore-path`). |
179+
| `withNodeModules` | `boolean` | `false` | Include files under `node_modules` during ignore checks. |
180+
| `disableNestedConfig` | `boolean` | `false` | Disable nested config discovery and resolve config from `cwd` / `configPath` only. |
181+
| `respectOxfmtDefaultIgnores` | `boolean` | `true` | Respect oxfmt default ignores (`.gitignore`, `.prettierignore`, default ignored directories, default ignored lockfiles). |
164182

165183
> Note: `cwd` is taken from ESLint automatically; you usually do not need to set it manually.
166184
> `.editorconfig` merge behavior follows oxfmt's documented strategy: https://oxc.rs/docs/guide/usage/formatter/config#editorconfig
@@ -173,8 +191,7 @@ When `useConfig` is `true`, the plugin loads config using `load-oxfmt-config`.
173191
- `.editorconfig` support: nearest `.editorconfig` (including section overrides) is merged into the final options
174192
- `configPath` overrides discovery and directly targets the specified config file
175193
- ESLint rule options generally take highest priority because inline rule options are merged after loaded config.
176-
- When `useConfig` is `true`, rule-level `overrides` are ignored. Only `overrides` loaded from the resolved oxfmt config file are applied.
177-
- Rule-level `ignorePatterns` still override config-derived `ignorePatterns` when provided.
194+
- Rule-level `ignorePatterns` are resolved relative to ESLint `cwd`; config-level `ignorePatterns` are resolved relative to the resolved config file directory.
178195

179196
For detailed behavior, see:
180197

@@ -381,12 +398,31 @@ This plugin provides a single rule that formats your code using oxfmt.
381398
- Fixable: Yes (automatically applies formatting)
382399
- Type: Layout
383400

401+
## CLI parity mode
402+
403+
`oxfmt/cli-parity` tries to match `oxfmt` CLI behavior for files processed by ESLint.
404+
405+
It respects:
406+
407+
- `.oxfmtrc.json`
408+
- `.oxfmtrc.jsonc`
409+
- `oxfmt.config.*`
410+
- `.editorconfig`
411+
- `ignorePatterns`
412+
- `.gitignore`
413+
- `.prettierignore`
414+
- default ignored directories
415+
- default ignored lockfiles
416+
417+
Note: ESLint still controls file discovery. Files excluded by ESLint will never reach this rule.
418+
384419
## Integration
385420

386421
### Parser Compatibility
387422

388423
- `recommended`: forces `eslint-parser-plain` for matched files
389424
- `recommendedWithoutParser`: parser-agnostic (safe to compose with language-specific parsers)
425+
- `cliParity`: parser-agnostic preset tuned for CLI-like config/ignore behavior
390426

391427
When composing shareable configs, prefer `recommendedWithoutParser` if parser ownership belongs to another preset.
392428

dts/rule-options.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,16 @@ export type OxfmtOxfmt = []|[{
134134

135135
configPath?: string
136136

137+
disableNestedConfig?: boolean
138+
139+
ignorePath?: (string | string[])
140+
141+
respectOxfmtDefaultIgnores?: boolean
142+
137143
useConfig?: boolean
138144

145+
withNodeModules?: boolean
146+
139147
overrides?: {
140148

141149
excludeFiles?: string[]

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "eslint-plugin-oxfmt",
33
"type": "module",
44
"version": "0.5.1",
5-
"packageManager": "pnpm@10.33.2",
5+
"packageManager": "pnpm@10.33.4",
66
"description": "An ESLint plugin for formatting code with oxfmt.",
77
"keywords": [
88
"eslint",
@@ -65,17 +65,17 @@
6565
},
6666
"dependencies": {
6767
"generate-differences": "^0.1.1",
68-
"load-oxfmt-config": "^0.4.1",
68+
"load-oxfmt-config": "^0.5.0",
6969
"picomatch": "^4.0.4",
7070
"synckit": "^0.11.12"
7171
},
7272
"devDependencies": {
73-
"@ntnyq/eslint-config": "^6.1.1",
73+
"@ntnyq/eslint-config": "^6.1.3",
7474
"@types/json-schema": "^7.0.15",
7575
"@types/node": "^25.6.0",
76-
"@typescript/native-preview": "^7.0.0-dev.20260429.1",
76+
"@typescript/native-preview": "^7.0.0-dev.20260506.1",
7777
"bumpp": "^11.0.1",
78-
"eslint": "^10.2.1",
78+
"eslint": "^10.3.0",
7979
"eslint-parser-plain": "^0.1.1",
8080
"eslint-plugin-oxfmt": "workspace:*",
8181
"eslint-typegen": "^2.3.1",
@@ -84,7 +84,7 @@
8484
"jsonc-eslint-parser": "^3.1.0",
8585
"nano-staged": "^1.0.2",
8686
"npm-run-all2": "^8.0.4",
87-
"oxfmt": "^0.47.0",
87+
"oxfmt": "^0.48.0",
8888
"show-invisibles": "^0.0.2",
8989
"tinyglobby": "^0.2.16",
9090
"tsdown": "^0.21.10",

0 commit comments

Comments
 (0)