0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-29 07:00:59 +01:00
nodejs/test/parallel/test-eslint-prefer-util-format-errors.js
Myles Borins 1fd69872e6 test: add common.skipIfEslintMissing
We've added a number of tests that hook into ESLint which can error
when running the test suite with the distributed tarball. This PR
adds a new test helper `common.skipIfEslintMissing` and will skip
remaining tests in a file when `ESLint` is not available at
`tools/node_modules/eslint`

PR-URL: https://github.com/nodejs/node/pull/18807
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2018-02-16 15:54:56 -08:00

30 lines
857 B
JavaScript

'use strict';
/* eslint-disable no-template-curly-in-string */
const common = require('../common');
common.skipIfEslintMissing();
const RuleTester = require('../../tools/node_modules/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.'
}]
}
]
});