@subf/config 0.1.0 → 0.1.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 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
@@ -1,16 +1,15 @@
1
+ import { FILES_TS_TSX, solidConfig as solid } from "@subf/oxlint-plugin/config";
1
2
  import { OxlintConfig, OxlintOverride } from "oxlint";
2
3
 
3
4
  //#region src/oxlint.d.ts
4
5
  declare const baseConfig: OxlintConfig;
5
6
  declare const baseRules: OxlintConfig;
6
- declare const FILES_TS_TSX: string[];
7
7
  declare const ts: OxlintOverride;
8
8
  declare const vitest: OxlintOverride;
9
9
  declare const markdownOverrideConfig: OxlintOverride;
10
10
  declare const overrides: OxlintOverride[];
11
11
  declare const CONFIG: OxlintConfig;
12
12
  declare const unocss: OxlintOverride;
13
- declare const solid: OxlintOverride;
14
13
  interface SubfOpions extends OxlintConfig {
15
14
  /**
16
15
  * Used for lib, force to explicit function return type
package/dist/oxlint.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { FILES_TS_TSX, FILES_TS_TSX as FILES_TS_TSX$1, solidConfig, solidConfig as solid } from "@subf/oxlint-plugin/config";
1
2
  //#region src/oxlint.ts
2
3
  const baseConfig = {
3
4
  env: {
@@ -208,6 +209,7 @@ const baseRules = {
208
209
  "no-constant-condition": "error",
209
210
  "no-useless-escape": "error",
210
211
  "no-unsafe-optional-chaining": "error",
212
+ "object-shorthand": ["error", "always"],
211
213
  "prefer-exponentiation-operator": "error",
212
214
  "prefer-rest-params": "error",
213
215
  "prefer-spread": "error",
@@ -255,8 +257,9 @@ const baseRules = {
255
257
  "unicorn/prefer-number-properties": "error",
256
258
  "unicorn/prefer-string-starts-ends-with": "error",
257
259
  "unicorn/prefer-type-error": "error",
258
- "unicorn/throw-new-error": "error",
259
260
  "unicorn/prefer-set-has": "error",
261
+ "unicorn/switch-case-braces": ["error", "avoid"],
262
+ "unicorn/throw-new-error": "error",
260
263
  "import/consistent-type-specifier-style": "error",
261
264
  "import/no-absolute-path": "error",
262
265
  "import/no-duplicates": "error",
@@ -268,9 +271,8 @@ const baseRules = {
268
271
  "oxc/no-this-in-exported-function": "error"
269
272
  }
270
273
  };
271
- const FILES_TS_TSX = ["**/*.{ts,tsx}"];
272
274
  const ts = {
273
- files: FILES_TS_TSX,
275
+ files: FILES_TS_TSX$1,
274
276
  plugins: ["typescript"],
275
277
  jsPlugins: [{
276
278
  name: "subf",
@@ -303,6 +305,7 @@ const ts = {
303
305
  variables: true
304
306
  }],
305
307
  "typescript/ban-ts-comment": ["error", { "ts-expect-error": "allow-with-description" }],
308
+ "typescript/dot-notation": "error",
306
309
  "typescript/no-duplicate-enum-values": "error",
307
310
  "typescript/no-extra-non-null-assertion": "error",
308
311
  "typescript/no-misused-new": "error",
@@ -311,6 +314,7 @@ const ts = {
311
314
  "typescript/no-require-imports": "error",
312
315
  "typescript/no-this-alias": "error",
313
316
  "typescript/no-unnecessary-type-constraint": "error",
317
+ "typescript/no-unnecessary-type-conversion": "error",
314
318
  "typescript/no-unnecessary-type-assertion": "error",
315
319
  "typescript/no-unsafe-declaration-merging": "error",
316
320
  "typescript/no-unsafe-function-type": "error",
@@ -371,40 +375,16 @@ const CONFIG = {
371
375
  overrides
372
376
  };
373
377
  const unocss = {
374
- files: FILES_TS_TSX,
378
+ files: FILES_TS_TSX$1,
375
379
  jsPlugins: [{
376
380
  name: "uno",
377
- specifier: "@unocss/eslint-plugin"
381
+ specifier: "@subf/unocss/oxlint-plugin"
378
382
  }],
379
383
  rules: {
380
384
  "uno/order": ["warn", { unoFunctions: ["cn", "cva"] }],
381
385
  "uno/blocklist": "error"
382
386
  }
383
387
  };
384
- const solid = {
385
- files: FILES_TS_TSX,
386
- jsPlugins: ["eslint-plugin-solid"],
387
- rules: {
388
- "solid/event-handlers": ["error", {
389
- ignoreCase: false,
390
- warnOnSpread: false
391
- }],
392
- "solid/imports": "error",
393
- "solid/jsx-no-duplicate-props": "error",
394
- "solid/jsx-no-script-url": "error",
395
- "solid/no-destructure": "error",
396
- "solid/no-innerhtml": ["error", { allowStatic: true }],
397
- "solid/no-react-deps": "error",
398
- "solid/no-react-specific-props": "error",
399
- "solid/no-unknown-namespaces": "error",
400
- "solid/prefer-for": "error",
401
- "solid/prefer-show": "error",
402
- "solid/self-closing-comp": "error",
403
- "solid/style-prop": ["error", { styleProps: ["style", "css"] }],
404
- "solid/jsx-no-undef": ["error", { typescriptEnabled: true }],
405
- "solid/reactivity": "warn"
406
- }
407
- };
408
388
  function subfLint(options = {}) {
409
389
  const { lib, unocss: enableUnocss, solid: enableSolid, overrides: customOverrides = [], ...oxlint } = options;
410
390
  const ovr = [vitest, markdownOverrideConfig];
@@ -421,7 +401,7 @@ function subfLint(options = {}) {
421
401
  });
422
402
  else ovr.push(ts);
423
403
  if (enableUnocss) ovr.push(unocss);
424
- if (enableSolid) ovr.push(solid);
404
+ if (enableSolid) ovr.push(solidConfig);
425
405
  ovr.push(...customOverrides);
426
406
  return {
427
407
  ...baseConfig,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@subf/config",
3
- "version": "0.1.0",
4
- "description": "Universal configuration for TypeScript, SolidJS, oxlint, oxfmt, and tsdown.",
3
+ "version": "0.1.2",
4
+ "description": "Universal configuration for TypeScript, oxlint (+unocss, +solid), oxfmt, and tsdown.",
5
5
  "keywords": [
6
6
  "config",
7
7
  "configuration",
@@ -56,14 +56,14 @@
56
56
  "prepublishOnly": "bun run build"
57
57
  },
58
58
  "dependencies": {
59
- "@subf/oxlint-plugin": "^0.1.0"
59
+ "@subf/oxlint-plugin": "^0.2.1"
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
69
  }