From 62fb5c6a7c8d97b3b0f42ec2bda19cf6a1be3d91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=87=A4=E5=AE=9D?= Date: Thu, 5 Dec 2019 21:01:56 +0800 Subject: [PATCH] [Fix] raise an error when a method name is in string form --- lib/rules/no-typos.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/rules/no-typos.js b/lib/rules/no-typos.js index 3c943ad068..25acb5a901 100644 --- a/lib/rules/no-typos.js +++ b/lib/rules/no-typos.js @@ -144,7 +144,11 @@ module.exports = { function reportErrorIfLifecycleMethodCasingTypo(node) { LIFECYCLE_METHODS.forEach((method) => { - if (method.toLowerCase() === node.key.name.toLowerCase() && method !== node.key.name) { + let nodeKeyName = node.key.name; + if(node.key.type === "Literal") { + nodeKeyName = node.key.value; + } + if (method.toLowerCase() === nodeKeyName.toLowerCase() && method !== nodeKeyName) { context.report({ node, message: 'Typo in component lifecycle method declaration'