File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -118,6 +118,18 @@ function isCallerViolation(
118118 . some ( ( signature ) => signature . parameters . length === caller . arguments . length ) ;
119119}
120120
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+
121133/**
122134 * Get the fixes for a call to a reference violation.
123135 */
@@ -260,6 +272,13 @@ function checkFunction(
260272 context : Readonly < RuleContext < keyof typeof errorMessages , RawOptions > > ,
261273 options : RawOptions ,
262274) : RuleResult < keyof typeof errorMessages , RawOptions > {
275+ if ( isDirectChildOfGetter ( node ) ) {
276+ return {
277+ context,
278+ descriptors : [ ] ,
279+ } ;
280+ }
281+
263282 return {
264283 context,
265284 descriptors : [
Original file line number Diff line number Diff line change @@ -97,6 +97,23 @@ describe(name, () => {
9797 ` ) ;
9898 } ) ;
9999
100+ it ( "doesn't report getters" , async ( ) => {
101+ await 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+
100117 describe ( "options" , ( ) => {
101118 describe ( "checkMemberExpressions" , ( ) => {
102119 it ( "doesn't report member expressions when disabled" , async ( ) => {
You can’t perform that action at this time.
0 commit comments