mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 21:19:50 +01:00
5c22d19f44
PR-URL: https://github.com/nodejs/node/pull/54987 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
33 lines
744 B
JavaScript
33 lines
744 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
if ((!common.hasCrypto) || (!common.hasIntl)) {
|
|
common.skip('ESLint tests require crypto and Intl');
|
|
}
|
|
|
|
common.skipIfEslintMissing();
|
|
|
|
const { RuleTester } = require('../../tools/eslint/node_modules/eslint');
|
|
const rule = require('../../tools/eslint-rules/no-duplicate-requires');
|
|
|
|
new RuleTester({
|
|
languageOptions: {
|
|
sourceType: 'script',
|
|
},
|
|
}).run('no-duplicate-requires', rule, {
|
|
valid: [
|
|
{
|
|
code: '(function() { require("a"); }); (function() { require("a"); });',
|
|
},
|
|
{
|
|
code: 'require(a); require(a);',
|
|
},
|
|
],
|
|
invalid: [
|
|
{
|
|
code: 'require("a"); require("a");',
|
|
errors: [{ message: '\'a\' require is duplicated.' }],
|
|
},
|
|
],
|
|
});
|