From d28868647a9a381c51c2821a37841da2cc9f984b Mon Sep 17 00:00:00 2001 From: Jesse Date: Fri, 12 Aug 2022 14:54:06 -0400 Subject: [PATCH] adding return types to function declarations, see https://github.com/phetsims/chipper/issues/1288 --- eslint/rules/explicit-method-return-type.js | 34 ++++++++++----------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/eslint/rules/explicit-method-return-type.js b/eslint/rules/explicit-method-return-type.js index be83dbec..f21d36fc 100644 --- a/eslint/rules/explicit-method-return-type.js +++ b/eslint/rules/explicit-method-return-type.js @@ -65,23 +65,23 @@ module.exports = { }, create: context => { return { - // FunctionDeclaration: node => { - // if ( !node.returnType ) { - // - // context.report( { - // message: 'Missing return type.', - // node: node, - // - // // Comment out for next time we need this fixer, but it requires type info, where the rule doesn't, so don't always include it. - // fix: fixer => { // eslint-disable-line - // - // const returnTypeString = getReturnTypeString( context, node ); - // const bodyStart = node.body.range[ 0 ]; - // return insertReturnType( bodyStart, returnTypeString, fixer ); - // } - // } ); - // } - // }, + FunctionDeclaration: node => { + if ( !node.returnType ) { + + context.report( { + message: 'Missing return type.', + node: node, + + // Comment out for next time we need this fixer, but it requires type info, where the rule doesn't, so don't always include it. + fix: fixer => { + + const returnTypeString = getReturnTypeString( context, node ); + const bodyStart = node.body.range[ 0 ]; + return insertReturnType( bodyStart, returnTypeString, fixer ); + } + } ); + } + }, MethodDefinition: node => { if ( !exemptMethods.includes( node.kind ) && node.value && !node.value.returnType ) {