How to use the @hint/utils-types.Severity.information function in @hint/utils-types

To help you get started, we’ve selected a few @hint/utils-types 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 / hint-html-checker / src / hint.ts View on Github external
const toSeverity = (message: HtmlError) => {
            if (message.type === 'info') {
                if (message.subType === 'warning') {
                    return Severity.warning;
                }

                // "Otherwise, the message is taken to generally informative."
                return Severity.information;
            }

            if (message.type === 'error') {
                return Severity.error;
            }

            // Internal errors by the validator, io, etc.
            return Severity.warning;
        };
github webhintio / hint / packages / formatter-summary / src / formatter.ts View on Github external
_.forEach(sortedResources, ([hintId, problems]) => {
            const msgsBySeverity = _.groupBy(problems, 'severity');
            const errors = msgsBySeverity[Severity.error] ? msgsBySeverity[Severity.error].length : 0;
            const warnings = msgsBySeverity[Severity.warning] ? msgsBySeverity[Severity.warning].length : 0;
            const informations = msgsBySeverity[Severity.information] ? msgsBySeverity[Severity.information].length : 0;
            const hints = msgsBySeverity[Severity.hint] ? msgsBySeverity[Severity.hint].length : 0;
            const red = severityToColor(Severity.error);
            const yellow = severityToColor(Severity.warning);
            const gray = severityToColor(Severity.information);
            const pink = severityToColor(Severity.hint);
            const line: string[] = [chalk.cyan(hintId)];

            if (errors > 0) {
                line.push(red(getMessage(errors === 1 ? 'errorCount' : 'errorsCount', language, errors.toString())));
            }
            if (warnings > 0) {
                line.push(yellow(getMessage(warnings === 1 ? 'warningCount' : 'warningsCount', language, warnings.toString())));
            }
            if (hints > 0) {
                line.push(pink(getMessage(hints === 1 ? 'hintCount' : 'hintsCount', language, hints.toString())));
            }
github webhintio / hint / packages / extension-browser / src / devtools / views / pages / config / sections / severities.tsx View on Github external
const onInformationSelected = useCallback(() => {
        onChange(Severity.information.toString());
    }, [onChange]);
github webhintio / hint / packages / formatter-summary / src / formatter.ts View on Github external
public async format(messages: Problem[], options: FormatterOptions = {}) {
        debug('Formatting results');

        if (messages.length === 0) {
            return;
        }

        const tableData: string[][] = [];
        const language: string = options.language!;
        const totals = {
            [Severity.error.toString()]: 0,
            [Severity.warning.toString()]: 0,
            [Severity.information.toString()]: 0,
            [Severity.hint.toString()]: 0
        };
        const resources: _.Dictionary = _.groupBy(messages, 'hintId');
        const sortedResources = Object.entries(resources).sort(([hintA, problemsA], [hintB, problemsB]) => {
            if (problemsA.length < problemsB.length) {
                return -1;
            }

            if (problemsA.length > problemsB.length) {
                return 1;
            }

            return hintA.localeCompare(hintB);
        });

        _.forEach(sortedResources, ([hintId, problems]) => {
github webhintio / hint / packages / formatter-codeframe / src / formatter.ts View on Github external
public async format(messages: Problem[], options: FormatterOptions = {}) {
        debug('Formatting results');

        const language: string = options.language!;

        if (messages.length === 0) {
            return;
        }

        const resources: _.Dictionary = _.groupBy(messages, 'resource');
        const totals = {
            [Severity.error.toString()]: 0,
            [Severity.warning.toString()]: 0,
            [Severity.information.toString()]: 0,
            [Severity.hint.toString()]: 0
        };

        let result = _.reduce(resources, (total: string, msgs: Problem[], resource: string) => {
            const sortedMessages: Problem[] = _.sortBy(msgs, ['location.line', 'location.column']);
            const resourceString = chalk.cyan(`${cutString(resource, 80)}`);

            const partialResult = _.reduce(sortedMessages, (subtotal: string, msg: Problem) => {
                let partial: string;
                const color = severityToColor(msg.severity);
                const severity = color(getMessage(`capitalized${Severity[msg.severity].toString()}` as MessageName, language));
                const location = msg.location;

                totals[msg.severity.toString()]++;

                partial = `${getMessage('hintInfo', language, [
github webhintio / hint / packages / formatter-codeframe / src / formatter.ts View on Github external
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);

            return;
        }

        await writeFileAsync(options.output, stripAnsi(result));
    }
}
github webhintio / hint / packages / formatter-stylish / src / formatter.ts View on Github external
public async format(messages: Problem[], options: FormatterOptions = {}) {
        const language: string = options.language!;

        debug('Formatting results');

        if (messages.length === 0) {
            return;
        }

        const resources: _.Dictionary = _.groupBy(messages, 'resource');
        const totals = {
            [Severity.error.toString()]: 0,
            [Severity.warning.toString()]: 0,
            [Severity.information.toString()]: 0,
            [Severity.hint.toString()]: 0
        };

        let result = _.reduce(resources, (total: string, msgs: Problem[], resource: string) => {
            const partials = {
                [Severity.error.toString()]: 0,
                [Severity.warning.toString()]: 0,
                [Severity.information.toString()]: 0,
                [Severity.hint.toString()]: 0
            };
            const sortedMessages: Problem[] = _.sortBy(msgs, ['location.line', 'location.column']);
            const tableData: string[][] = [];
            let hasPosition: boolean = false;

            let partialResult = `${chalk.cyan(cutString(resource, 80))}\n`;
github webhintio / hint / packages / formatter-stylish / src / formatter.ts View on Github external
let result = _.reduce(resources, (total: string, msgs: Problem[], resource: string) => {
            const partials = {
                [Severity.error.toString()]: 0,
                [Severity.warning.toString()]: 0,
                [Severity.information.toString()]: 0,
                [Severity.hint.toString()]: 0
            };
            const sortedMessages: Problem[] = _.sortBy(msgs, ['location.line', 'location.column']);
            const tableData: string[][] = [];
            let hasPosition: boolean = false;

            let partialResult = `${chalk.cyan(cutString(resource, 80))}\n`;

            _.forEach(sortedMessages, (msg: Problem) => {
                const color = severityToColor(msg.severity);
                const severity = color(getMessage(`capitalized${Severity[msg.severity].toString()}` as MessageName, language));

                partials[msg.severity.toString()]++;

                const line: string = printPosition(msg.location.line, getMessage('line', language));
                const column: string = printPosition(msg.location.column, getMessage('col', language));
github webhintio / hint / packages / extension-browser / src / devtools / views / pages / results / hint.tsx View on Github external
const getSummaryMessage = (problems: ProblemData[]): string => {
    if (!problems.length) {
        return getMessage('noIssuesLabel');
    }

    const messages = [];
    const groups = groupProblems(problems, 'severity');
    const errorGroup = groups.get(Severity.error.toString());
    const warningGroup = groups.get(Severity.warning.toString());
    const informationGroup = groups.get(Severity.information.toString());
    const hintGroup = groups.get(Severity.hint.toString());

    if (errorGroup) {
        messages.push(getMessage('errorIssuesLabel', errorGroup.length.toString()));
    }
    if (warningGroup) {
        messages.push(getMessage('warningIssuesLabel', warningGroup.length.toString()));
    }
    if (hintGroup) {
        messages.push(getMessage('hintIssuesLabel', hintGroup.length.toString()));
    }
    if (informationGroup) {
        messages.push(getMessage('informationIssuesLabel', informationGroup.length.toString()));
    }

    return messages.join(', ');