How to use the @hint/utils.occurencesToColor function in @hint/utils

To help you get started, we’ve selected a few @hint/utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github webhintio / hint / packages / formatter-stylish / src / formatter.ts View on Github external
tableData.push([line, column, severity, msg.message, msg.hintId]);
            });

            /*
             * If no message in this resource has a position, then we remove the
             * position components from the array to avoid unnecessary white spaces
             */
            if (!hasPosition) {
                tableData.forEach((row: string[]) => {
                    row.splice(0, 2);
                });
            }

            partialResult += `${table(tableData)}\n`;

            const color = occurencesToColor(partials);

            totals[Severity.error] += partials[Severity.error];
            totals[Severity.warning] += partials[Severity.warning];
            totals[Severity.information] += partials[Severity.information];
            totals[Severity.hint] += partials[Severity.hint];

            const foundMessage = getMessage('partialFound', language, [
                partials[Severity.error].toString(),
                partials[Severity.error] === 1 ? getMessage('error', language) : getMessage('errors', language),
                partials[Severity.warning].toString(),
                partials[Severity.warning] === 1 ? getMessage('warning', language) : getMessage('warnings', language),
                partials[Severity.hint].toString(),
                partials[Severity.hint] === 1 ? getMessage('hint', language) : getMessage('hints', language),
                partials[Severity.information].toString(),
                partials[Severity.information] === 1 ? getMessage('information', language) : getMessage('informations', language)
            ]);
github webhintio / hint / packages / formatter-stylish / src / formatter.ts View on Github external
partials[Severity.error] === 1 ? getMessage('error', language) : getMessage('errors', language),
                partials[Severity.warning].toString(),
                partials[Severity.warning] === 1 ? getMessage('warning', language) : getMessage('warnings', language),
                partials[Severity.hint].toString(),
                partials[Severity.hint] === 1 ? getMessage('hint', language) : getMessage('hints', language),
                partials[Severity.information].toString(),
                partials[Severity.information] === 1 ? getMessage('information', language) : getMessage('informations', language)
            ]);

            partialResult += color.bold(`${logSymbols.error} ${foundMessage}`);
            partialResult += '\n\n';

            return total + partialResult;
        }, '');

        const color = occurencesToColor(totals);
        const foundTotalMessage = getMessage('totalFound', language, [
            totals[Severity.error].toString(),
            totals[Severity.error] === 1 ? getMessage('error', language) : getMessage('errors', language),
            totals[Severity.warning].toString(),
            totals[Severity.warning] === 1 ? getMessage('warning', language) : getMessage('warnings', language),
            totals[Severity.hint].toString(),
            totals[Severity.hint] === 1 ? getMessage('hint', language) : getMessage('hints', language),
            totals[Severity.information].toString(),
            totals[Severity.information] === 1 ? getMessage('information', language) : getMessage('informations', language)
        ]);

        result += color.bold(`${logSymbols.error} ${foundTotalMessage}`);

        if (!options.output) {
            logger.log(result);
github webhintio / hint / packages / formatter-summary / src / formatter.ts View on Github external
if (hints > 0) {
                line.push(pink(getMessage(hints === 1 ? 'hintCount' : 'hintsCount', language, hints.toString())));
            }
            if (informations > 0) {
                line.push(gray(getMessage(informations === 1 ? 'informationCount' : 'informationsCount', language, informations.toString())));
            }

            tableData.push(line);

            totals[Severity.error.toString()] += errors;
            totals[Severity.warning.toString()] += warnings;
            totals[Severity.information.toString()] += informations;
            totals[Severity.hint.toString()] += hints;
        });

        const color = occurencesToColor(totals);
        const foundTotalMessage = getMessage('totalFound', language, [
            totals[Severity.error].toString(),
            totals[Severity.error] === 1 ? getMessage('error', language) : getMessage('errors', language),
            totals[Severity.warning].toString(),
            totals[Severity.warning] === 1 ? getMessage('warning', language) : getMessage('warnings', language),
            totals[Severity.hint].toString(),
            totals[Severity.hint] === 1 ? getMessage('hint', language) : getMessage('hints', language),
            totals[Severity.information].toString(),
            totals[Severity.information] === 1 ? getMessage('information', language) : getMessage('informations', language)
        ]);

        const result = `${table(tableData)}
${color.bold(`${logSymbols.error} ${foundTotalMessage}`)}`;

        if (!options.output) {
            logger.log(result);
github webhintio / hint / packages / formatter-codeframe / src / formatter.ts View on Github external
(location.line !== -1 && location.column !== -1) ? `:${location.line}:${location.column}` : ''
                ])}\n`;

                if (msg.sourceCode) {
                    partial += codeFrame(msg.sourceCode, location);
                }

                partial += '\n';

                return subtotal + partial;
            }, '');

            return total + partialResult;
        }, '');

        const color = occurencesToColor(totals);

        const foundTotalMessage = getMessage('totalFound', language, [
            totals[Severity.error].toString(),
            totals[Severity.error] === 1 ? getMessage('error', language) : getMessage('errors', language),
            totals[Severity.warning].toString(),
            totals[Severity.warning] === 1 ? getMessage('warning', language) : getMessage('warnings', language),
            totals[Severity.hint].toString(),
            totals[Severity.hint] === 1 ? getMessage('hint', language) : getMessage('hints', language),
            totals[Severity.information].toString(),
            totals[Severity.information] === 1 ? getMessage('information', language) : getMessage('informations', language)
        ]);

        result += color.bold(`${logSymbols.error} ${foundTotalMessage}`);

        if (!options.output) {
            logger.log(result);