@subf/config 0.1.1 → 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 +1 -1
- package/bin/subf.js +50 -54
- package/dist/oxlint.js +5 -1
- package/package.json +6 -6
package/README.md
CHANGED
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
|
-
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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
|
-
|
|
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.js
CHANGED
|
@@ -209,6 +209,7 @@ const baseRules = {
|
|
|
209
209
|
"no-constant-condition": "error",
|
|
210
210
|
"no-useless-escape": "error",
|
|
211
211
|
"no-unsafe-optional-chaining": "error",
|
|
212
|
+
"object-shorthand": ["error", "always"],
|
|
212
213
|
"prefer-exponentiation-operator": "error",
|
|
213
214
|
"prefer-rest-params": "error",
|
|
214
215
|
"prefer-spread": "error",
|
|
@@ -256,8 +257,9 @@ const baseRules = {
|
|
|
256
257
|
"unicorn/prefer-number-properties": "error",
|
|
257
258
|
"unicorn/prefer-string-starts-ends-with": "error",
|
|
258
259
|
"unicorn/prefer-type-error": "error",
|
|
259
|
-
"unicorn/throw-new-error": "error",
|
|
260
260
|
"unicorn/prefer-set-has": "error",
|
|
261
|
+
"unicorn/switch-case-braces": ["error", "avoid"],
|
|
262
|
+
"unicorn/throw-new-error": "error",
|
|
261
263
|
"import/consistent-type-specifier-style": "error",
|
|
262
264
|
"import/no-absolute-path": "error",
|
|
263
265
|
"import/no-duplicates": "error",
|
|
@@ -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",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@subf/config",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Universal configuration for TypeScript,
|
|
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.2.
|
|
59
|
+
"@subf/oxlint-plugin": "^0.2.1"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@oxlint/plugins": "^1.
|
|
62
|
+
"@oxlint/plugins": "^1.59.0",
|
|
63
63
|
"@types/bun": "^1.3.11",
|
|
64
64
|
"bumpp": "^11.0.1",
|
|
65
|
-
"oxfmt": "^0.
|
|
66
|
-
"oxlint": "^1.
|
|
65
|
+
"oxfmt": "^0.44.0",
|
|
66
|
+
"oxlint": "^1.59.0",
|
|
67
67
|
"tsdown": "^0.21.7",
|
|
68
68
|
"typescript": "^5.9.3"
|
|
69
69
|
}
|