@adamhl8/configs 0.18.3 → 0.19.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 +0 -8
- package/dist/adamhl8-knip/index +3 -1
- package/dist/adamhl8-knip/knip-preprocessor.js +55 -0
- package/dist/configs/biome.base.json +189 -110
- package/dist/configs/knip.d.ts +4 -4
- package/dist/configs/knip.d.ts.map +1 -1
- package/dist/configs/knip.js +2 -1
- package/dist/configs/knip.js.map +1 -1
- package/dist/configs/tsconfig.base.json +2 -6
- package/dist/configs/tsdown.d.ts +2 -2
- package/dist/configs/tsdown.d.ts.map +1 -1
- package/dist/configs/tsdown.js +4 -3
- package/dist/configs/tsdown.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -2
- package/dist/{configs/utils.d.ts → utils.d.ts} +1 -1
- package/dist/utils.d.ts.map +1 -0
- package/dist/{configs/utils.js → utils.js} +8 -0
- package/dist/utils.js.map +1 -0
- package/package.json +15 -26
- package/dist/configs/knip-preprocessor.d.ts +0 -7
- package/dist/configs/knip-preprocessor.d.ts.map +0 -1
- package/dist/configs/knip-preprocessor.js +0 -21
- package/dist/configs/knip-preprocessor.js.map +0 -1
- package/dist/configs/prettier.d.ts +0 -27
- package/dist/configs/prettier.d.ts.map +0 -1
- package/dist/configs/prettier.js +0 -23
- package/dist/configs/prettier.js.map +0 -1
- package/dist/configs/utils.d.ts.map +0 -1
- package/dist/configs/utils.js.map +0 -1
- package/dist/ts-import-fix/index +0 -201
package/README.md
CHANGED
package/dist/adamhl8-knip/index
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import process from "node:process";
|
|
4
|
-
|
|
4
|
+
//#region src/adamhl8-knip/index.ts
|
|
5
|
+
const KNIP_PREPROCESSOR_PATH = `${path.resolve(import.meta.dir, "./knip-preprocessor")}`;
|
|
5
6
|
const knipPreprocessorPath = `${KNIP_PREPROCESSOR_PATH}${await Bun.file(`${KNIP_PREPROCESSOR_PATH}.ts`).exists() ? ".ts" : ".js"}`;
|
|
6
7
|
process.exitCode = Bun.spawnSync({
|
|
7
8
|
cmd: [
|
|
@@ -13,4 +14,5 @@ process.exitCode = Bun.spawnSync({
|
|
|
13
14
|
stdout: "inherit",
|
|
14
15
|
stderr: "inherit"
|
|
15
16
|
}).exitCode;
|
|
17
|
+
//#endregion
|
|
16
18
|
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { mergeWith } from "es-toolkit";
|
|
2
|
+
import { clone } from "remeda";
|
|
3
|
+
//#region src/utils.ts
|
|
4
|
+
/**
|
|
5
|
+
* A wrapper around es-toolkit's `mergeWith` with a custom merge function that concatenates arrays.
|
|
6
|
+
*/
|
|
7
|
+
function merge(target, source) {
|
|
8
|
+
return mergeWith(target, source, (objValue, srcValue) => Array.isArray(objValue) ? objValue.concat(srcValue) : void 0);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Creates a config merge function with proper type overloads for merging with a base config.
|
|
12
|
+
*/
|
|
13
|
+
function createMergeConfigFn(baseConfig) {
|
|
14
|
+
const mergeConfigFn = (userConfig) => {
|
|
15
|
+
if (userConfig === void 0) return baseConfig;
|
|
16
|
+
return merge(clone(baseConfig), clone(userConfig));
|
|
17
|
+
};
|
|
18
|
+
return mergeConfigFn;
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/configs/knip.ts
|
|
22
|
+
const DEFAULT_ENTRIES = [
|
|
23
|
+
"./src/index.ts",
|
|
24
|
+
"**/*.test.ts",
|
|
25
|
+
"./tsdown.config.ts"
|
|
26
|
+
];
|
|
27
|
+
createMergeConfigFn({
|
|
28
|
+
entry: DEFAULT_ENTRIES,
|
|
29
|
+
project: ["**"],
|
|
30
|
+
tsdown: false
|
|
31
|
+
});
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region src/adamhl8-knip/knip-preprocessor.ts
|
|
34
|
+
/**
|
|
35
|
+
* Modifies issues based on the provided map function.
|
|
36
|
+
*
|
|
37
|
+
* This is needed because we also need to update `options.counters` after modifying issues.
|
|
38
|
+
*/
|
|
39
|
+
function modifyIssues(options, issueType, mapFn) {
|
|
40
|
+
const originalIssues = options.issues[issueType];
|
|
41
|
+
const modifiedIssueEntries = Object.entries(originalIssues).map(([key, issueRecord]) => [key, Object.entries(issueRecord)]).map(([key, issueRecordEntries]) => [key, Object.fromEntries(mapFn([key, issueRecordEntries]))]);
|
|
42
|
+
const modifiedIssues = Object.fromEntries(modifiedIssueEntries);
|
|
43
|
+
const countIssues = (issueRecords) => Object.values(issueRecords).map((issueRecord) => Object.keys(issueRecord).length).reduce((acc, curr) => acc + curr, 0);
|
|
44
|
+
const originalIssueCount = countIssues(originalIssues);
|
|
45
|
+
const issuesRemovedCount = originalIssueCount - countIssues(modifiedIssues);
|
|
46
|
+
options.counters[issueType] = originalIssueCount - issuesRemovedCount;
|
|
47
|
+
options.issues[issueType] = modifiedIssues;
|
|
48
|
+
}
|
|
49
|
+
const preprocess = (options) => {
|
|
50
|
+
options.configurationHints = options.configurationHints.filter((hint) => !(DEFAULT_ENTRIES.some((entry) => typeof hint.identifier === "string" && hint.identifier.includes(entry)) && (hint.type === "entry-empty" || hint.type === "entry-redundant")));
|
|
51
|
+
modifyIssues(options, "unlisted", ([, issueRecordEntries]) => issueRecordEntries.filter(([key]) => !key.includes("prettier")));
|
|
52
|
+
return options;
|
|
53
|
+
};
|
|
54
|
+
//#endregion
|
|
55
|
+
export { preprocess as default };
|
|
@@ -6,25 +6,6 @@
|
|
|
6
6
|
"clientKind": "git",
|
|
7
7
|
"useIgnoreFile": true
|
|
8
8
|
},
|
|
9
|
-
"formatter": {
|
|
10
|
-
"indentStyle": "space",
|
|
11
|
-
"lineWidth": 120
|
|
12
|
-
},
|
|
13
|
-
"javascript": {
|
|
14
|
-
"formatter": {
|
|
15
|
-
"semicolons": "asNeeded"
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
"json": {
|
|
19
|
-
"formatter": {
|
|
20
|
-
"expand": "auto"
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
"css": {
|
|
24
|
-
"parser": {
|
|
25
|
-
"tailwindDirectives": true
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
9
|
"assist": {
|
|
29
10
|
"enabled": true,
|
|
30
11
|
"actions": {
|
|
@@ -33,7 +14,7 @@
|
|
|
33
14
|
"level": "on",
|
|
34
15
|
"options": {
|
|
35
16
|
"groups": [
|
|
36
|
-
[":NODE:", ":BUN:", ":
|
|
17
|
+
[":NODE:", ":BUN:", ":PACKAGE_WITH_PROTOCOL:", ":URL:", ":PACKAGE:"],
|
|
37
18
|
":BLANK_LINE:",
|
|
38
19
|
[":ALIAS:", ":PATH:"]
|
|
39
20
|
]
|
|
@@ -44,7 +25,7 @@
|
|
|
44
25
|
},
|
|
45
26
|
"overrides": [
|
|
46
27
|
{
|
|
47
|
-
"includes": ["**/*.tsx", "
|
|
28
|
+
"includes": ["**/*.tsx", "knip.ts", "prettier.config.js", "tsdown.config.ts", "astro.config.ts"],
|
|
48
29
|
"linter": {
|
|
49
30
|
"rules": {
|
|
50
31
|
"style": {
|
|
@@ -54,6 +35,35 @@
|
|
|
54
35
|
}
|
|
55
36
|
}
|
|
56
37
|
],
|
|
38
|
+
"formatter": {
|
|
39
|
+
"indentStyle": "space",
|
|
40
|
+
"lineWidth": 120
|
|
41
|
+
},
|
|
42
|
+
"javascript": {
|
|
43
|
+
"formatter": {
|
|
44
|
+
"semicolons": "asNeeded"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"json": {
|
|
48
|
+
"formatter": {
|
|
49
|
+
"expand": "auto"
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"css": {
|
|
53
|
+
"parser": {
|
|
54
|
+
"cssModules": true,
|
|
55
|
+
"tailwindDirectives": true
|
|
56
|
+
},
|
|
57
|
+
"formatter": {
|
|
58
|
+
"enabled": true
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"html": {
|
|
62
|
+
"experimentalFullSupportEnabled": true,
|
|
63
|
+
"formatter": {
|
|
64
|
+
"enabled": true
|
|
65
|
+
}
|
|
66
|
+
},
|
|
57
67
|
"linter": {
|
|
58
68
|
"rules": {
|
|
59
69
|
"a11y": {
|
|
@@ -96,22 +106,25 @@
|
|
|
96
106
|
"useValidLang": "error"
|
|
97
107
|
},
|
|
98
108
|
"complexity": {
|
|
109
|
+
"noExcessiveCognitiveComplexity": "off",
|
|
110
|
+
"noExcessiveLinesPerFunction": "off",
|
|
111
|
+
"noForEach": "off",
|
|
112
|
+
"noVoid": "off",
|
|
113
|
+
"useLiteralKeys": "off",
|
|
99
114
|
"noAdjacentSpacesInRegex": "error",
|
|
100
115
|
"noArguments": "error",
|
|
101
116
|
"noBannedTypes": "error",
|
|
102
117
|
"noCommaOperator": "error",
|
|
103
118
|
"noEmptyTypeParameters": "error",
|
|
104
|
-
"noExcessiveCognitiveComplexity": "off",
|
|
105
|
-
"noExcessiveLinesPerFunction": "off",
|
|
106
119
|
"noExcessiveNestedTestSuites": "error",
|
|
107
120
|
"noExtraBooleanCast": "error",
|
|
108
121
|
"noFlatMapIdentity": "error",
|
|
109
|
-
"noForEach": "off",
|
|
110
122
|
"noImplicitCoercions": "error",
|
|
111
123
|
"noImportantStyles": "error",
|
|
112
124
|
"noStaticOnlyClass": "error",
|
|
113
125
|
"noThisInStatic": "error",
|
|
114
126
|
"noUselessCatch": "error",
|
|
127
|
+
"noUselessCatchBinding": "error",
|
|
115
128
|
"noUselessConstructor": "error",
|
|
116
129
|
"noUselessContinue": "error",
|
|
117
130
|
"noUselessEmptyExport": "error",
|
|
@@ -126,13 +139,13 @@
|
|
|
126
139
|
"noUselessTernary": "error",
|
|
127
140
|
"noUselessThisAlias": "error",
|
|
128
141
|
"noUselessTypeConstraint": "error",
|
|
142
|
+
"noUselessUndefined": "error",
|
|
129
143
|
"noUselessUndefinedInitialization": "error",
|
|
130
|
-
"noVoid": "off",
|
|
131
144
|
"useArrowFunction": "error",
|
|
132
145
|
"useDateNow": "error",
|
|
133
146
|
"useFlatMap": "error",
|
|
134
147
|
"useIndexOf": "error",
|
|
135
|
-
"
|
|
148
|
+
"useMaxParams": "error",
|
|
136
149
|
"useNumericLiterals": "error",
|
|
137
150
|
"useOptionalChain": "error",
|
|
138
151
|
"useRegexLiterals": "error",
|
|
@@ -141,10 +154,23 @@
|
|
|
141
154
|
"useWhile": "error"
|
|
142
155
|
},
|
|
143
156
|
"correctness": {
|
|
157
|
+
"noNodejsModules": "off",
|
|
158
|
+
"noQwikUseVisibleTask": "off",
|
|
159
|
+
"noSolidDestructuredProps": "off",
|
|
160
|
+
"noUndeclaredDependencies": "off",
|
|
161
|
+
"noUndeclaredVariables": "off",
|
|
162
|
+
"noUnresolvedImports": "off",
|
|
163
|
+
"noVueDataObjectDeclaration": "off",
|
|
164
|
+
"noVueDuplicateKeys": "off",
|
|
165
|
+
"noVueReservedKeys": "off",
|
|
166
|
+
"noVueReservedProps": "off",
|
|
167
|
+
"useQwikClasslist": "off",
|
|
168
|
+
"useQwikMethodUsage": "off",
|
|
169
|
+
"useQwikValidLexicalScope": "off",
|
|
144
170
|
"noChildrenProp": "error",
|
|
145
|
-
"noConstAssign": "error",
|
|
146
171
|
"noConstantCondition": "error",
|
|
147
172
|
"noConstantMathMinMaxClamp": "error",
|
|
173
|
+
"noConstAssign": "error",
|
|
148
174
|
"noConstructorReturn": "error",
|
|
149
175
|
"noEmptyCharacterClassInRegex": "error",
|
|
150
176
|
"noEmptyPattern": "error",
|
|
@@ -159,22 +185,18 @@
|
|
|
159
185
|
"noInvalidUseBeforeDeclaration": "error",
|
|
160
186
|
"noMissingVarFunction": "error",
|
|
161
187
|
"noNestedComponentDefinitions": "error",
|
|
162
|
-
"
|
|
188
|
+
"noNextAsyncClientComponent": "error",
|
|
163
189
|
"noNonoctalDecimalEscape": "error",
|
|
164
190
|
"noPrecisionLoss": "error",
|
|
165
191
|
"noPrivateImports": "error",
|
|
166
192
|
"noProcessGlobal": "error",
|
|
167
|
-
"noQwikUseVisibleTask": "off",
|
|
168
193
|
"noReactPropAssignments": "error",
|
|
169
194
|
"noRenderReturnValue": "error",
|
|
170
195
|
"noRestrictedElements": "error",
|
|
171
196
|
"noSelfAssign": "error",
|
|
172
197
|
"noSetterReturn": "error",
|
|
173
|
-
"noSolidDestructuredProps": "off",
|
|
174
198
|
"noStringCaseMismatch": "error",
|
|
175
199
|
"noSwitchDeclarations": "error",
|
|
176
|
-
"noUndeclaredDependencies": "off",
|
|
177
|
-
"noUndeclaredVariables": "off",
|
|
178
200
|
"noUnknownFunction": "error",
|
|
179
201
|
"noUnknownMediaFeatureName": "error",
|
|
180
202
|
"noUnknownProperty": "error",
|
|
@@ -194,6 +216,7 @@
|
|
|
194
216
|
"noUnusedVariables": "error",
|
|
195
217
|
"noVoidElementsWithChildren": "error",
|
|
196
218
|
"noVoidTypeReturn": "error",
|
|
219
|
+
"noVueSetupPropsReactivityLoss": "error",
|
|
197
220
|
"useExhaustiveDependencies": "error",
|
|
198
221
|
"useGraphqlNamedOperations": "error",
|
|
199
222
|
"useHookAtTopLevel": "error",
|
|
@@ -203,7 +226,6 @@
|
|
|
203
226
|
"useJsonImportAttributes": "error",
|
|
204
227
|
"useJsxKeyInIterable": "error",
|
|
205
228
|
"useParseIntRadix": "error",
|
|
206
|
-
"useQwikClasslist": "off",
|
|
207
229
|
"useSingleJsDocAsterisk": "error",
|
|
208
230
|
"useUniqueElementIds": "error",
|
|
209
231
|
"useValidForDirection": "error",
|
|
@@ -211,143 +233,208 @@
|
|
|
211
233
|
"useYield": "error"
|
|
212
234
|
},
|
|
213
235
|
"nursery": {
|
|
236
|
+
"noContinue": "off",
|
|
237
|
+
"noExcessiveClassesPerFile": "off",
|
|
238
|
+
"noExcessiveLinesPerFile": "off",
|
|
239
|
+
"noIncrementDecrement": "off",
|
|
240
|
+
"noSyncScripts": "off",
|
|
241
|
+
"noTernary": "off",
|
|
242
|
+
"noUnknownAttribute": {
|
|
243
|
+
"level": "error",
|
|
244
|
+
"options": {
|
|
245
|
+
"ignore": ["class", "class:list"]
|
|
246
|
+
}
|
|
247
|
+
},
|
|
248
|
+
"noUntrustedLicenses": "off",
|
|
249
|
+
"noVueVIfWithVFor": "off",
|
|
250
|
+
"useAwaitThenable": "off",
|
|
251
|
+
"useExplicitReturnType": "off",
|
|
252
|
+
"useExplicitType": "off",
|
|
253
|
+
"useSortedClasses": {
|
|
254
|
+
"level": "error",
|
|
255
|
+
"fix": "safe"
|
|
256
|
+
},
|
|
257
|
+
"useVueDefineMacrosOrder": "off",
|
|
258
|
+
"useVueHyphenatedAttributes": "off",
|
|
259
|
+
"useVueMultiWordComponentNames": "off",
|
|
260
|
+
"useVueValidVBind": "off",
|
|
261
|
+
"useVueValidVElse": "off",
|
|
262
|
+
"useVueValidVElseIf": "off",
|
|
263
|
+
"useVueValidVHtml": "off",
|
|
264
|
+
"useVueValidVIf": "off",
|
|
265
|
+
"useVueValidVOn": "off",
|
|
266
|
+
"useVueValidVText": "off",
|
|
214
267
|
"noAmbiguousAnchorText": "error",
|
|
215
268
|
"noBeforeInteractiveScriptOutsideDocument": "error",
|
|
216
|
-
"
|
|
217
|
-
"
|
|
269
|
+
"noComponentHookFactories": "error",
|
|
270
|
+
"noConditionalExpect": "error",
|
|
271
|
+
"noDeprecatedMediaType": "error",
|
|
218
272
|
"noDivRegex": "error",
|
|
273
|
+
"noDrizzleDeleteWithoutWhere": "error",
|
|
274
|
+
"noDrizzleUpdateWithoutWhere": "error",
|
|
219
275
|
"noDuplicateArgumentNames": "error",
|
|
220
276
|
"noDuplicateAttributes": "error",
|
|
221
|
-
"
|
|
277
|
+
"noDuplicatedSpreadProps": "error",
|
|
222
278
|
"noDuplicateEnumValueNames": "error",
|
|
223
279
|
"noDuplicateEnumValues": "error",
|
|
224
280
|
"noDuplicateFieldDefinitionNames": "error",
|
|
225
281
|
"noDuplicateGraphqlOperationName": "error",
|
|
226
282
|
"noDuplicateInputFieldNames": "error",
|
|
283
|
+
"noDuplicateSelectors": "error",
|
|
227
284
|
"noDuplicateVariableNames": "error",
|
|
228
|
-
"
|
|
229
|
-
"noEmptySource": "error",
|
|
285
|
+
"noEmptyObjectKeys": "error",
|
|
230
286
|
"noEqualsToNull": "error",
|
|
231
|
-
"
|
|
232
|
-
"noExcessiveLinesPerFile": "off",
|
|
287
|
+
"noExcessiveSelectorClasses": "error",
|
|
233
288
|
"noFloatingClasses": "error",
|
|
234
289
|
"noFloatingPromises": "error",
|
|
235
290
|
"noForIn": "error",
|
|
236
|
-
"
|
|
237
|
-
"
|
|
238
|
-
"
|
|
291
|
+
"noHexColors": "error",
|
|
292
|
+
"noIdenticalTestTitle": "error",
|
|
293
|
+
"noImpliedEval": "error",
|
|
294
|
+
"noInlineStyles": "error",
|
|
295
|
+
"noJsxLeakedDollar": "error",
|
|
296
|
+
"noJsxNamespace": "error",
|
|
239
297
|
"noJsxPropsBind": "error",
|
|
240
298
|
"noLeakedRender": "error",
|
|
299
|
+
"noLoopFunc": "error",
|
|
300
|
+
"noMisleadingReturnType": "error",
|
|
241
301
|
"noMisusedPromises": "error",
|
|
242
302
|
"noMultiAssign": "error",
|
|
243
303
|
"noMultiStr": "error",
|
|
244
|
-
"
|
|
304
|
+
"noNestedPromises": "error",
|
|
245
305
|
"noParametersOnlyUsedInRecursion": "error",
|
|
306
|
+
"noPlaywrightElementHandle": "error",
|
|
307
|
+
"noPlaywrightEval": "error",
|
|
308
|
+
"noPlaywrightForceOption": "error",
|
|
309
|
+
"noPlaywrightMissingAwait": "error",
|
|
310
|
+
"noPlaywrightNetworkidle": "error",
|
|
311
|
+
"noPlaywrightPagePause": "error",
|
|
312
|
+
"noPlaywrightUselessAwait": "error",
|
|
313
|
+
"noPlaywrightWaitForNavigation": "error",
|
|
314
|
+
"noPlaywrightWaitForSelector": "error",
|
|
315
|
+
"noPlaywrightWaitForTimeout": "error",
|
|
246
316
|
"noProto": "error",
|
|
247
|
-
"
|
|
317
|
+
"noReactNativeDeepImports": "error",
|
|
318
|
+
"noReactNativeLiteralColors": "error",
|
|
319
|
+
"noReactNativeRawText": "error",
|
|
320
|
+
"noRedundantDefaultExport": "error",
|
|
248
321
|
"noReturnAssign": "error",
|
|
249
322
|
"noRootType": "error",
|
|
250
323
|
"noScriptUrl": "error",
|
|
251
324
|
"noShadow": "error",
|
|
252
|
-
"
|
|
253
|
-
"noTernary": "off",
|
|
325
|
+
"noTopLevelLiterals": "error",
|
|
254
326
|
"noUndeclaredEnvVars": "error",
|
|
255
|
-
"noUnknownAttribute": "error",
|
|
256
327
|
"noUnnecessaryConditions": "error",
|
|
257
|
-
"
|
|
258
|
-
"
|
|
259
|
-
"
|
|
260
|
-
"
|
|
261
|
-
"
|
|
262
|
-
"noVueDuplicateKeys": "off",
|
|
328
|
+
"noUnnecessaryTemplateExpression": "error",
|
|
329
|
+
"noUnsafePlusOperands": "error",
|
|
330
|
+
"noUselessReturn": "error",
|
|
331
|
+
"noUselessTypeConversion": "error",
|
|
332
|
+
"noVueArrowFuncInWatch": "error",
|
|
263
333
|
"noVueOptionsApi": "error",
|
|
264
|
-
"
|
|
265
|
-
"
|
|
266
|
-
"noVueSetupPropsReactivityLoss": "error",
|
|
267
|
-
"noVueVIfWithVFor": "off",
|
|
334
|
+
"noVueRefAsOperand": "error",
|
|
335
|
+
"useArraySome": "error",
|
|
268
336
|
"useArraySortCompare": "error",
|
|
269
|
-
"
|
|
270
|
-
"useConsistentArrowReturn": "error",
|
|
337
|
+
"useBaseline": "error",
|
|
271
338
|
"useConsistentEnumValueType": "error",
|
|
272
339
|
"useConsistentGraphqlDescriptions": "error",
|
|
273
|
-
"
|
|
340
|
+
"useConsistentMethodSignatures": "error",
|
|
341
|
+
"useConsistentTestIt": "error",
|
|
274
342
|
"useDestructuring": "error",
|
|
343
|
+
"useDisposables": "error",
|
|
344
|
+
"useDomNodeTextContent": "error",
|
|
345
|
+
"useDomQuerySelector": "error",
|
|
275
346
|
"useErrorCause": "error",
|
|
276
347
|
"useExhaustiveSwitchCases": "error",
|
|
277
|
-
"
|
|
348
|
+
"useExpect": "error",
|
|
278
349
|
"useFind": "error",
|
|
350
|
+
"useGlobalThis": "error",
|
|
351
|
+
"useIframeSandbox": "error",
|
|
352
|
+
"useImportsFirst": "error",
|
|
279
353
|
"useInlineScriptId": "error",
|
|
354
|
+
"useInputName": "error",
|
|
280
355
|
"useLoneAnonymousOperation": "error",
|
|
281
356
|
"useLoneExecutableDefinition": "error",
|
|
282
|
-
"
|
|
283
|
-
"
|
|
284
|
-
"
|
|
357
|
+
"useNamedCaptureGroup": "error",
|
|
358
|
+
"useNullishCoalescing": "error",
|
|
359
|
+
"usePlaywrightValidDescribeCallback": "error",
|
|
360
|
+
"useQwikLoaderLocation": "error",
|
|
361
|
+
"useReactAsyncServerFunction": "error",
|
|
362
|
+
"useReactNativePlatformComponents": "error",
|
|
363
|
+
"useReduceTypeParameter": "error",
|
|
285
364
|
"useRegexpExec": "error",
|
|
365
|
+
"useRegexpTest": "error",
|
|
286
366
|
"useRequiredScripts": "error",
|
|
287
|
-
"
|
|
288
|
-
"level": "error",
|
|
289
|
-
"fix": "safe"
|
|
290
|
-
},
|
|
367
|
+
"useScopedStyles": "error",
|
|
291
368
|
"useSpread": "error",
|
|
369
|
+
"useStringStartsEndsWith": "error",
|
|
370
|
+
"useUnicodeRegex": "error",
|
|
371
|
+
"useVarsOnTop": "error",
|
|
292
372
|
"useVueConsistentDefinePropsDeclaration": "error",
|
|
293
373
|
"useVueConsistentVBindStyle": "error",
|
|
294
374
|
"useVueConsistentVOnStyle": "error",
|
|
295
|
-
"useVueDefineMacrosOrder": "off",
|
|
296
|
-
"useVueHyphenatedAttributes": "off",
|
|
297
|
-
"useVueMultiWordComponentNames": "off",
|
|
298
|
-
"useVueVForKey": "error",
|
|
299
375
|
"useVueValidTemplateRoot": "error",
|
|
300
|
-
"useVueValidVBind": "off",
|
|
301
376
|
"useVueValidVCloak": "error",
|
|
302
|
-
"useVueValidVElse": "off",
|
|
303
|
-
"useVueValidVElseIf": "off",
|
|
304
|
-
"useVueValidVHtml": "off",
|
|
305
|
-
"useVueValidVIf": "off",
|
|
306
|
-
"useVueValidVOn": "off",
|
|
307
377
|
"useVueValidVOnce": "error",
|
|
308
378
|
"useVueValidVPre": "error",
|
|
309
|
-
"
|
|
310
|
-
"
|
|
379
|
+
"useVueVapor": "error",
|
|
380
|
+
"useVueVForKey": "error"
|
|
311
381
|
},
|
|
312
382
|
"performance": {
|
|
383
|
+
"noBarrelFile": "off",
|
|
384
|
+
"noNamespaceImport": "off",
|
|
385
|
+
"useSolidForComponent": "off",
|
|
313
386
|
"noAccumulatingSpread": "error",
|
|
314
387
|
"noAwaitInLoops": "error",
|
|
315
|
-
"noBarrelFile": "off",
|
|
316
388
|
"noDelete": "error",
|
|
317
389
|
"noDynamicNamespaceImportAccess": "error",
|
|
318
390
|
"noImgElement": "error",
|
|
319
|
-
"noNamespaceImport": "off",
|
|
320
391
|
"noReExportAll": "error",
|
|
321
392
|
"noUnwantedPolyfillio": "error",
|
|
322
393
|
"useGoogleFontPreconnect": "error",
|
|
323
|
-
"useSolidForComponent": "off",
|
|
324
394
|
"useTopLevelRegex": "error"
|
|
325
395
|
},
|
|
326
396
|
"security": {
|
|
397
|
+
"noSecrets": "off",
|
|
327
398
|
"noBlankTarget": "error",
|
|
328
399
|
"noDangerouslySetInnerHtml": "error",
|
|
329
400
|
"noDangerouslySetInnerHtmlWithChildren": "error",
|
|
330
|
-
"noGlobalEval": "error"
|
|
331
|
-
"noSecrets": "off"
|
|
401
|
+
"noGlobalEval": "error"
|
|
332
402
|
},
|
|
333
403
|
"style": {
|
|
404
|
+
"noEnum": "off",
|
|
405
|
+
"noHeadElement": "off",
|
|
406
|
+
"noJsxLiterals": "off",
|
|
407
|
+
"noMagicNumbers": "off",
|
|
408
|
+
"noProcessEnv": "off",
|
|
409
|
+
"useBlockStatements": "off",
|
|
410
|
+
"useConsistentMemberAccessibility": {
|
|
411
|
+
"level": "error",
|
|
412
|
+
"options": {
|
|
413
|
+
"accessibility": "explicit"
|
|
414
|
+
}
|
|
415
|
+
},
|
|
416
|
+
"useExportsLast": "off",
|
|
417
|
+
"useFilenamingConvention": "off",
|
|
418
|
+
"useImportType": {
|
|
419
|
+
"level": "error",
|
|
420
|
+
"options": {
|
|
421
|
+
"style": "separatedType"
|
|
422
|
+
}
|
|
423
|
+
},
|
|
424
|
+
"useNamingConvention": "off",
|
|
334
425
|
"noCommonJs": "error",
|
|
335
426
|
"noDefaultExport": "error",
|
|
336
427
|
"noDescendingSpecificity": "error",
|
|
337
428
|
"noDoneCallback": "error",
|
|
338
|
-
"noEnum": "off",
|
|
339
429
|
"noExportedImports": "error",
|
|
340
|
-
"noHeadElement": "off",
|
|
341
430
|
"noImplicitBoolean": "error",
|
|
342
431
|
"noInferrableTypes": "error",
|
|
343
|
-
"noMagicNumbers": "off",
|
|
344
432
|
"noNamespace": "error",
|
|
345
433
|
"noNegationElse": "error",
|
|
346
434
|
"noNestedTernary": "error",
|
|
347
435
|
"noNonNullAssertion": "error",
|
|
348
436
|
"noParameterAssign": "error",
|
|
349
437
|
"noParameterProperties": "error",
|
|
350
|
-
"noProcessEnv": "off",
|
|
351
438
|
"noRestrictedGlobals": "error",
|
|
352
439
|
"noRestrictedImports": "error",
|
|
353
440
|
"noRestrictedTypes": "error",
|
|
@@ -360,19 +447,13 @@
|
|
|
360
447
|
"useArrayLiterals": "error",
|
|
361
448
|
"useAsConstAssertion": "error",
|
|
362
449
|
"useAtIndex": "error",
|
|
363
|
-
"useBlockStatements": "off",
|
|
364
450
|
"useCollapsedElseIf": "error",
|
|
365
451
|
"useCollapsedIf": "error",
|
|
366
452
|
"useComponentExportOnlyModules": "error",
|
|
367
453
|
"useConsistentArrayType": "error",
|
|
454
|
+
"useConsistentArrowReturn": "error",
|
|
368
455
|
"useConsistentBuiltinInstantiation": "error",
|
|
369
456
|
"useConsistentCurlyBraces": "error",
|
|
370
|
-
"useConsistentMemberAccessibility": {
|
|
371
|
-
"level": "error",
|
|
372
|
-
"options": {
|
|
373
|
-
"accessibility": "explicit"
|
|
374
|
-
}
|
|
375
|
-
},
|
|
376
457
|
"useConsistentObjectDefinitions": "error",
|
|
377
458
|
"useConsistentTypeDefinitions": "error",
|
|
378
459
|
"useConst": "error",
|
|
@@ -383,20 +464,11 @@
|
|
|
383
464
|
"useExplicitLengthCheck": "error",
|
|
384
465
|
"useExponentiationOperator": "error",
|
|
385
466
|
"useExportType": "error",
|
|
386
|
-
"useExportsLast": "off",
|
|
387
|
-
"useFilenamingConvention": "off",
|
|
388
467
|
"useForOf": "error",
|
|
389
468
|
"useFragmentSyntax": "error",
|
|
390
469
|
"useGraphqlNamingConvention": "error",
|
|
391
470
|
"useGroupedAccessorPairs": "error",
|
|
392
|
-
"useImportType": {
|
|
393
|
-
"level": "error",
|
|
394
|
-
"options": {
|
|
395
|
-
"style": "separatedType"
|
|
396
|
-
}
|
|
397
|
-
},
|
|
398
471
|
"useLiteralEnumMembers": "error",
|
|
399
|
-
"useNamingConvention": "off",
|
|
400
472
|
"useNodeAssertStrict": "error",
|
|
401
473
|
"useNodejsImportProtocol": "error",
|
|
402
474
|
"useNumberNamespace": "error",
|
|
@@ -416,6 +488,8 @@
|
|
|
416
488
|
"useUnifiedTypeSignatures": "error"
|
|
417
489
|
},
|
|
418
490
|
"suspicious": {
|
|
491
|
+
"noConsole": "off",
|
|
492
|
+
"noReactSpecificProps": "off",
|
|
419
493
|
"noAlert": "error",
|
|
420
494
|
"noApproximativeNumericConstant": "error",
|
|
421
495
|
"noArrayIndexKey": "error",
|
|
@@ -429,11 +503,11 @@
|
|
|
429
503
|
"noCompareNegZero": "error",
|
|
430
504
|
"noConfusingLabels": "error",
|
|
431
505
|
"noConfusingVoidType": "error",
|
|
432
|
-
"noConsole": "off",
|
|
433
|
-
"noConstEnum": "error",
|
|
434
506
|
"noConstantBinaryExpressions": "error",
|
|
507
|
+
"noConstEnum": "error",
|
|
435
508
|
"noControlCharactersInRegex": "error",
|
|
436
509
|
"noDebugger": "error",
|
|
510
|
+
"noDeprecatedImports": "error",
|
|
437
511
|
"noDocumentCookie": "error",
|
|
438
512
|
"noDocumentImportInPage": "error",
|
|
439
513
|
"noDoubleEquals": "error",
|
|
@@ -441,6 +515,7 @@
|
|
|
441
515
|
"noDuplicateCase": "error",
|
|
442
516
|
"noDuplicateClassMembers": "error",
|
|
443
517
|
"noDuplicateCustomProperties": "error",
|
|
518
|
+
"noDuplicateDependencies": "error",
|
|
444
519
|
"noDuplicateElseIf": "error",
|
|
445
520
|
"noDuplicateFields": "error",
|
|
446
521
|
"noDuplicateFontNames": "error",
|
|
@@ -453,6 +528,7 @@
|
|
|
453
528
|
"noEmptyBlock": "error",
|
|
454
529
|
"noEmptyBlockStatements": "error",
|
|
455
530
|
"noEmptyInterface": "error",
|
|
531
|
+
"noEmptySource": "error",
|
|
456
532
|
"noEvolvingTypes": "error",
|
|
457
533
|
"noExplicitAny": "error",
|
|
458
534
|
"noExportsInTest": "error",
|
|
@@ -465,8 +541,9 @@
|
|
|
465
541
|
"noGlobalIsNan": "error",
|
|
466
542
|
"noHeadImportInDocument": "error",
|
|
467
543
|
"noImplicitAnyLet": "error",
|
|
468
|
-
"noImportAssign": "error",
|
|
469
544
|
"noImportantInKeyframe": "error",
|
|
545
|
+
"noImportAssign": "error",
|
|
546
|
+
"noImportCycles": "error",
|
|
470
547
|
"noIrregularWhitespace": "error",
|
|
471
548
|
"noLabelVar": "error",
|
|
472
549
|
"noMisleadingCharacterClass": "error",
|
|
@@ -477,7 +554,7 @@
|
|
|
477
554
|
"noOctalEscape": "error",
|
|
478
555
|
"noPrototypeBuiltins": "error",
|
|
479
556
|
"noQuickfixBiome": "error",
|
|
480
|
-
"
|
|
557
|
+
"noReactForwardRef": "error",
|
|
481
558
|
"noRedeclare": "error",
|
|
482
559
|
"noRedundantUseStrict": "error",
|
|
483
560
|
"noSelfCompare": "error",
|
|
@@ -493,6 +570,7 @@
|
|
|
493
570
|
"noUnknownAtRules": "error",
|
|
494
571
|
"noUnsafeDeclarationMerging": "error",
|
|
495
572
|
"noUnsafeNegation": "error",
|
|
573
|
+
"noUnusedExpressions": "error",
|
|
496
574
|
"noUselessEscapeInString": "error",
|
|
497
575
|
"noUselessRegexBackrefs": "error",
|
|
498
576
|
"noVar": "error",
|
|
@@ -501,6 +579,7 @@
|
|
|
501
579
|
"useAwait": "error",
|
|
502
580
|
"useBiomeIgnoreFolder": "error",
|
|
503
581
|
"useDefaultSwitchClauseLast": "error",
|
|
582
|
+
"useDeprecatedDate": "error",
|
|
504
583
|
"useErrorMessage": "error",
|
|
505
584
|
"useGetterReturn": "error",
|
|
506
585
|
"useGoogleFontDisplay": "error",
|
package/dist/configs/knip.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { OptionalMergeConfigFn } from "../utils.js";
|
|
2
|
+
import { KnipConfig } from "knip";
|
|
3
3
|
|
|
4
4
|
//#region src/configs/knip.d.ts
|
|
5
5
|
declare const baseConfig: {
|
|
6
|
-
readonly entry: [
|
|
6
|
+
readonly entry: string[];
|
|
7
7
|
readonly project: ["**"];
|
|
8
8
|
readonly tsdown: false;
|
|
9
9
|
};
|
|
10
|
-
declare const knipConfig: OptionalMergeConfigFn<
|
|
10
|
+
declare const knipConfig: OptionalMergeConfigFn<KnipConfig, typeof baseConfig>;
|
|
11
11
|
//#endregion
|
|
12
12
|
export { knipConfig };
|
|
13
13
|
//# sourceMappingURL=knip.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"knip.d.ts","names":[],"sources":["../../src/configs/knip.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"knip.d.ts","names":[],"sources":["../../src/configs/knip.ts"],"mappings":";;;;cAWM,UAAA;EAAA;;;;cAMO,UAAA,EAAY,qBAAA,CAAsB,UAAA,SAAmB,UAAA"}
|
package/dist/configs/knip.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createMergeConfigFn } from "
|
|
1
|
+
import { createMergeConfigFn } from "../utils.js";
|
|
2
2
|
const knipConfig = createMergeConfigFn({
|
|
3
3
|
entry: [
|
|
4
4
|
"./src/index.ts",
|
|
@@ -8,6 +8,7 @@ const knipConfig = createMergeConfigFn({
|
|
|
8
8
|
project: ["**"],
|
|
9
9
|
tsdown: false
|
|
10
10
|
});
|
|
11
|
+
//#endregion
|
|
11
12
|
export { knipConfig };
|
|
12
13
|
|
|
13
14
|
//# sourceMappingURL=knip.js.map
|
package/dist/configs/knip.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"knip.js","names":[],"sources":["../../src/configs/knip.ts"],"sourcesContent":["import type { KnipConfig } from \"knip\"\n\nimport type { OptionalMergeConfigFn } from \"
|
|
1
|
+
{"version":3,"file":"knip.js","names":[],"sources":["../../src/configs/knip.ts"],"sourcesContent":["import type { KnipConfig } from \"knip\"\n\nimport type { OptionalMergeConfigFn } from \"../utils.ts\"\nimport { createMergeConfigFn } from \"../utils.ts\"\n\n// Normally, specifying the `./src/index.ts` entry would cause knip to complain about a redundant entry because it gets automatically included via the tsdown plugin.\n// However, in projects that _don't_ use tsdown, the `./src/index.ts` entry would be missing entirely.\n// To handle this, we specify it and disable the tsdown plugin. This makes knip work in both cases.\n\nexport const DEFAULT_ENTRIES = [\"./src/index.ts\", \"**/*.test.ts\", \"./tsdown.config.ts\"]\n\nconst baseConfig = {\n entry: DEFAULT_ENTRIES,\n project: [\"**\"],\n tsdown: false,\n} as const satisfies KnipConfig\n\nexport const knipConfig: OptionalMergeConfigFn<KnipConfig, typeof baseConfig> = createMergeConfigFn(baseConfig)\n"],"mappings":";AAiBA,MAAa,aAAmE,oBAAoB;CALlG,OAAO;EAHuB;EAAkB;EAAgB;EAGzD;CACP,SAAS,CAAC,KAAK;CACf,QAAQ;CAG0F,CAAW"}
|
|
@@ -3,15 +3,14 @@
|
|
|
3
3
|
"include": ["${configDir}/**/*", "${configDir}/**/.*/**/*"],
|
|
4
4
|
"exclude": ["${configDir}/dist/"],
|
|
5
5
|
"compilerOptions": {
|
|
6
|
+
"types": ["bun"],
|
|
7
|
+
"lib": ["ESNext"],
|
|
6
8
|
"target": "ESNext",
|
|
7
9
|
"jsx": "react-jsx",
|
|
8
10
|
"module": "preserve",
|
|
9
11
|
"moduleResolution": "bundler",
|
|
10
12
|
"moduleDetection": "force",
|
|
11
|
-
"isolatedModules": true,
|
|
12
13
|
"verbatimModuleSyntax": true,
|
|
13
|
-
"esModuleInterop": false,
|
|
14
|
-
"allowSyntheticDefaultImports": true,
|
|
15
14
|
"allowImportingTsExtensions": true,
|
|
16
15
|
"resolveJsonModule": true,
|
|
17
16
|
"allowJs": true,
|
|
@@ -19,7 +18,6 @@
|
|
|
19
18
|
"skipLibCheck": true,
|
|
20
19
|
"noEmit": true,
|
|
21
20
|
|
|
22
|
-
"strict": true,
|
|
23
21
|
"allowUnreachableCode": false,
|
|
24
22
|
"allowUnusedLabels": false,
|
|
25
23
|
"exactOptionalPropertyTypes": true,
|
|
@@ -30,8 +28,6 @@
|
|
|
30
28
|
"noUncheckedIndexedAccess": true,
|
|
31
29
|
"noUnusedLocals": true,
|
|
32
30
|
"noUnusedParameters": true,
|
|
33
|
-
"forceConsistentCasingInFileNames": true,
|
|
34
|
-
"noUncheckedSideEffectImports": true,
|
|
35
31
|
|
|
36
32
|
"paths": {
|
|
37
33
|
"~/*": ["${configDir}/src/*"]
|
package/dist/configs/tsdown.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MergeConfigFn, OptionalMergeConfigFn } from "
|
|
1
|
+
import { MergeConfigFn, OptionalMergeConfigFn } from "../utils.js";
|
|
2
2
|
import { SetRequired } from "type-fest";
|
|
3
3
|
import { UserConfig } from "tsdown";
|
|
4
4
|
|
|
@@ -35,11 +35,11 @@ declare const binConfig: {
|
|
|
35
35
|
readonly sourcemap: false;
|
|
36
36
|
readonly dts: false;
|
|
37
37
|
readonly attw: false;
|
|
38
|
-
readonly publint: false;
|
|
39
38
|
readonly target: false;
|
|
40
39
|
readonly fixedExtension: false;
|
|
41
40
|
readonly minify: "dce-only";
|
|
42
41
|
readonly hash: false;
|
|
42
|
+
readonly publint: true;
|
|
43
43
|
readonly failOnWarn: true;
|
|
44
44
|
};
|
|
45
45
|
declare const tsdownConfig: MergeConfigFn<StrictUserConfig, typeof baseConfig>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tsdown.d.ts","names":[],"sources":["../../src/configs/tsdown.ts"],"mappings":";;;;;KAOK,gBAAA,GAAmB,WAAA,CAAY,UAAA;AAAA,cAE9B,UAAA;EAAA;;;;;;;;;;;;;;;;;;;;cAsBA,SAAA;EAAA;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"tsdown.d.ts","names":[],"sources":["../../src/configs/tsdown.ts"],"mappings":";;;;;KAOK,gBAAA,GAAmB,WAAA,CAAY,UAAA;AAAA,cAE9B,UAAA;EAAA;;;;;;;;;;;;;;;;;;;;cAsBA,SAAA;EAAA;;;;;;;;;;;;;;;;cAWO,YAAA,EAAc,aAAA,CAAc,gBAAA,SAAyB,UAAA;AAAA,cACrD,eAAA,EAAiB,qBAAA,CAAsB,UAAA,SAAmB,SAAA"}
|
package/dist/configs/tsdown.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { createMergeConfigFn } from "
|
|
1
|
+
import { createMergeConfigFn } from "../utils.js";
|
|
2
|
+
//#region src/configs/tsdown.ts
|
|
2
3
|
const baseConfig = {
|
|
3
4
|
entry: ["./src/index.ts"],
|
|
4
5
|
unbundle: true,
|
|
@@ -28,11 +29,11 @@ const binConfig = {
|
|
|
28
29
|
unbundle: false,
|
|
29
30
|
sourcemap: false,
|
|
30
31
|
dts: false,
|
|
31
|
-
attw: false
|
|
32
|
-
publint: false
|
|
32
|
+
attw: false
|
|
33
33
|
};
|
|
34
34
|
const tsdownConfig = createMergeConfigFn(baseConfig);
|
|
35
35
|
const tsdownBinConfig = createMergeConfigFn(binConfig);
|
|
36
|
+
//#endregion
|
|
36
37
|
export { tsdownBinConfig, tsdownConfig };
|
|
37
38
|
|
|
38
39
|
//# sourceMappingURL=tsdown.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tsdown.js","names":[],"sources":["../../src/configs/tsdown.ts"],"sourcesContent":["import type { UserConfig } from \"tsdown\"\nimport type { SetRequired } from \"type-fest\"\n\nimport type { MergeConfigFn, OptionalMergeConfigFn } from \"
|
|
1
|
+
{"version":3,"file":"tsdown.js","names":[],"sources":["../../src/configs/tsdown.ts"],"sourcesContent":["import type { UserConfig } from \"tsdown\"\nimport type { SetRequired } from \"type-fest\"\n\nimport type { MergeConfigFn, OptionalMergeConfigFn } from \"../utils.ts\"\nimport { createMergeConfigFn } from \"../utils.ts\"\n\n// force projects to specify platform\ntype StrictUserConfig = SetRequired<UserConfig, \"platform\">\n\nconst baseConfig = {\n entry: [\"./src/index.ts\"],\n unbundle: true,\n target: false,\n platform: \"neutral\",\n fixedExtension: false,\n minify: \"dce-only\",\n sourcemap: true,\n hash: false,\n dts: {\n resolver: \"tsc\",\n newContext: true,\n sourcemap: true,\n },\n attw: {\n level: \"error\",\n profile: \"esm-only\",\n },\n publint: true,\n failOnWarn: true,\n} as const satisfies StrictUserConfig\n\nconst binConfig = {\n ...baseConfig,\n entry: [],\n platform: \"node\",\n outExtensions: () => ({ js: \"\" }),\n unbundle: false,\n sourcemap: false,\n dts: false,\n attw: false,\n} as const satisfies UserConfig\n\nexport const tsdownConfig: MergeConfigFn<StrictUserConfig, typeof baseConfig> = createMergeConfigFn(baseConfig)\nexport const tsdownBinConfig: OptionalMergeConfigFn<UserConfig, typeof binConfig> = createMergeConfigFn(binConfig)\n"],"mappings":";;AASA,MAAM,aAAa;CACjB,OAAO,CAAC,iBAAiB;CACzB,UAAU;CACV,QAAQ;CACR,UAAU;CACV,gBAAgB;CAChB,QAAQ;CACR,WAAW;CACX,MAAM;CACN,KAAK;EACH,UAAU;EACV,YAAY;EACZ,WAAW;EACZ;CACD,MAAM;EACJ,OAAO;EACP,SAAS;EACV;CACD,SAAS;CACT,YAAY;CACb;AAED,MAAM,YAAY;CAChB,GAAG;CACH,OAAO,EAAE;CACT,UAAU;CACV,sBAAsB,EAAE,IAAI,IAAI;CAChC,UAAU;CACV,WAAW;CACX,KAAK;CACL,MAAM;CACP;AAED,MAAa,eAAmE,oBAAoB,WAAW;AAC/G,MAAa,kBAAuE,oBAAoB,UAAU"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { knipConfig } from "./configs/knip.js";
|
|
2
|
-
import { prettierConfig } from "./configs/prettier.js";
|
|
3
2
|
import { tsdownBinConfig, tsdownConfig } from "./configs/tsdown.js";
|
|
4
|
-
export { knipConfig,
|
|
3
|
+
export { knipConfig, tsdownBinConfig, tsdownConfig };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { knipConfig } from "./configs/knip.js";
|
|
2
|
-
import { prettierConfig } from "./configs/prettier.js";
|
|
3
2
|
import { tsdownBinConfig, tsdownConfig } from "./configs/tsdown.js";
|
|
4
|
-
export { knipConfig,
|
|
3
|
+
export { knipConfig, tsdownBinConfig, tsdownConfig };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","names":[],"sources":["../src/utils.ts"],"mappings":";;;;AAkBA;;UAAiB,aAAA;EAAA,2BAEY,UAAA,EACzB,UAAA,EAAY,iBAAA,GACX,SAAA,CAAU,UAAA,EAAY,iBAAA;IAAqB,cAAA;EAAA;AAAA;;;;;;;;UAW/B,qBAAA,iCAAsD,aAAA,CAAc,UAAA,EAAY,UAAA;EAAA,IAC3F,UAAA;AAAA"}
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import { mergeWith } from "es-toolkit";
|
|
2
2
|
import { clone } from "remeda";
|
|
3
|
+
//#region src/utils.ts
|
|
4
|
+
/**
|
|
5
|
+
* A wrapper around es-toolkit's `mergeWith` with a custom merge function that concatenates arrays.
|
|
6
|
+
*/
|
|
3
7
|
function merge(target, source) {
|
|
4
8
|
return mergeWith(target, source, (objValue, srcValue) => Array.isArray(objValue) ? objValue.concat(srcValue) : void 0);
|
|
5
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* Creates a config merge function with proper type overloads for merging with a base config.
|
|
12
|
+
*/
|
|
6
13
|
function createMergeConfigFn(baseConfig) {
|
|
7
14
|
const mergeConfigFn = (userConfig) => {
|
|
8
15
|
if (userConfig === void 0) return baseConfig;
|
|
@@ -10,6 +17,7 @@ function createMergeConfigFn(baseConfig) {
|
|
|
10
17
|
};
|
|
11
18
|
return mergeConfigFn;
|
|
12
19
|
}
|
|
20
|
+
//#endregion
|
|
13
21
|
export { createMergeConfigFn };
|
|
14
22
|
|
|
15
23
|
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","names":[],"sources":["../src/utils.ts"],"sourcesContent":["import { mergeWith } from \"es-toolkit\"\nimport { clone } from \"remeda\"\nimport type { MergeDeep } from \"type-fest\"\n\ntype AnyObj = object\n\n/**\n * A wrapper around es-toolkit's `mergeWith` with a custom merge function that concatenates arrays.\n */\nfunction merge<T extends AnyObj, S extends AnyObj>(target: T, source: S): T & S {\n return mergeWith(target, source, (objValue: unknown, srcValue: unknown) =>\n Array.isArray(objValue) ? objValue.concat(srcValue) : undefined,\n )\n}\n\n/**\n * The merge config function, where the `UserConfig` passed in is merged with `BaseConfig`.\n */\nexport interface MergeConfigFn<UserConfig, BaseConfig> {\n // biome-ignore lint/style/useShorthandFunctionType: need to use call signature type\n <UserConfigToMerge extends UserConfig>(\n userConfig: UserConfigToMerge,\n ): MergeDeep<BaseConfig, UserConfigToMerge, { arrayMergeMode: \"spread\" }>\n // instead of returning `BaseConfig & UserConfig` (from `merge`), return a more friendly type using `MergeDeep`\n}\n\n/**\n * The optional merge config function, where the `userConfig` argument is optional.\n * - if `UserConfig` is not provided, the return type is `BaseConfig`\n * - if `UserConfig` is provided, the return type is the merged type of `BaseConfig` and `UserConfig`.\n *\n * Note that this extends `MergeConfigFn`, so this type has both function signatures on it.\n */\nexport interface OptionalMergeConfigFn<UserConfig, BaseConfig> extends MergeConfigFn<UserConfig, BaseConfig> {\n (): BaseConfig\n}\n\n/**\n * Creates a config merge function with proper type overloads for merging with a base config.\n */\nexport function createMergeConfigFn<UserConfig extends AnyObj, BaseConfig extends UserConfig>(baseConfig: BaseConfig) {\n // we don't care about the specific type of userConfig here because we assert mergeConfigFn as the correct type below\n const mergeConfigFn = (userConfig?: AnyObj) => {\n if (userConfig === undefined) return baseConfig\n // clone both target and source so we never mutate the original objects\n return merge(clone(baseConfig), clone(userConfig))\n }\n\n return mergeConfigFn as MergeConfigFn<UserConfig, BaseConfig> & OptionalMergeConfigFn<UserConfig, BaseConfig>\n}\n"],"mappings":";;;;;;AASA,SAAS,MAA0C,QAAW,QAAkB;AAC9E,QAAO,UAAU,QAAQ,SAAS,UAAmB,aACnD,MAAM,QAAQ,SAAS,GAAG,SAAS,OAAO,SAAS,GAAG,KAAA,EACvD;;;;;AA4BH,SAAgB,oBAA8E,YAAwB;CAEpH,MAAM,iBAAiB,eAAwB;AAC7C,MAAI,eAAe,KAAA,EAAW,QAAO;AAErC,SAAO,MAAM,MAAM,WAAW,EAAE,MAAM,WAAW,CAAC;;AAGpD,QAAO"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adamhl8/configs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -17,8 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"bin": {
|
|
20
|
-
"adamhl8-knip": "./dist/adamhl8-knip/index"
|
|
21
|
-
"ts-import-fix": "./dist/ts-import-fix/index"
|
|
20
|
+
"adamhl8-knip": "./dist/adamhl8-knip/index"
|
|
22
21
|
},
|
|
23
22
|
"exports": {
|
|
24
23
|
"./tsconfig": "./dist/configs/tsconfig.base.json",
|
|
@@ -31,38 +30,28 @@
|
|
|
31
30
|
"files": ["./dist/"],
|
|
32
31
|
"scripts": {
|
|
33
32
|
"bundle": "bun lint && tsdown",
|
|
34
|
-
"lint": "bun ./generate-biome-rules.ts && markdown-toc -i --bullets '-' --maxdepth 3 ./README.md &&
|
|
33
|
+
"lint": "bun ./generate-biome-rules.ts && markdown-toc -i --bullets '-' --maxdepth 3 ./README.md && tsc --noEmit && biome check --write && ./src/adamhl8-knip/index.ts",
|
|
35
34
|
"prepare": "find .githooks -type f -exec ln -srf {} .git/hooks/ \\; || true",
|
|
36
|
-
"prepublishOnly": "bun bundle"
|
|
35
|
+
"prepublishOnly": "bun bundle",
|
|
36
|
+
"postinstall": "bun ./patch-knip.ts"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"typescript": "^
|
|
39
|
+
"typescript": "^6.0.0"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"es-toolkit": "^1.44.0",
|
|
46
|
-
"get-tsconfig": "^4.13.1",
|
|
47
|
-
"picocolors": "^1.1.1",
|
|
48
|
-
"prettier-plugin-astro": "^0.14.1",
|
|
49
|
-
"prettier-plugin-sh": "^0.18.0",
|
|
50
|
-
"prettier-plugin-tailwindcss": "^0.7.2",
|
|
51
|
-
"prettier-plugin-toml": "^2.0.6",
|
|
52
|
-
"remeda": "^2.33.4",
|
|
53
|
-
"ts-explicit-errors": "^4.1.1",
|
|
54
|
-
"type-fest": "^5.4.3"
|
|
42
|
+
"es-toolkit": "^1.46.0",
|
|
43
|
+
"remeda": "^2.33.7",
|
|
44
|
+
"type-fest": "^5.6.0"
|
|
55
45
|
},
|
|
56
46
|
"devDependencies": {
|
|
57
47
|
"@arethetypeswrong/core": "^0.18.2",
|
|
58
|
-
"@biomejs/biome": "^2.
|
|
59
|
-
"@types/bun": "^1.3.
|
|
60
|
-
"knip": "^
|
|
48
|
+
"@biomejs/biome": "^2.4.13",
|
|
49
|
+
"@types/bun": "^1.3.13",
|
|
50
|
+
"knip": "^6.7.0",
|
|
61
51
|
"markdown-toc": "^1.2.0",
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"typescript": "^5.9.3"
|
|
52
|
+
"publint": "^0.3.18",
|
|
53
|
+
"tsdown": "^0.21.10",
|
|
54
|
+
"typescript": "^6.0.3"
|
|
66
55
|
},
|
|
67
56
|
"publishConfig": {
|
|
68
57
|
"access": "public"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"knip-preprocessor.d.ts","names":[],"sources":["../../src/configs/knip-preprocessor.ts"],"mappings":";;;cA4FM,UAAA,EAAY,YAAA"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { knipConfig } from "./knip.js";
|
|
2
|
-
function modifyIssues(options, issueType, mapFn) {
|
|
3
|
-
const originalIssues = options.issues[issueType];
|
|
4
|
-
const modifiedIssueEntries = Object.entries(originalIssues).map(([key, issueRecord]) => [key, Object.entries(issueRecord)]).map(([key, issueRecordEntries]) => [key, Object.fromEntries(mapFn([key, issueRecordEntries]))]);
|
|
5
|
-
const modifiedIssues = Object.fromEntries(modifiedIssueEntries);
|
|
6
|
-
const countIssues = (issueRecords) => Object.values(issueRecords).map((issueRecord) => Object.keys(issueRecord).length).reduce((acc, curr) => acc + curr, 0);
|
|
7
|
-
const originalIssueCount = countIssues(originalIssues);
|
|
8
|
-
const issuesRemovedCount = originalIssueCount - countIssues(modifiedIssues);
|
|
9
|
-
options.counters[issueType] = originalIssueCount - issuesRemovedCount;
|
|
10
|
-
options.issues[issueType] = modifiedIssues;
|
|
11
|
-
}
|
|
12
|
-
const entries = knipConfig().entry;
|
|
13
|
-
const preprocess = (options) => {
|
|
14
|
-
options.configurationHints = options.configurationHints.filter((hint) => !(entries.some((entry) => typeof hint.identifier === "string" && hint.identifier.includes(entry)) && (hint.type === "entry-empty" || hint.type === "entry-redundant")));
|
|
15
|
-
modifyIssues(options, "unlisted", ([, issueRecordEntries]) => issueRecordEntries.filter(([key]) => !key.includes("prettier")));
|
|
16
|
-
return options;
|
|
17
|
-
};
|
|
18
|
-
var knip_preprocessor_default = preprocess;
|
|
19
|
-
export { knip_preprocessor_default as default };
|
|
20
|
-
|
|
21
|
-
//# sourceMappingURL=knip-preprocessor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"knip-preprocessor.js","names":[],"sources":["../../src/configs/knip-preprocessor.ts"],"sourcesContent":["import type {\n IssueRecords,\n Preprocessor,\n ReporterOptions,\n SymbolIssueType,\n} from \"../../node_modules/knip/dist/types/issues.d.ts\"\nimport { knipConfig } from \"./knip.ts\"\n\n/*\n * The `IssueRecords` type represents an object where each key is the file path and the value is an object containing each issue object.\n *\n * For example:\n *\n * ```ts\n * {\n * \"path/to/file/with/issues.ts\": {\n * \"issue1\": { ... },\n * \"issue2\": { ... },\n * },\n * // ...\n * }\n * ```\n */\n\n/** The object containing all the issues for the given file path. */\ntype IssueRecord = IssueRecords[keyof IssueRecords]\ntype IssueRecordEntry = [keyof IssueRecord, IssueRecord[keyof IssueRecord]]\n\n/**\n * We transform `IssueRecords` into object entries where where the _value_ is an array of the object entries from each `IssueRecord`.\n *\n * For example, we're going from this:\n *\n * ```ts\n * {\n * \"path/to/file/with/issues.ts\": {\n * \"issue1\": { ... },\n * \"issue2\": { ... },\n * },\n * // ...\n * }\n * ```\n *\n * to this:\n *\n * ```ts\n * [\n * [\"path/to/file/with/issues.ts\", [[\"issue1\", { ... }], [\"issue2\", { ... }]]],\n * // ...\n * ]\n * ```\n */\ntype IssueRecordsEntry = [keyof IssueRecords, IssueRecordEntry[]]\n\n/**\n * Modifies issues based on the provided map function.\n *\n * This is needed because we also need to update `options.counters` after modifying issues.\n */\nfunction modifyIssues(\n options: ReporterOptions,\n issueType: SymbolIssueType,\n mapFn: (issueRecordsEntry: IssueRecordsEntry) => IssueRecordEntry[], // The mapFn should return the entries for the individual issues. We want to make the key (which is the file path) available, but we don't want to allow modification of the key.\n) {\n const originalIssues: IssueRecords = options.issues[issueType]\n const originalIssueEntries: IssueRecordsEntry[] = Object.entries(originalIssues).map(([key, issueRecord]) => [\n key,\n Object.entries(issueRecord),\n ])\n\n const modifiedIssueEntries = originalIssueEntries.map(\n // The map function receives something like `[\"path/to/file.ts\", [[\"issue1\", { ... }], [\"issue2\", { ... }]]]`\n // It then returns *only* the entries for the individual issues: `[[\"issue1\", { ... }], [\"issue2\", { ... }]]`\n ([key, issueRecordEntries]) => [key, Object.fromEntries(mapFn([key, issueRecordEntries]))] as const,\n )\n const modifiedIssues: IssueRecords = Object.fromEntries(modifiedIssueEntries)\n\n const countIssues = (issueRecords: IssueRecords) =>\n Object.values(issueRecords)\n .map((issueRecord) => Object.keys(issueRecord).length) // count the number of issues in each issue record\n .reduce((acc, curr) => acc + curr, 0)\n\n const originalIssueCount = countIssues(originalIssues)\n const modifiedIssueCount = countIssues(modifiedIssues)\n const issuesRemovedCount = originalIssueCount - modifiedIssueCount\n\n options.counters[issueType] = originalIssueCount - issuesRemovedCount\n options.issues[issueType] = modifiedIssues\n}\n\nconst entries = knipConfig().entry as string[]\n\nconst preprocess: Preprocessor = (options) => {\n // ignore the \"Refine entry pattern (no matches)\" configuration hints for entries in the base config\n options.configurationHints = options.configurationHints.filter(\n (hint) =>\n !(\n entries.some((entry) => typeof hint.identifier === \"string\" && hint.identifier.includes(entry)) &&\n (hint.type === \"entry-empty\" || hint.type === \"entry-redundant\")\n ),\n )\n\n modifyIssues(options, \"unlisted\", ([, issueRecordEntries]) =>\n issueRecordEntries.filter(([key]) => !key.includes(\"prettier\")),\n )\n\n return options\n}\n\nexport default preprocess\n"],"mappings":";AA2DA,SAAS,aACP,SACA,WACA,OACA;CACA,MAAM,iBAA+B,QAAQ,OAAO;CAMpD,MAAM,uBAL4C,OAAO,QAAQ,eAAe,CAAC,KAAK,CAAC,KAAK,iBAAiB,CAC3G,KACA,OAAO,QAAQ,YAAY,CAC5B,CAAC,CAEgD,KAG/C,CAAC,KAAK,wBAAwB,CAAC,KAAK,OAAO,YAAY,MAAM,CAAC,KAAK,mBAAmB,CAAC,CAAC,CAAC,CAC3F;CACD,MAAM,iBAA+B,OAAO,YAAY,qBAAqB;CAE7E,MAAM,eAAe,iBACnB,OAAO,OAAO,aAAa,CACxB,KAAK,gBAAgB,OAAO,KAAK,YAAY,CAAC,OAAO,CACrD,QAAQ,KAAK,SAAS,MAAM,MAAM,EAAE;CAEzC,MAAM,qBAAqB,YAAY,eAAe;CAEtD,MAAM,qBAAqB,qBADA,YAAY,eAAe;AAGtD,SAAQ,SAAS,aAAa,qBAAqB;AACnD,SAAQ,OAAO,aAAa;;AAG9B,MAAM,UAAU,YAAY,CAAC;AAE7B,MAAM,cAA4B,YAAY;AAE5C,SAAQ,qBAAqB,QAAQ,mBAAmB,QACrD,SACC,EACE,QAAQ,MAAM,UAAU,OAAO,KAAK,eAAe,YAAY,KAAK,WAAW,SAAS,MAAM,CAAC,KAC9F,KAAK,SAAS,iBAAiB,KAAK,SAAS,oBAEnD;AAED,cAAa,SAAS,aAAa,GAAG,wBACpC,mBAAmB,QAAQ,CAAC,SAAS,CAAC,IAAI,SAAS,WAAW,CAAC,CAChE;AAED,QAAO;;AAGT,IAAA,4BAAe"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { OptionalMergeConfigFn } from "./utils.js";
|
|
2
|
-
import { Simplify } from "type-fest";
|
|
3
|
-
import { Config } from "prettier";
|
|
4
|
-
|
|
5
|
-
//#region src/configs/prettier.d.ts
|
|
6
|
-
type PrettierConfig = Simplify<Config>;
|
|
7
|
-
declare const baseConfig: {
|
|
8
|
-
readonly printWidth: 120;
|
|
9
|
-
readonly semi: false;
|
|
10
|
-
readonly plugins: ["@prettier/plugin-xml", "prettier-plugin-sh", "prettier-plugin-toml", "prettier-plugin-astro", "prettier-plugin-tailwindcss"];
|
|
11
|
-
readonly tailwindStylesheet: "./src/global.css";
|
|
12
|
-
readonly overrides: [{
|
|
13
|
-
readonly files: "*.jsonc";
|
|
14
|
-
readonly options: {
|
|
15
|
-
readonly trailingComma: "none";
|
|
16
|
-
};
|
|
17
|
-
}, {
|
|
18
|
-
readonly files: "*.astro";
|
|
19
|
-
readonly options: {
|
|
20
|
-
readonly parser: "astro";
|
|
21
|
-
};
|
|
22
|
-
}];
|
|
23
|
-
};
|
|
24
|
-
declare const prettierConfig: OptionalMergeConfigFn<PrettierConfig, typeof baseConfig>;
|
|
25
|
-
//#endregion
|
|
26
|
-
export { prettierConfig };
|
|
27
|
-
//# sourceMappingURL=prettier.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prettier.d.ts","names":[],"sources":["../../src/configs/prettier.ts"],"mappings":";;;;;KAOK,cAAA,GAAiB,QAAA,CAAS,MAAA;AAAA,cAEzB,UAAA;EAAA;;;;;;;;;;;;;;;;cA4BO,cAAA,EAAgB,qBAAA,CAAsB,cAAA,SAAuB,UAAA"}
|
package/dist/configs/prettier.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { createMergeConfigFn } from "./utils.js";
|
|
2
|
-
const prettierConfig = createMergeConfigFn({
|
|
3
|
-
printWidth: 120,
|
|
4
|
-
semi: false,
|
|
5
|
-
plugins: [
|
|
6
|
-
"@prettier/plugin-xml",
|
|
7
|
-
"prettier-plugin-sh",
|
|
8
|
-
"prettier-plugin-toml",
|
|
9
|
-
"prettier-plugin-astro",
|
|
10
|
-
"prettier-plugin-tailwindcss"
|
|
11
|
-
],
|
|
12
|
-
tailwindStylesheet: "./src/global.css",
|
|
13
|
-
overrides: [{
|
|
14
|
-
files: "*.jsonc",
|
|
15
|
-
options: { trailingComma: "none" }
|
|
16
|
-
}, {
|
|
17
|
-
files: "*.astro",
|
|
18
|
-
options: { parser: "astro" }
|
|
19
|
-
}]
|
|
20
|
-
});
|
|
21
|
-
export { prettierConfig };
|
|
22
|
-
|
|
23
|
-
//# sourceMappingURL=prettier.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prettier.js","names":[],"sources":["../../src/configs/prettier.ts"],"sourcesContent":["import type { Config } from \"prettier\"\nimport type { Simplify } from \"type-fest\"\n\nimport type { OptionalMergeConfigFn } from \"./utils.ts\"\nimport { createMergeConfigFn } from \"./utils.ts\"\n\n// for some reason the Config type from prettier doesn't satisfy AnyObj unless we simplify it\ntype PrettierConfig = Simplify<Config>\n\nconst baseConfig = {\n printWidth: 120,\n semi: false,\n plugins: [\n \"@prettier/plugin-xml\",\n \"prettier-plugin-sh\",\n \"prettier-plugin-toml\",\n \"prettier-plugin-astro\",\n \"prettier-plugin-tailwindcss\",\n ],\n tailwindStylesheet: \"./src/global.css\",\n overrides: [\n {\n // https://github.com/prettier/prettier/issues/15956\n files: \"*.jsonc\",\n options: {\n trailingComma: \"none\",\n },\n },\n {\n files: \"*.astro\",\n options: {\n parser: \"astro\",\n },\n },\n ],\n} as const satisfies PrettierConfig\n\nexport const prettierConfig: OptionalMergeConfigFn<PrettierConfig, typeof baseConfig> = createMergeConfigFn(baseConfig)\n"],"mappings":";AAqCA,MAAa,iBAA2E,oBA5BrE;CACjB,YAAY;CACZ,MAAM;CACN,SAAS;EACP;EACA;EACA;EACA;EACA;EACD;CACD,oBAAoB;CACpB,WAAW,CACT;EAEE,OAAO;EACP,SAAS,EACP,eAAe,QAChB;EACF,EACD;EACE,OAAO;EACP,SAAS,EACP,QAAQ,SACT;EACF,CACF;CACF,CAEsH"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","names":[],"sources":["../../src/configs/utils.ts"],"mappings":";;;;AAkBA;;UAAiB,aAAA;EAAA,2BAEY,UAAA,EACzB,UAAA,EAAY,iBAAA,GACX,SAAA,CAAU,UAAA,EAAY,iBAAA;IAAqB,cAAA;EAAA;AAAA;;;;;;;;UAW/B,qBAAA,iCAAsD,aAAA,CAAc,UAAA,EAAY,UAAA;EAAA,IAC3F,UAAA;AAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":[],"sources":["../../src/configs/utils.ts"],"sourcesContent":["import { mergeWith } from \"es-toolkit\"\nimport { clone } from \"remeda\"\nimport type { MergeDeep } from \"type-fest\"\n\ntype AnyObj = object\n\n/**\n * A wrapper around es-toolkit's `mergeWith` with a custom merge function that concatenates arrays.\n */\nfunction merge<T extends AnyObj, S extends AnyObj>(target: T, source: S): T & S {\n return mergeWith(target, source, (objValue: unknown, srcValue: unknown) =>\n Array.isArray(objValue) ? objValue.concat(srcValue) : undefined,\n )\n}\n\n/**\n * The merge config function, where the `UserConfig` passed in is merged with `BaseConfig`.\n */\nexport interface MergeConfigFn<UserConfig, BaseConfig> {\n // biome-ignore lint/style/useShorthandFunctionType: need to use call signature type\n <UserConfigToMerge extends UserConfig>(\n userConfig: UserConfigToMerge,\n ): MergeDeep<BaseConfig, UserConfigToMerge, { arrayMergeMode: \"spread\" }>\n // instead of returning `BaseConfig & UserConfig` (from `merge`), return a more friendly type using `MergeDeep`\n}\n\n/**\n * The optional merge config function, where the `userConfig` argument is optional.\n * - if `UserConfig` is not provided, the return type is `BaseConfig`\n * - if `UserConfig` is provided, the return type is the merged type of `BaseConfig` and `UserConfig`.\n *\n * Note that this extends `MergeConfigFn`, so this type has both function signatures on it.\n */\nexport interface OptionalMergeConfigFn<UserConfig, BaseConfig> extends MergeConfigFn<UserConfig, BaseConfig> {\n (): BaseConfig\n}\n\n/**\n * Creates a config merge function with proper type overloads for merging with a base config.\n */\nexport function createMergeConfigFn<UserConfig extends AnyObj, BaseConfig extends UserConfig>(baseConfig: BaseConfig) {\n // we don't care about the specific type of userConfig here because we assert mergeConfigFn as the correct type below\n const mergeConfigFn = (userConfig?: AnyObj) => {\n if (userConfig === undefined) return baseConfig\n // clone both target and source so we never mutate the original objects\n return merge(clone(baseConfig), clone(userConfig))\n }\n\n return mergeConfigFn as MergeConfigFn<UserConfig, BaseConfig> & OptionalMergeConfigFn<UserConfig, BaseConfig>\n}\n"],"mappings":";;AASA,SAAS,MAA0C,QAAW,QAAkB;AAC9E,QAAO,UAAU,QAAQ,SAAS,UAAmB,aACnD,MAAM,QAAQ,SAAS,GAAG,SAAS,OAAO,SAAS,GAAG,KAAA,EACvD;;AA4BH,SAAgB,oBAA8E,YAAwB;CAEpH,MAAM,iBAAiB,eAAwB;AAC7C,MAAI,eAAe,KAAA,EAAW,QAAO;AAErC,SAAO,MAAM,MAAM,WAAW,EAAE,MAAM,WAAW,CAAC;;AAGpD,QAAO"}
|
package/dist/ts-import-fix/index
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import process from "node:process";
|
|
4
|
-
import fs from "node:fs/promises";
|
|
5
|
-
import pc from "picocolors";
|
|
6
|
-
import { attempt, err, isErr } from "ts-explicit-errors";
|
|
7
|
-
import { message, multiple, object, option, string } from "@optique/core";
|
|
8
|
-
import { run } from "@optique/run";
|
|
9
|
-
import ts from "typescript";
|
|
10
|
-
import fss from "node:fs";
|
|
11
|
-
import { getTsconfig } from "get-tsconfig";
|
|
12
|
-
function cli() {
|
|
13
|
-
return run(object({
|
|
14
|
-
write: option("-w", "--write", { description: message`Write changes to files` }),
|
|
15
|
-
skipAlias: option("--skip-alias", { description: message`Skip transforming relative imports to use an alias` }),
|
|
16
|
-
fileIgnorePatterns: multiple(option("-f", "--file-ignore", string({ metavar: "PATTERN" }), { description: message`Additional glob patterns for files to ignore` })),
|
|
17
|
-
importIgnoreStrings: multiple(option("-i", "--import-ignore", string(), { description: message`An import path *containing* the given string will be ignored` }))
|
|
18
|
-
}), {
|
|
19
|
-
programName: "ts-import-fix",
|
|
20
|
-
help: "option",
|
|
21
|
-
showDefault: { prefix: " [default: " }
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
async function checkExports(filePaths) {
|
|
25
|
-
const EXPORT_ERRORS = [];
|
|
26
|
-
const exportCheckResult = await attempt(() => {
|
|
27
|
-
const filePromises = filePaths.map(async (filePath) => {
|
|
28
|
-
const filePathParts = path.parse(filePath);
|
|
29
|
-
if (filePathParts.name === "index") return;
|
|
30
|
-
const sourceCode = await fs.readFile(filePath, "utf8");
|
|
31
|
-
const sourceFile = ts.createSourceFile(filePathParts.base, sourceCode, ts.ScriptTarget.Latest, true);
|
|
32
|
-
const exportDeclarations = [];
|
|
33
|
-
const visit = (node) => {
|
|
34
|
-
if (ts.isExportDeclaration(node)) exportDeclarations.push(node);
|
|
35
|
-
ts.forEachChild(node, visit);
|
|
36
|
-
};
|
|
37
|
-
visit(sourceFile);
|
|
38
|
-
if (exportDeclarations.length === 0) return;
|
|
39
|
-
const exportDeclarationText = exportDeclarations.map((declaration) => declaration.getText()).join("\n");
|
|
40
|
-
EXPORT_ERRORS.push(`${pc.redBright("✗")} ${pc.blue(filePath)}\n${pc.dim(exportDeclarationText)}\n`);
|
|
41
|
-
});
|
|
42
|
-
return Promise.all(filePromises);
|
|
43
|
-
});
|
|
44
|
-
if (isErr(exportCheckResult)) return err("something went wrong when checking exports", exportCheckResult);
|
|
45
|
-
if (EXPORT_ERRORS.length > 0) return err(`found export declarations:\n${EXPORT_ERRORS.join("\n")}`, void 0);
|
|
46
|
-
}
|
|
47
|
-
const IMPORT_PATTERN = /(?:import|from)\s+['"]([^'"]+)['"]$/gm;
|
|
48
|
-
function getPathsMap() {
|
|
49
|
-
const tsconfig = getTsconfig();
|
|
50
|
-
if (!tsconfig) return err("failed to load tsconfig", void 0);
|
|
51
|
-
const pathsMap = {};
|
|
52
|
-
for (let [alias, [aliasDir]] of Object.entries(tsconfig.config.compilerOptions?.paths ?? {})) {
|
|
53
|
-
if (!alias.endsWith("/*")) continue;
|
|
54
|
-
if (!aliasDir?.endsWith("/*")) continue;
|
|
55
|
-
alias = alias.slice(0, -1);
|
|
56
|
-
aliasDir = aliasDir.slice(0, -1);
|
|
57
|
-
pathsMap[alias] = aliasDir;
|
|
58
|
-
}
|
|
59
|
-
return pathsMap;
|
|
60
|
-
}
|
|
61
|
-
function resolveImportPath(importPath, filePath, pathsMap) {
|
|
62
|
-
const fileDir = path.dirname(filePath);
|
|
63
|
-
const sortedAliases = Object.keys(pathsMap).sort((a, b) => b.length - a.length);
|
|
64
|
-
for (const alias of sortedAliases) {
|
|
65
|
-
if (!importPath.startsWith(alias)) continue;
|
|
66
|
-
const aliasDir = pathsMap[alias];
|
|
67
|
-
if (!aliasDir) continue;
|
|
68
|
-
const relativePath = importPath.slice(alias.length);
|
|
69
|
-
return path.resolve(aliasDir, relativePath);
|
|
70
|
-
}
|
|
71
|
-
return path.resolve(fileDir, importPath);
|
|
72
|
-
}
|
|
73
|
-
function changeExtension(importParts, newExtension) {
|
|
74
|
-
return {
|
|
75
|
-
...importParts,
|
|
76
|
-
ext: newExtension,
|
|
77
|
-
base: ""
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
const ALLOWED_EXTENSIONS = [
|
|
81
|
-
".ts",
|
|
82
|
-
".tsx",
|
|
83
|
-
".d.ts"
|
|
84
|
-
];
|
|
85
|
-
function getNewExtensionPathParts(importParts) {
|
|
86
|
-
const tsExtensionLookups = [
|
|
87
|
-
"",
|
|
88
|
-
".js",
|
|
89
|
-
".jsx",
|
|
90
|
-
".ts",
|
|
91
|
-
".tsx"
|
|
92
|
-
];
|
|
93
|
-
if (!tsExtensionLookups.includes(importParts.ext)) return {
|
|
94
|
-
ext: importParts.ext,
|
|
95
|
-
base: importParts.base
|
|
96
|
-
};
|
|
97
|
-
if (tsExtensionLookups.includes(importParts.ext)) for (const allowedExtension of ALLOWED_EXTENSIONS) {
|
|
98
|
-
const targetPathParts = changeExtension(importParts, allowedExtension);
|
|
99
|
-
const targetPath = path.format(targetPathParts);
|
|
100
|
-
if (fss.existsSync(targetPath)) return {
|
|
101
|
-
ext: targetPathParts.ext,
|
|
102
|
-
base: targetPathParts.base
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
function getAliasPathParts(importParts, pathsMap) {
|
|
107
|
-
const importPath = path.format(importParts);
|
|
108
|
-
for (const [alias, aliasDir] of Object.entries(pathsMap)) {
|
|
109
|
-
const relativeToAliasDir = path.relative(aliasDir, importPath);
|
|
110
|
-
if (relativeToAliasDir.startsWith("..")) continue;
|
|
111
|
-
return { dir: path.parse(`${alias}${relativeToAliasDir}`).dir };
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
async function fixImports(filePaths, { write, importIgnoreStrings, skipAlias }) {
|
|
115
|
-
const IMPORT_ERRORS = [];
|
|
116
|
-
const TRANSFORMED_IMPORTS = [];
|
|
117
|
-
const pathsMap = getPathsMap();
|
|
118
|
-
if (isErr(pathsMap)) return pathsMap;
|
|
119
|
-
const importFixResult = await attempt(() => {
|
|
120
|
-
const filePromises = filePaths.map(async (filePath) => {
|
|
121
|
-
const content = await fs.readFile(filePath, "utf8");
|
|
122
|
-
const importErrorsForFile = [];
|
|
123
|
-
const transformedImportsForFile = [];
|
|
124
|
-
const transformedContent = content.replace(IMPORT_PATTERN, (match, importPath) => {
|
|
125
|
-
const isRelativeImport = importPath.startsWith("./") || importPath.startsWith("../");
|
|
126
|
-
const isAliasImport = Object.keys(pathsMap).some((alias) => importPath.startsWith(alias));
|
|
127
|
-
if (!(isRelativeImport || isAliasImport)) return match;
|
|
128
|
-
if (importIgnoreStrings.some((ignoreString) => importPath.includes(ignoreString))) return match;
|
|
129
|
-
let newImportParts = path.parse(importPath);
|
|
130
|
-
const resolvedImportPath = resolveImportPath(importPath, filePath, pathsMap);
|
|
131
|
-
const resolvedImportParts = path.parse(resolvedImportPath);
|
|
132
|
-
const transformExtensionResult = getNewExtensionPathParts(resolvedImportParts);
|
|
133
|
-
if (transformExtensionResult) newImportParts = {
|
|
134
|
-
...newImportParts,
|
|
135
|
-
...transformExtensionResult
|
|
136
|
-
};
|
|
137
|
-
else {
|
|
138
|
-
const targetFilePath = `${path.format(changeExtension(resolvedImportParts, ""))}.{${ALLOWED_EXTENSIONS.map((ext) => ext.replace(".", "")).join()}}`;
|
|
139
|
-
importErrorsForFile.push(`skipped extension transform of '${importPath}': target file not found (looking for '${targetFilePath}')`);
|
|
140
|
-
}
|
|
141
|
-
if (isRelativeImport && !skipAlias) {
|
|
142
|
-
const transformToAliasImportResult = getAliasPathParts(resolvedImportParts, pathsMap);
|
|
143
|
-
if (transformToAliasImportResult) newImportParts = {
|
|
144
|
-
...newImportParts,
|
|
145
|
-
...transformToAliasImportResult
|
|
146
|
-
};
|
|
147
|
-
else importErrorsForFile.push(`skipped transforming relative import path '${importPath}': could not find appropriate alias`);
|
|
148
|
-
}
|
|
149
|
-
const newImportPath = path.format(newImportParts);
|
|
150
|
-
if (newImportPath === importPath) return match;
|
|
151
|
-
const { ext: originalExt } = path.parse(importPath);
|
|
152
|
-
const { ext: newExt } = newImportParts;
|
|
153
|
-
let newImportPathString = newImportPath;
|
|
154
|
-
if (newExt !== originalExt) newImportPathString = `${path.format(changeExtension(newImportParts, ""))}${pc.greenBright(newExt)}`;
|
|
155
|
-
transformedImportsForFile.push(`'${importPath}' -> '${newImportPathString}'`);
|
|
156
|
-
return match.replace(importPath, newImportPath);
|
|
157
|
-
});
|
|
158
|
-
if (importErrorsForFile.length > 0) IMPORT_ERRORS.push(`${pc.redBright("✗")} ${pc.blue(filePath)}\n${importErrorsForFile.join("\n")}\n`);
|
|
159
|
-
if (transformedImportsForFile.length > 0) TRANSFORMED_IMPORTS.push(`${pc.greenBright("✓")} ${pc.blue(filePath)}\n${transformedImportsForFile.join("\n")}\n`);
|
|
160
|
-
if (transformedContent === content) return;
|
|
161
|
-
if (write) await fs.writeFile(filePath, transformedContent);
|
|
162
|
-
});
|
|
163
|
-
return Promise.all(filePromises);
|
|
164
|
-
});
|
|
165
|
-
if (TRANSFORMED_IMPORTS.length > 0) console.log(`${pc.greenBright("[ts-import-fix]")} transformed imports:\n${TRANSFORMED_IMPORTS.join("\n")}`);
|
|
166
|
-
if (isErr(importFixResult)) return err("something went wrong when transforming imports", importFixResult);
|
|
167
|
-
if (IMPORT_ERRORS.length > 0) return err(`failed to transform some imports:\n${IMPORT_ERRORS.join("\n")}`, void 0);
|
|
168
|
-
}
|
|
169
|
-
const FILES_GLOB = "**/*.{ts,tsx,js,jsx,astro}";
|
|
170
|
-
const BASE_IGNORE_PATTERNS = [
|
|
171
|
-
".git/",
|
|
172
|
-
"node_modules/",
|
|
173
|
-
"dist/"
|
|
174
|
-
];
|
|
175
|
-
async function tsImportFix() {
|
|
176
|
-
const { fileIgnorePatterns, ...fixImportsOptions } = cli();
|
|
177
|
-
const errors = [];
|
|
178
|
-
const allFileIgnorePatterns = [
|
|
179
|
-
...BASE_IGNORE_PATTERNS,
|
|
180
|
-
"astro.config.ts",
|
|
181
|
-
...fileIgnorePatterns
|
|
182
|
-
];
|
|
183
|
-
const filePaths = await Array.fromAsync(fs.glob(FILES_GLOB, { exclude: allFileIgnorePatterns }));
|
|
184
|
-
const fixImportsResult = await fixImports(filePaths, fixImportsOptions);
|
|
185
|
-
if (isErr(fixImportsResult)) errors.push(fixImportsResult);
|
|
186
|
-
const checkExportsResult = await checkExports(filePaths);
|
|
187
|
-
if (isErr(checkExportsResult)) errors.push(checkExportsResult);
|
|
188
|
-
return errors;
|
|
189
|
-
}
|
|
190
|
-
async function main() {
|
|
191
|
-
const errors = await tsImportFix();
|
|
192
|
-
if (errors.length === 0) {
|
|
193
|
-
console.log(`${pc.greenBright("[ts-import-fix]")} Done`);
|
|
194
|
-
return 0;
|
|
195
|
-
}
|
|
196
|
-
const errorMessage = errors.map((error) => `${pc.redBright("[ts-import-fix]")} ${error.messageChain}`).join("\n\n");
|
|
197
|
-
process.stderr.write(`${errorMessage}\n`);
|
|
198
|
-
return 1;
|
|
199
|
-
}
|
|
200
|
-
if (import.meta.main) process.exitCode = await main();
|
|
201
|
-
export {};
|