securityos/node_modules/stylelint/lib/utils/ruleMessages.js

21 lines
589 B
JavaScript
Raw Permalink Normal View History

2024-09-06 15:32:35 +00:00
'use strict';
/**
* @type {import('stylelint').Utils['ruleMessages']}
*/
module.exports = function ruleMessages(ruleName, messages) {
/** @type {import('stylelint').RuleMessages} */
const newMessages = {};
for (const [messageId, messageText] of Object.entries(messages)) {
if (typeof messageText === 'string') {
newMessages[messageId] = `${messageText} (${ruleName})`;
} else {
newMessages[messageId] = (...args) => `${messageText(...args)} (${ruleName})`;
}
}
// @ts-expect-error -- TS2322: Type 'RuleMessages' is not assignable to type 'R'.
return newMessages;
};