Skip to content

Commit e41344f

Browse files
maclover7MylesBorins
authored andcommitted
tools: add docs for prefer-util-format-errors rule
I had a little trouble understanding what the rule was trying to say, so am documenting what would pass/fail. PR-URL: #17376 Reviewed-By: Anatoli Papirovski <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
1 parent 7f55f98 commit e41344f

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

tools/eslint-rules/prefer-util-format-errors.js

+5
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ module.exports = {
2626
if (!isArrowFunctionWithTemplateLiteral(msg))
2727
return;
2828

29+
// Checks to see if order of arguments to function is the same as the
30+
// order of them being concatenated in the template string. The idea is
31+
// that if both match, then you can use `util.format`-style args.
32+
// Would pass rule: (a, b) => `${b}${a}`.
33+
// Would fail rule: (a, b) => `${a}${b}`, and needs to be rewritten.
2934
const { expressions } = msg.body;
3035
const hasSequentialParams = msg.params.every((param, index) => {
3136
const expr = expressions[index];

0 commit comments

Comments
 (0)