File tree 2 files changed +36
-0
lines changed
2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -118,6 +118,18 @@ function isCallerViolation(
118
118
. some ( ( signature ) => signature . parameters . length === caller . arguments . length ) ;
119
119
}
120
120
121
+ /**
122
+ * Is the given node a direct child of a getter.
123
+ */
124
+ function isDirectChildOfGetter ( node : TSESTree . Node ) : boolean {
125
+ const { parent } = node ;
126
+ if ( parent ?. type !== TSESTree . AST_NODE_TYPES . Property ) {
127
+ return false ;
128
+ }
129
+
130
+ return parent . kind === 'get' ;
131
+ }
132
+
121
133
/**
122
134
* Get the fixes for a call to a reference violation.
123
135
*/
@@ -260,6 +272,13 @@ function checkFunction(
260
272
context : Readonly < RuleContext < keyof typeof errorMessages , RawOptions > > ,
261
273
options : RawOptions ,
262
274
) : RuleResult < keyof typeof errorMessages , RawOptions > {
275
+ if ( isDirectChildOfGetter ( node ) ) {
276
+ return {
277
+ context,
278
+ descriptors : [ ] ,
279
+ } ;
280
+ }
281
+
263
282
return {
264
283
context,
265
284
descriptors : [
Original file line number Diff line number Diff line change @@ -97,6 +97,23 @@ describe(name, () => {
97
97
` ) ;
98
98
} ) ;
99
99
100
+ it ( "doesn't report getters" , ( ) => {
101
+ valid ( dedent `
102
+ const foo = () => {
103
+ const getBar = () => 1;
104
+ const setBar = (value: number) => {};
105
+ return {
106
+ get baz() {
107
+ return getBar();
108
+ },
109
+ set baz(value) {
110
+ setBar(value);
111
+ },
112
+ };
113
+ };
114
+ ` ) ;
115
+ } ) ;
116
+
100
117
describe ( "options" , ( ) => {
101
118
describe ( "checkMemberExpressions" , ( ) => {
102
119
it ( "doesn't report member expressions when disabled" , ( ) => {
You can’t perform that action at this time.
0 commit comments