@subf/config 0.1.1 → 0.1.3

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
@@ -1,6 +1,6 @@
1
1
  # @subf/config
2
2
 
3
- Universal configuration for TypeScript, SolidJS, oxlint, oxfmt, and tsdown.
3
+ Universal configuration for TypeScript, oxlint (+unocss, +solid), oxfmt, and tsdown.
4
4
 
5
5
  ## Quick start
6
6
 
package/bin/subf.js CHANGED
@@ -1,9 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  import { existsSync, readFileSync, writeFileSync } from 'node:fs'
3
3
  import path from 'node:path'
4
- import { fileURLToPath } from 'node:url'
5
4
 
6
- export function createConfigs({ cwd = process.cwd(), force = false } = {}) {
5
+ function createConfigs({ cwd = process.cwd(), force = false } = {}) {
7
6
  const files = [
8
7
  {
9
8
  name: 'oxfmt.config.ts',
@@ -42,62 +41,59 @@ export function createConfigs({ cwd = process.cwd(), force = false } = {}) {
42
41
  return created
43
42
  }
44
43
 
45
- // If invoked directly, run with CLI args
46
- if (fileURLToPath(import.meta.url) === process.argv[1]) {
47
- const projectRoot = process.env.INIT_CWD || process.cwd()
48
- const args = new Set(process.argv.slice(2))
49
- const force = args.has('--force') || args.has('-f')
50
- const help = args.has('--help') || args.has('-h')
44
+ const projectRoot = process.env.INIT_CWD || process.cwd()
45
+ const args = new Set(process.argv.slice(2))
46
+ const force = args.has('--force') || args.has('-f')
47
+ const help = args.has('--help') || args.has('-h')
51
48
 
52
- if (help) {
53
- console.log('Usage: subf [-f|--force]')
54
- console.log('Create helper config files in the current project:')
55
- console.log(' oxfmt.config.ts, oxlint.config.ts, tsconfig.json')
56
- console.log('Use -f or --force to overwrite existing files.')
57
- process.exit(0)
58
- }
59
-
60
- try {
61
- createConfigs({ cwd: projectRoot, force })
62
- } catch (err) {
63
- console.error('Failed to create config files:', err)
64
- process.exit(1)
65
- }
49
+ if (help) {
50
+ console.log('Usage: subf [-f|--force]')
51
+ console.log('Create helper config files in the current project:')
52
+ console.log(' oxfmt.config.ts, oxlint.config.ts, tsconfig.json')
53
+ console.log('Use -f or --force to overwrite existing files.')
54
+ process.exit(0)
55
+ }
66
56
 
67
- // If project has package.json, suggest installing @subf/config when it's not listed
68
- const projectPkgPath = path.join(projectRoot, 'package.json')
69
- if (!existsSync(projectPkgPath)) {
70
- console.log('No package.json found in project root.')
71
- console.log('To keep these configs in sync, install @subf/config as a devDependency:')
72
- console.log(' bun i -D @subf/config')
73
- console.log(' npm i -D @subf/config')
74
- process.exit(0)
75
- }
57
+ try {
58
+ createConfigs({ cwd: projectRoot, force })
59
+ } catch (err) {
60
+ console.error('Failed to create config files:', err)
61
+ process.exit(1)
62
+ }
76
63
 
77
- let projectPkg
78
- try {
79
- projectPkg = JSON.parse(readFileSync(projectPkgPath, 'utf8'))
80
- } catch (err) {
81
- console.log(
82
- 'Created helper configs. Could not read package.json to suggest install command.',
83
- err && (err.message || err),
84
- )
85
- process.exit(0)
86
- }
64
+ // If project has package.json, suggest installing @subf/config when it's not listed
65
+ const projectPkgPath = path.join(projectRoot, 'package.json')
66
+ if (!existsSync(projectPkgPath)) {
67
+ console.log('No package.json found in project root.')
68
+ console.log('To keep these configs in sync, install @subf/config as a devDependency:')
69
+ console.log(' bun i -D @subf/config')
70
+ console.log(' npm i -D @subf/config')
71
+ process.exit(0)
72
+ }
87
73
 
88
- const hasDep =
89
- (projectPkg.devDependencies && projectPkg.devDependencies['@subf/config']) ||
90
- (projectPkg.dependencies && projectPkg.dependencies['@subf/config'])
74
+ let projectPkg
75
+ try {
76
+ projectPkg = JSON.parse(readFileSync(projectPkgPath, 'utf8'))
77
+ } catch (err) {
78
+ console.log(
79
+ 'Created helper configs. Could not read package.json to suggest install command.',
80
+ err && (err.message || err),
81
+ )
82
+ process.exit(0)
83
+ }
91
84
 
92
- if (hasDep) {
93
- console.log('Helper configs created. @subf/config is present in package.json.')
94
- } else {
95
- console.log(
96
- 'Helper configs created. To keep them in sync, install @subf/config as a devDependency:',
97
- )
98
- console.log(' bun i -D @subf/config')
99
- console.log(' npm i -D @subf/config')
100
- }
85
+ const hasDep =
86
+ (projectPkg.devDependencies && projectPkg.devDependencies['@subf/config']) ||
87
+ (projectPkg.dependencies && projectPkg.dependencies['@subf/config'])
101
88
 
102
- process.exit(0)
89
+ if (hasDep) {
90
+ console.log('Helper configs created. @subf/config is present in package.json.')
91
+ } else {
92
+ console.log(
93
+ 'Helper configs created. To keep them in sync, install @subf/config as a devDependency:',
94
+ )
95
+ console.log(' bun i -D @subf/config')
96
+ console.log(' npm i -D @subf/config')
103
97
  }
98
+
99
+ process.exit(0)
package/dist/oxlint.d.ts CHANGED
@@ -10,7 +10,7 @@ declare const markdownOverrideConfig: OxlintOverride;
10
10
  declare const overrides: OxlintOverride[];
11
11
  declare const CONFIG: OxlintConfig;
12
12
  declare const unocss: OxlintOverride;
13
- interface SubfOpions extends OxlintConfig {
13
+ interface SubfOptions extends OxlintConfig {
14
14
  /**
15
15
  * Used for lib, force to explicit function return type
16
16
  */
@@ -18,6 +18,6 @@ interface SubfOpions extends OxlintConfig {
18
18
  solid?: boolean;
19
19
  unocss?: boolean;
20
20
  }
21
- declare function subfLint(options?: SubfOpions): OxlintConfig;
21
+ declare function subfLint(options?: SubfOptions): OxlintConfig;
22
22
  //#endregion
23
- export { CONFIG, CONFIG as default, FILES_TS_TSX, SubfOpions, baseConfig, baseRules, markdownOverrideConfig, overrides, solid, subfLint, ts, unocss, vitest };
23
+ export { CONFIG, CONFIG as default, FILES_TS_TSX, SubfOptions, baseConfig, baseRules, markdownOverrideConfig, overrides, solid, subfLint, ts, unocss, vitest };
package/dist/oxlint.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { FILES_TS_TSX, FILES_TS_TSX as FILES_TS_TSX$1, solidConfig, solidConfig as solid } from "@subf/oxlint-plugin/config";
2
+ import { defu } from "defu";
2
3
  //#region src/oxlint.ts
3
4
  const baseConfig = {
4
5
  env: {
@@ -112,7 +113,7 @@ const baseRules = {
112
113
  "no-case-declarations": "error",
113
114
  "no-class-assign": "error",
114
115
  "no-compare-neg-zero": "error",
115
- "no-cond-assign": ["error", "always"],
116
+ "no-cond-assign": ["error", "except-parens"],
116
117
  "no-const-assign": "error",
117
118
  "no-control-regex": "error",
118
119
  "no-debugger": "error",
@@ -209,6 +210,7 @@ const baseRules = {
209
210
  "no-constant-condition": "error",
210
211
  "no-useless-escape": "error",
211
212
  "no-unsafe-optional-chaining": "error",
213
+ "object-shorthand": ["error", "always"],
212
214
  "prefer-exponentiation-operator": "error",
213
215
  "prefer-rest-params": "error",
214
216
  "prefer-spread": "error",
@@ -242,7 +244,7 @@ const baseRules = {
242
244
  "unicorn/new-for-builtins": "error",
243
245
  "unicorn/no-instanceof-builtins": "error",
244
246
  "unicorn/no-instanceof-array": "error",
245
- "unicorn/no-new-array": "allow",
247
+ "unicorn/no-new-array": "off",
246
248
  "unicorn/no-new-buffer": "error",
247
249
  "unicorn/number-literal-case": "error",
248
250
  "unicorn/prefer-array-find": "error",
@@ -256,8 +258,9 @@ const baseRules = {
256
258
  "unicorn/prefer-number-properties": "error",
257
259
  "unicorn/prefer-string-starts-ends-with": "error",
258
260
  "unicorn/prefer-type-error": "error",
259
- "unicorn/throw-new-error": "error",
260
261
  "unicorn/prefer-set-has": "error",
262
+ "unicorn/switch-case-braces": ["error", "avoid"],
263
+ "unicorn/throw-new-error": "error",
261
264
  "import/consistent-type-specifier-style": "error",
262
265
  "import/no-absolute-path": "error",
263
266
  "import/no-duplicates": "error",
@@ -303,6 +306,7 @@ const ts = {
303
306
  variables: true
304
307
  }],
305
308
  "typescript/ban-ts-comment": ["error", { "ts-expect-error": "allow-with-description" }],
309
+ "typescript/dot-notation": "error",
306
310
  "typescript/no-duplicate-enum-values": "error",
307
311
  "typescript/no-extra-non-null-assertion": "error",
308
312
  "typescript/no-misused-new": "error",
@@ -311,6 +315,7 @@ const ts = {
311
315
  "typescript/no-require-imports": "error",
312
316
  "typescript/no-this-alias": "error",
313
317
  "typescript/no-unnecessary-type-constraint": "error",
318
+ "typescript/no-unnecessary-type-conversion": "error",
314
319
  "typescript/no-unnecessary-type-assertion": "error",
315
320
  "typescript/no-unsafe-declaration-merging": "error",
316
321
  "typescript/no-unsafe-function-type": "error",
@@ -382,7 +387,7 @@ const unocss = {
382
387
  }
383
388
  };
384
389
  function subfLint(options = {}) {
385
- const { lib, unocss: enableUnocss, solid: enableSolid, overrides: customOverrides = [], ...oxlint } = options;
390
+ const { lib, unocss: enableUnocss, solid: enableSolid, ...oxlint } = options;
386
391
  const ovr = [vitest, markdownOverrideConfig];
387
392
  if (lib) ovr.push({
388
393
  ...ts,
@@ -398,13 +403,7 @@ function subfLint(options = {}) {
398
403
  else ovr.push(ts);
399
404
  if (enableUnocss) ovr.push(unocss);
400
405
  if (enableSolid) ovr.push(solidConfig);
401
- ovr.push(...customOverrides);
402
- return {
403
- ...baseConfig,
404
- ...baseRules,
405
- ...oxlint,
406
- overrides: ovr
407
- };
406
+ return defu(oxlint, baseConfig, baseRules, { overrides: ovr });
408
407
  }
409
408
  //#endregion
410
409
  export { CONFIG, CONFIG as default, FILES_TS_TSX, baseConfig, baseRules, markdownOverrideConfig, overrides, solid, subfLint, ts, unocss, vitest };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@subf/config",
3
- "version": "0.1.1",
4
- "description": "Universal configuration for TypeScript, SolidJS, oxlint, oxfmt, and tsdown.",
3
+ "version": "0.1.3",
4
+ "description": "Universal configuration for TypeScript, oxlint (+unocss, +solid), oxfmt, and tsdown.",
5
5
  "keywords": [
6
6
  "config",
7
7
  "configuration",
@@ -56,15 +56,18 @@
56
56
  "prepublishOnly": "bun run build"
57
57
  },
58
58
  "dependencies": {
59
- "@subf/oxlint-plugin": "^0.2.0"
59
+ "@subf/oxlint-plugin": "^0.2.2"
60
60
  },
61
61
  "devDependencies": {
62
- "@oxlint/plugins": "^1.58.0",
62
+ "@oxlint/plugins": "^1.59.0",
63
63
  "@types/bun": "^1.3.11",
64
64
  "bumpp": "^11.0.1",
65
- "oxfmt": "^0.43.0",
66
- "oxlint": "^1.58.0",
65
+ "oxfmt": "^0.44.0",
66
+ "oxlint": "^1.59.0",
67
67
  "tsdown": "^0.21.7",
68
68
  "typescript": "^5.9.3"
69
+ },
70
+ "peerDependencies": {
71
+ "defu": "*"
69
72
  }
70
73
  }
@@ -7,7 +7,6 @@
7
7
  "strict": true,
8
8
  "strictNullChecks": true,
9
9
  "noUnusedLocals": true,
10
- "noUncheckedIndexedAccess": true,
11
10
  "noImplicitOverride": true,
12
11
  "esModuleInterop": true,
13
12
  "isolatedModules": true,
package/tsconfig.lib.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "extends": "./tsconfig.base.json",
3
3
  "compilerOptions": {
4
- "moduleResolution": "bundler"
4
+ "moduleResolution": "bundler",
5
+ "noUncheckedIndexedAccess": true
5
6
  }
6
7
  }