@@ -44,11 +44,13 @@ export enum RuleEnforcementComparator {
4444type FixerConfigRaw = {
4545 pattern : string ;
4646 replace : string ;
47+ message ?: string ;
4748} ;
4849
4950type FixerConfig = {
5051 pattern : RegExp ;
5152 replace : string ;
53+ message ?: string ;
5254} ;
5355
5456type SuggestionsConfig = FixerConfig [ ] ;
@@ -188,6 +190,7 @@ const errorMessages = {
188190 Exactly : 'This type is declare to have an immutability of exactly "{{ expected }}" (actual: "{{ actual }}").' ,
189191 AtMost : 'This type is declare to have an immutability of at most "{{ expected }}" (actual: "{{ actual }}").' ,
190192 More : 'This type is declare to have an immutability more than "{{ expected }}" (actual: "{{ actual }}").' ,
193+ userDefined : "{{ message }}" ,
191194} as const ;
192195
193196/**
@@ -313,7 +316,6 @@ function getConfiguredSuggestions<T extends TSESTree.Node>(
313316 node : T ,
314317 context : Readonly < RuleContext < keyof typeof errorMessages , RawOptions > > ,
315318 configs : ReadonlyArray < FixerConfig > ,
316- messageId : keyof typeof errorMessages ,
317319) : NonNullable < Descriptor [ "suggest" ] > | null {
318320 const text = context . sourceCode . getText ( node ) ;
319321 const matchingConfig = configs . filter ( ( c ) => c . pattern . test ( text ) ) ;
@@ -322,7 +324,10 @@ function getConfiguredSuggestions<T extends TSESTree.Node>(
322324 }
323325 return matchingConfig . map ( ( config ) => ( {
324326 fix : ( fixer ) => fixer . replaceText ( node , text . replace ( config . pattern , config . replace ) ) ,
325- messageId,
327+ messageId : "userDefined" ,
328+ data : {
329+ message : config . message ?? `Replace with: ${ text . replace ( config . pattern , config . replace ) } ` ,
330+ } ,
326331 } ) ) ;
327332}
328333
@@ -376,7 +381,7 @@ function getResults(
376381 const suggest =
377382 rule . suggestions === false || isTSInterfaceDeclaration ( node )
378383 ? null
379- : getConfiguredSuggestions ( node . typeAnnotation , context , rule . suggestions , messageId ) ;
384+ : getConfiguredSuggestions ( node . typeAnnotation , context , rule . suggestions ) ;
380385
381386 return {
382387 context,
0 commit comments