load-oxfmt-config 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -191,66 +191,77 @@ Load and parse oxfmt configuration files, then merge supported `.editorconfig` f
191
191
 
192
192
  **Parameters:**
193
193
 
194
- - `options` - Optional configuration object
194
+ - `options` - Optional configuration object (`Options`)
195
195
 
196
- **Returns:** `Promise<OxfmtOptions>` - Parsed and merged oxfmt configuration object. Returns empty object `{}` if no supported config file is found.
196
+ Option fields:
197
197
 
198
- ### `loadOxfmtConfigResult(options?)`
198
+ #### `cwd`
199
199
 
200
- Load and parse oxfmt configuration files, merge supported `.editorconfig` fields, and return metadata for the resolved config file.
200
+ - **Type:** `string`
201
+ - **Default:** `process.cwd()`
201
202
 
202
- **Parameters:**
203
+ Current working directory to start searching for config files. The loader will walk up from this directory to find a config file.
203
204
 
204
- - `options` - Optional configuration object (same as `loadOxfmtConfig`)
205
+ #### `configPath`
205
206
 
206
- **Returns:** `Promise<LoadOxfmtConfigResult>`
207
+ - **Type:** `string`
208
+ - **Default:** `undefined`
207
209
 
208
- - `config` - Parsed and merged oxfmt configuration object
209
- - `filepath` - Resolved config absolute path (undefined when not found)
210
- - `dirname` - Config directory (undefined when not found)
210
+ Explicit path to the config file:
211
211
 
212
- **Throws:** Error if config file exists but cannot be parsed.
212
+ - **Relative path:** Resolved relative to `cwd`
213
+ - **Absolute path:** Used as-is
214
+ - **When provided:** Skips auto-discovery and uses this path directly
213
215
 
214
- ### `resolveOxfmtrcPath(cwd, configPath?)`
216
+ #### `useCache`
215
217
 
216
- Resolve the absolute path to oxfmt config file.
218
+ - **Type:** `boolean`
219
+ - **Default:** `true`
217
220
 
218
- **Parameters:**
221
+ Enable in-memory caching for both path resolution and parsed config contents. When enabled:
219
222
 
220
- - `cwd` - Starting directory for resolution
221
- - `configPath` - Optional explicit path (absolute or relative to cwd)
223
+ - Config file paths are cached to avoid repeated filesystem lookups
224
+ - Parsed config objects are cached to avoid re-parsing
225
+ - Subsequent calls with the same parameters return cached results instantly
222
226
 
223
- **Returns:** `Promise<string | undefined>` - Absolute path to config file, or `undefined` if not found.
227
+ Set to `false` to force reload from disk on every call.
224
228
 
225
- ### `isOxfmtIgnored(options)`
229
+ #### `editorconfig`
226
230
 
227
- Resolve whether a file should be ignored with oxfmt CLI-like semantics.
231
+ - **Type:** `boolean | EditorconfigOption`
232
+ - **Default:** `true`
228
233
 
229
- **Returns:** `Promise<IsOxfmtIgnoredResult>`
234
+ Control how `.editorconfig` files are read and merged:
230
235
 
231
- `ignorePath` accepts either a single path (`string`) or multiple paths (`string[]`).
236
+ - **`true`** Read and merge the nearest `.editorconfig`, walking up from the config file's directory (or `cwd` when no config path is given).
237
+ - **`false`** — Disable `.editorconfig` reading entirely.
238
+ - **`EditorconfigOption`** — Enable with additional settings:
232
239
 
233
- - `ignored` - Whether the file is ignored
234
- - `reason` - One of:
235
- - `default-dir`
236
- - `lockfile`
237
- - `gitignore`
238
- - `prettierignore`
239
- - `ignore-path`
240
- - `config-ignore-patterns`
240
+ | Property | Type | Default | Description |
241
+ | --------- | --------- | ----------- | --------------------------------------------------------------------------------------------------------------------- |
242
+ | `onlyCwd` | `boolean` | `false` | When `true`, only look for `.editorconfig` in `cwd` itself — no upward traversal. |
243
+ | `cwd` | `string` | `undefined` | Override the directory from which `.editorconfig` resolution starts, instead of the config file's directory or `cwd`. |
244
+
245
+ **Returns:** `Promise<OxfmtOptions>` - Parsed and merged oxfmt configuration object. Returns empty object `{}` if no supported config file is found.
246
+
247
+ ### `loadOxfmtConfigResult(options?)`
248
+
249
+ Load and parse oxfmt configuration files, merge supported `.editorconfig` fields, and return metadata for the resolved config file.
250
+
251
+ **Parameters:**
241
252
 
