mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
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 <apapirovski@mac.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
This commit is contained in:
1 parent
7f55f98a84
commit
e41344f1b8
1 file changed
+5
@@ -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];
|
||||
|
||||
Reference in new issue
Block a user