• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3/* eslint-disable no-template-curly-in-string */
4
5const common = require('../common');
6if (!common.hasCrypto)
7  common.skip('missing crypto');
8
9common.skipIfEslintMissing();
10
11const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
12const rule = require('../../tools/eslint-rules/prefer-util-format-errors');
13
14new RuleTester({ parserOptions: { ecmaVersion: 6 } })
15  .run('prefer-util-format-errors', rule, {
16    valid: [
17      'E(\'ABC\', \'abc\');',
18      'E(\'ABC\', (arg1, arg2) => `${arg2}${arg1}`);',
19      'E(\'ABC\', (arg1, arg2) => `${arg1}{arg2.something}`);',
20      'E(\'ABC\', (arg1, arg2) => fn(arg1, arg2));',
21    ],
22    invalid: [
23      {
24        code: 'E(\'ABC\', (arg1, arg2) => `${arg1}${arg2}`);',
25        errors: [{
26          message: 'Please use a printf-like formatted string that ' +
27                   'util.format can consume.'
28        }]
29      },
30    ]
31  });
32