How to use the @hint/utils-string.prettyPrintArray function in @hint/utils-string

To help you get started, we’ve selected a few @hint/utils-string 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-no-html-only-headers / src / hint.ts View on Github external
}

            if (!willBeTreatedAsHTML(response)) {
                let headersToValidate = unneededHeaders;

                if (exceptionMediaTypes.includes(response.mediaType)) {
                    headersToValidate = mergeIgnoreIncludeArrays(headersToValidate, exceptionHeaders, []);
                }
                const headers = includedHeaders(response.headers, headersToValidate);
                const numberOfHeaders = headers.length;

                if (numberOfHeaders > 0) {
                    let message: string;

                    if (numberOfHeaders === 1) {
                        message = getMessage('unneededHeader', context.language, prettyPrintArray(headers));
                    } else {
                        message = getMessage('unneededHeaders', context.language, prettyPrintArray(headers));
                    }

                    context.report(resource, message, { element, severity: Severity.warning });
                }
            }
        };
github webhintio / hint / packages / hint-no-disallowed-headers / src / hint.ts View on Github external
resource,
                    message,
                    {
                        codeLanguage,
                        codeSnippet: `Server: ${serverHeaderValue}`,
                        severity: Severity.warning
                    });
            }

            if (numberOfHeaders > 0) {
                let message: string;

                if (numberOfHeaders === 1) {
                    message = getMessage('disallowedHeader', context.language, prettyPrintArray(headers));
                } else {
                    message = getMessage('disallowedHeaders', context.language, prettyPrintArray(headers));
                }

                const codeSnippet = headers.reduce((total, header) => {
                    return `${total}${total ? '\n' : ''}${header}: ${normalizeHeaderValue(response.headers, header)}`;
                }, '');

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