@@ -52,6 +52,19 @@ ruleTester.run("no-return-assign", rule, {
5252 {
5353 code : "() => (result = a * b)" ,
5454 options : [ "except-parens" ]
55+ } ,
56+ "const foo = (a,b,c) => ((a = b), c)" ,
57+ `function foo(){
58+ return (a = b)
59+ }` ,
60+ `function bar(){
61+ return function foo(){
62+ return (a = b) && c
63+ }
64+ }` ,
65+ {
66+ code : "const foo = (a) => (b) => (a = b)" ,
67+ parserOptions : { ecmaVersion : 6 }
5568 }
5669 ] ,
5770 invalid : [
@@ -79,7 +92,12 @@ ruleTester.run("no-return-assign", rule, {
7992 } ,
8093 {
8194 code : "() => result = a * b" ,
82- errors : [ { messageId : "arrowAssignment" , type : "ArrowFunctionExpression" } ]
95+ errors : [
96+ {
97+ messageId : "arrowAssignment" ,
98+ type : "ArrowFunctionExpression"
99+ }
100+ ]
83101 } ,
84102 {
85103 code : "function x() { return result = a * b; };" ,
@@ -95,6 +113,68 @@ ruleTester.run("no-return-assign", rule, {
95113 code : "function x() { return result || (result = a * b); };" ,
96114 options : [ "always" ] ,
97115 errors : [ { messageId : "returnAssignment" , type : "ReturnStatement" } ]
116+ } ,
117+ {
118+ code : `function foo(){
119+ return a = b
120+ }` ,
121+ errors : [ { messageId : "returnAssignment" , type : "ReturnStatement" } ]
122+ } ,
123+ {
124+ code : `function doSomething() {
125+ return foo = bar && foo > 0;
126+ }` ,
127+ errors : [ { messageId : "returnAssignment" , type : "ReturnStatement" } ]
128+ } ,
129+ {
130+ code : `function doSomething() {
131+ return foo = function(){
132+ return (bar = bar1)
133+ }
134+ }` ,
135+ errors : [ { messageId : "returnAssignment" , type : "ReturnStatement" } ]
136+ } ,
137+ {
138+ code : `function doSomething() {
139+ return foo = () => a
140+ }` ,
141+ parserOptions : { ecmaVersion : 6 } ,
142+ errors : [
143+ {
144+ messageId : "returnAssignment" ,
145+ type : "ReturnStatement"
146+ }
147+ ]
148+ } ,
149+ {
150+ code : `function doSomething() {
151+ return () => a = () => b
152+ }` ,
153+ parserOptions : { ecmaVersion : 6 } ,
154+ errors : [
155+ {
156+ messageId : "arrowAssignment" ,
157+ type : "ArrowFunctionExpression"
158+ }
159+ ]
160+ } ,
161+ {
162+ code : `function foo(a){
163+ return function bar(b){
164+ return a = b
165+ }
166+ }` ,
167+ errors : [ { messageId : "returnAssignment" , type : "ReturnStatement" } ]
168+ } ,
169+ {
170+ code : "const foo = (a) => (b) => a = b" ,
171+ parserOptions : { ecmaVersion : 6 } ,
172+ errors : [
173+ {
174+ messageId : "arrowAssignment" ,
175+ type : "ArrowFunctionExpression"
176+ }
177+ ]
98178 }
99179 ]
100180} ) ;
0 commit comments