How to use the @lwc/errors.DiagnosticLevel.Error function in @lwc/errors

To help you get started, we’ve selected a few @lwc/errors 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 salesforce / lwc / packages / @lwc / template-compiler / src / __tests__ / parser.spec.ts View on Github external
it('disallows `);
        expect(warnings).toEqual([
            {
                code: expect.any(Number),
                level: DiagnosticLevel.Error,
                message: expect.stringContaining(
                    `The <style> element is disallowed inside the template.`
                ),
                location: EXPECTED_LOCATION,
            },
        ]);
    });
</style>
github salesforce / lwc / packages / @lwc / template-compiler / src / __tests__ / parser.spec.ts View on Github external
it('event handler attribute', () =&gt; {
        const { warnings } = parseTemplate(`<template><h1></h1></template>`);
        expect(warnings).toContainEqual({
            code: expect.any(Number),
            level: DiagnosticLevel.Error,
            message: expect.stringContaining('Event handler should be an expression'),
            location: EXPECTED_LOCATION,
        });
    });
});
github forcedotcom / lightning-language-server / packages / lwc-language-server / src / template / linter.ts View on Github external
import { DiagnosticLevel } from '@lwc/errors';
import templateCompiler from '@lwc/template-compiler';
import { TextDocument, Diagnostic, DiagnosticSeverity, Range } from 'vscode-languageserver';
import { DIAGNOSTIC_SOURCE } from '../constants';

const LEVEL_MAPPING: Map = new Map([
    [DiagnosticLevel.Log, DiagnosticSeverity.Information],
    [DiagnosticLevel.Warning, DiagnosticSeverity.Warning],
    [DiagnosticLevel.Error, DiagnosticSeverity.Error],
    [DiagnosticLevel.Fatal, DiagnosticSeverity.Error],
]);

export default function lint(document: TextDocument): Diagnostic[] {
    const source = document.getText();
    const { warnings } = templateCompiler(source, {});

    return warnings.map(warning =&gt; {
        const { start = 0, length = 0 } = warning.location || { start: 0, length: 0 };

        return {
            range: toRange(document, start, length),
            message: warning.message,
            severity: LEVEL_MAPPING.get(warning.level),
            source: DIAGNOSTIC_SOURCE,
        };
github salesforce / lwc / packages / @lwc / compiler / src / transformers / template.ts View on Github external
    const fatalError = result.warnings.find(warning => warning.level === DiagnosticLevel.Error);
    if (fatalError) {
github salesforce / lwc / packages / @lwc / compiler / src / transformers / template.ts View on Github external
    const fatalError = result.warnings.find(warning => warning.level === DiagnosticLevel.Error);
    if (fatalError) {