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:
parent
701dc9a86e
commit
85e34b0c73
@ -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];
|
||||
|
Loading…
x
Reference in New Issue
Block a user