From 881456332afab0dc8d93341b39c835bbc78a3b87 Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Tue, 14 Jan 2020 07:25:41 -0800 Subject: [PATCH] Handle the fact that types in Maki are case insensitive --- modern/eslint/maki-method-types.js | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/modern/eslint/maki-method-types.js b/modern/eslint/maki-method-types.js index 5be78e60..72022063 100644 --- a/modern/eslint/maki-method-types.js +++ b/modern/eslint/maki-method-types.js @@ -34,6 +34,14 @@ const TYPE_MAP = { }, }; +function getTypeData(makiType) { + const type = TYPE_MAP[makiType.toLowerCase()]; + if (type == null) { + console.warn(`Could not find type for "${makiType}"`); + } + return type; +} + module.exports = { meta: { docs: { @@ -89,12 +97,16 @@ module.exports = { const { params, returnType, body } = node.value; const sourceCode = context.getSourceCode(); + const unimplemented = sourceCode + .getText(node) + .includes("unimplementedWarning"); + + if (unimplemented) { + return; + } if (returnType == null) { - const expectedTypeData = TYPE_MAP[func.result]; - if ( - expectedTypeData != null && - !sourceCode.getText(node).includes("unimplementedWarning") - ) { + const expectedTypeData = getTypeData(func.result); + if (expectedTypeData != null) { context.report({ node: body, message: `Missing return type for Maki method. Expected \`${expectedTypeData.stringRepresentation}\`.`,