From e41344f1b801bda6fccd0a08ad2558685abc656c Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Tue, 28 Nov 2017 16:56:45 -0500 Subject: [PATCH] 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: https://github.com/nodejs/node/pull/17376 Reviewed-By: Anatoli Papirovski Reviewed-By: Rich Trott Reviewed-By: Colin Ihrig Reviewed-By: Gibson Fahnestock Reviewed-By: Michael Dawson --- tools/eslint-rules/prefer-util-format-errors.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/eslint-rules/prefer-util-format-errors.js b/tools/eslint-rules/prefer-util-format-errors.js index c3f4819e43b51c..f6993e627782dd 100644 --- a/tools/eslint-rules/prefer-util-format-errors.js +++ b/tools/eslint-rules/prefer-util-format-errors.js @@ -26,6 +26,11 @@ module.exports = { if (!isArrowFunctionWithTemplateLiteral(msg)) return; + // Checks to see if order of arguments to function is the same as the + // order of them being concatenated in the template string. The idea is + // that if both match, then you can use `util.format`-style args. + // Would pass rule: (a, b) => `${b}${a}`. + // Would fail rule: (a, b) => `${a}${b}`, and needs to be rewritten. const { expressions } = msg.body; const hasSequentialParams = msg.params.every((param, index) => { const expr = expressions[index];