load-oxfmt-config 0.3.0 → 0.3.1
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 +17 -3
- package/dist/index.d.mts +9 -0
- package/dist/index.mjs +3 -2
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -111,6 +111,19 @@ const config = await loadOxfmtConfig({
|
|
|
111
111
|
})
|
|
112
112
|
```
|
|
113
113
|
|
|
114
|
+
### Override `.editorconfig` Search Directory
|
|
115
|
+
|
|
116
|
+
```ts
|
|
117
|
+
import { loadOxfmtConfig } from 'load-oxfmt-config'
|
|
118
|
+
|
|
119
|
+
// Search .editorconfig from a custom directory instead of the config file's directory
|
|
120
|
+
const config = await loadOxfmtConfig({
|
|
121
|
+
editorconfig: {
|
|
122
|
+
cwd: '/path/to/editorconfig-dir',
|
|
123
|
+
},
|
|
124
|
+
})
|
|
125
|
+
```
|
|
126
|
+
|
|
114
127
|
### Disable Caching
|
|
115
128
|
|
|
116
129
|
```ts
|
|
@@ -203,9 +216,10 @@ Control how `.editorconfig` files are read and merged:
|
|
|
203
216
|
- **`false`** — Disable `.editorconfig` reading entirely.
|
|
204
217
|
- **`EditorconfigOption`** — Enable with additional settings:
|
|
205
218
|
|
|
206
|
-
| Property | Type | Default
|
|
207
|
-
| --------- | --------- |
|
|
208
|
-
| `onlyCwd` | `boolean` | `false`
|
|
219
|
+
| Property | Type | Default | Description |
|
|
220
|
+
| --------- | --------- | ----------- | --------------------------------------------------------------------------------------------------------------------- |
|
|
221
|
+
| `onlyCwd` | `boolean` | `false` | When `true`, only look for `.editorconfig` in `cwd` itself — no upward traversal. |
|
|
222
|
+
| `cwd` | `string` | `undefined` | Override the directory from which `.editorconfig` resolution starts, instead of the config file's directory or `cwd`. |
|
|
209
223
|
|
|
210
224
|
## Config File Discovery
|
|
211
225
|
|
package/dist/index.d.mts
CHANGED
|
@@ -12,6 +12,15 @@ interface EditorconfigOption {
|
|
|
12
12
|
* @default false
|
|
13
13
|
*/
|
|
14
14
|
onlyCwd?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Override the directory from which `.editorconfig` resolution starts.
|
|
17
|
+
* When set, editorconfig is searched from this directory instead of from
|
|
18
|
+
* the config file's directory (or the top-level `cwd`).
|
|
19
|
+
*
|
|
20
|
+
* This is useful when the oxfmt config path is pre-resolved and you still
|
|
21
|
+
* want editorconfig to be resolved relative to each file's directory.
|
|
22
|
+
*/
|
|
23
|
+
cwd?: string;
|
|
15
24
|
}
|
|
16
25
|
/**
|
|
17
26
|
* Format option override for a single matching rule
|
package/dist/index.mjs
CHANGED
|
@@ -224,9 +224,10 @@ async function loadOxfmtConfig(options = {}) {
|
|
|
224
224
|
const editorconfig = options.editorconfig ?? true;
|
|
225
225
|
const useEditorconfig = editorconfig !== false;
|
|
226
226
|
const onlyCwd = useEditorconfig && typeof editorconfig === "object" ? editorconfig.onlyCwd ?? false : false;
|
|
227
|
+
const editorconfigCwd = useEditorconfig && typeof editorconfig === "object" ? editorconfig.cwd : void 0;
|
|
227
228
|
const resolveKey = getResolveCacheKey(cwd, options.configPath);
|
|
228
|
-
const editorconfigSearchDir = getEditorconfigSearchDir(cwd, options.configPath);
|
|
229
|
-
const editorconfigResolveKey = getEditorconfigResolveCacheKey(resolveKey);
|
|
229
|
+
const editorconfigSearchDir = editorconfigCwd || getEditorconfigSearchDir(cwd, options.configPath);
|
|
230
|
+
const editorconfigResolveKey = editorconfigCwd ? getEditorconfigResolveCacheKey(`${editorconfigCwd}::${options.configPath || ""}`) : getEditorconfigResolveCacheKey(resolveKey);
|
|
230
231
|
const resolvedPath = useCache ? await cachePromise(resolveCache, resolveKey, () => resolveOxfmtrcPath(cwd, options.configPath)) : await resolveOxfmtrcPath(cwd, options.configPath);
|
|
231
232
|
const editorconfigPath = useEditorconfig ? await (useCache ? cachePromise(resolveCache, editorconfigResolveKey, () => resolveEditorconfigPath(editorconfigSearchDir, onlyCwd)) : resolveEditorconfigPath(editorconfigSearchDir, onlyCwd)) : void 0;
|
|
232
233
|
const anchorDir = dirname(resolvedPath || editorconfigPath || cwd);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "load-oxfmt-config",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Load oxfmt config files and merge supported .editorconfig options.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"editorconfig",
|
|
@@ -47,14 +47,14 @@
|
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@ntnyq/tsconfig": "^3.1.0",
|
|
49
49
|
"@types/node": "^25.5.0",
|
|
50
|
-
"@typescript/native-preview": "^7.0.0-dev.
|
|
50
|
+
"@typescript/native-preview": "^7.0.0-dev.20260328.1",
|
|
51
51
|
"bumpp": "^11.0.1",
|
|
52
52
|
"husky": "^9.1.7",
|
|
53
53
|
"nano-staged": "^0.9.0",
|
|
54
54
|
"npm-run-all2": "^8.0.4",
|
|
55
55
|
"oxfmt": "^0.42.0",
|
|
56
56
|
"oxlint": "^1.57.0",
|
|
57
|
-
"tsdown": "^0.21.
|
|
57
|
+
"tsdown": "^0.21.7",
|
|
58
58
|
"vitest": "^4.1.2"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|