Plugins and localization
Loading plugins
runProject calls loadPlugins with the plugins list from the config. The core plugin is always loaded first.
The two branches are the key part of loadOnePlugin:
const moduleUrl = isLocalSpecifier(spec)
? pathToFileURL(resolve(dirname(configPath), spec)).href
: resolveNpmPlugin(spec, configPath);
const imported = (await import(moduleUrl)) as { default?: unknown };
return validatePlugin(spec, unwrapDefaultExport(imported.default));resolveNpmPlugin resolves the package the way import would from the project: with the ESM conditions (import, default). A package that only has an import condition in exports works, and a dual package resolves to its ESM build. require.resolve is not used, because it applies the CommonJS conditions. import.meta.resolve(spec, parent) is not used either, because it needs an experimental Node flag; the import-meta-resolve package provides the same resolution without it. If that fails because exports has no import or default condition, it falls back to createRequire(configPath).resolve(spec), so a package that only declares require still loads as CommonJS. It reports three distinct errors: the package is not installed (plugin.npmResolveFailed), it is installed but its exports does not export that name (plugin.npmNotExported), or any other reason (plugin.npmResolveError, with Node's message).
unwrapDefaultExport handles plugins compiled to CommonJS. import() of such a module puts module.exports into default, so exports.default = plugin arrives as { default: plugin }.
Local paths resolve relative to the config file. npm packages resolve from the project, not from the folder of the audit tool. The supported plugin API version is "1".
Rule IDs and namespacing
buildRuleMap flattens all plugins into one map. The first plugin (core) keeps bare IDs. Every other plugin gets a <plugin>/<rule> prefix:
plugins.forEach((plugin, index) => {
const prefix = index === 0 ? "" : `${plugin.name}/`;
for (const [ruleId, rule] of Object.entries(plugin.rules)) {
map[`${prefix}${ruleId}`] = rule;
}
});Rule configuration
mergeRuleConfig starts from each rule's defaultSeverity and applies the overrides from the config. A config entry is either a severity or [severity, options]:
function normalize(value: RuleConfigValue): RuleConfigEntry {
if (Array.isArray(value)) {
const [severity, options] = value;
return { severity, options };
}
return { severity: value };
}Localization
Every text a user can see goes through a translator. The pieces live in -types:
createTranslator is short:
export function createTranslator(registry: LocaleRegistry, locale: LocaleCode): Translator {
return (key, params) => {
const template = registry.bundles[locale]?.[key] ?? registry.bundles[registry.referenceLocale]?.[key] ?? key;
return interpolate(template, params);
};
}Bundles in the repository
- Rule messages:
packages/ui5-blueprint-audit-plugin-core/src/locales/ - Report labels and error texts:
packages/ui5-blueprint-audit/src/locales/
en.ts is the source of truth for the key names. de.ts and pt-BR.ts are typed as Record<keyof typeof en, string>, so a missing key is a build error:
const de: Record<keyof typeof en, string> = {
"typescript.description": "Das Projekt verwendet TypeScript.",
// ...
};A test in each package also checks that all languages have the same keys.
Output languages
| Output | Languages |
|---|---|
report_LOCALE.md | One file per active language |
report.xml | Always English, so CI dashboards stay stable |
report.html | One file with all active languages and a switcher |
| Console summary | The first active language |
To add a language without changing the repository, ship it as a plugin with locales.