UNPKG

510 BJavaScriptView Raw
1'use strict';
2
3/**
4 * Omit any properties starting with `_`, which are fake-private
5 *
6 * @param {import('stylelint').StylelintResult[]} results
7 * @returns {string}
8 */
9module.exports = function jsonFormatter(results) {
10 const cleanedResults = results.map((result) =>
11 Object.entries(result)
12 .filter(([key]) => !key.startsWith('_'))
13 .reduce((/** @type {{ [key: string]: any }} */ obj, [key, value]) => {
14 obj[key] = value;
15
16 return obj;
17 }, {}),
18 );
19
20 return JSON.stringify(cleanedResults);
21};