@adamhl8/configs 0.15.17 → 0.15.19
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"knip-preprocessor.d.ts","names":[],"sources":["../src/knip-preprocessor.ts"],"sourcesContent":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"knip-preprocessor.d.ts","names":[],"sources":["../src/knip-preprocessor.ts"],"sourcesContent":[],"mappings":";;;cA6BM,YAAY"}
|
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
import { knipConfig } from "./knip.js";
|
|
2
2
|
import "./index.js";
|
|
3
3
|
const entries = knipConfig().entry;
|
|
4
|
+
function filterIssue(options, issueType, filter) {
|
|
5
|
+
const issuesObject = options.issues[issueType];
|
|
6
|
+
const filteredIssues = Object.fromEntries(Object.entries(issuesObject).filter(filter));
|
|
7
|
+
const issueCount = Object.keys(issuesObject).length;
|
|
8
|
+
const filteredIssueCount = Object.keys(filteredIssues).length;
|
|
9
|
+
const issuesRemovedCount = issueCount - filteredIssueCount;
|
|
10
|
+
options.counters[issueType] = issueCount - issuesRemovedCount;
|
|
11
|
+
options.issues[issueType] = filteredIssues;
|
|
12
|
+
}
|
|
4
13
|
const preprocess = (options) => {
|
|
5
14
|
const filteredConfigurationHints = [...options.configurationHints].filter((hint) => !(entries.some((entry) => typeof hint.identifier === "string" && hint.identifier.includes(entry)) && hint.type === "entry-empty"));
|
|
6
15
|
options.configurationHints = new Set(filteredConfigurationHints);
|
|
7
|
-
|
|
8
|
-
options.
|
|
16
|
+
filterIssue(options, "unlisted", ([key]) => !key.includes("prettier"));
|
|
17
|
+
filterIssue(options, "unlisted", ([, issueObj]) => Object.keys(issueObj).length > 0);
|
|
9
18
|
return options;
|
|
10
19
|
};
|
|
11
20
|
var knip_preprocessor_default = preprocess;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"knip-preprocessor.js","names":["preprocess: Preprocessor"],"sources":["../src/knip-preprocessor.ts"],"sourcesContent":["import type { Preprocessor } from \"knip\"\n\n// biome-ignore lint/plugin: ignore\nimport { knipConfig } from \"./index.ts\"\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 const filteredConfigurationHints = [...options.configurationHints].filter(\n (hint) =>\n !(\n entries.some((entry) => typeof hint.identifier === \"string\" && hint.identifier.includes(entry)) &&\n hint.type === \"entry-empty\"\n ),\n )\n options.configurationHints = new Set(filteredConfigurationHints)\n\n
|
|
1
|
+
{"version":3,"file":"knip-preprocessor.js","names":["preprocess: Preprocessor"],"sources":["../src/knip-preprocessor.ts"],"sourcesContent":["import type { Preprocessor, ReporterOptions } from \"knip\"\nimport type { Issue, SymbolIssueType } from \"knip/dist/types/issues\"\n\n// biome-ignore lint/plugin: ignore\nimport { knipConfig } from \"./index.ts\"\n\nconst entries = knipConfig().entry as string[]\n\n/**\n * Filters issues based on the provided filter function.\n *\n * This is needed because we also need to update `options.counters` after filtering issues.\n */\nfunction filterIssue(\n options: ReporterOptions,\n issueType: SymbolIssueType,\n filter: (issueEntry: [string, Record<string, Issue>]) => boolean,\n) {\n const issuesObject = options.issues[issueType]\n const filteredIssues = Object.fromEntries(Object.entries(issuesObject).filter(filter))\n\n const issueCount = Object.keys(issuesObject).length\n const filteredIssueCount = Object.keys(filteredIssues).length\n const issuesRemovedCount = issueCount - filteredIssueCount\n\n options.counters[issueType] = issueCount - issuesRemovedCount\n options.issues[issueType] = filteredIssues\n}\n\nconst preprocess: Preprocessor = (options) => {\n // ignore the \"Refine entry pattern (no matches)\" configuration hints for entries in the base config\n const filteredConfigurationHints = [...options.configurationHints].filter(\n (hint) =>\n !(\n entries.some((entry) => typeof hint.identifier === \"string\" && hint.identifier.includes(entry)) &&\n hint.type === \"entry-empty\"\n ),\n )\n options.configurationHints = new Set(filteredConfigurationHints)\n\n filterIssue(options, \"unlisted\", ([key]) => !key.includes(\"prettier\"))\n filterIssue(options, \"unlisted\", ([, issueObj]) => Object.keys(issueObj).length > 0)\n\n return options\n}\n\nexport default preprocess\n"],"mappings":";;AAMA,MAAM,UAAU,YAAY,CAAC;AAO7B,SAAS,YACP,SACA,WACA,QACA;CACA,MAAM,eAAe,QAAQ,OAAO;CACpC,MAAM,iBAAiB,OAAO,YAAY,OAAO,QAAQ,aAAa,CAAC,OAAO,OAAO,CAAC;CAEtF,MAAM,aAAa,OAAO,KAAK,aAAa,CAAC;CAC7C,MAAM,qBAAqB,OAAO,KAAK,eAAe,CAAC;CACvD,MAAM,qBAAqB,aAAa;AAExC,SAAQ,SAAS,aAAa,aAAa;AAC3C,SAAQ,OAAO,aAAa;;AAG9B,MAAMA,cAA4B,YAAY;CAE5C,MAAM,6BAA6B,CAAC,GAAG,QAAQ,mBAAmB,CAAC,QAChE,SACC,EACE,QAAQ,MAAM,UAAU,OAAO,KAAK,eAAe,YAAY,KAAK,WAAW,SAAS,MAAM,CAAC,IAC/F,KAAK,SAAS,eAEnB;AACD,SAAQ,qBAAqB,IAAI,IAAI,2BAA2B;AAEhE,aAAY,SAAS,aAAa,CAAC,SAAS,CAAC,IAAI,SAAS,WAAW,CAAC;AACtE,aAAY,SAAS,aAAa,GAAG,cAAc,OAAO,KAAK,SAAS,CAAC,SAAS,EAAE;AAEpF,QAAO;;AAGT,IAAA,4BAAe"}
|
package/dist/utils.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { mergeWith } from "es-toolkit";
|
|
2
|
-
import { isPlainObject } from "remeda";
|
|
2
|
+
import { clone, isPlainObject } from "remeda";
|
|
3
3
|
function merge(target, source) {
|
|
4
4
|
return mergeWith(target, source, (objValue, srcValue) => Array.isArray(objValue) ? objValue.concat(srcValue) : void 0);
|
|
5
5
|
}
|
|
@@ -7,7 +7,7 @@ function createMergeConfigFn(baseConfig) {
|
|
|
7
7
|
function mergeConfig(userConfig) {
|
|
8
8
|
if (userConfig === void 0) return baseConfig;
|
|
9
9
|
if (!(isPlainObject(baseConfig) && isPlainObject(userConfig))) throw new Error(`target and/or source is not an object: target='${baseConfig}'\nsource='${userConfig}'`);
|
|
10
|
-
return merge(baseConfig, userConfig);
|
|
10
|
+
return merge(clone(baseConfig), clone(userConfig));
|
|
11
11
|
}
|
|
12
12
|
return mergeConfig;
|
|
13
13
|
}
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":[],"sources":["../src/utils.ts"],"sourcesContent":["import { mergeWith } from \"es-toolkit\"\nimport { isPlainObject } from \"remeda\"\nimport type { MergeDeep } from \"type-fest\"\n\ntype AnyObj = Record<PropertyKey, unknown>\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\ntype MergeDeepConcat<D, S> = MergeDeep<D, S, { arrayMergeMode: \"spread\" }>\n\nexport interface MergeConfigFn<UserConfigType, BaseConfig extends UserConfigType> {\n // if `userConfig` is not provided, return the type of `baseConfig`\n (): BaseConfig\n // if `userConfig` is provided, instead of returning `BaseConfig & UserConfig` (from `merge`), return a more friendly type using `MergeDeep`\n <UserConfig extends UserConfigType>(userConfig: UserConfig): MergeDeepConcat<BaseConfig, UserConfig>\n}\n\n/**\n * Creates a config merge function with proper type overloads for merging with a base config.\n */\nexport function createMergeConfigFn<UserConfigType, BaseConfig extends UserConfigType>(\n baseConfig: BaseConfig,\n): MergeConfigFn<UserConfigType, BaseConfig> {\n function mergeConfig(): BaseConfig\n\n function mergeConfig<UserConfig extends UserConfigType>(\n userConfig: UserConfig,\n ): MergeDeepConcat<BaseConfig, UserConfig>\n\n function mergeConfig<UserConfig extends UserConfigType>(userConfig?: UserConfig) {\n if (userConfig === undefined) return baseConfig\n\n if (!(isPlainObject(baseConfig) && isPlainObject(userConfig)))\n throw new Error(`target and/or source is not an object: target='${baseConfig}'\\nsource='${userConfig}'`)\n\n return merge(baseConfig, userConfig)\n }\n\n return mergeConfig\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;;AAeH,SAAgB,oBACd,YAC2C;CAO3C,SAAS,YAA+C,YAAyB;AAC/E,MAAI,eAAe,KAAA,EAAW,QAAO;AAErC,MAAI,EAAE,cAAc,WAAW,IAAI,cAAc,WAAW,EAC1D,OAAM,IAAI,MAAM,kDAAkD,WAAW,aAAa,WAAW,GAAG;
|
|
1
|
+
{"version":3,"file":"utils.js","names":[],"sources":["../src/utils.ts"],"sourcesContent":["import { mergeWith } from \"es-toolkit\"\nimport { clone, isPlainObject } from \"remeda\"\nimport type { MergeDeep } from \"type-fest\"\n\ntype AnyObj = Record<PropertyKey, unknown>\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\ntype MergeDeepConcat<D, S> = MergeDeep<D, S, { arrayMergeMode: \"spread\" }>\n\nexport interface MergeConfigFn<UserConfigType, BaseConfig extends UserConfigType> {\n // if `userConfig` is not provided, return the type of `baseConfig`\n (): BaseConfig\n // if `userConfig` is provided, instead of returning `BaseConfig & UserConfig` (from `merge`), return a more friendly type using `MergeDeep`\n <UserConfig extends UserConfigType>(userConfig: UserConfig): MergeDeepConcat<BaseConfig, UserConfig>\n}\n\n/**\n * Creates a config merge function with proper type overloads for merging with a base config.\n */\nexport function createMergeConfigFn<UserConfigType, BaseConfig extends UserConfigType>(\n baseConfig: BaseConfig,\n): MergeConfigFn<UserConfigType, BaseConfig> {\n function mergeConfig(): BaseConfig\n\n function mergeConfig<UserConfig extends UserConfigType>(\n userConfig: UserConfig,\n ): MergeDeepConcat<BaseConfig, UserConfig>\n\n function mergeConfig<UserConfig extends UserConfigType>(userConfig?: UserConfig) {\n if (userConfig === undefined) return baseConfig\n\n if (!(isPlainObject(baseConfig) && isPlainObject(userConfig)))\n throw new Error(`target and/or source is not an object: target='${baseConfig}'\\nsource='${userConfig}'`)\n\n // clone both target and source so we never mutate the original objects\n return merge(clone(baseConfig), clone(userConfig))\n }\n\n return mergeConfig\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;;AAeH,SAAgB,oBACd,YAC2C;CAO3C,SAAS,YAA+C,YAAyB;AAC/E,MAAI,eAAe,KAAA,EAAW,QAAO;AAErC,MAAI,EAAE,cAAc,WAAW,IAAI,cAAc,WAAW,EAC1D,OAAM,IAAI,MAAM,kDAAkD,WAAW,aAAa,WAAW,GAAG;AAG1G,SAAO,MAAM,MAAM,WAAW,EAAE,MAAM,WAAW,CAAC;;AAGpD,QAAO"}
|