diff --git a/packages/@lwc/compiler/src/bundler/bundler.ts b/packages/@lwc/compiler/src/bundler/bundler.ts index 893e7e4933..acfd325a85 100755 --- a/packages/@lwc/compiler/src/bundler/bundler.ts +++ b/packages/@lwc/compiler/src/bundler/bundler.ts @@ -39,18 +39,22 @@ interface RollupWarning { line: number; column: number; }; + pos?: number; } const DEFAULT_FORMAT = "amd"; function handleRollupWarning(diagnostics: CompilerDiagnostic[]) { - return function onwarn({ message, loc }: RollupWarning) { - const origin = loc + return function onwarn({ message, loc, pos }: RollupWarning) { + // loc and pos are bundled together + const origin = loc && pos ? { filename: loc.file, location: { line: loc.line, - column: loc.column + column: loc.column, + start: pos, + length: 0, } } : {}; diff --git a/packages/@lwc/compiler/src/compiler/compiler.ts b/packages/@lwc/compiler/src/compiler/compiler.ts index d11423fc48..d461c3db93 100755 --- a/packages/@lwc/compiler/src/compiler/compiler.ts +++ b/packages/@lwc/compiler/src/compiler/compiler.ts @@ -1,5 +1,4 @@ import { CompilerDiagnostic, DiagnosticLevel } from "@lwc/errors"; -import { Diagnostic } from "../diagnostics/diagnostic"; import { bundle } from "../bundler/bundler"; import { BundleMetadata } from "../bundler/meta-collector"; @@ -8,24 +7,9 @@ import { version } from '../index'; export { default as templateCompiler } from "@lwc/template-compiler"; -/** - * Transforms a CompilerDiagnostic object so that it's compatible with previous Diagnostic type - * @param diagnostic - */ -function temporaryAdapterForTypesafety(diagnostic: CompilerDiagnostic): Diagnostic { - const diag = diagnostic as any; - - if (diagnostic.location) { - const { line, column } = diagnostic.location; - diag.location = { line, column, start: -1, length: -1 }; - } - - return diag as Diagnostic; -} - export interface CompilerOutput { success: boolean; - diagnostics: Diagnostic[]; + diagnostics: CompilerDiagnostic[]; result?: BundleResult; version: string; } @@ -68,7 +52,7 @@ export async function compile( return { version, success: !hasError(diagnostics), - diagnostics: diagnostics.map(temporaryAdapterForTypesafety), + diagnostics, result }; } diff --git a/packages/@lwc/compiler/src/diagnostics/diagnostic.ts b/packages/@lwc/compiler/src/diagnostics/diagnostic.ts deleted file mode 100755 index be76958378..0000000000 --- a/packages/@lwc/compiler/src/diagnostics/diagnostic.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { Location } from '../common-interfaces/location'; - -export interface Diagnostic { - /** Level of the diagnostic */ - level: DiagnosticLevel; - - /** Error messages that should be outputed */ - message: string; - - /** Relative path location of the file in the bundle. */ - filename?: string; - - /** - * Location in the code affected by the diagnostic. - * This field is optional, for example when the compiler throws an uncaught exception. - */ - location?: Location; - - /** - * Error code for the diagnostic. Temporarily added while all older references - * to Diagnostics is migrated to the new object. - */ - code?: number; -} - -export enum DiagnosticLevel { - /** Unexpected error, parsing error, bundling error */ - Fatal = 0, - /** Linting error with error level, invalid external reference, invalid import, invalid transform */ - Error = 1, - /** Linting error with warning level, usage of an API to be deprecated */ - Warning = 2, - /** Logging messages */ - Log = 3, -} diff --git a/packages/@lwc/errors/src/compiler/__tests__/errors.spec.ts b/packages/@lwc/errors/src/compiler/__tests__/errors.spec.ts index c917b3eece..c79559b4ac 100644 --- a/packages/@lwc/errors/src/compiler/__tests__/errors.spec.ts +++ b/packages/@lwc/errors/src/compiler/__tests__/errors.spec.ts @@ -10,6 +10,13 @@ import { import { Location, DiagnosticLevel } from "../../shared/types"; +const DEFAULT_LOCATION = { + line: 1, + column: 22, + start: 22, + length: 8 +}; + const ERROR_INFO = { code: 4, message: "Test Error {0} with message {1}", @@ -23,12 +30,21 @@ const GENERIC_ERROR = { }; class CustomError extends Error { + public lwcCode?: number; public filename?: string; public line?: number; public column?: number; - public lwcCode?: number; - - constructor(message: string, filename?: string, line?: number, column?: number) { + public start?: number; + public length?: number; + + constructor( + message: string, + filename?: string, + line?: number, + column?: number, + start?: number, + length?: number + ) { super(message); this.name = 'CustomError'; @@ -36,9 +52,19 @@ class CustomError extends Error { this.filename = filename; this.line = line; this.column = column; + this.start = start; + this.length = length; } } +function checkErrorEquality(actual: CompilerError, expected: CompilerError) { + expect(actual).toEqual(expected); + expect(actual.code).toEqual(expected.code); + expect(actual.level).toEqual(expected.level); + expect(actual.filename).toEqual(expected.filename); + expect(actual.location).toEqual(expected.location); +} + describe('error handling', () => { describe('generate compiler diagnostic', () => { it('generates a compiler diagnostic when config is null', () => { @@ -56,14 +82,14 @@ describe('error handling', () => { message: 'LWC4: Test Error arg1 with message 500', level: DiagnosticLevel.Error, filename: 'test.js', - location: { line: 1, column: 22 } + location: DEFAULT_LOCATION }; expect(generateCompilerDiagnostic(ERROR_INFO, { messageArgs: ['arg1', 500], origin: { filename: 'test.js', - location: { line: 1, column: 22 } + location: DEFAULT_LOCATION } })).toEqual(target); }); @@ -73,15 +99,15 @@ describe('error handling', () => { it('generates a compiler error when config is null', () => { const target = new CompilerError(4, 'LWC4: Test Error {0} with message {1}'); - expect(generateCompilerError(ERROR_INFO)).toEqual(target); + checkErrorEquality(generateCompilerError(ERROR_INFO), target); }); it('generates a compiler error based on the provided error info', () => { const args = ['arg1', 10]; const target = new CompilerError(4, 'LWC4: Test Error arg1 with message 10'); - expect(generateCompilerError(ERROR_INFO, { + checkErrorEquality(generateCompilerError(ERROR_INFO, { messageArgs: args - })).toEqual(target); + }), target); }); it('formats an error string properly', () => { @@ -106,47 +132,44 @@ describe('error handling', () => { it('adds the location to the compiler error if it exists as context', () => { const args = ['arg1', 10]; - const location = { line: 4, column: 27 }; const error = generateCompilerError(ERROR_INFO, { messageArgs: args, - origin: { location } + origin: { location: DEFAULT_LOCATION } }); - expect(error.location).toEqual(location); + expect(error.location).toEqual(DEFAULT_LOCATION); }); }); describe('normalizeToCompilerError', () => { it('preserves existing compiler error', () => { const error = new CompilerError(100, 'LWC100: test err'); - expect(normalizeToCompilerError(GENERIC_ERROR, error)).toEqual(error); + checkErrorEquality(normalizeToCompilerError(GENERIC_ERROR, error), error); }); it('adds origin info to an existing compiler error', () => { - const filename = 'test.js'; - const location = { line: 1, column: 1 }; - - const oldError = new CompilerError(100, 'LWC100: test error', 'old.js', { line: 1, column: 7 }); - const newError = new CompilerError(100, 'LWC100: test error', filename, location); + const oldError = new CompilerError(100, 'LWC100: test error', 'old.js', { line: 1, column: 7, start: 7, length: 3 }); + const target = new CompilerError(100, 'LWC100: test error', 'test.js', DEFAULT_LOCATION); - expect(normalizeToCompilerError(GENERIC_ERROR, oldError, { filename, location })).toEqual(newError); + checkErrorEquality(normalizeToCompilerError(GENERIC_ERROR, oldError, { filename: 'test.js', location: DEFAULT_LOCATION }), target); }); it('normalizes a given error into a compiler error', () => { - const error = new CustomError('test error', 'test.js', 2, 5); - const target = new CompilerError(100, 'CustomError: LWC100: Unexpected error: test error', 'test.js', { line: 2, column: 5}); + const error = new CustomError('test error', 'test.js', 3, 5, 16, 10); + const target = new CompilerError(100, 'CustomError: LWC100: Unexpected error: test error', 'test.js', { line: 3, column: 5, start: 16, length: 10 }); - expect(normalizeToCompilerError(GENERIC_ERROR, error)).toEqual(target); + const normalized = normalizeToCompilerError(GENERIC_ERROR, error); + checkErrorEquality(normalized, target); }); it('adds additional origin info into the normalized error if provided', () => { const error = new CustomError('test error'); - const target = new CompilerError(100, 'CustomError: LWC100: Unexpected error: test error', 'test.js', { line: 2, column: 5}); + const target = new CompilerError(100, 'CustomError: LWC100: Unexpected error: test error', 'test.js', DEFAULT_LOCATION); - expect(normalizeToCompilerError(GENERIC_ERROR, error, { + checkErrorEquality(normalizeToCompilerError(GENERIC_ERROR, error, { filename: 'test.js', - location: { line: 2, column: 5 } - })).toEqual(target); + location: DEFAULT_LOCATION + }), target); }); it('ignores the fallback errorInfo when an error code already exists on the error', () => { @@ -158,15 +181,15 @@ describe('error handling', () => { messageArgs: ['arg1', 10], origin: { filename: 'test.js', - location: { line: 1, column: 1} + location: DEFAULT_LOCATION } }); target.message = `CustomError: ${target.message}`; - expect(normalizeToCompilerError(GENERIC_ERROR, error, { + checkErrorEquality(normalizeToCompilerError(GENERIC_ERROR, error, { filename: 'test.js', - location: { line: 1, column: 1 } - })).toEqual(target); + location: DEFAULT_LOCATION + }), target); }); }); @@ -177,7 +200,7 @@ describe('error handling', () => { message: 'LWC100: test error', level: DiagnosticLevel.Error, filename: 'test.js', - location: { line: 1, column: 1 } + location: DEFAULT_LOCATION }; const error = new CompilerError( target.code, target.message, target.filename, target.location @@ -192,10 +215,10 @@ describe('error handling', () => { message: 'LWC100: test error', level: DiagnosticLevel.Error, filename: 'test.js', - location: { line: 1, column: 1 } + location: DEFAULT_LOCATION }; const error = new CompilerError( - target.code, target.message, 'old.js', { line: 1, column: 7 } + target.code, target.message, 'old.js', DEFAULT_LOCATION ); expect(normalizeToDiagnostic(GENERIC_ERROR, error, { @@ -205,13 +228,18 @@ describe('error handling', () => { }); it('normalizes a given error into a compiler diagnostic', () => { - const error = new CustomError('test error', 'test.js', 2, 5); + const error = new CustomError('test error', 'test.js', 2, 5, 10, 5); const target = { code: 100, message: 'LWC100: Unexpected error: test error', level: DiagnosticLevel.Error, filename: 'test.js', - location: { line: 2, column: 5} + location: { + line: 2, + column: 5, + start: 10, + length: 5 + } }; expect(normalizeToDiagnostic(GENERIC_ERROR, error)).toEqual(target); @@ -224,12 +252,12 @@ describe('error handling', () => { message: 'LWC100: Unexpected error: test error', level: DiagnosticLevel.Error, filename: 'test.js', - location: { line: 2, column: 5} + location: DEFAULT_LOCATION }; expect(normalizeToDiagnostic(GENERIC_ERROR, error, { filename: 'test.js', - location: { line: 2, column: 5 } + location: DEFAULT_LOCATION })).toEqual(target); }); }); diff --git a/packages/@lwc/errors/src/compiler/utils.ts b/packages/@lwc/errors/src/compiler/utils.ts index a71237654f..613b1f667b 100644 --- a/packages/@lwc/errors/src/compiler/utils.ts +++ b/packages/@lwc/errors/src/compiler/utils.ts @@ -80,8 +80,11 @@ function getLocationFromObject(obj: any): Location | undefined { return obj.location; } else if (obj.loc) { return obj.loc; - } else if (obj.line && obj.column) { - return { line: obj.line, column: obj.column }; + } else if ( + Number.isInteger(obj.line) && + Number.isInteger(obj.column) + ) { + return { line: obj.line, column: obj.column, start: obj.start, length: obj.length }; } } diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/attributes/error-boolean/metadata.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/attributes/error-boolean/metadata.json index c2eb171c11..c9a73ac4df 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/attributes/error-boolean/metadata.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/attributes/error-boolean/metadata.json @@ -6,7 +6,9 @@ "level": 1, "location": { "line": 2, - "column": 8 + "column": 8, + "start": 18, + "length": 11 } }, { @@ -15,7 +17,9 @@ "level": 1, "location": { "line": 3, - "column": 8 + "column": 8, + "start": 43, + "length": 12 } }, { @@ -24,7 +28,9 @@ "level": 1, "location": { "line": 4, - "column": 8 + "column": 8, + "start": 69, + "length": 13 } }, { @@ -33,7 +39,9 @@ "level": 1, "location": { "line": 5, - "column": 8 + "column": 8, + "start": 96, + "length": 14 } } ], diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/attributes/error-camelcase/metadata.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/attributes/error-camelcase/metadata.json index 5edeed19a1..ce1d8d1482 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/attributes/error-camelcase/metadata.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/attributes/error-camelcase/metadata.json @@ -6,7 +6,9 @@ "level": 1, "location": { "line": 3, - "column": 16 + "column": 16, + "start": 40, + "length": 13 } } ], diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/attributes/error-is-dynamic/metadata.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/attributes/error-is-dynamic/metadata.json index 97af790cef..fb1d03a52b 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/attributes/error-is-dynamic/metadata.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/attributes/error-is-dynamic/metadata.json @@ -1,18 +1,22 @@ { - "warnings": [ - { - "code": 1001, - "message": "LWC1001: \"is\" attribute value can't be an expression", - "level": 1, - "location": { - "line": 2, - "column": 13 - } - } - ], - "metadata": { - "definedSlots": [], - "templateUsedIds": ["dynamicCmp"], - "templateDependencies": [] - } -} + "warnings": [ + { + "code": 1001, + "message": "LWC1001: \"is\" attribute value can't be an expression", + "level": 1, + "location": { + "line": 2, + "column": 13, + "start": 23, + "length": 30 + } + } + ], + "metadata": { + "definedSlots": [], + "templateUsedIds": [ + "dynamicCmp" + ], + "templateDependencies": [] + } +} \ No newline at end of file diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/attributes/error-is/metadata.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/attributes/error-is/metadata.json index 1e679fe2de..b093328f98 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/attributes/error-is/metadata.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/attributes/error-is/metadata.json @@ -1,28 +1,31 @@ { - "warnings": [ - { - "code": 1001, - "message": "LWC1001: \"is\" attribute is not supported", - "level": 1, - "location": { - "line": 3, - "column": 16 - } - } - ], - "metadata": { - "definedSlots": [], - "templateUsedIds": [], - "templateDependencies": [ - { - "moduleName": "x/foo", - "properties": { - "is": { - "type": "literal", "value": "x-button" - } - }, - "tagName": "x-foo" - } - ] - } -} + "warnings": [ + { + "code": 1001, + "message": "LWC1001: \"is\" attribute is not supported", + "level": 1, + "location": { + "line": 3, + "column": 16, + "start": 40, + "length": 13 + } + } + ], + "metadata": { + "definedSlots": [], + "templateUsedIds": [], + "templateDependencies": [ + { + "moduleName": "x/foo", + "properties": { + "is": { + "type": "literal", + "value": "x-button" + } + }, + "tagName": "x-foo" + } + ] + } +} \ No newline at end of file diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/attributes/html-tag-invalid/metadata.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/attributes/html-tag-invalid/metadata.json index 9ad4ebf1d2..d78077628d 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/attributes/html-tag-invalid/metadata.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/attributes/html-tag-invalid/metadata.json @@ -6,7 +6,9 @@ "level": 1, "location": { "line": 3, - "column": 47 + "column": 47, + "start": 71, + "length": 21 } } ], diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/attributes/tabindex/metadata.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/attributes/tabindex/metadata.json index 0fcf2d712b..528a85df9d 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/attributes/tabindex/metadata.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/attributes/tabindex/metadata.json @@ -6,7 +6,9 @@ "level": 1, "location": { "line": 2, - "column": 5 + "column": 5, + "start": 15, + "length": 24 } }, { @@ -15,7 +17,9 @@ "level": 1, "location": { "line": 3, - "column": 5 + "column": 5, + "start": 44, + "length": 21 } }, { @@ -24,7 +28,9 @@ "level": 1, "location": { "line": 4, - "column": 5 + "column": 5, + "start": 70, + "length": 30 } }, { @@ -33,7 +39,9 @@ "level": 1, "location": { "line": 5, - "column": 5 + "column": 5, + "start": 105, + "length": 23 } }, { @@ -42,7 +50,9 @@ "level": 1, "location": { "line": 10, - "column": 5 + "column": 5, + "start": 231, + "length": 32 } }, { @@ -51,7 +61,9 @@ "level": 1, "location": { "line": 11, - "column": 5 + "column": 5, + "start": 268, + "length": 29 } }, { @@ -60,7 +72,9 @@ "level": 1, "location": { "line": 12, - "column": 5 + "column": 5, + "start": 302, + "length": 38 } }, { @@ -69,7 +83,9 @@ "level": 1, "location": { "line": 13, - "column": 5 + "column": 5, + "start": 345, + "length": 31 } } ], diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-for-each/error-invalid-identifier/metadata.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-for-each/error-invalid-identifier/metadata.json index 5003adfec3..9d5be7f554 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-for-each/error-invalid-identifier/metadata.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-for-each/error-invalid-identifier/metadata.json @@ -6,7 +6,9 @@ "level": 1, "location": { "line": 2, - "column": 26 + "column": 26, + "start": 36, + "length": 18 } }, { @@ -15,7 +17,9 @@ "level": 1, "location": { "line": 3, - "column": 43 + "column": 43, + "start": 103, + "length": 20 } } ], diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-for-each/error-invalid-type/metadata.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-for-each/error-invalid-type/metadata.json index 1367fd46de..fe51993000 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-for-each/error-invalid-type/metadata.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-for-each/error-invalid-type/metadata.json @@ -6,7 +6,9 @@ "level": 1, "location": { "line": 2, - "column": 27 + "column": 27, + "start": 37, + "length": 15 } }, { @@ -15,7 +17,9 @@ "level": 1, "location": { "line": 2, - "column": 43 + "column": 43, + "start": 53, + "length": 17 } }, { @@ -24,7 +28,9 @@ "level": 1, "location": { "line": 3, - "column": 10 + "column": 10, + "start": 87, + "length": 16 } }, { @@ -33,7 +39,9 @@ "level": 1, "location": { "line": 3, - "column": 43 + "column": 43, + "start": 120, + "length": 17 } }, { @@ -42,7 +50,9 @@ "level": 1, "location": { "line": 4, - "column": 43 + "column": 43, + "start": 187, + "length": 17 } } ], diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-for-each/error-missing-key/metadata.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-for-each/error-missing-key/metadata.json index c56e07c1c8..4a5ce153cc 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-for-each/error-missing-key/metadata.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-for-each/error-missing-key/metadata.json @@ -6,7 +6,9 @@ "level": 1, "location": { "line": 3, - "column": 9 + "column": 9, + "start": 67, + "length": 14 } } ], diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-if/error-invalid-expression/metadata.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-if/error-invalid-expression/metadata.json index 28ef5e7cc9..bd06d53d31 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-if/error-invalid-expression/metadata.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-if/error-invalid-expression/metadata.json @@ -6,7 +6,9 @@ "level": 1, "location": { "line": 3, - "column": 19 + "column": 19, + "start": 43, + "length": 16 } } ], diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-iterator/error-expression/metadata.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-iterator/error-expression/metadata.json index ba5fa8d750..e94470bd90 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-iterator/error-expression/metadata.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-iterator/error-expression/metadata.json @@ -6,7 +6,9 @@ "level": 1, "location": { "line": 4, - "column": 35 + "column": 35, + "start": 97, + "length": 14 } } ], diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-iterator/error-identifier/metadata.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-iterator/error-identifier/metadata.json index c3ac4a555c..57f9ddc7c9 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-iterator/error-identifier/metadata.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-iterator/error-identifier/metadata.json @@ -6,7 +6,9 @@ "level": 1, "location": { "line": 2, - "column": 9 + "column": 9, + "start": 19, + "length": 28 } } ], diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-key/error-expression/metadata.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-key/error-expression/metadata.json index 1b36770f0e..883ae5a3b2 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-key/error-expression/metadata.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-key/error-expression/metadata.json @@ -6,7 +6,9 @@ "level": 1, "location": { "line": 2, - "column": 9 + "column": 9, + "start": 19, + "length": 11 } } ], diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-key/error-for-each-index-as-key/metadata.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-key/error-for-each-index-as-key/metadata.json index 069199d500..f2ba18ca65 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-key/error-for-each-index-as-key/metadata.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-key/error-for-each-index-as-key/metadata.json @@ -6,7 +6,9 @@ "level": 1, "location": { "line": 3, - "column": 14 + "column": 14, + "start": 38, + "length": 11 } } ], diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-key/error-iterator-index-as-key/metadata.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-key/error-iterator-index-as-key/metadata.json index 29627c63eb..986746912b 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-key/error-iterator-index-as-key/metadata.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-key/error-iterator-index-as-key/metadata.json @@ -6,7 +6,9 @@ "level": 1, "location": { "line": 4, - "column": 16 + "column": 16, + "start": 78, + "length": 13 } } ], diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/events/error-component-handler-name/metadata.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/events/error-component-handler-name/metadata.json index c370a97e61..9c3b8f2a64 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/events/error-component-handler-name/metadata.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/events/error-component-handler-name/metadata.json @@ -6,7 +6,9 @@ "level": 1, "location": { "line": 3, - "column": 17 + "column": 17, + "start": 41, + "length": 24 } } ], diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/events/error-inline-javascript/metadata.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/events/error-inline-javascript/metadata.json index 91e7a33683..f39504ac8d 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/events/error-inline-javascript/metadata.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/events/error-inline-javascript/metadata.json @@ -6,7 +6,9 @@ "level": 1, "location": { "line": 2, - "column": 9 + "column": 9, + "start": 19, + "length": 24 } } ], diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/events/error-name-contains-numeric/metadata.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/events/error-name-contains-numeric/metadata.json index 178b6a5be5..4f9e1a5217 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/events/error-name-contains-numeric/metadata.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/events/error-name-contains-numeric/metadata.json @@ -6,7 +6,9 @@ "level": 1, "location": { "line": 2, - "column": 10 + "column": 10, + "start": 20, + "length": 19 } } ], diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/events/error-name-contains-special-char/metadata.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/events/error-name-contains-special-char/metadata.json index 521b4f4419..d065c4b31a 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/events/error-name-contains-special-char/metadata.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/events/error-name-contains-special-char/metadata.json @@ -6,7 +6,9 @@ "level": 1, "location": { "line": 2, - "column": 10 + "column": 10, + "start": 20, + "length": 19 } } ], diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/events/error-tag-handler-name/metadata.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/events/error-tag-handler-name/metadata.json index 62508c1ca5..7d7fc411cb 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/events/error-tag-handler-name/metadata.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/events/error-tag-handler-name/metadata.json @@ -6,7 +6,9 @@ "level": 1, "location": { "line": 3, - "column": 14 + "column": 14, + "start": 38, + "length": 26 } } ], diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/expression/error-computed-attribute/metadata.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression/error-computed-attribute/metadata.json index 958574362f..bf7d340f6d 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/expression/error-computed-attribute/metadata.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression/error-computed-attribute/metadata.json @@ -6,7 +6,9 @@ "level": 1, "location": { "line": 3, - "column": 12 + "column": 12, + "start": 36, + "length": 21 } } ], diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/expression/error-computed-property/metadata.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression/error-computed-property/metadata.json index e9de84105a..62a3502b41 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/expression/error-computed-property/metadata.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression/error-computed-property/metadata.json @@ -6,7 +6,9 @@ "level": 1, "location": { "line": 1, - "column": 11 + "column": 11, + "start": 10, + "length": 22 } } ], diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/expression/error-method-call/metadata.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression/error-method-call/metadata.json index 316b4fb4f8..cc56a3ae88 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/expression/error-method-call/metadata.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression/error-method-call/metadata.json @@ -6,7 +6,9 @@ "level": 1, "location": { "line": 2, - "column": 8 + "column": 8, + "start": 18, + "length": 17 } } ], diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/locators/error-context-no-id/metadata.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/locators/error-context-no-id/metadata.json index 603bc1cd42..1a5e0f8b3f 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/locators/error-context-no-id/metadata.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/locators/error-context-no-id/metadata.json @@ -6,7 +6,9 @@ "level": 1, "location": { "line": 2, - "column": 5 + "column": 5, + "start": 15, + "length": 44 } } ], diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/lwc-dom/error-custom-element-invalid-value/metadata.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/lwc-dom/error-custom-element-invalid-value/metadata.json index b180e6238d..e88042cc2d 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/lwc-dom/error-custom-element-invalid-value/metadata.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/lwc-dom/error-custom-element-invalid-value/metadata.json @@ -6,7 +6,9 @@ "level": 1, "location": { "line": 2, - "column": 5 + "column": 5, + "start": 15, + "length": 33 } } ], diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/lwc-dom/error-custom-element/metadata.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/lwc-dom/error-custom-element/metadata.json index b180e6238d..75840f929a 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/lwc-dom/error-custom-element/metadata.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/lwc-dom/error-custom-element/metadata.json @@ -6,7 +6,9 @@ "level": 1, "location": { "line": 2, - "column": 5 + "column": 5, + "start": 15, + "length": 32 } } ], diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/lwc-dom/error-expression/metadata.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/lwc-dom/error-expression/metadata.json index 5ff575197c..bb39a8a6e4 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/lwc-dom/error-expression/metadata.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/lwc-dom/error-expression/metadata.json @@ -6,7 +6,9 @@ "level": 1, "location": { "line": 2, - "column": 5 + "column": 5, + "start": 15, + "length": 39 } } ], diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/lwc-dom/error-invalid-children/metadata.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/lwc-dom/error-invalid-children/metadata.json index e86ee73dea..bc30074bbd 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/lwc-dom/error-invalid-children/metadata.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/lwc-dom/error-invalid-children/metadata.json @@ -6,7 +6,9 @@ "level": 1, "location": { "line": 2, - "column": 5 + "column": 5, + "start": 15, + "length": 68 } } ], diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/lwc-dom/error-invalid-value/metadata.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/lwc-dom/error-invalid-value/metadata.json index 6fe5e826fa..3d22e30eaf 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/lwc-dom/error-invalid-value/metadata.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/lwc-dom/error-invalid-value/metadata.json @@ -6,7 +6,9 @@ "level": 1, "location": { "line": 2, - "column": 5 + "column": 5, + "start": 15, + "length": 31 } } ], diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/lwc-dom/error-slot-element/metadata.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/lwc-dom/error-slot-element/metadata.json index 6bc2d36bd0..e566def89d 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/lwc-dom/error-slot-element/metadata.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/lwc-dom/error-slot-element/metadata.json @@ -6,7 +6,9 @@ "level": 1, "location": { "line": 2, - "column": 5 + "column": 5, + "start": 15, + "length": 30 } } ], diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/parsing-errors/component-camelcase/metadata.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/parsing-errors/component-camelcase/metadata.json index 18b1ea2d19..92f9c765ff 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/parsing-errors/component-camelcase/metadata.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/parsing-errors/component-camelcase/metadata.json @@ -6,7 +6,9 @@ "level": 1, "location": { "line": 2, - "column": 13 + "column": 13, + "start": 23, + "length": 12 } } ], diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/parsing-errors/empty-template/metadata.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/parsing-errors/empty-template/metadata.json index 63432f9b1d..c937280ce8 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/parsing-errors/empty-template/metadata.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/parsing-errors/empty-template/metadata.json @@ -6,7 +6,9 @@ "level": 1, "location": { "line": 0, - "column": 0 + "column": 0, + "start": 0, + "length": 0 } } ], diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/parsing-errors/forbidden-base-tag/metadata.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/parsing-errors/forbidden-base-tag/metadata.json index 4be852f56c..4498cdc26e 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/parsing-errors/forbidden-base-tag/metadata.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/parsing-errors/forbidden-base-tag/metadata.json @@ -6,7 +6,9 @@ "level": 1, "location": { "line": 2, - "column": 5 + "column": 5, + "start": 15, + "length": 38 } } ], diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/parsing-errors/forbidden-link-tag/metadata.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/parsing-errors/forbidden-link-tag/metadata.json index 0556d8f4e5..220201f5e9 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/parsing-errors/forbidden-link-tag/metadata.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/parsing-errors/forbidden-link-tag/metadata.json @@ -6,7 +6,9 @@ "level": 1, "location": { "line": 2, - "column": 5 + "column": 5, + "start": 15, + "length": 23 } } ], diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/parsing-errors/forbidden-meta-tag/metadata.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/parsing-errors/forbidden-meta-tag/metadata.json index 060f6a6f76..3c29095e6c 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/parsing-errors/forbidden-meta-tag/metadata.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/parsing-errors/forbidden-meta-tag/metadata.json @@ -6,7 +6,9 @@ "level": 1, "location": { "line": 2, - "column": 5 + "column": 5, + "start": 15, + "length": 27 } } ], diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/parsing-errors/forbidden-script-tag/metadata.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/parsing-errors/forbidden-script-tag/metadata.json index ea65a31be9..2e7b6440aa 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/parsing-errors/forbidden-script-tag/metadata.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/parsing-errors/forbidden-script-tag/metadata.json @@ -6,7 +6,9 @@ "level": 1, "location": { "line": 2, - "column": 5 + "column": 5, + "start": 15, + "length": 31 } } ], diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/parsing-errors/forbidden-title-tag/metadata.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/parsing-errors/forbidden-title-tag/metadata.json index ad27a34d7e..601cdd9785 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/parsing-errors/forbidden-title-tag/metadata.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/parsing-errors/forbidden-title-tag/metadata.json @@ -6,7 +6,9 @@ "level": 1, "location": { "line": 2, - "column": 5 + "column": 5, + "start": 15, + "length": 20 } } ], diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/parsing-errors/invalid-empty-tag/metadata.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/parsing-errors/invalid-empty-tag/metadata.json index 761fd2267f..ced1602257 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/parsing-errors/invalid-empty-tag/metadata.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/parsing-errors/invalid-empty-tag/metadata.json @@ -6,7 +6,9 @@ "level": 1, "location": { "line": 2, - "column": 5 + "column": 5, + "start": 15, + "length": 10 } } ], diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/parsing-errors/invalid-id/metadata.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/parsing-errors/invalid-id/metadata.json index c1ff9e1a72..1f815ccfb1 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/parsing-errors/invalid-id/metadata.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/parsing-errors/invalid-id/metadata.json @@ -6,7 +6,9 @@ "level": 1, "location": { "line": 4, - "column": 12 + "column": 12, + "start": 64, + "length": 12 } }, { @@ -15,7 +17,9 @@ "level": 1, "location": { "line": 5, - "column": 12 + "column": 12, + "start": 89, + "length": 10 } }, { @@ -24,7 +28,9 @@ "level": 1, "location": { "line": 7, - "column": 16 + "column": 16, + "start": 165, + "length": 9 } }, { @@ -33,7 +39,9 @@ "level": 1, "location": { "line": 3, - "column": 12 + "column": 12, + "start": 43, + "length": 8 } } ], diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/parsing-errors/invalid-root-tag/metadata.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/parsing-errors/invalid-root-tag/metadata.json index a31aae4441..b88c82cafc 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/parsing-errors/invalid-root-tag/metadata.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/parsing-errors/invalid-root-tag/metadata.json @@ -6,7 +6,9 @@ "level": 1, "location": { "line": 1, - "column": 1 + "column": 1, + "start": 0, + "length": 42 } } ], diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/parsing-errors/invalid-template-element/metadata.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/parsing-errors/invalid-template-element/metadata.json index bf6b3b9341..00b98fff11 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/parsing-errors/invalid-template-element/metadata.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/parsing-errors/invalid-template-element/metadata.json @@ -6,7 +6,9 @@ "level": 1, "location": { "line": 2, - "column": 5 + "column": 5, + "start": 15, + "length": 39 } } ], diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/parsing-errors/multiple-root/metadata.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/parsing-errors/multiple-root/metadata.json index 24c6c1bdb0..c536cd3875 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/parsing-errors/multiple-root/metadata.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/parsing-errors/multiple-root/metadata.json @@ -6,7 +6,9 @@ "level": 1, "location": { "line": 3, - "column": 12 + "column": 12, + "start": 38, + "length": 10 } } ], diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/parsing-errors/no-closing-tag/metadata.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/parsing-errors/no-closing-tag/metadata.json index b90b248744..ba85b77c9d 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/parsing-errors/no-closing-tag/metadata.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/parsing-errors/no-closing-tag/metadata.json @@ -6,7 +6,9 @@ "level": 1, "location": { "line": 2, - "column": 5 + "column": 5, + "start": 15, + "length": 3 } } ], diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/slots/error-definition-dynamic-name/metadata.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/slots/error-definition-dynamic-name/metadata.json index 02e4dc11f4..7ab13acefd 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/slots/error-definition-dynamic-name/metadata.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/slots/error-definition-dynamic-name/metadata.json @@ -6,7 +6,9 @@ "level": 1, "location": { "line": 2, - "column": 11 + "column": 11, + "start": 21, + "length": 15 } } ], diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/slots/error-slot-and-directive/metadata.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/slots/error-slot-and-directive/metadata.json index e85f7d36b4..8235a4ba8b 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/slots/error-slot-and-directive/metadata.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/slots/error-slot-and-directive/metadata.json @@ -6,7 +6,9 @@ "level": 1, "location": { "line": 3, - "column": 8 + "column": 8, + "start": 32, + "length": 31 } } ], diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/slots/error-usage-dynamic-name/metadata.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/slots/error-usage-dynamic-name/metadata.json index d67b924db9..4504eb20cf 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/slots/error-usage-dynamic-name/metadata.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/slots/error-usage-dynamic-name/metadata.json @@ -6,7 +6,9 @@ "level": 1, "location": { "line": 3, - "column": 12 + "column": 12, + "start": 35, + "length": 13 } } ], diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/style/invalid-empty-style-tag/metadata.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/style/invalid-empty-style-tag/metadata.json index 7d5f084f26..c9127a9c14 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/style/invalid-empty-style-tag/metadata.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/style/invalid-empty-style-tag/metadata.json @@ -6,7 +6,9 @@ "level": 1, "location": { "line": 2, - "column": 5 + "column": 5, + "length": 15, + "start": 15 } } ], @@ -15,4 +17,4 @@ "templateUsedIds": [], "templateDependencies": [] } -} \ No newline at end of file +} diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/style/invalid-multiple-style-tags/metadata.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/style/invalid-multiple-style-tags/metadata.json index 93e64b39d4..4460706be3 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/style/invalid-multiple-style-tags/metadata.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/style/invalid-multiple-style-tags/metadata.json @@ -6,7 +6,9 @@ "level": 1, "location": { "line": 5, - "column": 5 + "column": 5, + "length": 49, + "start": 68 } } ], diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/style/invalid-nested-style-tags/metadata.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/style/invalid-nested-style-tags/metadata.json index 109609c81a..d9b2936d0a 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/style/invalid-nested-style-tags/metadata.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/style/invalid-nested-style-tags/metadata.json @@ -6,7 +6,9 @@ "level": 1, "location": { "line": 3, - "column": 9 + "column": 9, + "length": 55, + "start": 56 } } ], diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/style/invalid-style-tag/metadata.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/style/invalid-style-tag/metadata.json index 2e5b325fc2..24c1c76d93 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/style/invalid-style-tag/metadata.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/style/invalid-style-tag/metadata.json @@ -6,7 +6,9 @@ "level": 1, "location": { "line": 2, - "column": 5 + "column": 5, + "length": 72, + "start": 15 } } ], @@ -15,4 +17,4 @@ "templateUsedIds": [], "templateDependencies": [] } -} \ No newline at end of file +} diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/svg/invalid-svg/metadata.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/svg/invalid-svg/metadata.json index e1d060c48b..2e8a751e4b 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/svg/invalid-svg/metadata.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/svg/invalid-svg/metadata.json @@ -6,7 +6,9 @@ "level": 1, "location": { "line": 6, - "column": 9 + "column": 9, + "start": 160, + "length": 19 } }, { @@ -15,7 +17,9 @@ "level": 1, "location": { "line": 10, - "column": 9 + "column": 9, + "start": 339, + "length": 17 } }, { @@ -24,7 +28,9 @@ "level": 1, "location": { "line": 11, - "column": 9 + "column": 9, + "start": 365, + "length": 19 } }, { @@ -33,7 +39,9 @@ "level": 1, "location": { "line": 13, - "column": 9 + "column": 9, + "start": 415, + "length": 23 } }, { @@ -42,7 +50,9 @@ "level": 1, "location": { "line": 14, - "column": 9 + "column": 9, + "start": 447, + "length": 37 } }, { @@ -51,7 +61,9 @@ "level": 1, "location": { "line": 15, - "column": 9 + "column": 9, + "start": 493, + "length": 33 } }, { @@ -60,7 +72,9 @@ "level": 1, "location": { "line": 16, - "column": 9 + "column": 9, + "start": 535, + "length": 31 } }, { @@ -69,7 +83,9 @@ "level": 1, "location": { "line": 17, - "column": 9 + "column": 9, + "start": 575, + "length": 31 } }, { @@ -78,7 +94,9 @@ "level": 1, "location": { "line": 21, - "column": 9 + "column": 9, + "start": 727, + "length": 15 } }, { @@ -87,7 +105,9 @@ "level": 1, "location": { "line": 22, - "column": 9 + "column": 9, + "start": 751, + "length": 23 } }, { @@ -96,7 +116,9 @@ "level": 1, "location": { "line": 24, - "column": 9 + "column": 9, + "start": 807, + "length": 21 } }, { @@ -105,7 +127,9 @@ "level": 1, "location": { "line": 25, - "column": 9 + "column": 9, + "start": 837, + "length": 31 } }, { @@ -114,7 +138,9 @@ "level": 1, "location": { "line": 27, - "column": 9 + "column": 9, + "start": 901, + "length": 17 } }, { @@ -123,7 +149,9 @@ "level": 1, "location": { "line": 28, - "column": 9 + "column": 9, + "start": 927, + "length": 11 } }, { @@ -132,7 +160,9 @@ "level": 1, "location": { "line": 29, - "column": 9 + "column": 9, + "start": 947, + "length": 25 } }, { @@ -141,7 +171,9 @@ "level": 1, "location": { "line": 30, - "column": 9 + "column": 9, + "start": 981, + "length": 15 } } ], diff --git a/packages/@lwc/template-compiler/src/__tests__/parser.spec.ts b/packages/@lwc/template-compiler/src/__tests__/parser.spec.ts index 655ea7b2f3..29a48850bd 100644 --- a/packages/@lwc/template-compiler/src/__tests__/parser.spec.ts +++ b/packages/@lwc/template-compiler/src/__tests__/parser.spec.ts @@ -11,7 +11,9 @@ const TEMPLATE_IDENTIFIER = { type: 'Identifier' }; const EXPECTED_LOCATION = expect.objectContaining({ line: expect.any(Number), - column: expect.any(Number) + column: expect.any(Number), + start: expect.any(Number), + length: expect.any(Number) }); function parseTemplate(src: string): any { @@ -171,7 +173,7 @@ describe('locator parsing', () => { code: 1001, level: DiagnosticLevel.Error, message: 'LWC1001: locator:context must be used with locator:id', - location: { line: 2, column: 13 } + location: { line: 2, column: 13, start: 23, length: 40 } }); }); @@ -185,7 +187,7 @@ describe('locator parsing', () => { code: 1001, level: DiagnosticLevel.Error, message: "LWC1001: locator:id directive is expected to be a string.", - location: {column: 25, line: 3}, + location: {column: 25, line: 3, start: 48, length: 18}, }); }); @@ -199,7 +201,7 @@ describe('locator parsing', () => { code: 1001, level: DiagnosticLevel.Error, message: "LWC1001: locator:context directive is expected to be an expression.", - location: {column: 44, line: 3}, + location: {column: 44, line: 3, start: 67, length: 21}, }); }); @@ -213,7 +215,7 @@ describe('locator parsing', () => { code: 1001, level: DiagnosticLevel.Error, message: "LWC1001: locator:context cannot be a member expression. It can only be functions on the component", - location: {line: 3, column: 44}, + location: {line: 3, column: 44, start: 67, length: 25}, }); }); }); diff --git a/packages/@lwc/template-compiler/src/parser/html.ts b/packages/@lwc/template-compiler/src/parser/html.ts index d1f8fc9503..b0a853e6ac 100644 --- a/packages/@lwc/template-compiler/src/parser/html.ts +++ b/packages/@lwc/template-compiler/src/parser/html.ts @@ -26,13 +26,18 @@ export function parseHTML(source: string) { const parsingErrors: CompilerDiagnostic[] = []; const onParseError = (err: parse5.Errors.ParsingError) => { - const { code, startLine, startCol } = err; + const { code, startLine, startCol, startOffset, endOffset } = err; parsingErrors.push( generateCompilerDiagnostic(ParserDiagnostics.INVALID_HTML_SYNTAX, { messageArgs: [code], origin: { - location: { line: startLine, column: startCol } + location: { + line: startLine, + column: startCol, + start: startOffset, + length: endOffset - startOffset + } } }) ); @@ -54,7 +59,9 @@ export function parseHTML(source: string) { origin: { location: { line: startTag.startLine || startTag.line, - column: startTag.startCol || startTag.col + column: startTag.startCol || startTag.col, + start: startTag.startOffset, + length: startTag.endOffset - startTag.startOffset } } }) diff --git a/packages/@lwc/template-compiler/src/parser/index.ts b/packages/@lwc/template-compiler/src/parser/index.ts index bbd5041341..e14d7a9527 100644 --- a/packages/@lwc/template-compiler/src/parser/index.ts +++ b/packages/@lwc/template-compiler/src/parser/index.ts @@ -876,9 +876,9 @@ export default function parse(source: string, state: State): { } function warnOnElement(errorInfo: LWCErrorInfo, node: parse5.AST.Node, messageArgs?: any[]) { - const getLocation = (toLocate?: parse5.AST.Node): { line: number, column: number } => { + const getLocation = (toLocate?: parse5.AST.Node): { line: number, column: number, start: number, length: number } => { if (!toLocate) { - return { line: 0, column: 0 }; + return { line: 0, column: 0, start: 0, length: 0 }; } const location = (toLocate as parse5.AST.Default.Element).__location; @@ -889,6 +889,8 @@ export default function parse(source: string, state: State): { return { line: location.line || location.startLine, column: location.col || location.startCol, + start: location.startOffset, + length: location.endOffset - location.startOffset, }; } }; @@ -911,15 +913,21 @@ export default function parse(source: string, state: State): { } // TODO: Update parse5-with-error to match version used for jsdom (interface for ElementLocation changed) - function normalizeLocation(location?: parse5.MarkupData.Location): { line: number, column: number } { + function normalizeLocation(location?: parse5.MarkupData.Location): { line: number, column: number, start: number, length: number } { let line = 0; let column = 0; + let start = 0; + let length = 0; if (location) { + const { startOffset, endOffset } = location; + line = location.line || location.startLine; column = location.col || location.startCol; + start = startOffset; + length = endOffset - startOffset; } - return { line, column }; + return { line, column, start, length }; } function addDiagnostic(diagnostic: CompilerDiagnostic) {