mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 01:30:43 +00:00
refactor(lint): enable map spread rule
This commit is contained in:
@@ -28,8 +28,7 @@ function loadPluginRuntime(): PluginRuntimeModule | null {
|
||||
}
|
||||
|
||||
export function resolveRuntimeCliBackends(): PluginCliBackendEntry[] {
|
||||
return (loadPluginRuntime()?.getActivePluginRegistry()?.cliBackends ?? []).map((entry) => ({
|
||||
...entry.backend,
|
||||
pluginId: entry.pluginId,
|
||||
}));
|
||||
return (loadPluginRuntime()?.getActivePluginRegistry()?.cliBackends ?? []).map((entry) =>
|
||||
Object.assign({}, entry.backend, { pluginId: entry.pluginId }),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2822,12 +2822,13 @@ module.exports = { id: "throws-after-import", register() {} };`,
|
||||
] as const;
|
||||
|
||||
runSinglePluginRegistryScenarios(
|
||||
scenarios.map((scenario) => ({
|
||||
...scenario,
|
||||
body: `module.exports = { id: "${scenario.pluginId}", register(api) {
|
||||
scenarios.map((scenario) =>
|
||||
Object.assign({}, scenario, {
|
||||
body: `module.exports = { id: "${scenario.pluginId}", register(api) {
|
||||
api.registerHttpRoute(${scenario.routeOptions});
|
||||
} };`,
|
||||
})),
|
||||
}),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -57,10 +57,9 @@ function resolveProviderDiscoveryEntryPlugins(params: {
|
||||
try {
|
||||
const moduleExport = loadSource(manifest.providerDiscoverySource!) as ProviderDiscoveryModule;
|
||||
providers.push(
|
||||
...normalizeDiscoveryModule(moduleExport).map((provider) => ({
|
||||
...provider,
|
||||
pluginId: manifest.id,
|
||||
})),
|
||||
...normalizeDiscoveryModule(moduleExport).map((provider) =>
|
||||
Object.assign({}, provider, { pluginId: manifest.id }),
|
||||
),
|
||||
);
|
||||
} catch {
|
||||
// Discovery fast path is optional. Fall back to the full plugin loader
|
||||
|
||||
@@ -275,10 +275,9 @@ export function resolvePluginProviders(params: {
|
||||
return [];
|
||||
}
|
||||
const registry = loadOpenClawPlugins(loadState.loadOptions);
|
||||
return registry.providers.map((entry) => ({
|
||||
...entry.provider,
|
||||
pluginId: entry.pluginId,
|
||||
}));
|
||||
return registry.providers.map((entry) =>
|
||||
Object.assign({}, entry.provider, { pluginId: entry.pluginId }),
|
||||
);
|
||||
}
|
||||
const loadState = resolveRuntimeProviderPluginLoadState(params, base);
|
||||
const registry = resolveRuntimePluginRegistry(loadState.loadOptions);
|
||||
@@ -286,8 +285,7 @@ export function resolvePluginProviders(params: {
|
||||
return [];
|
||||
}
|
||||
|
||||
return registry.providers.map((entry) => ({
|
||||
...entry.provider,
|
||||
pluginId: entry.pluginId,
|
||||
}));
|
||||
return registry.providers.map((entry) =>
|
||||
Object.assign({}, entry.provider, { pluginId: entry.pluginId }),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -19,29 +19,38 @@ const LIVE_RUNTIME_STATE_GUARDS: Record<
|
||||
},
|
||||
};
|
||||
|
||||
function guardAssertions() {
|
||||
return Object.entries(LIVE_RUNTIME_STATE_GUARDS).flatMap(([relativePath, guard]) => [
|
||||
...guard.required.map((needle) => ({
|
||||
relativePath,
|
||||
type: "required" as const,
|
||||
needle,
|
||||
message: `${relativePath} missing ${needle}`,
|
||||
})),
|
||||
...guard.forbidden.map((needle) => ({
|
||||
relativePath,
|
||||
type: "forbidden" as const,
|
||||
needle,
|
||||
message: `${relativePath} must not contain ${needle}`,
|
||||
})),
|
||||
]);
|
||||
}
|
||||
|
||||
function expectGuardState(params: {
|
||||
source: string;
|
||||
type GuardAssertion = {
|
||||
relativePath: string;
|
||||
type: "required" | "forbidden";
|
||||
needle: string;
|
||||
message: string;
|
||||
}) {
|
||||
};
|
||||
|
||||
function guardAssertions(): GuardAssertion[] {
|
||||
return Object.entries(LIVE_RUNTIME_STATE_GUARDS).flatMap(([relativePath, guard]) =>
|
||||
guard.required
|
||||
.map<GuardAssertion>((needle) => ({
|
||||
relativePath,
|
||||
type: "required",
|
||||
needle,
|
||||
message: `${relativePath} missing ${needle}`,
|
||||
}))
|
||||
.concat(
|
||||
guard.forbidden.map<GuardAssertion>((needle) => ({
|
||||
relativePath,
|
||||
type: "forbidden",
|
||||
needle,
|
||||
message: `${relativePath} must not contain ${needle}`,
|
||||
})),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
function expectGuardState(
|
||||
params: {
|
||||
source: string;
|
||||
} & Pick<GuardAssertion, "message" | "needle" | "type">,
|
||||
) {
|
||||
if (params.type === "required") {
|
||||
expect(params.source, params.message).toContain(params.needle);
|
||||
return;
|
||||
|
||||
@@ -208,11 +208,12 @@ function buildPluginReport(
|
||||
return {
|
||||
workspaceDir,
|
||||
...registry,
|
||||
plugins: registry.plugins.map((plugin) => ({
|
||||
...plugin,
|
||||
imported: plugin.format !== "bundle" && importedPluginIds.has(plugin.id),
|
||||
version: resolveReportedPluginVersion(plugin, params?.env),
|
||||
})),
|
||||
plugins: registry.plugins.map((plugin) =>
|
||||
Object.assign({}, plugin, {
|
||||
imported: plugin.format !== `bundle` && importedPluginIds.has(plugin.id),
|
||||
version: resolveReportedPluginVersion(plugin, params?.env),
|
||||
}),
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ export function loadBundledWebSearchProviderEntriesFromDir(params: {
|
||||
if (providers.length === 0) {
|
||||
return null;
|
||||
}
|
||||
return providers.map((provider) => ({ ...provider, pluginId: params.pluginId }));
|
||||
return providers.map((provider) => Object.assign({}, provider, { pluginId: params.pluginId }));
|
||||
}
|
||||
|
||||
export function loadBundledRuntimeWebSearchProviderEntriesFromDir(params: {
|
||||
@@ -148,7 +148,7 @@ export function loadBundledRuntimeWebSearchProviderEntriesFromDir(params: {
|
||||
if (providers.length === 0) {
|
||||
return null;
|
||||
}
|
||||
return providers.map((provider) => ({ ...provider, pluginId: params.pluginId }));
|
||||
return providers.map((provider) => Object.assign({}, provider, { pluginId: params.pluginId }));
|
||||
}
|
||||
|
||||
export function loadBundledWebFetchProviderEntriesFromDir(params: {
|
||||
@@ -170,7 +170,7 @@ export function loadBundledWebFetchProviderEntriesFromDir(params: {
|
||||
if (providers.length === 0) {
|
||||
return null;
|
||||
}
|
||||
return providers.map((provider) => ({ ...provider, pluginId: params.pluginId }));
|
||||
return providers.map((provider) => Object.assign({}, provider, { pluginId: params.pluginId }));
|
||||
}
|
||||
|
||||
export function resolveBundledExplicitWebSearchProvidersFromPublicArtifacts(params: {
|
||||
|
||||
@@ -175,9 +175,6 @@ export function mapRegistryProviders<TProvider extends { id: string }>(params: {
|
||||
return params.sortProviders(
|
||||
params.entries
|
||||
.filter((entry) => !onlyPluginIdSet || onlyPluginIdSet.has(entry.pluginId))
|
||||
.map((entry) => ({
|
||||
...entry.provider,
|
||||
pluginId: entry.pluginId,
|
||||
})),
|
||||
.map((entry) => Object.assign({}, entry.provider, { pluginId: entry.pluginId })),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user