Documentation
      ¶
    
    
  
    
  
    Index ¶
Constants ¶
This section is empty.
Variables ¶
      View Source
      
  
var NoUnsafeCallRule = rule.CreateRule(rule.Rule{ Name: "no-unsafe-call", Run: func(ctx rule.RuleContext, options any) rule.RuleListeners { compilerOptions := ctx.Program.Options() isNoImplicitThis := utils.IsStrictCompilerOptionEnabled( compilerOptions, compilerOptions.NoImplicitThis, ) checkCall := func( node *ast.Node, reportingNode *ast.Node, messageBuilder func(t string) rule.RuleMessage, newCall bool, ) { t := utils.GetConstrainedTypeAtLocation(ctx.TypeChecker, node) if utils.IsTypeAnyType(t) { if !isNoImplicitThis { thisExpression := utils.GetThisExpression(node) if thisExpression != nil && utils.IsTypeAnyType( utils.GetConstrainedTypeAtLocation(ctx.TypeChecker, thisExpression), ) { messageBuilder = buildUnsafeCallThisMessage } } isErrorType := utils.IsIntrinsicErrorType(t) msg := "`any`" if isErrorType { msg = "`error` type" } ctx.ReportNode(reportingNode, messageBuilder(msg)) return } if utils.IsBuiltinSymbolLike(ctx.Program, ctx.TypeChecker, t, "Function") { constructSignatures := utils.GetConstructSignatures(ctx.TypeChecker, t) if len(constructSignatures) > 0 { return } callSignatures := utils.GetCallSignatures(ctx.TypeChecker, t) if newCall { if utils.Some(callSignatures, func(signature *checker.Signature) bool { return !utils.IsIntrinsicVoidType(checker.Checker_getReturnTypeOfSignature(ctx.TypeChecker, signature)) }) { return } } else if len(callSignatures) > 0 { return } ctx.ReportNode(reportingNode, messageBuilder("`Function`")) return } } return rule.RuleListeners{ ast.KindCallExpression: func(node *ast.Node) { callee := node.Expression() if callee.Kind == ast.KindImportKeyword { return } checkCall(callee, callee, buildUnsafeCallMessage, false) }, ast.KindNewExpression: func(node *ast.Node) { callee := node.Expression() checkCall(callee, node, buildUnsafeNewMessage, true) }, ast.KindTaggedTemplateExpression: func(node *ast.Node) { tag := node.AsTaggedTemplateExpression().Tag checkCall(tag, tag, buildUnsafeTemplateTagMessage, false) }, } }, })
Functions ¶
This section is empty.
Types ¶
This section is empty.
 Click to show internal directories. 
   Click to hide internal directories.