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 subclassing RxJS classes." , recommended : false , } , fixable : undefined , hasSuggestions : false , messages : { forbidden : "Subclassing RxJS classes is forbidden." , } , schema : [ ] , type : "problem" , } , name : "no-subclass" , create : ( context ) => { const { couldBeType } = getTypeServices ( context ) ; const queryNames = [ "AsyncSubject" , "BehaviorSubject" , "Observable" , "ReplaySubject" , "Scheduler" , "Subject" , "Subscriber" , ] ; return { [ `ClassDeclaration[superClass.name=/^(${ queryNames . join ( "|" ) })$/] > Identifier.superClass` ] : ( node ) => { if ( queryNames . some ( ( name ) => couldBeType ( node , name , { name : /[\/\\]rxjs[\/\\]/ } ) ) ) { context . report ( { messageId : "forbidden" , node , } ) ; } } , } ; } , } ) ; export = rule ;