import { TSESTree , ESLintUtils , ParserServices , } from "@typescript-eslint/experimental-utils" ; import { REPO_URL , callExpressionAnalysis , assignmentExpressionAnalysis , variableDeclaratorAnalysis , } from "./utils" ; import { RuleContext , RuleMetaDataDocs , RuleMetaData , } from "@typescript-eslint/experimental-utils/dist/ts-eslint" ; import ts from "typescript" ; fileoverview ( "use strict" ) ; type Options = unknown [ ] ; type MessageIds = "officeReadCall" ; export = { name : "no-office-read-calls" , meta : { docs : { description : "Prevents office read api calls" , category : < RuleMetaDataDocs [ "category" ] > "Best Practices" , recommended : < RuleMetaDataDocs [ "recommended" ] > "warn" , requiresTypeChecking : true , url : REPO_URL , } , type : < RuleMetaData < MessageIds > [ "type" ] > "problem" , messages : < Record < MessageIds , string > > { officeReadCall : "No Office API read calls within Custom Functions" , } , schema : [ ] , } , create : function ( ruleContext ) : { CallExpression : ( node : TSESTree . CallExpression ) => void ; AssignmentExpression : ( node : TSESTree . AssignmentExpression ) => void ; VariableDeclarator : ( node : TSESTree . VariableDeclarator ) => void ; } { const services = ESLintUtils . getParserServices ( ruleContext ) ; const typeChecker = services . program . getTypeChecker ( ) ; let officeCallingFuncs = new Set < ts . Node > ( ) ; let helperFuncToMentionsMap = new Map < ts . Node , Array < { messageId : MessageIds ; loc : TSESTree . SourceLocation ; node : TSESTree . Node ; } > > ( ) ; let helperFuncToHelperFuncMap = new Map < ts . Node , Set < ts . Node > > ( ) ; return { CallExpression : function ( node ) { callExpressionAnalysis ( node , services , typeChecker , ruleContext , officeCallingFuncs , helperFuncToMentionsMap , helperFuncToHelperFuncMap , false ) ; } , AssignmentExpression : function ( node ) { assignmentExpressionAnalysis ( node , ruleContext , services , typeChecker , false ) ; } , VariableDeclarator : function ( node ) { variableDeclaratorAnalysis ( node , ruleContext , services , typeChecker ) ; } , } ; } , } ;