mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-10 21:54:47 +08:00
This also adds CC-BY-4.0 to the list of accepted licenses. DISABLE_THIRD_PARTY_CHECK=update dependencies Bug: chromium:1083142 Change-Id: I8612de2fba52dae32eeb71af79d5aacfde52142b Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2220097 Reviewed-by: Paul Lewis <aerotwist@chromium.org> Commit-Queue: Mathias Bynens <mathias@chromium.org>
36 lines
1.1 KiB
JavaScript
36 lines
1.1 KiB
JavaScript
'use strict';
|
|
|
|
/**
|
|
* Given an object of violation messages, return another
|
|
* that provides the same messages postfixed with the rule
|
|
* that has been violated.
|
|
*
|
|
* @param {string} ruleName
|
|
* @param {{[k: string]: string|Function}} messages - Object whose keys are message identifiers
|
|
* and values are either message strings or functions that return message strings
|
|
* @return {{[k: string]: string|Function}} New message object, whose messages will be marked with the rule name
|
|
*/
|
|
module.exports = function (ruleName, messages) {
|
|
return Object.keys(messages).reduce(
|
|
/**
|
|
* @param {{[k: string]: string|Function}} newMessages
|
|
* @param {string} messageId
|
|
* @return {{[k: string]: string|Function}}
|
|
*/
|
|
(newMessages, messageId) => {
|
|
const messageText = messages[messageId];
|
|
|
|
if (typeof messageText === 'string') {
|
|
newMessages[messageId] = `${messageText} (${ruleName})`;
|
|
} else {
|
|
newMessages[messageId] = (/** @type {any[]} */ ...args) => {
|
|
return `${messageText(...args)} (${ruleName})`;
|
|
};
|
|
}
|
|
|
|
return newMessages;
|
|
},
|
|
{},
|
|
);
|
|
};
|