appendRuleName.cjs 725 B

12345678910111213141516171819
  1. // NOTICE: This file is generated by Rollup. To modify it,
  2. // please instead edit the ESM counterpart and rebuild with Rollup (npm run build).
  3. 'use strict';
  4. /**
  5. * Ensures the given rule name is appended to the provided string.
  6. *
  7. * If the string does not already end with the rule name in parentheses, the rule name is appended in parentheses.
  8. *
  9. * @param {string} string - The message to which the rule name may be appended
  10. * @param {string} ruleName - The rule name to append
  11. *
  12. * @returns {string} The provided string with the given rule name appended
  13. */
  14. function appendRuleName(string, ruleName) {
  15. return !string.endsWith(`(${ruleName})`) ? `${string} (${ruleName})` : string;
  16. }
  17. module.exports = appendRuleName;