@@ -20,18 +20,17 @@ import { ESLintUtils } from '@typescript-eslint/utils';
2020
2121const createRule = ESLintUtils . RuleCreator ( name => `https://example.com/rule/${ name } ` )
2222
23- const UTILITY_TYPES = [ 'Record' , 'Partial' , 'Required' , 'Pick' , 'Omit' ] ;
24-
25- const COLLECTION_TYPES = [ 'Map' , 'Set' , 'WeakMap' , 'WeakSet' ] ;
26-
27- const TYPES_TO_AVOID = [ ...UTILITY_TYPES , ...COLLECTION_TYPES ] ;
28-
2923const TYPE_SUGGESTIONS = {
3024 'Record' : 'Use Dictionary instead' ,
25+ 'Partial' : 'Use spec-defined aliases instead' ,
26+ 'Required' : 'Use spec-defined aliases instead' ,
27+ 'Pick' : 'Use spec-defined aliases instead' ,
28+ 'Omit' : 'Use spec-defined aliases instead' ,
3129 'Map' : 'Use Dictionary instead' ,
3230 'Set' : 'Use an array type instead (e.g., string[])' ,
3331 'WeakMap' : 'Use Dictionary instead' ,
3432 'WeakSet' : 'Use an array type instead' ,
33+ 'Array' : 'Use array syntax instead (e.g., string[])' ,
3534} ;
3635
3736export default createRule ( {
@@ -40,13 +39,13 @@ export default createRule({
4039 return {
4140 TSTypeReference ( node ) {
4241 const typeName = node . typeName . name ;
43- if ( TYPES_TO_AVOID . includes ( typeName ) ) {
42+ if ( TYPE_SUGGESTIONS [ typeName ] ) {
4443 context . report ( {
4544 node,
4645 messageId : 'noNativeType' ,
4746 data : {
4847 type : typeName ,
49- suggestion : TYPE_SUGGESTIONS [ typeName ] || 'Use spec-defined aliases instead'
48+ suggestion : TYPE_SUGGESTIONS [ typeName ]
5049 }
5150 } )
5251 }
0 commit comments