@subf/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
@@ -29,8 +29,8 @@ Helpers to create `tsdown` build configs.
29
29
  Example: use `lib()` in your `tsdown.config.ts`:
30
30
 
31
31
  ```ts
32
- import { defineConfig } from 'tsdown'
33
32
  import { lib } from '@subf/config/tsdown'
33
+ import { defineConfig } from 'tsdown'
34
34
 
35
35
  export default lib({
36
36
  entry: 'shallow',
@@ -56,8 +56,8 @@ export default nodeLib({ entry: 'src/index.ts' })
56
56
  For Solid builds (requires `vite-plugin-solid`) use `solidLib()`:
57
57
 
58
58
  ```ts
59
- import { defineConfig } from 'tsdown'
60
59
  import { solidLib } from '@subf/config/tsdown'
60
+ import { defineConfig } from 'tsdown'
61
61
 
62
62
  export default solidLib({ entry: 'src/index.tsx' })
63
63
  ```
@@ -95,8 +95,8 @@ export default CONFIG
95
95
  or use `defineConfig()` with `extend` if you want to extend it:
96
96
 
97
97
  ```ts
98
- import { defineConfig } from 'oxlint'
99
98
  import { CONFIG } from '@subf/config/oxlint'
99
+ import { defineConfig } from 'oxlint'
100
100
 
