@subf/config 0.5.0 → 0.6.1
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 +3 -3
- package/dist/cli.d.mts +3 -6
- package/dist/cli.mjs +27 -36
- package/dist/oxfmt.d.mts +0 -2
- package/dist/oxfmt.mjs +17 -5
- package/dist/oxlint.d.mts +10 -6
- package/dist/oxlint.mjs +195 -21
- package/package.json +7 -12
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
|
-
|
|
5
|
-
|
|
6
|
-
export
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 =
|
|
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
|
-
|
|
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
|
-
|
|
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
package/dist/oxfmt.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 {
|
|
2
|
-
|
|
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",
|
|
@@ -75,7 +75,6 @@ const baseConfig = {
|
|
|
75
75
|
"**/*.min.*",
|
|
76
76
|
"**/LICENSE*",
|
|
77
77
|
"**/__snapshots__",
|
|
78
|
-
"**/auto-import?(s).d.ts",
|
|
79
78
|
"**/components.d.ts",
|
|
80
79
|
"_fixtures"
|
|
81
80
|
]
|
|
@@ -88,7 +87,8 @@ const baseRules = {
|
|
|
88
87
|
"unicorn",
|
|
89
88
|
"oxc",
|
|
90
89
|
"typescript",
|
|
91
|
-
"eslint"
|
|
90
|
+
"eslint",
|
|
91
|
+
"promise"
|
|
92
92
|
],
|
|
93
93
|
jsPlugins: [{
|
|
94
94
|
name: "subf",
|
|
@@ -107,6 +107,8 @@ const baseRules = {
|
|
|
107
107
|
"default-case-last": "error",
|
|
108
108
|
"default-param-last": "error",
|
|
109
109
|
eqeqeq: ["error", "smart"],
|
|
110
|
+
"for-direction": "error",
|
|
111
|
+
"getter-return": "error",
|
|
110
112
|
"new-cap": ["error", {
|
|
111
113
|
capIsNew: false,
|
|
112
114
|
newIsCap: true,
|
|
@@ -122,6 +124,7 @@ const baseRules = {
|
|
|
122
124
|
"no-class-assign": "error",
|
|
123
125
|
"no-compare-neg-zero": "error",
|
|
124
126
|
"no-cond-assign": ["error", "except-parens"],
|
|
127
|
+
"no-console": "warn",
|
|
125
128
|
"no-const-assign": "error",
|
|
126
129
|
"no-control-regex": "error",
|
|
127
130
|
"no-debugger": "error",
|
|
@@ -131,6 +134,7 @@ const baseRules = {
|
|
|
131
134
|
"no-duplicate-case": "error",
|
|
132
135
|
"no-empty": ["error", { allowEmptyCatch: true }],
|
|
133
136
|
"no-empty-pattern": "error",
|
|
137
|
+
"no-empty-static-block": "error",
|
|
134
138
|
"no-eq-null": "error",
|
|
135
139
|
"no-eval": "error",
|
|
136
140
|
"no-ex-assign": "error",
|
|
@@ -165,6 +169,7 @@ const baseRules = {
|
|
|
165
169
|
"no-new-native-nonconstructor": "error",
|
|
166
170
|
"no-new-wrappers": "error",
|
|
167
171
|
"no-obj-calls": "error",
|
|
172
|
+
"no-promise-executor-return": "error",
|
|
168
173
|
"no-proto": "error",
|
|
169
174
|
"no-prototype-builtins": "error",
|
|
170
175
|
"no-redeclare": ["error", { builtinGlobals: false }],
|
|
@@ -187,6 +192,7 @@ const baseRules = {
|
|
|
187
192
|
"no-template-curly-in-string": "error",
|
|
188
193
|
"no-this-before-super": "error",
|
|
189
194
|
"no-throw-literal": "error",
|
|
195
|
+
"no-undef": "error",
|
|
190
196
|
"no-unexpected-multiline": "error",
|
|
191
197
|
"no-unmodified-loop-condition": "error",
|
|
192
198
|
"no-unneeded-ternary": ["error", { defaultAssignment: false }],
|
|
@@ -198,12 +204,14 @@ const baseRules = {
|
|
|
198
204
|
allowTaggedTemplates: true,
|
|
199
205
|
allowTernary: true
|
|
200
206
|
}],
|
|
207
|
+
"no-unused-private-class-members": "error",
|
|
201
208
|
"no-use-before-define": ["error", {
|
|
202
209
|
classes: false,
|
|
203
210
|
functions: false,
|
|
204
211
|
variables: true
|
|
205
212
|
}],
|
|
206
213
|
"no-useless-assignment": "error",
|
|
214
|
+
"no-useless-backreference": "error",
|
|
207
215
|
"no-useless-call": "error",
|
|
208
216
|
"no-useless-catch": "error",
|
|
209
217
|
"no-useless-computed-key": "error",
|
|
@@ -211,10 +219,18 @@ const baseRules = {
|
|
|
211
219
|
"no-useless-rename": "error",
|
|
212
220
|
"no-useless-return": "error",
|
|
213
221
|
"no-var": "error",
|
|
222
|
+
"no-warning-comments": ["error", { terms: ["@nocommit"] }],
|
|
214
223
|
"no-with": "error",
|
|
215
224
|
"no-empty-character-class": "error",
|
|
216
225
|
"no-constructor-return": "error",
|
|
217
|
-
"no-unused-vars": "error",
|
|
226
|
+
"no-unused-vars": ["error", {
|
|
227
|
+
args: "none",
|
|
228
|
+
fix: {
|
|
229
|
+
imports: "safe-fix",
|
|
230
|
+
variables: "off"
|
|
231
|
+
},
|
|
232
|
+
varsIgnorePattern: "^_"
|
|
233
|
+
}],
|
|
218
234
|
"no-nonoctal-decimal-escape": "error",
|
|
219
235
|
"no-setter-return": "error",
|
|
220
236
|
"no-unused-labels": "error",
|
|
@@ -224,11 +240,17 @@ const baseRules = {
|
|
|
224
240
|
"no-useless-escape": "error",
|
|
225
241
|
"no-unsafe-optional-chaining": "error",
|
|
226
242
|
"object-shorthand": ["error", "always"],
|
|
243
|
+
"prefer-arrow-callback": ["error", { allowNamedFunctions: true }],
|
|
244
|
+
"prefer-const": "error",
|
|
227
245
|
"prefer-exponentiation-operator": "error",
|
|
246
|
+
"prefer-object-has-own": "error",
|
|
247
|
+
"prefer-promise-reject-errors": "error",
|
|
228
248
|
"prefer-rest-params": "error",
|
|
229
249
|
"prefer-regex-literals": "error",
|
|
230
250
|
"prefer-spread": "error",
|
|
231
251
|
"prefer-template": "error",
|
|
252
|
+
"preserve-caught-error": "error",
|
|
253
|
+
"require-yield": "error",
|
|
232
254
|
"symbol-description": "error",
|
|
233
255
|
"unicode-bom": ["error", "never"],
|
|
234
256
|
"use-isnan": ["error", {
|
|
@@ -242,6 +264,8 @@ const baseRules = {
|
|
|
242
264
|
"node/no-exports-assign": "error",
|
|
243
265
|
"node/no-new-require": "error",
|
|
244
266
|
"node/no-path-concat": "error",
|
|
267
|
+
"promise/no-multiple-resolved": "error",
|
|
268
|
+
"promise/no-return-in-finally": "error",
|
|
245
269
|
"jsdoc/check-access": "warn",
|
|
246
270
|
"jsdoc/check-property-names": "warn",
|
|
247
271
|
"jsdoc/empty-tags": "warn",
|
|
@@ -252,39 +276,80 @@ const baseRules = {
|
|
|
252
276
|
"jsdoc/require-property-description": "warn",
|
|
253
277
|
"jsdoc/require-property-name": "warn",
|
|
254
278
|
"jsdoc/require-returns-description": "warn",
|
|
279
|
+
"unicorn/catch-error-name": "error",
|
|
255
280
|
"unicorn/consistent-empty-array-spread": "error",
|
|
281
|
+
"unicorn/consistent-function-scoping": "error",
|
|
256
282
|
"unicorn/error-message": "error",
|
|
257
283
|
"unicorn/escape-case": "error",
|
|
258
284
|
"unicorn/new-for-builtins": "error",
|
|
285
|
+
"unicorn/no-abusive-eslint-disable": "error",
|
|
286
|
+
"unicorn/no-hex-escape": "error",
|
|
259
287
|
"unicorn/no-instanceof-builtins": "error",
|
|
260
288
|
"unicorn/no-instanceof-array": "error",
|
|
289
|
+
"unicorn/no-invalid-fetch-options": "error",
|
|
290
|
+
"unicorn/no-invalid-remove-event-listener": "error",
|
|
291
|
+
"unicorn/no-magic-array-flat-depth": "error",
|
|
261
292
|
"unicorn/no-new-array": "off",
|
|
262
293
|
"unicorn/no-new-buffer": "error",
|
|
263
294
|
"unicorn/no-array-fill-with-reference-type": "error",
|
|
295
|
+
"unicorn/no-typeof-undefined": "error",
|
|
296
|
+
"unicorn/no-unnecessary-slice-end": "error",
|
|
297
|
+
"unicorn/no-useless-promise-resolve-reject": "error",
|
|
298
|
+
"unicorn/no-useless-spread": "error",
|
|
299
|
+
"unicorn/numeric-separators-style": "error",
|
|
264
300
|
"unicorn/prefer-array-find": "error",
|
|
265
301
|
"unicorn/prefer-array-flat-map": "error",
|
|
302
|
+
"unicorn/prefer-array-index-of": "error",
|
|
266
303
|
"unicorn/prefer-array-some": "error",
|
|
304
|
+
"unicorn/prefer-at": "error",
|
|
267
305
|
"unicorn/prefer-code-point": "error",
|
|
268
306
|
"unicorn/prefer-date-now": "error",
|
|
307
|
+
"unicorn/prefer-dom-node-append": "error",
|
|
269
308
|
"unicorn/prefer-dom-node-text-content": "error",
|
|
309
|
+
"unicorn/prefer-import-meta-properties": "error",
|
|
270
310
|
"unicorn/prefer-includes": "error",
|
|
311
|
+
"unicorn/prefer-native-coercion-functions": "error",
|
|
271
312
|
"unicorn/prefer-node-protocol": "error",
|
|
272
313
|
"unicorn/prefer-number-properties": "error",
|
|
314
|
+
"unicorn/prefer-optional-catch-binding": "error",
|
|
315
|
+
"unicorn/prefer-set-size": "error",
|
|
316
|
+
"unicorn/prefer-single-call": "error",
|
|
317
|
+
"unicorn/prefer-string-raw": "error",
|
|
318
|
+
"unicorn/prefer-string-replace-all": "error",
|
|
319
|
+
"unicorn/prefer-string-slice": "error",
|
|
273
320
|
"unicorn/prefer-string-starts-ends-with": "error",
|
|
321
|
+
"unicorn/prefer-structured-clone": "error",
|
|
322
|
+
"unicorn/prefer-top-level-await": "error",
|
|
274
323
|
"unicorn/prefer-type-error": "error",
|
|
275
324
|
"unicorn/prefer-set-has": "error",
|
|
276
325
|
"unicorn/switch-case-braces": ["error", "avoid"],
|
|
326
|
+
"unicorn/text-encoding-identifier-case": "error",
|
|
277
327
|
"unicorn/throw-new-error": "error",
|
|
278
328
|
"import/consistent-type-specifier-style": "error",
|
|
329
|
+
"import/export": "error",
|
|
279
330
|
"import/no-absolute-path": "error",
|
|
280
331
|
"import/no-cycle": "error",
|
|
281
332
|
"import/no-duplicates": "error",
|
|
333
|
+
"import/no-namespace": "error",
|
|
282
334
|
"import/no-self-import": "error",
|
|
283
335
|
"import/no-named-export": "allow",
|
|
284
336
|
"import/first": "error",
|
|
285
337
|
"oxc/no-map-spread": "error",
|
|
286
338
|
"oxc/misrefactored-assign-op": "error",
|
|
287
|
-
"oxc/no-this-in-exported-function": "error"
|
|
339
|
+
"oxc/no-this-in-exported-function": "error",
|
|
340
|
+
"oxc/approx-constant": "error",
|
|
341
|
+
"oxc/bad-bitwise-operator": "error",
|
|
342
|
+
"oxc/bad-char-at-comparison": "error",
|
|
343
|
+
"oxc/bad-comparison-sequence": "error",
|
|
344
|
+
"oxc/bad-min-max-func": "error",
|
|
345
|
+
"oxc/bad-object-literal-comparison": "error",
|
|
346
|
+
"oxc/bad-replace-all-arg": "error",
|
|
347
|
+
"oxc/const-comparisons": "error",
|
|
348
|
+
"oxc/double-comparisons": "error",
|
|
349
|
+
"oxc/missing-throw": "error",
|
|
350
|
+
"oxc/no-accumulating-spread": "error",
|
|
351
|
+
"oxc/number-arg-out-of-range": "error",
|
|
352
|
+
"oxc/uninvoked-array-callback": "error"
|
|
288
353
|
}
|
|
289
354
|
};
|
|
290
355
|
const ts = {
|
|
@@ -302,6 +367,7 @@ const ts = {
|
|
|
302
367
|
"no-redeclare": ["error", { builtinGlobals: false }],
|
|
303
368
|
"no-setter-return": "off",
|
|
304
369
|
"no-this-before-super": "off",
|
|
370
|
+
"no-undef": "off",
|
|
305
371
|
"no-unsafe-negation": "off",
|
|
306
372
|
"no-with": "off",
|
|
307
373
|
"no-unused-expressions": ["error", {
|
|
@@ -315,16 +381,22 @@ const ts = {
|
|
|
315
381
|
functions: false,
|
|
316
382
|
variables: true
|
|
317
383
|
}],
|
|
384
|
+
"typescript/array-type": ["error", { default: "generic" }],
|
|
318
385
|
"typescript/ban-ts-comment": ["error", { "ts-expect-error": "allow-with-description" }],
|
|
319
386
|
"typescript/dot-notation": "error",
|
|
320
387
|
"typescript/method-signature-style": ["error", "property"],
|
|
388
|
+
"typescript/no-confusing-non-null-assertion": "error",
|
|
321
389
|
"typescript/no-duplicate-enum-values": "error",
|
|
390
|
+
"typescript/no-empty-object-type": "error",
|
|
391
|
+
"typescript/no-explicit-any": "error",
|
|
322
392
|
"typescript/no-extra-non-null-assertion": "error",
|
|
323
393
|
"typescript/no-misused-new": "error",
|
|
324
394
|
"typescript/no-non-null-asserted-nullish-coalescing": "error",
|
|
325
395
|
"typescript/no-non-null-asserted-optional-chain": "error",
|
|
396
|
+
"typescript/no-non-null-assertion": "error",
|
|
326
397
|
"typescript/no-require-imports": "error",
|
|
327
398
|
"typescript/no-this-alias": "error",
|
|
399
|
+
"typescript/no-unnecessary-parameter-property-assignment": "error",
|
|
328
400
|
"typescript/no-unnecessary-type-constraint": "error",
|
|
329
401
|
"typescript/no-unnecessary-type-conversion": "error",
|
|
330
402
|
"typescript/no-unnecessary-type-assertion": "error",
|
|
@@ -344,16 +416,17 @@ const ts = {
|
|
|
344
416
|
prefer: "type-imports"
|
|
345
417
|
}],
|
|
346
418
|
"typescript/no-import-type-side-effects": "error",
|
|
347
|
-
"typescript/no-unnecessary-type-arguments": "error"
|
|
419
|
+
"typescript/no-unnecessary-type-arguments": "error",
|
|
420
|
+
"typescript/triple-slash-reference": "error"
|
|
348
421
|
}
|
|
349
422
|
};
|
|
350
423
|
const vitest = {
|
|
351
424
|
files: [
|
|
352
|
-
"**/__tests__/**/*.?
|
|
353
|
-
"**/*.spec.?
|
|
354
|
-
"**/*.test.?
|
|
355
|
-
"**/*.bench.?
|
|
356
|
-
"**/*.benchmark.?
|
|
425
|
+
"**/__tests__/**/*.?{js,ts,jsx,tsx}",
|
|
426
|
+
"**/*.spec.?{js,ts,jsx,tsx}",
|
|
427
|
+
"**/*.test.?{js,ts,jsx,tsx}",
|
|
428
|
+
"**/*.bench.?{js,ts,jsx,tsx}",
|
|
429
|
+
"**/*.benchmark.?{js,ts,jsx,tsx}"
|
|
357
430
|
],
|
|
358
431
|
plugins: ["vitest"],
|
|
359
432
|
rules: {
|
|
@@ -366,11 +439,67 @@ const vitest = {
|
|
|
366
439
|
"vitest/prefer-hooks-in-order": "error",
|
|
367
440
|
"vitest/prefer-lowercase-title": "error",
|
|
368
441
|
"vitest/prefer-called-exactly-once-with": "warn",
|
|
369
|
-
"
|
|
442
|
+
"vitest/require-awaited-expect-poll": "error",
|
|
443
|
+
"no-unused-expressions": "off",
|
|
444
|
+
"typescript/no-explicit-any": "off",
|
|
445
|
+
"typescript/no-non-null-assertion": "off"
|
|
370
446
|
}
|
|
371
447
|
};
|
|
448
|
+
const typeAware = {
|
|
449
|
+
options: { typeAware: true },
|
|
450
|
+
rules: {
|
|
451
|
+
"typescript/await-thenable": ["error", { allowMixedPromiseArrays: true }],
|
|
452
|
+
"typescript/no-array-delete": "error",
|
|
453
|
+
"typescript/no-deprecated": "warn",
|
|
454
|
+
"typescript/no-duplicate-type-constituents": "error",
|
|
455
|
+
"typescript/no-floating-promises": "error",
|
|
456
|
+
"typescript/no-for-in-array": "error",
|
|
457
|
+
"typescript/no-misused-promises": "error",
|
|
458
|
+
"typescript/no-misused-spread": "error",
|
|
459
|
+
"typescript/no-unsafe-argument": "error",
|
|
460
|
+
"typescript/no-unsafe-assignment": "error",
|
|
461
|
+
"typescript/no-unsafe-call": "error",
|
|
462
|
+
"typescript/no-unsafe-member-access": "error",
|
|
463
|
+
"typescript/no-unsafe-return": "error",
|
|
464
|
+
"typescript/no-unsafe-type-assertion": "error",
|
|
465
|
+
"typescript/no-unsafe-unary-minus": "error",
|
|
466
|
+
"typescript/require-array-sort-compare": "error",
|
|
467
|
+
"typescript/return-await": ["error", "error-handling-correctness-only"],
|
|
468
|
+
"typescript/unbound-method": "error",
|
|
469
|
+
"typescript/use-unknown-in-catch-callback-variable": "error"
|
|
470
|
+
},
|
|
471
|
+
overrides: [
|
|
472
|
+
{
|
|
473
|
+
files: FILES_TS_TSX$1,
|
|
474
|
+
rules: {
|
|
475
|
+
"no-throw-literal": "off",
|
|
476
|
+
"typescript/only-throw-error": "error"
|
|
477
|
+
}
|
|
478
|
+
},
|
|
479
|
+
{
|
|
480
|
+
files: ["**/*.{test,spec,integration,e2e}.{ts,tsx,mts,cts}", "**/__tests__/**/*.{ts,tsx,mts,cts}"],
|
|
481
|
+
rules: {
|
|
482
|
+
"typescript/no-unsafe-argument": "off",
|
|
483
|
+
"typescript/no-unsafe-assignment": "off",
|
|
484
|
+
"typescript/no-unsafe-member-access": "off",
|
|
485
|
+
"typescript/only-throw-error": "off",
|
|
486
|
+
"typescript/unbound-method": "off"
|
|
487
|
+
}
|
|
488
|
+
},
|
|
489
|
+
{
|
|
490
|
+
files: ["**/*.{js,jsx,mjs,cjs}"],
|
|
491
|
+
rules: {
|
|
492
|
+
"typescript/no-unsafe-argument": "off",
|
|
493
|
+
"typescript/no-unsafe-assignment": "off",
|
|
494
|
+
"typescript/no-unsafe-call": "off",
|
|
495
|
+
"typescript/no-unsafe-member-access": "off",
|
|
496
|
+
"typescript/no-unsafe-return": "off"
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
]
|
|
500
|
+
};
|
|
372
501
|
const markdownOverrideConfig = {
|
|
373
|
-
files: ["**/*.md/**/*.?
|
|
502
|
+
files: ["**/*.md/**/*.?{js,ts,jsx,tsx}"],
|
|
374
503
|
rules: {
|
|
375
504
|
"no-alert": "off",
|
|
376
505
|
"no-labels": "off",
|
|
@@ -402,8 +531,9 @@ const unocss = {
|
|
|
402
531
|
}
|
|
403
532
|
};
|
|
404
533
|
function subfLint(options = {}) {
|
|
405
|
-
const { lib, unocss: enableUnocss, solid: enableSolid, overrides, ...oxlint } = options;
|
|
406
|
-
const ovr = [
|
|
534
|
+
const { lib, unocss: enableUnocss, solid: enableSolid, typeAware: enableTypeAware, overrides, extends: userExtends, ...oxlint } = options;
|
|
535
|
+
const ovr = [];
|
|
536
|
+
let solidSettings;
|
|
407
537
|
if (lib) ovr.push({
|
|
408
538
|
...ts,
|
|
409
539
|
rules: {
|
|
@@ -416,10 +546,54 @@ function subfLint(options = {}) {
|
|
|
416
546
|
}
|
|
417
547
|
});
|
|
418
548
|
else ovr.push(ts);
|
|
549
|
+
ovr.push(vitest, markdownOverrideConfig);
|
|
419
550
|
if (enableUnocss) ovr.push(unocss);
|
|
420
|
-
if (enableSolid)
|
|
551
|
+
if (enableSolid) {
|
|
552
|
+
const solidPreset = enableSolid === true ? "v2strict" : enableSolid;
|
|
553
|
+
if (solidPreset === "v1") ovr.push(solidConfig);
|
|
554
|
+
else {
|
|
555
|
+
const preset = solidPreset === "v2" ? solidV2Config : solidV2StrictConfig;
|
|
556
|
+
if (preset.overrides) ovr.push(...preset.overrides);
|
|
557
|
+
solidSettings = preset.settings;
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
if (enableTypeAware && typeAware.overrides) ovr.push(...typeAware.overrides);
|
|
421
561
|
if (overrides) ovr.push(...overrides);
|
|
422
|
-
return
|
|
562
|
+
return {
|
|
563
|
+
...oxlint,
|
|
564
|
+
env: {
|
|
565
|
+
...baseConfig.env,
|
|
566
|
+
...oxlint.env
|
|
567
|
+
},
|
|
568
|
+
globals: {
|
|
569
|
+
...baseConfig.globals,
|
|
570
|
+
...oxlint.globals
|
|
571
|
+
},
|
|
572
|
+
settings: {
|
|
573
|
+
...solidSettings,
|
|
574
|
+
...oxlint.settings
|
|
575
|
+
},
|
|
576
|
+
options: {
|
|
577
|
+
...baseConfig.options,
|
|
578
|
+
...enableTypeAware ? typeAware.options : {},
|
|
579
|
+
...oxlint.options
|
|
580
|
+
},
|
|
581
|
+
plugins: [
|
|
582
|
+
...baseRules.plugins ?? [],
|
|
583
|
+
...(userExtends ?? []).flatMap((config) => config.plugins ?? []),
|
|
584
|
+
...oxlint.plugins ?? []
|
|
585
|
+
],
|
|
586
|
+
ignorePatterns: [
|
|
587
|
+
...baseConfig.ignorePatterns ?? [],
|
|
588
|
+
...(userExtends ?? []).flatMap((config) => config.ignorePatterns ?? []),
|
|
589
|
+
...oxlint.ignorePatterns ?? []
|
|
590
|
+
],
|
|
591
|
+
extends: [
|
|
592
|
+
baseRules,
|
|
593
|
+
...enableTypeAware ? [{ rules: typeAware.rules }] : [],
|
|
594
|
+
...userExtends ?? []
|
|
595
|
+
],
|
|
596
|
+
overrides: ovr
|
|
597
|
+
};
|
|
423
598
|
}
|
|
424
|
-
|
|
425
|
-
export { CONFIG, CONFIG as default, FILES_TS_TSX, baseConfig, baseRules, markdownOverrideConfig, overrides, solid, subfLint, ts, unocss, vitest };
|
|
599
|
+
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.
|
|
3
|
+
"version": "0.6.1",
|
|
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.
|
|
45
|
+
"@subf/oxlint-plugin": "^0.4.1"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/node": "^24",
|
|
49
49
|
"bumpp": "^11.1.0",
|
|
50
|
-
"oxfmt": "^0.
|
|
51
|
-
"oxlint": "^1.
|
|
52
|
-
"tsdown": "^0.23.
|
|
53
|
-
"
|
|
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": "
|
|
58
|
+
"typecheck": "tsrs --noEmit --fast",
|
|
64
59
|
"lint": "oxlint --fix",
|
|
65
60
|
"format": "oxfmt",
|
|
66
61
|
"release": "bumpp --all",
|