@@ -66,6 +66,7 @@ ruleTester.run("array-callback-return", rule, {
6666 "foo.reduceRight(function() { return true; })" ,
6767 "foo.some(function() { return true; })" ,
6868 "foo.sort(function() { return 0; })" ,
69+ "foo.toSorted(function() { return 0; })" ,
6970 { code : "foo.every(() => { return true; })" , parserOptions : { ecmaVersion : 6 } } ,
7071 "foo.every(function() { if (a) return true; else return false; })" ,
7172 "foo.every(function() { switch (a) { case 0: bar(); default: return true; } })" ,
@@ -88,6 +89,7 @@ ruleTester.run("array-callback-return", rule, {
8889 { code : "foo.reduceRight(function() { return; })" , options : allowImplicitOptions } ,
8990 { code : "foo.some(function() { return; })" , options : allowImplicitOptions } ,
9091 { code : "foo.sort(function() { return; })" , options : allowImplicitOptions } ,
92+ { code : "foo.toSorted(function() { return; })" , options : allowImplicitOptions } ,
9193 { code : "foo.every(() => { return; })" , options : allowImplicitOptions , parserOptions : { ecmaVersion : 6 } } ,
9294 { code : "foo.every(function() { if (a) return; else return a; })" , options : allowImplicitOptions } ,
9395 { code : "foo.every(function() { switch (a) { case 0: bar(); default: return; } })" , options : allowImplicitOptions } ,
@@ -151,6 +153,8 @@ ruleTester.run("array-callback-return", rule, {
151153 { code : "foo.some(function foo() {})" , errors : [ { messageId : "expectedInside" , data : { name : "function 'foo'" , arrayMethodName : "Array.prototype.some" } } ] } ,
152154 { code : "foo.sort(function() {})" , errors : [ { messageId : "expectedInside" , data : { name : "function" , arrayMethodName : "Array.prototype.sort" } } ] } ,
153155 { code : "foo.sort(function foo() {})" , errors : [ { messageId : "expectedInside" , data : { name : "function 'foo'" , arrayMethodName : "Array.prototype.sort" } } ] } ,
156+ { code : "foo.toSorted(function() {})" , errors : [ { messageId : "expectedInside" , data : { name : "function" , arrayMethodName : "Array.prototype.toSorted" } } ] } ,
157+ { code : "foo.toSorted(function foo() {})" , errors : [ { messageId : "expectedInside" , data : { name : "function 'foo'" , arrayMethodName : "Array.prototype.toSorted" } } ] } ,
154158 { code : "foo.bar.baz.every(function() {})" , errors : [ { messageId : "expectedInside" , data : { name : "function" , arrayMethodName : "Array.prototype.every" } } ] } ,
155159 { code : "foo.bar.baz.every(function foo() {})" , errors : [ { messageId : "expectedInside" , data : { name : "function 'foo'" , arrayMethodName : "Array.prototype.every" } } ] } ,
156160 { code : "foo[\"every\"](function() {})" , errors : [ { messageId : "expectedInside" , data : { name : "function" , arrayMethodName : "Array.prototype.every" } } ] } ,
@@ -190,6 +194,7 @@ ruleTester.run("array-callback-return", rule, {
190194 { code : "foo.bar.baz.every(function foo() {})" , options : allowImplicitOptions , errors : [ { messageId : "expectedInside" , data : { name : "function 'foo'" , arrayMethodName : "Array.prototype.every" } } ] } ,
191195 { code : "foo.every(cb || function() {})" , options : allowImplicitOptions , errors : [ "Array.prototype.every() expects a return value from function." ] } ,
192196 { code : "[\"foo\",\"bar\"].sort(function foo() {})" , options : allowImplicitOptions , errors : [ { messageId : "expectedInside" , data : { name : "function 'foo'" , arrayMethodName : "Array.prototype.sort" } } ] } ,
197+ { code : "[\"foo\",\"bar\"].toSorted(function foo() {})" , options : allowImplicitOptions , errors : [ { messageId : "expectedInside" , data : { name : "function 'foo'" , arrayMethodName : "Array.prototype.toSorted" } } ] } ,
193198 { code : "foo.forEach(x => x)" , options : allowImplicitCheckForEach , parserOptions : { ecmaVersion : 6 } , errors : [ { messageId : "expectedNoReturnValue" , data : { name : "arrow function" , arrayMethodName : "Array.prototype.forEach" } } ] } ,
194199 { code : "foo.forEach(function(x) { if (a == b) {return x;}})" , options : allowImplicitCheckForEach , errors : [ { messageId : "expectedNoReturnValue" , data : { name : "function" , arrayMethodName : "Array.prototype.forEach" } } ] } ,
195200 { code : "foo.forEach(function bar(x) { return x;})" , options : allowImplicitCheckForEach , errors : [ { messageId : "expectedNoReturnValue" , data : { name : "function 'bar'" , arrayMethodName : "Array.prototype.forEach" } } ] } ,
0 commit comments