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