]> git.proxmox.com Git - pve-eslint.git/blob - eslint/messages/shared.js
import 8.41.0 source
[pve-eslint.git] / eslint / messages / shared.js
1 /**
2 * @fileoverview Shared utilities for error messages.
3 * @author Josh Goldberg
4 */
5
6 "use strict";
7
8 /**
9 * Converts a value to a string that may be printed in errors.
10 * @param {any} value The invalid value.
11 * @param {number} indentation How many spaces to indent
12 * @returns {string} The value, stringified.
13 */
14 function stringifyValueForError(value, indentation) {
15 return value ? JSON.stringify(value, null, 4).replace(/\n/gu, `\n${" ".repeat(indentation)}`) : `${value}`;
16 }
17
18 module.exports = { stringifyValueForError };