summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAnatoli Papirovski <apapirovski@mac.com>2017-11-09 10:18:12 -0500
committerAnna Henningsen <anna@addaleax.net>2017-11-18 20:27:40 +0100
commit4b82d892abfcac160a0486d432e23e27315a5765 (patch)
treea94ded22c5ea2657dd1592ce9bc6b0031e2a74e6 /test
parent2c0acc0bc191fbe37b91fe39d213fcc56ce23741 (diff)
downloadandroid-node-v8-4b82d892abfcac160a0486d432e23e27315a5765.tar.gz
android-node-v8-4b82d892abfcac160a0486d432e23e27315a5765.tar.bz2
android-node-v8-4b82d892abfcac160a0486d432e23e27315a5765.zip
errors: consistent format for error message
Consistently use printf-style strings for error messages that do not need a custom argument order or processing of arguments. PR-URL: https://github.com/nodejs/node/pull/16904 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-eslint-prefer-util-format-errors.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/parallel/test-eslint-prefer-util-format-errors.js b/test/parallel/test-eslint-prefer-util-format-errors.js
new file mode 100644
index 0000000000..265a0752c5
--- /dev/null
+++ b/test/parallel/test-eslint-prefer-util-format-errors.js
@@ -0,0 +1,27 @@
+'use strict';
+
+/* eslint-disable no-template-curly-in-string */
+
+require('../common');
+
+const RuleTester = require('../../tools/eslint').RuleTester;
+const rule = require('../../tools/eslint-rules/prefer-util-format-errors');
+
+new RuleTester({ parserOptions: { ecmaVersion: 6 } })
+ .run('prefer-util-format-errors', rule, {
+ valid: [
+ 'E(\'ABC\', \'abc\');',
+ 'E(\'ABC\', (arg1, arg2) => `${arg2}${arg1}`);',
+ 'E(\'ABC\', (arg1, arg2) => `${arg1}{arg2.something}`);',
+ 'E(\'ABC\', (arg1, arg2) => fn(arg1, arg2));'
+ ],
+ invalid: [
+ {
+ code: 'E(\'ABC\', (arg1, arg2) => `${arg1}${arg2}`);',
+ errors: [{
+ message: 'Please use a printf-like formatted string that ' +
+ 'util.format can consume.'
+ }]
+ }
+ ]
+ });