@@ -221,6 +221,55 @@ ruleTester.run('fixer-return', rule, {
221221 }
222222 };
223223 ` ,
224+
225+ // Suggestion
226+ `
227+ module.exports = {
228+ create: function(context) {
229+ context.report( {
230+ suggest: [
231+ {
232+ fix: function(fixer) {
233+ return fixer.foo();
234+ }
235+ }
236+ ]
237+ });
238+ }
239+ };
240+ ` ,
241+ // Suggestion but wrong `suggest` key
242+ `
243+ module.exports = {
244+ create: function(context) {
245+ context.report( {
246+ notSuggest: [
247+ {
248+ fix: function(fixer) {
249+ fixer.foo();
250+ }
251+ }
252+ ]
253+ });
254+ }
255+ };
256+ ` ,
257+ // Suggestion but wrong `fix` key
258+ `
259+ module.exports = {
260+ create: function(context) {
261+ context.report( {
262+ suggest: [
263+ {
264+ notFix: function(fixer) {
265+ fixer.foo();
266+ }
267+ }
268+ ]
269+ });
270+ }
271+ };
272+ ` ,
224273 ] ,
225274
226275 invalid : [
@@ -239,6 +288,25 @@ ruleTester.run('fixer-return', rule, {
239288 ` ,
240289 errors : [ { messageId : 'missingFix' , type : 'FunctionExpression' , line : 5 , column : 24 } ] ,
241290 } ,
291+ {
292+ // Fix but missing return (suggestion)
293+ code : `
294+ module.exports = {
295+ create: function(context) {
296+ context.report({
297+ suggest: [
298+ {
299+ fix(fixer) {
300+ fixer.foo();
301+ }
302+ }
303+ ]
304+ });
305+ }
306+ };
307+ ` ,
308+ errors : [ { messageId : 'missingFix' , type : 'FunctionExpression' , line : 7 , column : 36 } ] ,
309+ } ,
242310 {
243311 // Fix but missing return (arrow function, report on arrow)
244312 code : `
@@ -254,6 +322,25 @@ ruleTester.run('fixer-return', rule, {
254322 ` ,
255323 errors : [ { messageId : 'missingFix' , type : 'ArrowFunctionExpression' , line : 5 , endLine : 5 , column : 34 , endColumn : 36 } ] ,
256324 } ,
325+ {
326+ // Fix but missing return (arrow function, report on arrow, suggestion)
327+ code : `
328+ module.exports = {
329+ create: function(context) {
330+ context.report({
331+ suggest: [
332+ {
333+ fix: (fixer) => {
334+ fixer.foo();
335+ }
336+ }
337+ ]
338+ });
339+ }
340+ };
341+ ` ,
342+ errors : [ { messageId : 'missingFix' , type : 'ArrowFunctionExpression' , line : 7 , endLine : 7 , column : 46 , endColumn : 48 } ] ,
343+ } ,
257344 {
258345 // With no autofix (arrow function, explicit return, report on arrow)
259346 code : `
0 commit comments