load-oxfmt-config 0.0.1 → 0.0.2
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 +24 -4
- package/dist/index.d.mts +4 -140
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@ pnpm add load-oxfmt-config
|
|
|
26
26
|
```ts
|
|
27
27
|
import { loadOxfmtConfig } from 'load-oxfmt-config'
|
|
28
28
|
|
|
29
|
-
const config = loadOxfmtConfig({
|
|
29
|
+
const config = await loadOxfmtConfig({
|
|
30
30
|
cwd: '/configs',
|
|
31
31
|
})
|
|
32
32
|
|
|
@@ -35,9 +35,29 @@ console.log({ config })
|
|
|
35
35
|
|
|
36
36
|
## Options
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
### configPath
|
|
39
|
+
|
|
40
|
+
**Type**: `string`\
|
|
41
|
+
**Required**: `false`\
|
|
42
|
+
**Default**: `undefined`
|
|
43
|
+
|
|
44
|
+
Path to the oxfmt config file, resolved relative to `cwd`.
|
|
45
|
+
|
|
46
|
+
### cwd
|
|
47
|
+
|
|
48
|
+
**Type**: `string`\
|
|
49
|
+
**Required**: `false`\
|
|
50
|
+
**Default**: `process.cwd()`
|
|
51
|
+
|
|
52
|
+
Current working directory used when searching for config files.
|
|
53
|
+
|
|
54
|
+
### useCache
|
|
55
|
+
|
|
56
|
+
**Type**: `boolean`\
|
|
57
|
+
**Required**: `false`\
|
|
58
|
+
**Default**: `true`
|
|
59
|
+
|
|
60
|
+
Enable in-memory caching for path resolution and parsed config contents.
|
|
41
61
|
|
|
42
62
|
## License
|
|
43
63
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { FormatOptions } from "oxfmt";
|
|
2
|
+
|
|
1
3
|
//#region src/types.d.ts
|
|
2
4
|
interface Options {
|
|
3
5
|
/**
|
|
@@ -13,154 +15,16 @@ interface Options {
|
|
|
13
15
|
*/
|
|
14
16
|
useCache?: boolean;
|
|
15
17
|
}
|
|
16
|
-
/**
|
|
17
|
-
* Oxfmt configuration interface
|
|
18
|
-
*/
|
|
19
|
-
interface OxfmtConfig {
|
|
20
|
-
/**
|
|
21
|
-
* Include parentheses around a sole arrow function parameter.
|
|
22
|
-
* @default `always`
|
|
23
|
-
*/
|
|
24
|
-
arrowParens?: 'always' | 'avoid';
|
|
25
|
-
/**
|
|
26
|
-
* Put the `>` of a multi-line JSX element at the end of the last line\ninstead of being alone on the next line.
|
|
27
|
-
* @default false
|
|
28
|
-
*/
|
|
29
|
-
bracketSameLine?: boolean;
|
|
30
|
-
/**
|
|
31
|
-
* Print spaces between brackets in object literals.
|
|
32
|
-
* @default true
|
|
33
|
-
*/
|
|
34
|
-
bracketSpacing?: boolean;
|
|
35
|
-
/**
|
|
36
|
-
* Control whether to format embedded parts in the file.
|
|
37
|
-
* @default `off`
|
|
38
|
-
*/
|
|
39
|
-
embeddedLanguageFormatting?: 'auto' | 'off';
|
|
40
|
-
/**
|
|
41
|
-
* Which end of line characters to apply.
|
|
42
|
-
* @default `lf`
|
|
43
|
-
*/
|
|
44
|
-
endOfLine?: 'cr' | 'crlf' | 'lf';
|
|
45
|
-
/**
|
|
46
|
-
* Experimental: Sort `package.json` keys.
|
|
47
|
-
* @default true
|
|
48
|
-
*/
|
|
49
|
-
experimentalSortPackageJson?: boolean;
|
|
50
|
-
/**
|
|
51
|
-
* Ignore files matching these glob patterns. Current working directory is used as the root.
|
|
52
|
-
*/
|
|
53
|
-
ignorePatterns?: string[];
|
|
54
|
-
/**
|
|
55
|
-
* Whether to insert a final newline at the end of the file.
|
|
56
|
-
* @default true
|
|
57
|
-
*/
|
|
58
|
-
insertFinalNewline?: boolean;
|
|
59
|
-
/**
|
|
60
|
-
* Use single quotes instead of double quotes in JSX.
|
|
61
|
-
* @default false
|
|
62
|
-
*/
|
|
63
|
-
jsxSingleQuote?: boolean;
|
|
64
|
-
/**
|
|
65
|
-
* How to wrap object literals when they could fit on one line or span multiple lines.
|
|
66
|
-
* @default `preserve`
|
|
67
|
-
* NOTE: In addition to Prettier's `preserve` and `collapse`, we also support `always`
|
|
68
|
-
*/
|
|
69
|
-
objectWrap?: 'always' | 'never' | 'preserve';
|
|
70
|
-
/**
|
|
71
|
-
* The line length that the printer will wrap on.
|
|
72
|
-
* @default 100
|
|
73
|
-
*/
|
|
74
|
-
printWidth?: number;
|
|
75
|
-
/**
|
|
76
|
-
* Change when properties in objects are quoted.
|
|
77
|
-
* @default `as-needed`
|
|
78
|
-
*/
|
|
79
|
-
quoteProps?: 'as-needed' | 'consistent' | 'preserve';
|
|
80
|
-
/**
|
|
81
|
-
* Print semicolons at the ends of statements.
|
|
82
|
-
* @default true
|
|
83
|
-
*/
|
|
84
|
-
semi?: boolean;
|
|
85
|
-
/**
|
|
86
|
-
* Put each attribute on a new line in JSX.
|
|
87
|
-
* @default false
|
|
88
|
-
*/
|
|
89
|
-
singleAttributePerLine?: boolean;
|
|
90
|
-
/**
|
|
91
|
-
* Use single quotes instead of double quotes.
|
|
92
|
-
* @default false
|
|
93
|
-
*/
|
|
94
|
-
singleQuote?: boolean;
|
|
95
|
-
/**
|
|
96
|
-
* Number of spaces per indentation level.
|
|
97
|
-
* @default 2
|
|
98
|
-
*/
|
|
99
|
-
tabWidth?: number;
|
|
100
|
-
/**
|
|
101
|
-
* Print trailing commas wherever possible.
|
|
102
|
-
* @default `all`
|
|
103
|
-
*/
|
|
104
|
-
trailingComma?: 'all' | 'es5' | 'none';
|
|
105
|
-
/**
|
|
106
|
-
* Use tabs for indentation or spaces.
|
|
107
|
-
* @default false
|
|
108
|
-
*/
|
|
109
|
-
useTabs?: boolean;
|
|
110
|
-
/**
|
|
111
|
-
* Experimental: Sort import statements. Disabled by default.
|
|
112
|
-
*/
|
|
113
|
-
experimentalSortImports?: {
|
|
114
|
-
/**
|
|
115
|
-
* Custom groups configuration for organizing imports.\nEach array element represents a group, and multiple group names in the same array are treated as one.\nAccepts both `string` and `string[]` as group elements.
|
|
116
|
-
*/
|
|
117
|
-
groups?: Array<string | string[]>;
|
|
118
|
-
/**
|
|
119
|
-
* Ignore case when sorting.
|
|
120
|
-
* @default true
|
|
121
|
-
*/
|
|
122
|
-
ignoreCase?: boolean;
|
|
123
|
-
/**
|
|
124
|
-
* Glob patterns to identify internal imports.
|
|
125
|
-
*/
|
|
126
|
-
internalPattern?: string[];
|
|
127
|
-
/**
|
|
128
|
-
* Add newlines between import groups.
|
|
129
|
-
* @default true
|
|
130
|
-
*/
|
|
131
|
-
newlinesBetween?: boolean;
|
|
132
|
-
/**
|
|
133
|
-
* Sort order. (Default: `asc`)
|
|
134
|
-
* @default `asc`
|
|
135
|
-
*/
|
|
136
|
-
order?: 'asc' | 'desc';
|
|
137
|
-
/**
|
|
138
|
-
* Partition imports by comments.
|
|
139
|
-
* @default false
|
|
140
|
-
*/
|
|
141
|
-
partitionByComment?: boolean;
|
|
142
|
-
/**
|
|
143
|
-
* Partition imports by newlines.
|
|
144
|
-
* @default false
|
|
145
|
-
*/
|
|
146
|
-
partitionByNewline?: boolean;
|
|
147
|
-
/**
|
|
148
|
-
* Sort side-effect imports.
|
|
149
|
-
* @default false
|
|
150
|
-
*/
|
|
151
|
-
sortSideEffects?: boolean;
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
18
|
//#endregion
|
|
155
19
|
//#region src/core.d.ts
|
|
156
20
|
/**
|
|
157
21
|
* Load oxfmt configuration by resolving the config file path and parsing its contents.
|
|
158
22
|
* Uses in-memory caches by default; set `useCache` to false to force re-read.
|
|
159
23
|
*/
|
|
160
|
-
declare function loadOxfmtConfig(options?: Options): Promise<
|
|
24
|
+
declare function loadOxfmtConfig(options?: Options): Promise<FormatOptions>;
|
|
161
25
|
/**
|
|
162
26
|
* Resolve the oxfmt config file path, searching upward from the provided cwd when no explicit path is given.
|
|
163
27
|
*/
|
|
164
28
|
declare function resolveOxfmtrcPath(cwd: string, configPath?: string): Promise<string | undefined>;
|
|
165
29
|
//#endregion
|
|
166
|
-
export { Options,
|
|
30
|
+
export { Options, loadOxfmtConfig, resolveOxfmtrcPath };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "load-oxfmt-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.2",
|
|
5
5
|
"description": "Load .oxfmtrc.json(c) for oxfmt.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"jsonc-parser",
|
|
@@ -37,6 +37,9 @@
|
|
|
37
37
|
"access": "public"
|
|
38
38
|
},
|
|
39
39
|
"sideEffects": false,
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"oxfmt": "^0.20.0"
|
|
42
|
+
},
|
|
40
43
|
"dependencies": {
|
|
41
44
|
"jsonc-parser": "^3.3.1"
|
|
42
45
|
},
|
|
@@ -50,6 +53,7 @@
|
|
|
50
53
|
"husky": "^9.1.7",
|
|
51
54
|
"nano-staged": "^0.9.0",
|
|
52
55
|
"npm-run-all2": "^8.0.4",
|
|
56
|
+
"oxfmt": "^0.20.0",
|
|
53
57
|
"prettier": "^3.7.4",
|
|
54
58
|
"tsdown": "^0.18.2",
|
|
55
59
|
"typescript": "^5.9.3",
|