Skip to content

Commit

Permalink
tools: add docs for prefer-util-format-errors rule
Browse files Browse the repository at this point in the history
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 <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>
  • Loading branch information
maclover7 authored and MylesBorins committed Dec 12, 2017
1 parent 7f55f98 commit e41344f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tools/eslint-rules/prefer-util-format-errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit e41344f

Please sign in to comment.