How to use the @hint/utils-dom.getHTMLCodeSnippet function in @hint/utils-dom

To help you get started, we’ve selected a few @hint/utils-dom 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 / src / lib / hint-context.ts View on Github external
public report(resource: string, message: string, options: ReportOptions) {
        const { codeSnippet, element, severity = Severity.warning } = options;
        let sourceCode: string | null = null;
        let position = options.location || null;

        if (element) {
            // When element is provided, position is an offset in the content.
            position = this.findProblemLocation(element, position);
            sourceCode = getHTMLCodeSnippet(element);
        }

        /**
         * By default all hints get configured with `default` so they can
         * decide the severity of each report unless it's overriden by the
         * user.
         */
        const finalSeverity = this.severity !== Severity.default ?
            this.severity :
            severity;

        /*
         * If location is undefined or equal to null, `position` will be set as `{ column: -1, line: -1 }` later in `hint.report`.
         * So pass the `location` on as it is.
         */