File tree Expand file tree Collapse file tree 2 files changed +59
-1
lines changed Expand file tree Collapse file tree 2 files changed +59
-1
lines changed Original file line number Diff line number Diff line change @@ -66,9 +66,10 @@ const create = (context) => {
66
66
const shouldFilterNode = ( functionNode ) => {
67
67
const isArrow = functionNode . type === 'ArrowFunctionExpression' ;
68
68
const isMethod = functionNode . parent && functionNode . parent . type === 'MethodDefinition' ;
69
+ const isProperty = functionNode . parent && functionNode . parent . type === 'ClassProperty' ;
69
70
let selector ;
70
71
71
- if ( isMethod ) {
72
+ if ( isMethod || isProperty ) {
72
73
selector = 'parent.key.name' ;
73
74
} else if ( isArrow ) {
74
75
selector = 'parent.id.name' ;
Original file line number Diff line number Diff line change @@ -239,6 +239,30 @@ export default {
239
239
}
240
240
]
241
241
} ,
242
+ {
243
+ code : 'class Test { foo() { return 42; } }' ,
244
+ errors : [
245
+ {
246
+ message : 'Missing return type annotation.'
247
+ }
248
+ ]
249
+ } ,
250
+ {
251
+ code : 'class Test { foo = () => { return 42; } }' ,
252
+ errors : [
253
+ {
254
+ message : 'Missing return type annotation.'
255
+ }
256
+ ]
257
+ } ,
258
+ {
259
+ code : 'class Test { foo = () => 42; }' ,
260
+ errors : [
261
+ {
262
+ message : 'Missing return type annotation.'
263
+ }
264
+ ]
265
+ } ,
242
266
{
243
267
code : 'async () => { return; }' ,
244
268
errors : [
@@ -645,6 +669,39 @@ export default {
645
669
{
646
670
code : 'class Test { constructor() { } }'
647
671
} ,
672
+ {
673
+ code : 'class Test { foo() { return 42; } }' ,
674
+ options : [
675
+ 'always' ,
676
+ {
677
+ excludeMatching : [ 'foo' ]
678
+ }
679
+ ]
680
+ } ,
681
+ {
682
+ code : 'class Test { foo = () => { return 42; } }' ,
683
+ options : [
684
+ 'always' ,
685
+ {
686
+ excludeMatching : [ 'foo' ]
687
+ }
688
+ ]
689
+ } ,
690
+ {
691
+ code : 'class Test { foo = () => 42; }' ,
692
+ options : [
693
+ 'always' ,
694
+ {
695
+ excludeMatching : [ 'foo' ]
696
+ }
697
+ ]
698
+ } ,
699
+ {
700
+ code : 'class Test { foo = (): number => { return 42; } }'
701
+ } ,
702
+ {
703
+ code : 'class Test { foo = (): number => 42; }'
704
+ } ,
648
705
{
649
706
code : 'async (foo): Promise<number> => { return 3; }'
650
707
} ,
You can’t perform that action at this time.
0 commit comments