101
101
  export default defineConfig({
102
102
  extend: [CONFIG],
package/dist/cli.d.mts CHANGED
@@ -1,8 +1,5 @@
1
- //#region src/utils/tsconfig.d.ts
2
1
  declare const TSCONFIG_TYPE: readonly ['node', 'lib', 'solid', 'solid-lib'];
3
2
  type TsconfigType = (typeof TSCONFIG_TYPE)[number];
4
- //#endregion
5
- //#region src/cli.d.ts
6
- export declare function parseType(argv: readonly string[]): TsconfigType;
7
- export declare function main(argv?: readonly string[]): Promise<number>;
8
- //#endregion
3
+ export declare function parseType(argv: ReadonlyArray<string>): TsconfigType;
4
+ export declare function main(argv?: ReadonlyArray<string>): Promise<number>;
5
+ export {};
package/dist/cli.mjs CHANGED
@@ -1,8 +1,6 @@
1
1
  import { existsSync, readFileSync, writeFileSync } from "node:fs";
2
2
  import path from "node:path";
3
- import { createDefu } from "defu";
4
- import { fileURLToPath } from "node:url";
5
- //#region src/utils/tsconfig.ts
3
+ // src/utils/tsconfig.ts
6
4
  const TSCONFIG_TYPE = [
7
5
  "node",
8
6
  "lib",
@@ -61,32 +59,32 @@ function getCompilerOptions(type) {
61
59
  }
62
60
  return options;
63
61
  }
64
- //#endregion
65
- //#region src/utils/config-files.ts
62
+ // src/utils/config-files.ts
66
63
  function isRecord(value) {
67
64
  return typeof value === "object" && value !== null && !Array.isArray(value);
68
65
  }
69
66
  function mergeConfig(existing, generated, overwrite) {
70
- const merge = createDefu((object, key, value) => {
71
- if (overwrite) {
72
- if (isRecord(object[key]) && isRecord(value)) return false;
73
- object[key] = value;
74
- return true;
75
- }
76
- if (Array.isArray(object[key]) && Array.isArray(value)) {
77
- object[key] = value;
78
- return true;
67
+ return overwrite ? mergeObjects(generated, existing, false) : mergeObjects(existing, generated, true);
68
+ }
69
+ /**
70
+ * Merge `secondary` into `primary`. `primary` wins on conflicts, plain objects
71
+ * merge recursively, and `secondary` only fills in missing keys.
72
+ * When `keepPrimaryNull` is true, explicit `null` values in `primary` win too;
73
+ * otherwise they are skipped and the `secondary` value is kept.
74
+ */
75
+ function mergeObjects(primary, secondary, keepPrimaryNull) {
76
+ const result = { ...secondary };
77
+ for (const [key, value] of Object.entries(primary)) {
78
+ if (value === void 0) continue;
79
+ if (value === null) {
80
+ if (keepPrimaryNull) result[key] = null;
81
+ continue;
79
82
  }
80
- return false;
81
- });
82
- const result = overwrite ? merge(generated, existing) : merge(existing, generated);
83
- if (!overwrite) restoreNullValues(result, existing);
83
+ const current = result[key];
84
+ result[key] = isRecord(value) && isRecord(current) ? mergeObjects(value, current, keepPrimaryNull) : value;
85
+ }
84
86
  return result;
85
87
  }
86
- function restoreNullValues(result, source) {
87
- for (const [key, value] of Object.entries(source)) if (value === null) result[key] = null;
88
- else if (isRecord(value) && isRecord(result[key])) restoreNullValues(result[key], value);
89
- }
90
88
  function getTsconfigContent(fullPath, force, type) {
91
89
  const generated = { compilerOptions: getCompilerOptions(type) };
92
90
  if (!existsSync(fullPath)) return `${JSON.stringify(generated, null, 2)}\n`;
@@ -94,7 +92,7 @@ function getTsconfigContent(fullPath, force, type) {
94
92
  try {
95
93
  existing = JSON.parse(readFileSync(fullPath, "utf8"));
96
94
  } catch (error) {
97
- if (!force) throw new Error(`Failed to parse ${path.basename(fullPath)}: ${String(error)}`);
95
+ if (!force) throw new Error(`Failed to parse ${path.basename(fullPath)}: ${String(error)}`, { cause: error });
98
96
  return `${JSON.stringify(generated, null, 2)}\n`;
99
97
  }
100
98
  if (!isRecord(existing)) {
@@ -137,8 +135,7 @@ function createConfigs({ cwd, force, type }) {
137
135
  if (created.length === 0) console.log("No files created.");
138
136
  else console.log("Created:", created.join(", "));
139
137
  }
140
- //#endregion
141
- //#region src/utils/registry.ts
138
+ // src/utils/registry.ts
142
139
  function getRegistry(env = process.env) {
143
140
  return (env.npm_config_registry || env.NPM_CONFIG_REGISTRY || "https://registry.npmjs.org").replace(/\/+$/, "");
144
141
  }
@@ -155,8 +152,7 @@ async function getLatestVersion(name, registry) {
155
152
  clearTimeout(timeout);
156
153
  }
157
154
  }
158
- //#endregion
159
- //#region src/utils/package-json.ts
155
+ // src/utils/package-json.ts
160
156
  function sortObjectKeys(obj) {
161
157
  return Object.fromEntries(Object.entries(obj).sort(([a], [b]) => a.localeCompare(b)));
162
158
  }
@@ -184,7 +180,7 @@ function ensureDevDependency(pkg, name, versionRange) {
184
180
  }
185
181
  function getSelfVersionRange() {
186
182
  try {
187
- const moduleDirectory = path.dirname(fileURLToPath(import.meta.url));
183
+ const moduleDirectory = import.meta.dirname;
188
184
  const packagePath = [path.resolve(moduleDirectory, "..", "package.json"), path.resolve(moduleDirectory, "..", "..", "package.json")].find((candidate) => existsSync(candidate));
189
185
  if (!packagePath) return "latest";
190
186
  const pkg = JSON.parse(readFileSync(packagePath, "utf8"));
@@ -235,15 +231,11 @@ async function updateProjectPackage({ projectRoot, registry }) {
235
231
  } catch (error) {
236
232
  console.log("Created helper configs, but failed to write package.json.", error);
237
233
  }
238
- const missingTools = [
239
- "oxfmt",
240
- "oxlint",
241
- "typescript"
242
- ].filter((name) => !hasDependency(projectPackage, name));
234
+ const missingTools = ["oxfmt", "oxlint"].filter((name) => !hasDependency(projectPackage, name));
235
+ if (!hasDependency(projectPackage, "typescript") && !hasDependency(projectPackage, "tsrs")) missingTools.push("tsrs/typescript");
243
236
  if (missingTools.length > 0) console.log(`Hint: Install ${missingTools.join(" and ")} to use the generated configs.`);
244
237
  }
245
- //#endregion
246
- //#region src/cli.ts
238
+ // src/cli.ts
247
239
  function parseType(argv) {
248
240
  const index = argv.findIndex((arg) => arg === "--type" || arg.startsWith("--type="));
249
241
  if (index < 0) return "lib";
@@ -281,5 +273,4 @@ async function main(argv = process.argv.slice(2)) {
281
273
  });
282
274
  return 0;
283
275
  }
284
- //#endregion
285
276
  export { main, parseType };
package/dist/oxfmt.d.mts CHANGED
@@ -1,6 +1,4 @@
1
1
  import { OxfmtConfig } from "oxfmt";
2
- //#region src/oxfmt.d.ts
3
2
  export declare const CONFIG: OxfmtConfig;
4
3
  export declare function subfFmt(config?: OxfmtConfig): OxfmtConfig;
5
- //#endregion
6
4
  export { CONFIG as default, type OxfmtConfig };
package/dist/oxfmt.mjs CHANGED
@@ -1,5 +1,4 @@
1
- import { defu } from "defu";
2
- //#region src/oxfmt.ts
1
+ // src/oxfmt.ts
3
2
  const CONFIG = {
4
3
  semi: false,
5
4
  singleQuote: true,
@@ -13,8 +12,21 @@ const CONFIG = {
13
12
  ["index", "type-index"]
14
13
  ] }
15
14
  };
16
- function subfFmt(config) {
17
- return defu(CONFIG, config);
15
+ function subfFmt(config = {}) {
16
+ if (config.sortImports !== void 0 && typeof config.sortImports !== "object") return {
17
+ ...CONFIG,
18
+ ...config
19
+ };
20
+ const base = typeof CONFIG.sortImports === "object" ? CONFIG.sortImports : {};
21
+ const override = config.sortImports ?? {};
22
+ return {
23
+ ...CONFIG,
24
+ ...config,
25
+ sortImports: {
26
+ ...base,
27
+ ...override,
28
+ groups: [...base.groups ?? [], ...override.groups ?? []]
29
+ }
30
+ };
18
31
  }
19
- //#endregion
20
32
  export { CONFIG, CONFIG as default, subfFmt };
package/dist/oxlint.d.mts CHANGED
@@ -1,22 +1,26 @@
1
- import { FILES_TS_TSX, solidConfig as solid } from "@subf/oxlint-plugin/config";
2
1
  import { OxlintConfig, OxlintOverride } from "oxlint";
3
- //#region src/oxlint.d.ts
2
+ import { FILES_TS_TSX, solidConfig as solid, solidV2Config as solidV2, solidV2StrictConfig as solidV2Strict } from "@subf/oxlint-plugin/config";
4
3
  export declare const baseConfig: OxlintConfig;
5
4
  export declare const baseRules: OxlintConfig;
6
5
  export declare const ts: OxlintOverride;
7
6
  export declare const vitest: OxlintOverride;
7
+ export declare const typeAware: OxlintConfig;
8
8
  export declare const markdownOverrideConfig: OxlintOverride;
9
- export declare const overrides: OxlintOverride[];
9
+ export declare const overrides: Array<OxlintOverride>;
10
10
  export declare const CONFIG: OxlintConfig;
11
11
  export declare const unocss: OxlintOverride;
12
+ export type SolidPreset = 'v1' | 'v2' | 'v2strict';
12
13
  export interface SubfOptions extends OxlintConfig {
13
14
  /**
14
15
  * Used for lib, force to explicit function return type
15
16
  */
16
17
  lib?: boolean;
17
- solid?: boolean;
18
+ /**
19
+ * SolidJS lint preset. Passing `true` defaults to `'v2strict'`.
20
+ */
21
+ solid?: boolean | SolidPreset;
22
+ typeAware?: boolean;
18
23
  unocss?: boolean;
19
24
  }
20
25
  export declare function subfLint(options?: SubfOptions): OxlintConfig;
21
- //#endregion
22
- export { CONFIG as default, FILES_TS_TSX, type OxlintConfig, type OxlintOverride, solid };
26
+ export { CONFIG as default, FILES_TS_TSX, type OxlintConfig, type OxlintOverride, solid, solidV2, solidV2Strict };
package/dist/oxlint.mjs CHANGED
@@ -1,6 +1,5 @@
1
- import { defu } from "defu";
2
- import { FILES_TS_TSX, FILES_TS_TSX as FILES_TS_TSX$1, solidConfig, solidConfig as solid } from "@subf/oxlint-plugin/config";
3
- //#region src/oxlint.ts
1
+ import { FILES_TS_TSX, FILES_TS_TSX as FILES_TS_TSX$1, solidConfig, solidConfig as solid, solidV2Config, solidV2Config as solidV2, solidV2StrictConfig, solidV2StrictConfig as solidV2Strict } from "@subf/oxlint-plugin/config";
2
+ // src/oxlint.ts
4
3
  const baseConfig = {
5
4
  env: {
6
5
  builtin: true,
@@ -8,6 +7,7 @@ const baseConfig = {
8
7
  es2024: true,
9
8
  node: true
10
9
  },
10
+ options: { reportUnusedDisableDirectives: "error" },
11
11
  globals: {
12
12
  AudioWorkletGlobalScope: "readonly",
13
13
  AudioWorkletProcessor: "readonly",
@@ -88,7 +88,8 @@ const baseRules = {
88
88
  "unicorn",
89
89
  "oxc",
90
90
  "typescript",
91
- "eslint"
91
+ "eslint",
92
+ "promise"
92
93
  ],
93
94
  jsPlugins: [{
94
95
  name: "subf",
@@ -107,6 +108,8 @@ const baseRules = {
107
108
  "default-case-last": "error",
108
109
  "default-param-last": "error",
109
110
  eqeqeq: ["error", "smart"],
111
+ "for-direction": "error",
112
+ "getter-return": "error",
110
113
  "new-cap": ["error", {
111
114
  capIsNew: false,
112
115
  newIsCap: true,
@@ -122,6 +125,7 @@ const baseRules = {
122
125
  "no-class-assign": "error",
123
126
  "no-compare-neg-zero": "error",
124
127
  "no-cond-assign": ["error", "except-parens"],
128
+ "no-console": "warn",
125
129
  "no-const-assign": "error",
126
130
  "no-control-regex": "error",
127
131
  "no-debugger": "error",
@@ -131,6 +135,7 @@ const baseRules = {
131
135
  "no-duplicate-case": "error",
132
136
  "no-empty": ["error", { allowEmptyCatch: true }],
133
137
  "no-empty-pattern": "error",
138
+ "no-empty-static-block": "error",
134
139
  "no-eq-null": "error",
135
140
  "no-eval": "error",
136
141
  "no-ex-assign": "error",
@@ -165,6 +170,7 @@ const baseRules = {
165
170
  "no-new-native-nonconstructor": "error",
166
171
  "no-new-wrappers": "error",
167
172
  "no-obj-calls": "error",
173
+ "no-promise-executor-return": "error",
168
174
  "no-proto": "error",
169
175
  "no-prototype-builtins": "error",
170
176
  "no-redeclare": ["error", { builtinGlobals: false }],
@@ -187,6 +193,7 @@ const baseRules = {
187
193
  "no-template-curly-in-string": "error",
188
194
  "no-this-before-super": "error",
189
195
  "no-throw-literal": "error",
196
+ "no-undef": "error",
190
197
  "no-unexpected-multiline": "error",
191
198
  "no-unmodified-loop-condition": "error",
192
199
  "no-unneeded-ternary": ["error", { defaultAssignment: false }],
@@ -198,12 +205,14 @@ const baseRules = {
198
205
  allowTaggedTemplates: true,
199
206
  allowTernary: true
200
207
  }],
208
+ "no-unused-private-class-members": "error",
201
209
  "no-use-before-define": ["error", {
202
210
  classes: false,
203
211
  functions: false,
204
212
  variables: true
205
213
  }],
206
214
  "no-useless-assignment": "error",
215
+ "no-useless-backreference": "error",
207
216
  "no-useless-call": "error",
208
217
  "no-useless-catch": "error",
209
218
  "no-useless-computed-key": "error",
@@ -211,10 +220,18 @@ const baseRules = {
211
220
  "no-useless-rename": "error",
212
221
  "no-useless-return": "error",
213
222
  "no-var": "error",
223
+ "no-warning-comments": ["error", { terms: ["@nocommit"] }],
214
224
  "no-with": "error",
215
225
  "no-empty-character-class": "error",
216
226
  "no-constructor-return": "error",
217
- "no-unused-vars": "error",
227
+ "no-unused-vars": ["error", {
228
+ args: "none",
229
+ fix: {
230
+ imports: "safe-fix",
231
+ variables: "off"
232
+ },
233
+ varsIgnorePattern: "^_"
234
+ }],
218
235
  "no-nonoctal-decimal-escape": "error",
219
236
  "no-setter-return": "error",
220
237
  "no-unused-labels": "error",
@@ -224,11 +241,17 @@ const baseRules = {
224
241
  "no-useless-escape": "error",
225
242
  "no-unsafe-optional-chaining": "error",
226
243
  "object-shorthand": ["error", "always"],
244
+ "prefer-arrow-callback": ["error", { allowNamedFunctions: true }],
245
+ "prefer-const": "error",
227
246
  "prefer-exponentiation-operator": "error",
247
+ "prefer-object-has-own": "error",
248
+ "prefer-promise-reject-errors": "error",
228
249
  "prefer-rest-params": "error",
229
250
  "prefer-regex-literals": "error",
230
251
  "prefer-spread": "error",
231
252
  "prefer-template": "error",
253
+ "preserve-caught-error": "error",
254
+ "require-yield": "error",
232
255
  "symbol-description": "error",
233
256
  "unicode-bom": ["error", "never"],
234
257
  "use-isnan": ["error", {
@@ -242,6 +265,8 @@ const baseRules = {
242
265
  "node/no-exports-assign": "error",
243
266
  "node/no-new-require": "error",
244
267
  "node/no-path-concat": "error",
268
+ "promise/no-multiple-resolved": "error",
269
+ "promise/no-return-in-finally": "error",
245
270
  "jsdoc/check-access": "warn",
246
271
  "jsdoc/check-property-names": "warn",
247
272
  "jsdoc/empty-tags": "warn",
@@ -252,39 +277,80 @@ const baseRules = {
252
277
  "jsdoc/require-property-description": "warn",
253
278
  "jsdoc/require-property-name": "warn",
254
279
  "jsdoc/require-returns-description": "warn",
280
+ "unicorn/catch-error-name": "error",
255
281
  "unicorn/consistent-empty-array-spread": "error",
282
+ "unicorn/consistent-function-scoping": "error",
256
283
  "unicorn/error-message": "error",
257
284
  "unicorn/escape-case": "error",
258
285
  "unicorn/new-for-builtins": "error",
286
+ "unicorn/no-abusive-eslint-disable": "error",
287
+ "unicorn/no-hex-escape": "error",
259
288
  "unicorn/no-instanceof-builtins": "error",
260
289
  "unicorn/no-instanceof-array": "error",
290
+ "unicorn/no-invalid-fetch-options": "error",
291
+ "unicorn/no-invalid-remove-event-listener": "error",
292
+ "unicorn/no-magic-array-flat-depth": "error",
261
293
  "unicorn/no-new-array": "off",
262
294
  "unicorn/no-new-buffer": "error",
263
295
  "unicorn/no-array-fill-with-reference-type": "error",
296
+ "unicorn/no-typeof-undefined": "error",
297
+ "unicorn/no-unnecessary-slice-end": "error",
298
+ "unicorn/no-useless-promise-resolve-reject": "error",
299
+ "unicorn/no-useless-spread": "error",
300
+ "unicorn/numeric-separators-style": "error",
264
301
  "unicorn/prefer-array-find": "error",
265
302
  "unicorn/prefer-array-flat-map": "error",
303
+ "unicorn/prefer-array-index-of": "error",
266
304
  "unicorn/prefer-array-some": "error",
305
+ "unicorn/prefer-at": "error",
267
306
  "unicorn/prefer-code-point": "error",
268
307
  "unicorn/prefer-date-now": "error",
308
+ "unicorn/prefer-dom-node-append": "error",
269
309
  "unicorn/prefer-dom-node-text-content": "error",
310
+ "unicorn/prefer-import-meta-properties": "error",
270
311
  "unicorn/prefer-includes": "error",
312
+ "unicorn/prefer-native-coercion-functions": "error",
271
313
  "unicorn/prefer-node-protocol": "error",
272
314
  "unicorn/prefer-number-properties": "error",
315
+ "unicorn/prefer-optional-catch-binding": "error",
316
+ "unicorn/prefer-set-size": "error",
317
+ "unicorn/prefer-single-call": "error",
318
+ "unicorn/prefer-string-raw": "error",
319
+ "unicorn/prefer-string-replace-all": "error",
320
+ "unicorn/prefer-string-slice": "error",
273
321
  "unicorn/prefer-string-starts-ends-with": "error",
322
+ "unicorn/prefer-structured-clone": "error",
323
+ "unicorn/prefer-top-level-await": "error",
274
324
  "unicorn/prefer-type-error": "error",
275
325
  "unicorn/prefer-set-has": "error",
276
326
  "unicorn/switch-case-braces": ["error", "avoid"],
327
+ "unicorn/text-encoding-identifier-case": "error",
277
328
  "unicorn/throw-new-error": "error",
278
329
  "import/consistent-type-specifier-style": "error",
330
+ "import/export": "error",
279
331
  "import/no-absolute-path": "error",
280
332
  "import/no-cycle": "error",
281
333
  "import/no-duplicates": "error",
334
+ "import/no-namespace": "error",
282
335
  "import/no-self-import": "error",
283
336
  "import/no-named-export": "allow",
284
337
  "import/first": "error",
285
338
  "oxc/no-map-spread": "error",
286
339
  "oxc/misrefactored-assign-op": "error",
287
- "oxc/no-this-in-exported-function": "error"
340
+ "oxc/no-this-in-exported-function": "error",
341
+ "oxc/approx-constant": "error",
342
+ "oxc/bad-bitwise-operator": "error",
343
+ "oxc/bad-char-at-comparison": "error",
344
+ "oxc/bad-comparison-sequence": "error",
345
+ "oxc/bad-min-max-func": "error",
346
+ "oxc/bad-object-literal-comparison": "error",
347
+ "oxc/bad-replace-all-arg": "error",
348
+ "oxc/const-comparisons": "error",
349
+ "oxc/double-comparisons": "error",
350
+ "oxc/missing-throw": "error",
351
+ "oxc/no-accumulating-spread": "error",
352
+ "oxc/number-arg-out-of-range": "error",
353
+ "oxc/uninvoked-array-callback": "error"
288
354
  }
289
355
  };
290
356
  const ts = {
@@ -302,6 +368,7 @@ const ts = {
302
368
  "no-redeclare": ["error", { builtinGlobals: false }],
303
369
  "no-setter-return": "off",
304
370
  "no-this-before-super": "off",
371
+ "no-undef": "off",
305
372
  "no-unsafe-negation": "off",
306
373
  "no-with": "off",
307
374
  "no-unused-expressions": ["error", {
@@ -315,16 +382,22 @@ const ts = {
315
382
  functions: false,
316
383
  variables: true
317
384
  }],
385
+ "typescript/array-type": ["error", { default: "generic" }],
318
386
  "typescript/ban-ts-comment": ["error", { "ts-expect-error": "allow-with-description" }],
319
387
  "typescript/dot-notation": "error",
320
388
  "typescript/method-signature-style": ["error", "property"],
389
+ "typescript/no-confusing-non-null-assertion": "error",
321
390
  "typescript/no-duplicate-enum-values": "error",
391
+ "typescript/no-empty-object-type": "error",
392
+ "typescript/no-explicit-any": "error",
322
393
  "typescript/no-extra-non-null-assertion": "error",
323
394
  "typescript/no-misused-new": "error",
324
395
  "typescript/no-non-null-asserted-nullish-coalescing": "error",
325
396
  "typescript/no-non-null-asserted-optional-chain": "error",
397
+ "typescript/no-non-null-assertion": "error",
326
398
  "typescript/no-require-imports": "error",
327
399
  "typescript/no-this-alias": "error",
400
+ "typescript/no-unnecessary-parameter-property-assignment": "error",
328
401
  "typescript/no-unnecessary-type-constraint": "error",
329
402
  "typescript/no-unnecessary-type-conversion": "error",
330
403
  "typescript/no-unnecessary-type-assertion": "error",
@@ -344,7 +417,8 @@ const ts = {
344
417
  prefer: "type-imports"
345
418
  }],
346
419
  "typescript/no-import-type-side-effects": "error",
347
- "typescript/no-unnecessary-type-arguments": "error"
420
+ "typescript/no-unnecessary-type-arguments": "error",
421
+ "typescript/triple-slash-reference": "error"
348
422
  }
349
423
  };
350
424
  const vitest = {
@@ -366,9 +440,65 @@ const vitest = {
366
440
  "vitest/prefer-hooks-in-order": "error",
367
441
  "vitest/prefer-lowercase-title": "error",
368
442
  "vitest/prefer-called-exactly-once-with": "warn",
369
- "no-unused-expressions": "off"
443
+ "vitest/require-awaited-expect-poll": "error",
444
+ "no-unused-expressions": "off",
445
+ "typescript/no-explicit-any": "off",
446
+ "typescript/no-non-null-assertion": "off"
370
447
  }
371
448
  };
449
+ const typeAware = {
450
+ options: { typeAware: true },
451
+ rules: {
452
+ "typescript/await-thenable": ["error", { allowMixedPromiseArrays: true }],
453
+ "typescript/no-array-delete": "error",
454
+ "typescript/no-deprecated": "warn",
455
+ "typescript/no-duplicate-type-constituents": "error",
456
+ "typescript/no-floating-promises": "error",
457
+ "typescript/no-for-in-array": "error",
458
+ "typescript/no-misused-promises": "error",
459
+ "typescript/no-misused-spread": "error",
460
+ "typescript/no-unsafe-argument": "error",
461
+ "typescript/no-unsafe-assignment": "error",
462
+ "typescript/no-unsafe-call": "error",
463
+ "typescript/no-unsafe-member-access": "error",
464
+ "typescript/no-unsafe-return": "error",
465
+ "typescript/no-unsafe-type-assertion": "error",
466
+ "typescript/no-unsafe-unary-minus": "error",
467
+ "typescript/require-array-sort-compare": "error",
468
+ "typescript/return-await": ["error", "error-handling-correctness-only"],
469
+ "typescript/unbound-method": "error",
470
+ "typescript/use-unknown-in-catch-callback-variable": "error"
471
+ },
472
+ overrides: [
473
+ {
474
+ files: FILES_TS_TSX$1,
475
+ rules: {
476
+ "no-throw-literal": "off",
477
+ "typescript/only-throw-error": "error"
478
+ }
479
+ },
480
+ {
481
+ files: ["**/*.{test,spec,integration,e2e}.{ts,tsx,mts,cts}", "**/__tests__/**/*.{ts,tsx,mts,cts}"],
482
+ rules: {
483
+ "typescript/no-unsafe-argument": "off",
484
+ "typescript/no-unsafe-assignment": "off",
485
+ "typescript/no-unsafe-member-access": "off",
486
+ "typescript/only-throw-error": "off",
487
+ "typescript/unbound-method": "off"
488
+ }
489
+ },
490
+ {
491
+ files: ["**/*.{js,jsx,mjs,cjs}"],
492
+ rules: {
493
+ "typescript/no-unsafe-argument": "off",
494
+ "typescript/no-unsafe-assignment": "off",
495
+ "typescript/no-unsafe-call": "off",
496
+ "typescript/no-unsafe-member-access": "off",
497
+ "typescript/no-unsafe-return": "off"
498
+ }
499
+ }
500
+ ]
501
+ };
372
502
  const markdownOverrideConfig = {
373
503
  files: ["**/*.md/**/*.?([cm])[jt]s?(x)"],
374
504
  rules: {
@@ -402,8 +532,9 @@ const unocss = {
402
532
  }
403
533
  };
404
534
  function subfLint(options = {}) {
405
- const { lib, unocss: enableUnocss, solid: enableSolid, overrides, ...oxlint } = options;
406
- const ovr = [vitest, markdownOverrideConfig];
535
+ const { lib, unocss: enableUnocss, solid: enableSolid, typeAware: enableTypeAware, overrides, extends: userExtends, ...oxlint } = options;
536
+ const ovr = [];
537
+ let solidSettings;
407
538
  if (lib) ovr.push({
408
539
  ...ts,
409
540
  rules: {
@@ -416,10 +547,54 @@ function subfLint(options = {}) {
416
547
  }
417
548
  });
418
549
  else ovr.push(ts);
550
+ ovr.push(vitest, markdownOverrideConfig);
419
551
  if (enableUnocss) ovr.push(unocss);
420
- if (enableSolid) ovr.push(solidConfig);
552
+ if (enableSolid) {
553
+ const solidPreset = enableSolid === true ? "v2strict" : enableSolid;
554
+ if (solidPreset === "v1") ovr.push(solidConfig);
555
+ else {
556
+ const preset = solidPreset === "v2" ? solidV2Config : solidV2StrictConfig;
557
+ if (preset.overrides) ovr.push(...preset.overrides);
558
+ solidSettings = preset.settings;
559
+ }
560
+ }
561
+ if (enableTypeAware && typeAware.overrides) ovr.push(...typeAware.overrides);
421
562
  if (overrides) ovr.push(...overrides);
422
- return defu(oxlint, baseConfig, baseRules, { overrides: ovr });
563
+ return {
564
+ ...oxlint,
565
+ env: {
566
+ ...baseConfig.env,
567
+ ...oxlint.env
568
+ },
569
+ globals: {
570
+ ...baseConfig.globals,
571
+ ...oxlint.globals
572
+ },
573
+ settings: {
574
+ ...solidSettings,
575
+ ...oxlint.settings
576
+ },
577
+ options: {
578
+ ...baseConfig.options,
579
+ ...enableTypeAware ? typeAware.options : {},
580
+ ...oxlint.options
581
+ },
582
+ plugins: [
583
+ ...baseRules.plugins ?? [],
584
+ ...(userExtends ?? []).flatMap((config) => config.plugins ?? []),
585
+ ...oxlint.plugins ?? []
586
+ ],
587
+ ignorePatterns: [
588
+ ...baseConfig.ignorePatterns ?? [],
589
+ ...(userExtends ?? []).flatMap((config) => config.ignorePatterns ?? []),
590
+ ...oxlint.ignorePatterns ?? []
591
+ ],
592
+ extends: [
593
+ baseRules,
594
+ ...enableTypeAware ? [{ rules: typeAware.rules }] : [],
595
+ ...userExtends ?? []
596
+ ],
597
+ overrides: ovr
598
+ };
423
599
  }
424
- //#endregion
425
- export { CONFIG, CONFIG as default, FILES_TS_TSX, baseConfig, baseRules, markdownOverrideConfig, overrides, solid, subfLint, ts, unocss, vitest };
600
+ export { CONFIG, CONFIG as default, FILES_TS_TSX, baseConfig, baseRules, markdownOverrideConfig, overrides, solid, solidV2, solidV2Strict, subfLint, ts, typeAware, unocss, vitest };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@subf/config",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Universal configuration for TypeScript, oxlint (+unocss, +solid), oxfmt, and tsdown.",
5
5
  "keywords": [
6
6
  "config",
@@ -42,25 +42,20 @@
42
42
  "access": "public"
43
43
  },
44
44
  "dependencies": {
45
- "@subf/oxlint-plugin": "^0.3.0"
45
+ "@subf/oxlint-plugin": "^0.4.0"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@types/node": "^24",
49
49
  "bumpp": "^11.1.0",
50
- "oxfmt": "^0.71.0",
51
- "oxlint": "^1.86.0",
52
- "tsdown": "^0.23.0",
53
- "typescript": "^7.0.2"
54
- },
55
- "peerDependencies": {
56
- "defu": "^6.1.7",
57
- "oxfmt": "^0",
58
- "oxlint": "^1"
50
+ "oxfmt": "^0.79.0",
51
+ "oxlint": "^1.94.0",
52
+ "tsdown": "^0.23.7",
53
+ "tsrs": "0.25.0-ts7.1.0-beta"
59
54
  },
60
55
  "scripts": {
61
56
  "build": "tsdown",
62
57
  "dev": "tsdown --watch",
63
- "typecheck": "tsc --noEmit",
58
+ "typecheck": "tsrs --noEmit --fast",
64
59
  "lint": "oxlint --fix",
65
60
  "format": "oxfmt",
66
61
  "release": "bumpp --all",