license import { TSESTree as es } from "@typescript-eslint/experimental-utils" ; import { getTypeServices } from "eslint-etc" ; import { ruleCreator } from "../utils" ; const rule = ruleCreator ( { defaultOptions : [ ] , meta : { docs : { description : "Forbids the use of the `toPromise` method." , recommended : false , } , fixable : undefined , hasSuggestions : false , messages : { forbidden : "The toPromise method is forbidden." , } , schema : [ ] , type : "problem" , } , name : "no-topromise" , create : ( context ) => { const { couldBeObservable } = getTypeServices ( context ) ; return { [ `MemberExpression[property.name="toPromise"]` ] : ( node ) => { if ( couldBeObservable ( node . object ) ) { context . report ( { messageId : "forbidden" , node : node . property , } ) ; } } , } ; } , } ) ; export = rule ;