From 581689a305dc19140a7c06de35150f3df20f23a0 Mon Sep 17 00:00:00 2001 From: Toru Nagashima Date: Tue, 20 Jun 2017 12:29:36 +0900 Subject: [PATCH] Fix: crash `no-v-invalid-v-for` on `:key` (fixes #37) --- lib/rules/no-invalid-v-for.js | 3 +++ tests/lib/rules/no-invalid-v-for.js | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/lib/rules/no-invalid-v-for.js b/lib/rules/no-invalid-v-for.js index b9852b576..9b19599a3 100644 --- a/lib/rules/no-invalid-v-for.js +++ b/lib/rules/no-invalid-v-for.js @@ -21,6 +21,9 @@ const utils = require('../utils') * @returns {boolean} `true` if the node is using the variables which are defined by `v-for` directives. */ function isUsingIterationVar (node) { + if (node.value == null) { + return false + } const references = node.value.references const variables = node.parent.parent.variables diff --git a/tests/lib/rules/no-invalid-v-for.js b/tests/lib/rules/no-invalid-v-for.js index 861197737..f465b567c 100644 --- a/tests/lib/rules/no-invalid-v-for.js +++ b/tests/lib/rules/no-invalid-v-for.js @@ -144,6 +144,11 @@ tester.run('no-invalid-v-for', rule, { filename: 'test.vue', code: '', errors: ["Expected 'v-bind:key' directive to use the variables which are defined by the 'v-for' directive."] + }, + { + filename: 'test.vue', + code: '', + errors: ["Expected 'v-bind:key' directive to use the variables which are defined by the 'v-for' directive."] } ] })