2017-11-09 16:18:12 +01:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
/* eslint-disable no-template-curly-in-string */
|
|
|
|
|
2018-02-16 00:47:10 +01:00
|
|
|
const common = require('../common');
|
|
|
|
|
|
|
|
common.skipIfEslintMissing();
|
2017-11-09 16:18:12 +01:00
|
|
|
|
2017-12-22 16:53:42 +01:00
|
|
|
const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
|
2017-11-09 16:18:12 +01:00
|
|
|
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.'
|
|
|
|
}]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
});
|