File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,26 +10,11 @@ export = new class NoAnyCasts implements eslint.Rule.RuleModule {
1010
1111 create ( context : eslint . Rule . RuleContext ) : eslint . Rule . RuleListener {
1212 return {
13- // Detect TSTypeAssertion: <any>value
14- 'TSTypeAssertion' : ( node : any ) => {
15- const typeAssertion = node as TSESTree . TSTypeAssertion ;
16- if ( typeAssertion . typeAnnotation . type === 'TSAnyKeyword' ) {
17- context . report ( {
18- node,
19- message : `Avoid casting to 'any' type. Consider using a more specific type or type guards for better type safety.`
20- } ) ;
21- }
22- } ,
23-
24- // Detect TSAsExpression: value as any
25- 'TSAsExpression' : ( node : any ) => {
26- const asExpression = node as TSESTree . TSAsExpression ;
27- if ( asExpression . typeAnnotation . type === 'TSAnyKeyword' ) {
28- context . report ( {
29- node,
30- message : `Avoid casting to 'any' type. Consider using a more specific type or type guards for better type safety.`
31- } ) ;
32- }
13+ 'TSTypeAssertion[typeAnnotation.type="TSAnyKeyword"], TSAsExpression[typeAnnotation.type="TSAnyKeyword"]' : ( node : TSESTree . TSTypeAssertion | TSESTree . TSAsExpression ) => {
14+ context . report ( {
15+ node,
16+ message : `Avoid casting to 'any' type. Consider using a more specific type or type guards for better type safety.`
17+ } ) ;
3318 }
3419 } ;
3520 }
You can’t perform that action at this time.
0 commit comments