treewide: warn deprecation in singleOrListOf

This commit is contained in:
Ching Pei Yang 2025-08-23 20:52:32 +02:00
commit 154d8be4dc
No known key found for this signature in database
GPG key ID: B3841364253DC4C8
40 changed files with 106 additions and 96 deletions

View file

@ -1,4 +1,5 @@
{lib}: let
inherit (builtins) warn toJSON;
inherit (lib.options) mergeEqualOption;
inherit (lib.lists) singleton;
inherit (lib.strings) isString stringLength match;
@ -29,5 +30,14 @@ in {
check = v: isString v && (match "#?[0-9a-fA-F]{6}" v) != null;
};
singleOrListOf = t: coercedTo t singleton (listOf t);
# no compound types please
deprecatedSingleOrListOf = option: t:
coercedTo
t
(x:
warn ''
${option} no longer accepts non-list values, use [${toJSON x}] instead
''
(singleton x))
(listOf t);
}

View file

@ -10,5 +10,5 @@ in {
inherit (typesDag) dagOf;
inherit (typesPlugin) pluginsOpt extraPluginType mkPluginSetupOption luaInline pluginType borderType;
inherit (typesLanguage) diagnostics mkGrammarOption;
inherit (customTypes) char hexColor mergelessListOf singleOrListOf;
inherit (customTypes) char hexColor mergelessListOf deprecatedSingleOrListOf;
}