242
- ## Options
253
+ - `options` - Optional configuration object (`Options`)
243
254
 
244
- All options are optional.
255
+ Option fields:
245
256
 
246
- ### `cwd`
257
+ #### `cwd`
247
258
 
248
259
  - **Type:** `string`
249
260
  - **Default:** `process.cwd()`
250
261
 
251
262
  Current working directory to start searching for config files. The loader will walk up from this directory to find a config file.
252
263
 
253
- ### `configPath`
264
+ #### `configPath`
254
265
 
255
266
  - **Type:** `string`
256
267
  - **Default:** `undefined`
@@ -261,7 +272,7 @@ Explicit path to the config file:
261
272
  - **Absolute path:** Used as-is
262
273
  - **When provided:** Skips auto-discovery and uses this path directly
263
274
 
264
- ### `useCache`
275
+ #### `useCache`
265
276
 
266
277
  - **Type:** `boolean`
267
278
  - **Default:** `true`
@@ -274,7 +285,7 @@ Enable in-memory caching for both path resolution and parsed config contents. Wh
274
285
 
275
286
  Set to `false` to force reload from disk on every call.
276
287
 
277
- ### `editorconfig`
288
+ #### `editorconfig`
278
289
 
279
290
  - **Type:** `boolean | EditorconfigOption`
280
291
  - **Default:** `true`
@@ -290,6 +301,105 @@ Control how `.editorconfig` files are read and merged:
290
301
  | `onlyCwd` | `boolean` | `false` | When `true`, only look for `.editorconfig` in `cwd` itself — no upward traversal. |
291
302
  | `cwd` | `string` | `undefined` | Override the directory from which `.editorconfig` resolution starts, instead of the config file's directory or `cwd`. |
292
303
 
304
+ **Returns:** `Promise<LoadOxfmtConfigResult>`
305
+
306
+ - `config` - Parsed and merged oxfmt configuration object
307
+ - `filepath` - Resolved config absolute path (undefined when not found)
308
+ - `dirname` - Config directory (undefined when not found)
309
+
310
+ **Throws:** Error if config file exists but cannot be parsed.
311
+
312
+ ### `resolveOxfmtrcPath(cwd, configPath?)`
313
+
314
+ Resolve the absolute path to oxfmt config file.
315
+
316
+ **Parameters:**
317
+
318
+ - `cwd` - Starting directory for resolution
319
+ - `configPath` - Optional explicit path (absolute or relative to cwd)
320
+
321
+ **Returns:** `Promise<string | undefined>` - Absolute path to config file, or `undefined` if not found.
322
+
323
+ ### `isOxfmtIgnored(options)`
324
+
325
+ Resolve whether a file should be ignored with oxfmt CLI-like semantics.
326
+
327
+ **Parameters:**
328
+
329
+ - `options` - Required configuration object (`IsOxfmtIgnoredOptions`)
330
+
331
+ Option fields:
332
+
333
+ #### `cwd`
334
+
335
+ - **Type:** `string`
336
+ - **Default:** `process.cwd()`
337
+
338
+ Current working directory.
339
+ Also the base directory for default `.gitignore`/`.prettierignore` lookup.
340
+
341
+ #### `filepath`
342
+
343
+ - **Type:** `string`
344
+ - **Default:** required
345
+
346
+ File path to test.
347
+
348
+ #### `configPath`
349
+
350
+ - **Type:** `string`
351
+ - **Default:** `undefined`
352
+
353
+ Explicit oxfmt config path.
354
+ When provided, nested config lookup is disabled (same as oxfmt CLI `-c`).
355
+
356
+ #### `ignorePath`
357
+
358
+ - **Type:** `string | string[]`
359
+ - **Default:** `undefined`
360
+
361
+ Ignore files to use instead of cwd `.gitignore`/`.prettierignore`.
362
+ Can be passed multiple times in CLI style.
363
+
364
+ #### `withNodeModules`
365
+
366
+ - **Type:** `boolean`
367
+ - **Default:** `true`
368
+
369
+ Whether `node_modules` should be included.
370
+
371
+ #### `disableNestedConfig`
372
+
373
+ - **Type:** `boolean`
374
+ - **Default:** `false`
375
+
376
+ Disable nested config lookup.
377
+
378
+ #### `useCache`
379
+
380
+ - **Type:** `boolean`
381
+ - **Default:** `true`
382
+
383
+ Whether to use in-memory cache.
384
+
385
+ #### `includeConfigIgnorePatterns`
386
+
387
+ - **Type:** `boolean`
388
+ - **Default:** `true`
389
+
390
+ Whether to include ignore patterns defined in the resolved config file.
391
+
392
+ **Returns:** `Promise<IsOxfmtIgnoredResult>`
393
+
394
+ - `ignored` - Whether the file is ignored
395
+ - `reason` - One of:
396
+ - `default-dir`
397
+ - `lockfile`
398
+ - `gitignore`
399
+ - `prettierignore`
400
+ - `ignore-path`
401
+ - `config-ignore-patterns`
402
+
293
403
  ## Config File Discovery
