From ee73e8b68d541580a7017dbe8ed5c8e51bb257c7 Mon Sep 17 00:00:00 2001 From: Clark Du Date: Wed, 19 Dec 2018 17:06:37 +0000 Subject: [PATCH] fix: not-null check for hooks --- lib/rules/no-env-in-mounted.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/rules/no-env-in-mounted.js b/lib/rules/no-env-in-mounted.js index cdbf0a8..75457db 100644 --- a/lib/rules/no-env-in-mounted.js +++ b/lib/rules/no-env-in-mounted.js @@ -47,16 +47,18 @@ module.exports = { ...utils.executeOnVue(context, obj => { for (const funcName of HOOKS) { const func = utils.getFunctionWithName(obj, funcName) - for (const { name, node: child } of forbiddenNodes) { - if (utils.isInFunction(func, child)) { - context.report({ - node: child, - messageId: 'noEnv', - data: { - name, - funcName - } - }) + if (func) { + for (const { name, node: child } of forbiddenNodes) { + if (utils.isInFunction(func, child)) { + context.report({ + node: child, + messageId: 'noEnv', + data: { + name, + funcName + } + }) + } } } }