How to use the @hint/utils-types.Severity.warning 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 / hint-axe / src / util / axe.ts View on Github external
const toSeverity = (impact?: ImpactValue) => {
    if (impact === 'minor') {
        return Severity.hint;
    }

    if (impact === 'moderate' || impact === 'serious') {
        return Severity.warning;
    }

    if (impact === 'critical') {
        return Severity.error;
    }

    // In case axe adds a new `impact` that is not tracked above
    return Severity.warning;
};
github webhintio / hint / packages / extension-browser / src / devtools / views / pages / config / sections / severities.tsx View on Github external
const onWarningSelected = useCallback(() => {
        onChange(Severity.warning.toString());
    }, [onChange]);
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()]++;
github webhintio / hint / packages / hint-minified-js / src / hint.ts View on Github external
if (sourceCode.length < 1024) {
                debug(`Ignoring minification for script under 1KB: ${resource}`);

                return;
            }

            debug(`Calculated improvementIndex for ${resource}: ${improvementIndex}`);

            if (improvementIndex > threshold) {
                context.report(
                    resource,
                    getMessage('shouldBeMinified', context.language),
                    {
                        element,
                        severity: Severity.warning
                    });
            }
        };
github webhintio / hint / packages / hint-compat-api / src / css.ts View on Github external
const report = ({ feature, formatFeature, isValue, node, unsupported }: ReportData) => {
                const alternatives = formatAlternatives(context.language, unsupported, formatFeature);
                const message = [
                    getMessage('featureNotSupported', context.language, [feature, joinBrowsers(unsupported)]),
                    ...alternatives
                ].join(' ');
                const codeSnippet = getCSSCodeSnippet(node);
                const location = getCSSLocationFromNode(node, { isValue });
                const severity = alternatives.length ? Severity.error : Severity.warning;

                context.report(
                    resource,
                    message,
                    {
                        codeLanguage: 'css',
                        codeSnippet,
                        element,
                        location,
                        severity
                    });
            };
github webhintio / hint / packages / hint-html-checker / src / hint.ts View on Github external
const notifyError = (resource: string, error: any) => {
            debug(`Error getting HTML checker result for ${resource}.`, error);
            context.report(
                resource,
                getMessage('couldNotGetResult', context.language, [resource, error.toString()]),
                { severity: Severity.warning });
        };
github webhintio / hint / packages / hint-manifest-app-name / src / hint.ts View on Github external
const checkIfPropertyValueIsUnderLimit = (resource: string, content: string | undefined, propertyName: string, shortNameLengthLimit: number, getLocation: JSONLocationFunction) => {
            if (content && (ucs2.decode(content).length > shortNameLengthLimit)) {
                const message = getMessage('shouldHavePropertyShort', context.language, [propertyName, shortNameLengthLimit.toString()]);
                const location = getLocation(propertyName, { at: 'value' });

                context.report(resource, message, { location, severity: Severity.warning });

                return false;
            }

            return true;
        };
github webhintio / hint / packages / hint-webpack-config / src / no-devtool-in-prod.ts View on Github external
const configReceived = (webpackConfigEvent: WebpackConfigParse) => {
            const { config, resource } = webpackConfigEvent;

            debug(`'parse::end::webpack-config' received`);

            if (config.devtool && config.devtool.toString().includes('eval')) {
                context.report(
                    resource,
                    getMessage('noEval', context.language, config.devtool.toString()),
                    { severity: Severity.warning }
                );
            }
        };
github webhintio / hint / packages / extension-browser / src / content-script / webhint.ts View on Github external
const filteredProblems = problems.filter((problem) => {
        return problem.severity >= (userConfig.severityThreshold || Severity.warning);
    });