294
404
 
295
405
  When `configPath` is not provided, the loader automatically searches for config files:
@@ -368,6 +478,8 @@ Only `[*]` is treated as a global section to match oxfmt. Other sections such as
368
478
  1. Global ignore
369
479
  2. Ignore patterns from the resolved oxfmt config (`ignorePatterns`)
370
480
 
481
+ Set `includeConfigIgnorePatterns: false` to keep only global ignore behavior (skip config `ignorePatterns`).
482
+
371
483
  Global ignore includes:
372
484
 
373
485
  - Default ignored directories: `.git`, `.svn`, `.jj`, `node_modules`
@@ -382,6 +494,7 @@ Notes:
382
494
  - This package does not read parent `.gitignore` files or global gitignore settings.
383
495
  - The default lockfile list mirrors oxfmt documentation intent (`package-lock.json`, `pnpm-lock.yaml`, etc.) and common ecosystem lockfiles. It is not guaranteed to be a complete internal oxfmt list.
384
496
  - `ignorePatterns` are always interpreted relative to the resolved oxfmt config directory.
497
+ - `includeConfigIgnorePatterns` defaults to `true` to preserve current behavior.
385
498
  - Nested config behavior follows oxfmt semantics:
386
499
  - default: nearest config from target file directory upward
387
500
  - `disableNestedConfig: true`: resolve from `cwd` only
package/dist/index.d.mts CHANGED
@@ -119,16 +119,24 @@ interface IsOxfmtIgnoredOptions {
119
119
  ignorePath?: string | string[];
120
120
  /**
121
121
  * Whether node_modules should be included.
122
+ * @default true
122
123
  */
123
124
  withNodeModules?: boolean;
124
125
  /**
125
126
  * Disable nested config lookup.
127
+ * @default false
126
128
  */
127
129
  disableNestedConfig?: boolean;
128
130
  /**
129
131
  * Whether to use in-memory cache.
132
+ * @default true
130
133
  */
131
134
  useCache?: boolean;
135
+ /**
136
+ * Whether to include ignore patterns defined in the config file.
137
+ * @default true
138
+ */
139
+ includeConfigIgnorePatterns?: boolean;
132
140
  }
133
141
  /**
134
142
  * Ignore resolution result.
package/dist/index.mjs CHANGED
@@ -554,6 +554,7 @@ function matchConfigIgnorePatterns(filepath, configDir, patterns) {
554
554
  */
555
555
  async function isOxfmtIgnored(options) {
556
556
  const useCache = options.useCache !== false;
557
+ const includeConfigIgnorePatterns = options.includeConfigIgnorePatterns !== false;
557
558
  const cwd = resolve(options.cwd ?? process.cwd());
558
559
  const filepath = isAbsolute(options.filepath) ? resolve(options.filepath) : resolve(cwd, options.filepath);
559
560
  if (isDefaultIgnoredDir(filepath, options.withNodeModules ? { withNodeModules: true } : {})) return {
@@ -580,7 +581,7 @@ async function isOxfmtIgnored(options) {
580
581
  editorconfig: false,
581
582
  useCache
582
583
  });
583
- if (configResult.dirname && configResult.config.ignorePatterns && configResult.config.ignorePatterns.length > 0 && matchConfigIgnorePatterns(filepath, configResult.dirname, configResult.config.ignorePatterns)) return {
584
+ if (includeConfigIgnorePatterns && configResult.dirname && configResult.config.ignorePatterns && configResult.config.ignorePatterns.length > 0 && matchConfigIgnorePatterns(filepath, configResult.dirname, configResult.config.ignorePatterns)) return {
584
585
  ignored: true,
585
586
  reason: "config-ignore-patterns"
586
587
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "load-oxfmt-config",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Load oxfmt config files and merge supported .editorconfig options.",
5
5
  "keywords": [
6
6
  "editorconfig",