UNPKG

@elsikora/eslint-config

Version:

ESLint configuration vision of ElsiKora

30 lines (26 loc) 999 B
'use strict'; var pluginMap_constant = require('../constant/utility/plugin-map.constant.js'); /** * Formats a rule name according to mapping rules * @param {string} ruleName - The name of the rule to format * @returns {string} The formatted rule name */ function formatRuleName(ruleName) { for (const [oldName, newName] of getSortedPluginMapEntries()) { const oldPrefix = `${oldName}/`; if (ruleName.startsWith(oldPrefix)) { return ruleName.replace(oldPrefix, `${newName}/`); } } return ruleName; } /** * Returns plugin map entries sorted by longest source plugin name first. * @returns {Array<[string, string]>} Sorted plugin map entries */ function getSortedPluginMapEntries() { // eslint-disable-next-line @elsikora/unicorn/no-array-sort return Object.entries(pluginMap_constant.PLUGIN_MAP).sort((a, b) => b[0].length - a[0].length); } exports.formatRuleName = formatRuleName; //# sourceMappingURL=format-rule-name.utility.js.map