How to use the @hint/utils-types.Severity.error 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-stylesheet-limits / src / hint.ts View on Github external
const validateScanEnd = async (event: CanEvaluateScript) => {

            const results = await context.evaluate(`(${injectedCode})()`);

            // Report once we hit a limit to support flagging on platforms which will drop subsequent rules.

            // Only check `maxImports` if a limit has been specified
            if (hasImportLimit && results.imports >= maxImports) {
                context.report(
                    event.resource,
                    getMessage('maximumNested', context.language, [maxImports.toString(), results.imports.toString()]),
                    { severity: Severity.error }
                );
            }

            if (hasRuleLimit && results.rules >= maxRules) {
                context.report(
                    event.resource,
                    getMessage('maximumRules', context.language, [maxRules.toString(), results.rules.toString()]),
                    { severity: Severity.error }
                );
            }

            if (hasSheetLimit && results.sheets >= maxSheets) {
                context.report(
                    event.resource,
                    getMessage('maximumStylesheets', context.language, [maxSheets.toString(), results.sheets.toString()]),
                    { severity: Severity.error }
github webhintio / hint / packages / hint-meta-viewport / src / hint.ts View on Github external
const checkContentValue = (contentValue: string | null, resource: string, viewportMetaElement: HTMLElement) => {

            if (!contentValue) {
                const message = getMessage('metaElementNonEmptyContent', context.language);

                context.report(
                    resource,
                    message,
                    {
                        element: viewportMetaElement,
                        severity: Severity.error
                    }
                );

                return;
            }

            const content = parseMetaViewPortContent(contentValue);

            // Check for unknown properties and invalid values.

            for (const key of Object.keys(content.unknownProperties)) {
                const message = getMessage('metaElementUnknownProperty', context.language, key);

                context.report(
                    resource,
                    message,
github webhintio / hint / packages / hint-apple-touch-icons / src / hint.ts View on Github external
/*
             * Try to see if the `apple-touch-icon` file actually
             * exists and is accesible.
             */

            try {
                networkData = await context.fetchContent(appleTouchIconURL);
            } catch (e) {
                debug(`Failed to fetch the ${appleTouchIconHref} file`);

                const message = getMessage('couldNotBeFetch', context.language, appleTouchIconHref);

                context.report(
                    resource,
                    message,
                    { element: appleTouchIcon, severity: Severity.error }
                );

                return;
            }

            const response = networkData.response;

            if (response.statusCode !== 200) {
                const message = getMessage('couldNotBeFetchErrorStatusCode', context.language, [appleTouchIconHref, response.statusCode.toString()]);

                context.report(
                    resource,
                    message,
                    { element: appleTouchIcon, severity: Severity.error }
                );
github webhintio / hint / packages / hint-typescript-config / src / is-valid.ts View on Github external
const invalidExtends = (typeScriptConfigInvalid: TypeScriptConfigExtendsError, event: string) => {
            const { error, resource, getLocation } = typeScriptConfigInvalid;

            debug(`${event} received`);

            context.report(
                resource,
                error.message,
                {
                    location: getLocation('extends', { at: 'value' }),
                    severity: Severity.error
                }
            );
        };
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;
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()));
    }
github webhintio / hint / packages / hint-https-only / src / hint.ts View on Github external
urls.forEach((url) => {
                const fullUrl = URL.resolve(resource, url);

                if (!isHTTPS(fullUrl) && !isDataURI(fullUrl) && !reportedUrls.has(fullUrl)) {
                    reportedUrls.add(fullUrl);

                    context.report(
                        fullUrl,
                        getMessage('shouldBeHTTPS', context.language),
                        { severity: Severity.error }
                    );
                }
            });
        };
github webhintio / hint / packages / hint-ssllabs / src / hint.ts View on Github external
const verifyEndpoint = (resource: string, { grade, serverName = resource, details }: SSLLabsEndpoint) => {
            if (!grade && details.protocols.length === 0) {
                const message = getMessage('doesNotSupportHTTPS', context.language, resource);

                debug(message);
                context.report(resource, message, { severity: Severity.error });

                return;
            }

            const calculatedGrade: Grades = Grades[grade];
            const calculatedMiniumGrade: Grades = Grades[minimumGrade];

            if (calculatedGrade > calculatedMiniumGrade) {
                const message: string = getMessage('gradeNotMeetTheMinimum', context.language, [serverName, grade, minimumGrade]);

                debug(message);
                context.report(resource, message, { severity: Severity.error });
            } else {
                debug(`Grade ${grade} for ${resource} is ok.`);
            }
        };
github webhintio / hint / packages / hint-scoped-svg-styles / src / hint.ts View on Github external
severity: Severity.error
                        });

                        let maxReportsPerCSSRule = Infinity;

                        if (context.hintOptions && context.hintOptions.maxReportsPerCSSRule !== undefined) {
                            maxReportsPerCSSRule = context.hintOptions.maxReportsPerCSSRule;
                        }

                        for (let i = 0; (i < matchingElementsOutsideParentSVG.length && i < maxReportsPerCSSRule); i++) {
                            context.report(
                                resource,
                                formatElementMessage(codeSnippet),
                                {
                                    element: matchingElementsOutsideParentSVG[i],
                                    severity: Severity.error
                                });
                        }
                    }
                }
            });
        };
github webhintio / hint / packages / hint-create-element-svg / src / hint.ts View on Github external
codeSnippet = sourceCode.substring((node as any).start, (node as any).end);
                            location = {
                                column: loc.start.column,
                                line: loc.start.line - 1
                            };
                        }

                        context.report(
                            resource,
                            message,
                            {
                                codeLanguage,
                                codeSnippet,
                                element,
                                location,
                                severity: Severity.error
                            });
                    }
                }
            });