From 60f4cb95d4e1177c220e8f4b5021b2d870309a8e Mon Sep 17 00:00:00 2001 From: Armano Date: Sat, 13 Oct 2018 16:57:33 +0200 Subject: [PATCH] #598 Ignore templates with src tag in no-unused-components --- lib/rules/no-unused-components.js | 3 ++- tests/lib/rules/no-unused-components.js | 26 ++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/lib/rules/no-unused-components.js b/lib/rules/no-unused-components.js index 64c77291b..3f36f9cd9 100644 --- a/lib/rules/no-unused-components.js +++ b/lib/rules/no-unused-components.js @@ -66,7 +66,8 @@ module.exports = { "VElement[name='template']:exit" (rootNode) { if ( rootNode.loc.start !== templateLocation || - ignoreReporting + ignoreReporting || + utils.hasAttribute(rootNode, 'src') ) return registeredComponents diff --git a/tests/lib/rules/no-unused-components.js b/tests/lib/rules/no-unused-components.js index 939413a59..371194360 100644 --- a/tests/lib/rules/no-unused-components.js +++ b/tests/lib/rules/no-unused-components.js @@ -334,7 +334,7 @@ tester.run('no-unused-components', rule, { options: [{ ignoreWhenBindingPresent: true }] }, - // Ignore when `render` is used instead of temoplate + // Ignore when `render` is used instead of template { filename: 'test.vue', code: ` @@ -348,6 +348,30 @@ tester.run('no-unused-components', rule, { } } ` + }, + { + filename: 'test.vue', + code: ` +