@subf/config 0.2.0 → 0.3.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/bin/subf.js +27 -0
- package/dist/oxfmt.d.ts +1 -2
- package/dist/oxlint.d.ts +3 -4
- package/dist/oxlint.js +19 -7
- package/dist/tsdown.d.ts +32 -26
- package/dist/tsdown.js +8 -3
- package/package.json +10 -10
- package/tsconfig.lib.json +4 -3
- package/tsconfig.node.json +0 -1
- package/tsconfig.web.json +0 -1
package/bin/subf.js
CHANGED
|
@@ -141,4 +141,31 @@ if (depResult.changed) {
|
|
|
141
141
|
)
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
+
// If either oxfmt or oxlint aren't listed, hint how to install them
|
|
145
|
+
try {
|
|
146
|
+
const missingTools = []
|
|
147
|
+
const hasOxfmt = projectPkg.devDependencies?.oxfmt || projectPkg.dependencies?.oxfmt
|
|
148
|
+
const hasOxlint = projectPkg.devDependencies?.oxlint || projectPkg.dependencies?.oxlint
|
|
149
|
+
const hasTypescript =
|
|
150
|
+
projectPkg.devDependencies?.typescript || projectPkg.dependencies?.typescript
|
|
151
|
+
|
|
152
|
+
if (!hasOxfmt) {
|
|
153
|
+
missingTools.push('oxfmt')
|
|
154
|
+
}
|
|
155
|
+
if (!hasOxlint) {
|
|
156
|
+
missingTools.push('oxlint')
|
|
157
|
+
}
|
|
158
|
+
if (!hasTypescript) {
|
|
159
|
+
missingTools.push('typescript')
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (missingTools.length > 0) {
|
|
163
|
+
console.log(
|
|
164
|
+
`Hint: Install ${missingTools.join(' and ')} to use the generated configs. Example: npm install -D ${missingTools.join(
|
|
165
|
+
' ',
|
|
166
|
+
)}`,
|
|
167
|
+
)
|
|
168
|
+
}
|
|
169
|
+
} catch {}
|
|
170
|
+
|
|
144
171
|
process.exit(0)
|
package/dist/oxfmt.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { OxfmtConfig } from "oxfmt";
|
|
2
|
-
|
|
3
2
|
//#region src/oxfmt.d.ts
|
|
4
3
|
declare const CONFIG: OxfmtConfig;
|
|
5
4
|
declare function subfFmt(config?: OxfmtConfig): OxfmtConfig;
|
|
6
5
|
//#endregion
|
|
7
|
-
export { CONFIG, CONFIG as default, subfFmt };
|
|
6
|
+
export { CONFIG, CONFIG as default, type OxfmtConfig, subfFmt };
|
package/dist/oxlint.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { FILES_TS_TSX, solidConfig as solid } from "@subf/oxlint-plugin/config";
|
|
2
2
|
import { OxlintConfig, OxlintOverride } from "oxlint";
|
|
3
|
-
|
|
4
3
|
//#region src/oxlint.d.ts
|
|
5
4
|
declare const baseConfig: OxlintConfig;
|
|
6
5
|
declare const baseRules: OxlintConfig;
|
|
@@ -12,12 +11,12 @@ declare const CONFIG: OxlintConfig;
|
|
|
12
11
|
declare const unocss: OxlintOverride;
|
|
13
12
|
interface SubfOptions extends OxlintConfig {
|
|
14
13
|
/**
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
* Used for lib, force to explicit function return type
|
|
15
|
+
*/
|
|
17
16
|
lib?: boolean;
|
|
18
17
|
solid?: boolean;
|
|
19
18
|
unocss?: boolean;
|
|
20
19
|
}
|
|
21
20
|
declare function subfLint(options?: SubfOptions): OxlintConfig;
|
|
22
21
|
//#endregion
|
|
23
|
-
export { CONFIG, CONFIG as default, FILES_TS_TSX, SubfOptions, baseConfig, baseRules, markdownOverrideConfig, overrides, solid, subfLint, ts, unocss, vitest };
|
|
22
|
+
export { CONFIG, CONFIG as default, FILES_TS_TSX, type OxlintConfig, type OxlintOverride, SubfOptions, baseConfig, baseRules, markdownOverrideConfig, overrides, solid, subfLint, ts, unocss, vitest };
|
package/dist/oxlint.js
CHANGED
|
@@ -90,8 +90,15 @@ const baseRules = {
|
|
|
90
90
|
"typescript",
|
|
91
91
|
"eslint"
|
|
92
92
|
],
|
|
93
|
+
jsPlugins: [{
|
|
94
|
+
name: "subf",
|
|
95
|
+
specifier: "@subf/oxlint-plugin"
|
|
96
|
+
}],
|
|
93
97
|
categories: { correctness: "error" },
|
|
94
98
|
rules: {
|
|
99
|
+
"subf/method-signature-style": "error",
|
|
100
|
+
"subf/no-negated-conjunction": "error",
|
|
101
|
+
"subf/no-negated-disjunction": "error",
|
|
95
102
|
"array-callback-return": "error",
|
|
96
103
|
"block-scoped-var": "error",
|
|
97
104
|
"class-methods-use-this": "error",
|
|
@@ -105,6 +112,7 @@ const baseRules = {
|
|
|
105
112
|
newIsCap: true,
|
|
106
113
|
properties: true
|
|
107
114
|
}],
|
|
115
|
+
"logical-assignment-operators": ["error", "always"],
|
|
108
116
|
"no-alert": "error",
|
|
109
117
|
"no-array-constructor": "error",
|
|
110
118
|
"no-async-promise-executor": "error",
|
|
@@ -133,10 +141,14 @@ const baseRules = {
|
|
|
133
141
|
"no-func-assign": "error",
|
|
134
142
|
"no-global-assign": "error",
|
|
135
143
|
"no-import-assign": "error",
|
|
144
|
+
"no-implied-eval": "error",
|
|
136
145
|
"no-inner-declarations": [
|
|
137
146
|
"error",
|
|
138
147
|
"functions",
|
|
139
|
-
|
|
148
|
+
{
|
|
149
|
+
blockScopedFunctions: "disallow",
|
|
150
|
+
namespaces: "disallow"
|
|
151
|
+
}
|
|
140
152
|
],
|
|
141
153
|
"no-irregular-whitespace": "error",
|
|
142
154
|
"no-iterator": "error",
|
|
@@ -191,6 +203,7 @@ const baseRules = {
|
|
|
191
203
|
functions: false,
|
|
192
204
|
variables: true
|
|
193
205
|
}],
|
|
206
|
+
"no-useless-assignment": "error",
|
|
194
207
|
"no-useless-call": "error",
|
|
195
208
|
"no-useless-catch": "error",
|
|
196
209
|
"no-useless-computed-key": "error",
|
|
@@ -213,6 +226,7 @@ const baseRules = {
|
|
|
213
226
|
"object-shorthand": ["error", "always"],
|
|
214
227
|
"prefer-exponentiation-operator": "error",
|
|
215
228
|
"prefer-rest-params": "error",
|
|
229
|
+
"prefer-regex-literals": "error",
|
|
216
230
|
"prefer-spread": "error",
|
|
217
231
|
"prefer-template": "error",
|
|
218
232
|
"symbol-description": "error",
|
|
@@ -246,7 +260,7 @@ const baseRules = {
|
|
|
246
260
|
"unicorn/no-instanceof-array": "error",
|
|
247
261
|
"unicorn/no-new-array": "off",
|
|
248
262
|
"unicorn/no-new-buffer": "error",
|
|
249
|
-
"unicorn/
|
|
263
|
+
"unicorn/no-array-fill-with-reference-type": "error",
|
|
250
264
|
"unicorn/prefer-array-find": "error",
|
|
251
265
|
"unicorn/prefer-array-flat-map": "error",
|
|
252
266
|
"unicorn/prefer-array-some": "error",
|
|
@@ -263,6 +277,7 @@ const baseRules = {
|
|
|
263
277
|
"unicorn/throw-new-error": "error",
|
|
264
278
|
"import/consistent-type-specifier-style": "error",
|
|
265
279
|
"import/no-absolute-path": "error",
|
|
280
|
+
"import/no-cycle": "error",
|
|
266
281
|
"import/no-duplicates": "error",
|
|
267
282
|
"import/no-self-import": "error",
|
|
268
283
|
"import/no-named-export": "allow",
|
|
@@ -275,12 +290,7 @@ const baseRules = {
|
|
|
275
290
|
const ts = {
|
|
276
291
|
files: FILES_TS_TSX$1,
|
|
277
292
|
plugins: ["typescript"],
|
|
278
|
-
jsPlugins: [{
|
|
279
|
-
name: "subf",
|
|
280
|
-
specifier: "@subf/oxlint-plugin"
|
|
281
|
-
}],
|
|
282
293
|
rules: {
|
|
283
|
-
"subf/method-signature-style": ["error", "property"],
|
|
284
294
|
"constructor-super": "off",
|
|
285
295
|
"no-class-assign": "off",
|
|
286
296
|
"no-const-assign": "off",
|
|
@@ -307,6 +317,7 @@ const ts = {
|
|
|
307
317
|
}],
|
|
308
318
|
"typescript/ban-ts-comment": ["error", { "ts-expect-error": "allow-with-description" }],
|
|
309
319
|
"typescript/dot-notation": "error",
|
|
320
|
+
"typescript/method-signature-style": ["error", "property"],
|
|
310
321
|
"typescript/no-duplicate-enum-values": "error",
|
|
311
322
|
"typescript/no-extra-non-null-assertion": "error",
|
|
312
323
|
"typescript/no-misused-new": "error",
|
|
@@ -351,6 +362,7 @@ const vitest = {
|
|
|
351
362
|
"vitest/no-import-node-test": "error",
|
|
352
363
|
"vitest/prefer-hooks-in-order": "error",
|
|
353
364
|
"vitest/prefer-lowercase-title": "error",
|
|
365
|
+
"vitest/prefer-called-exactly-once-with": "warn",
|
|
354
366
|
"no-unused-expressions": "off"
|
|
355
367
|
}
|
|
356
368
|
};
|
package/dist/tsdown.d.ts
CHANGED
|
@@ -1,46 +1,52 @@
|
|
|
1
1
|
import { DepsConfig, ExportsOptions, TsdownInputOption, UserConfig } from "tsdown";
|
|
2
|
-
|
|
3
2
|
//#region src/tsdown.d.ts
|
|
4
|
-
interface
|
|
3
|
+
interface DepsOptions {
|
|
5
4
|
/**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
* tsdown's deps option, which controls which dependency to bundle.
|
|
6
|
+
*/
|
|
7
|
+
bundled?: DepsConfig["alwaysBundle"];
|
|
8
|
+
/**
|
|
9
|
+
* tsdown's deps option, which controls which dependency to exclude.
|
|
10
|
+
*/
|
|
11
|
+
unbundled?: DepsConfig["neverBundle"];
|
|
12
|
+
}
|
|
13
|
+
interface LibOptions extends DepsOptions {
|
|
14
|
+
/**
|
|
15
|
+
* The entry point for the library.
|
|
16
|
+
* - 'index' (default): Only include `src/index.ts`.
|
|
17
|
+
* - 'shallow': Include all `.ts` files directly under `src/`.
|
|
18
|
+
* - 'all': Include all `.ts` files under `src/` recursively.
|
|
19
|
+
* - Custom glob pattern or array of file paths.
|
|
20
|
+
*
|
|
21
|
+
* @default 'index'
|
|
22
|
+
*/
|
|
14
23
|
entry?: "index" | "shallow" | "all" | Exclude<TsdownInputOption, string>;
|
|
15
24
|
/**
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
25
|
+
* tsdown's `customExports` option, which controls how the exports field is generated in package.json.
|
|
26
|
+
*
|
|
27
|
+
* @default true
|
|
28
|
+
*/
|
|
20
29
|
extraExports?: ExportsOptions["customExports"];
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
*/
|
|
24
|
-
bundled?: DepsConfig["alwaysBundle"];
|
|
25
|
-
unbundled?: DepsConfig["neverBundle"];
|
|
30
|
+
dts?: UserConfig["dts"] & DepsOptions;
|
|
31
|
+
plugins?: UserConfig["plugins"];
|
|
26
32
|
overrides?: UserConfig;
|
|
27
33
|
}
|
|
28
34
|
declare function lib(options?: LibOptions): UserConfig;
|
|
29
35
|
declare function nodeLib(options?: LibOptions): UserConfig;
|
|
30
36
|
interface SolidLibOptions extends LibOptions {
|
|
31
37
|
/**
|
|
32
|
-
|
|
33
|
-
|
|
38
|
+
* Options to pass to the `vite-plugin-solid` plugin. This is useful if you want to customize the solid plugin options, such as enabling hot module replacement (HMR) or configuring the Solid compiler.
|
|
39
|
+
*/
|
|
34
40
|
solid?: Record<string, any>;
|
|
35
41
|
/**
|
|
36
|
-
|
|
37
|
-
|
|
42
|
+
* Overrides for the js output config. This is useful if you want to customize the js output config, such as adding additional plugins or changing the output format.
|
|
43
|
+
*/
|
|
38
44
|
jsOverride?: UserConfig;
|
|
39
45
|
/**
|
|
40
|
-
|
|
41
|
-
|
|
46
|
+
* Overrides for the jsx output config. This is useful if you want to customize the jsx output config, such as adding additional plugins or changing the output format.
|
|
47
|
+
*/
|
|
42
48
|
jsxOverride?: UserConfig;
|
|
43
49
|
}
|
|
44
50
|
declare function solidLib(options: SolidLibOptions): Promise<UserConfig[]>;
|
|
45
51
|
//#endregion
|
|
46
|
-
export { SolidLibOptions, lib, nodeLib, solidLib };
|
|
52
|
+
export { LibOptions, SolidLibOptions, lib, nodeLib, solidLib };
|
package/dist/tsdown.js
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import { mergeConfig } from "tsdown/config";
|
|
2
2
|
//#region src/tsdown.ts
|
|
3
3
|
function lib(options = {}) {
|
|
4
|
-
const { entry = "index", extraExports, bundled, unbundled, overrides = {} } = options;
|
|
4
|
+
const { entry = "index", extraExports, bundled, unbundled, plugins, dts = { oxc: true }, overrides = {} } = options;
|
|
5
5
|
return mergeConfig({
|
|
6
6
|
entry: entry === "index" ? "src/index.ts" : entry === "shallow" ? "src/*.ts" : entry === "all" ? "src/**/*.ts" : entry,
|
|
7
|
-
dts
|
|
7
|
+
dts,
|
|
8
8
|
platform: "neutral",
|
|
9
|
+
plugins,
|
|
9
10
|
deps: {
|
|
10
11
|
alwaysBundle: bundled,
|
|
11
|
-
neverBundle: unbundled
|
|
12
|
+
neverBundle: unbundled,
|
|
13
|
+
dts: {
|
|
14
|
+
alwaysBundle: dts.bundled,
|
|
15
|
+
neverBundle: dts.unbundled
|
|
16
|
+
}
|
|
12
17
|
},
|
|
13
18
|
exports: { customExports: extraExports }
|
|
14
19
|
}, overrides);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@subf/config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Universal configuration for TypeScript, oxlint (+unocss, +solid), oxfmt, and tsdown.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"config",
|
|
@@ -56,18 +56,18 @@
|
|
|
56
56
|
"prepublishOnly": "bun run build"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@subf/oxlint-plugin": "^0.
|
|
59
|
+
"@subf/oxlint-plugin": "^0.3.0"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@oxlint/plugins": "^1.
|
|
63
|
-
"@types/bun": "^1.3.
|
|
64
|
-
"bumpp": "^11.0
|
|
65
|
-
"oxfmt": "^0.
|
|
66
|
-
"oxlint": "^1.
|
|
67
|
-
"tsdown": "^0.
|
|
68
|
-
"typescript": "^
|
|
62
|
+
"@oxlint/plugins": "^1.77.0",
|
|
63
|
+
"@types/bun": "^1.3.14",
|
|
64
|
+
"bumpp": "^11.1.0",
|
|
65
|
+
"oxfmt": "^0.62.0",
|
|
66
|
+
"oxlint": "^1.77.0",
|
|
67
|
+
"tsdown": "^0.22.14",
|
|
68
|
+
"typescript": "^7.0.2"
|
|
69
69
|
},
|
|
70
70
|
"peerDependencies": {
|
|
71
|
-
"defu": "
|
|
71
|
+
"defu": "6.1.7"
|
|
72
72
|
}
|
|
73
73
|
}
|
package/tsconfig.lib.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
-
"extends": "./tsconfig.
|
|
2
|
+
"extends": "./tsconfig.node.json",
|
|
3
3
|
"compilerOptions": {
|
|
4
|
-
"
|
|
5
|
-
"
|
|
4
|
+
"noUncheckedIndexedAccess": true,
|
|
5
|
+
"strictFunctionTypes": true,
|
|
6
|
+
"strictNullChecks": true
|
|
6
7
|
}
|
|
7
8
|
}
|
package/tsconfig.node.json
CHANGED