You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/developer-guide/working-with-rules.md
+34Lines changed: 34 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -418,6 +418,40 @@ module.exports = {
418
418
};
419
419
```
420
420
421
+
#### Placeholders in suggestion messages
422
+
423
+
You can also use placeholders in the suggestion message. This works the same way as placeholders for the overall error (see [using message placeholders](#using-message-placeholders)).
424
+
425
+
Please note that you have to provide `data` on the suggestion's object. Suggestion messages cannot use properties from the overall error's `data`.
removeEscape: "Remove `\\` before {{character}}.",
433
+
}
434
+
},
435
+
create: function(context) {
436
+
// ...
437
+
context.report({
438
+
node: node,
439
+
messageId: "unnecessaryEscape",
440
+
data: { character }, // data for the unnecessaryEscape overall message
441
+
suggest: [
442
+
{
443
+
messageId: "removeEscape",
444
+
data: { character }, // data for the removeEscape suggestion message
445
+
fix: function(fixer) {
446
+
return fixer.removeRange(range);
447
+
}
448
+
}
449
+
]
450
+
});
451
+
}
452
+
};
453
+
```
454
+
421
455
### context.options
422
456
423
457
Some rules require options in order to function correctly. These options appear in configuration (`.eslintrc`, command line, or in comments). For example:
0 commit comments