From 64b882e3c55b33b5bde4bae90d69673d5d4b24c3 Mon Sep 17 00:00:00 2001 From: Tan Li Hau Date: Thu, 5 Aug 2021 00:03:34 +0800 Subject: [PATCH] [feat] improve parser errors (#6612) --- src/compiler/parse/errors.ts | 8 ++ src/compiler/parse/state/tag.ts | 20 +++- .../samples/attribute-empty-error/error.json | 10 ++ .../attribute-empty-error/input.svelte | 1 + .../samples/attribute-empty/input.svelte | 1 + .../samples/attribute-empty/output.json | 108 ++++++++++++++++++ .../error.json | 10 ++ .../input.svelte | 1 + 8 files changed, 158 insertions(+), 1 deletion(-) create mode 100644 test/parser/samples/attribute-empty-error/error.json create mode 100644 test/parser/samples/attribute-empty-error/input.svelte create mode 100644 test/parser/samples/attribute-empty/input.svelte create mode 100644 test/parser/samples/attribute-empty/output.json create mode 100644 test/parser/samples/error-unclosed-attribute-self-close-tag/error.json create mode 100644 test/parser/samples/error-unclosed-attribute-self-close-tag/input.svelte diff --git a/src/compiler/parse/errors.ts b/src/compiler/parse/errors.ts index b563b7572a..ef1f72a8be 100644 --- a/src/compiler/parse/errors.ts +++ b/src/compiler/parse/errors.ts @@ -157,6 +157,10 @@ export default { code: 'missing-component-definition', message: ' must have a \'this\' attribute' }, + missing_attribute_value: { + code: 'missing-attribute-value', + message: 'Expected value for the attribute' + }, unclosed_script: { code: 'unclosed-script', message: '