0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-21 21:19:50 +01:00
nodejs/test/parallel/test-eslint-duplicate-requires.js
Aviv Keller 5c22d19f44
lib, tools: remove duplicate requires
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>
2024-09-25 08:51:28 +00:00

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.' }],
},
],
});