From d45699db6fe44e7c4ee4fd621350896a0b68b335 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sun, 11 Jun 2017 15:45:25 -0400 Subject: [PATCH] warn on missing component (#623) --- src/validate/html/validateElement.ts | 5 +++++ test/validator/samples/missing-component/input.html | 3 +++ test/validator/samples/missing-component/warnings.json | 8 ++++++++ 3 files changed, 16 insertions(+) create mode 100644 test/validator/samples/missing-component/input.html create mode 100644 test/validator/samples/missing-component/warnings.json diff --git a/src/validate/html/validateElement.ts b/src/validate/html/validateElement.ts index 081fea6028..5ee8766f03 100644 --- a/src/validate/html/validateElement.ts +++ b/src/validate/html/validateElement.ts @@ -6,6 +6,11 @@ export default function validateElement(validator: Validator, node: Node) { const isComponent = node.name === ':Self' || validator.components.has(node.name); + if (!isComponent && node.name[0] === node.name[0].toUpperCase()) { + // TODO upgrade to validator.error in v2 + validator.warn(`${node.name} component is not defined`, node.start); + } + let hasIntro: boolean; let hasOutro: boolean; let hasTransition: boolean; diff --git a/test/validator/samples/missing-component/input.html b/test/validator/samples/missing-component/input.html new file mode 100644 index 0000000000..2b689d711c --- /dev/null +++ b/test/validator/samples/missing-component/input.html @@ -0,0 +1,3 @@ +
+ +
\ No newline at end of file diff --git a/test/validator/samples/missing-component/warnings.json b/test/validator/samples/missing-component/warnings.json new file mode 100644 index 0000000000..c3a3be4d02 --- /dev/null +++ b/test/validator/samples/missing-component/warnings.json @@ -0,0 +1,8 @@ +[{ + "message": "Widget component is not defined", + "loc": { + "line": 2, + "column": 1 + }, + "pos": 7 +}] \ No newline at end of file