mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
tools: force common be required before any other modules
PR-URL: https://github.com/nodejs/node/pull/27650 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This commit is contained in:
1 parent
618fcbd125
commit
dcc5e51e1c
52 files changed
+194
-66
No files matched your search
@@ -1,8 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
const common = require('../common');
|
||||
const child_process = require('child_process');
|
||||
const assert = require('assert');
|
||||
const common = require('../common');
|
||||
|
||||
if (process.env.NODE_PENDING_DEPRECATION)
|
||||
common.skip('test does not work when NODE_PENDING_DEPRECATION is set');
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// Flags: --no-warnings
|
||||
'use strict';
|
||||
|
||||
const common = require('../common');
|
||||
const vm = require('vm');
|
||||
const assert = require('assert');
|
||||
const common = require('../common');
|
||||
|
||||
if (new Error().stack.includes('node_modules'))
|
||||
common.skip('test does not work when inside `node_modules` directory');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
const assert = require('assert');
|
||||
const common = require('../common');
|
||||
const assert = require('assert');
|
||||
|
||||
const b = Buffer.from('abcdef');
|
||||
const buf_a = Buffer.from('a');
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
// caused the third argument (`options`) to be ignored.
|
||||
// See https://github.com/nodejs/node/issues/24912.
|
||||
|
||||
const assert = require('assert');
|
||||
const { spawn } = require('child_process');
|
||||
|
||||
const common = require('../common');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
|
||||
const assert = require('assert');
|
||||
const { spawn } = require('child_process');
|
||||
|
||||
tmpdir.refresh();
|
||||
|
||||
const command = common.isWindows ? 'cd' : 'pwd';
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
// caused the third argument (`options`) to be ignored.
|
||||
// See https://github.com/nodejs/node/issues/24912.
|
||||
|
||||
const assert = require('assert');
|
||||
const { spawnSync } = require('child_process');
|
||||
|
||||
const common = require('../common');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
|
||||
const assert = require('assert');
|
||||
const { spawnSync } = require('child_process');
|
||||
|
||||
const command = common.isWindows ? 'cd' : 'pwd';
|
||||
const options = { cwd: tmpdir.path };
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const common = require('../common');
|
||||
const assert = require('assert');
|
||||
const dgram = require('dgram');
|
||||
const fork = require('child_process').fork;
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
'use strict';
|
||||
|
||||
const common = require('../common');
|
||||
if (!common.hasCrypto)
|
||||
common.skip('missing crypto');
|
||||
|
||||
common.skipIfEslintMissing();
|
||||
|
||||
const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
|
||||
const rule = require('../../tools/eslint-rules/require-common-first');
|
||||
|
||||
new RuleTester().run('require-common-first', rule, {
|
||||
valid: [
|
||||
{
|
||||
code: 'require("common")\n' +
|
||||
'require("assert")'
|
||||
}
|
||||
],
|
||||
invalid: [
|
||||
{
|
||||
code: 'require("assert")\n' +
|
||||
'require("common")',
|
||||
errors: [{ message: 'Mandatory module "common" must be loaded ' +
|
||||
'before any other modules.' }]
|
||||
}
|
||||
]
|
||||
});
|
||||
@@ -1,4 +1,4 @@
|
||||
/* eslint-disable node-core/required-modules */
|
||||
/* eslint-disable node-core/require-common-first, node-core/required-modules */
|
||||
|
||||
'use strict';
|
||||
|
||||
|
||||
@@ -4,12 +4,13 @@
|
||||
// not get fired again when the 'error' event handler throws
|
||||
// an error.
|
||||
|
||||
const assert = require('assert');
|
||||
const http = require('http');
|
||||
const common = require('../common');
|
||||
const { addresses } = require('../common/internet');
|
||||
const { errorLookupMock } = require('../common/dns');
|
||||
|
||||
const assert = require('assert');
|
||||
const http = require('http');
|
||||
|
||||
const host = addresses.INVALID_HOST;
|
||||
|
||||
const req = http.get({
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
'use strict';
|
||||
const { expectsError, mustCall } = require('../common');
|
||||
const assert = require('assert');
|
||||
const { createServer, maxHeaderSize } = require('http');
|
||||
const { createConnection } = require('net');
|
||||
const { expectsError, mustCall } = require('../common');
|
||||
|
||||
const CRLF = '\r\n';
|
||||
const DUMMY_HEADER_NAME = 'Cookie: ';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Flags: --expose-internals
|
||||
|
||||
'use strict';
|
||||
|
||||
const common = require('../common');
|
||||
const { internalBinding } = require('internal/test/binding');
|
||||
const { getOptionValue } = require('internal/options');
|
||||
|
||||
@@ -21,7 +21,6 @@ const binding =
|
||||
internalBinding('http_parser') : internalBinding('http_parser_llhttp');
|
||||
binding.HTTPParser = DummyParser;
|
||||
|
||||
const common = require('../common');
|
||||
const assert = require('assert');
|
||||
const { spawn } = require('child_process');
|
||||
const { parsers } = require('_http_common');
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const common = require('../common');
|
||||
if (!common.hasCrypto)
|
||||
common.skip('missing crypto');
|
||||
|
||||
const assert = require('assert');
|
||||
const http2 = require('http2');
|
||||
|
||||
for (const chunkSequence of [
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Flags: --expose-internals
|
||||
'use strict';
|
||||
const { internalBinding } = require('internal/test/binding');
|
||||
const common = require('../common');
|
||||
const { internalBinding } = require('internal/test/binding');
|
||||
const os = require('os');
|
||||
|
||||
const { hasSmallICU } = internalBinding('config');
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable node-core/require-common-first */
|
||||
'use strict';
|
||||
// Flags: --expose_internals
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
require('../common');
|
||||
const assert = require('assert');
|
||||
|
||||
// Assert legit flags are allowed, and bogus flags are disallowed
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Flags: --expose-internals
|
||||
'use strict';
|
||||
const { internalBinding } = require('internal/test/binding');
|
||||
require('../common');
|
||||
const { internalBinding } = require('internal/test/binding');
|
||||
const { PassThrough } = require('stream');
|
||||
const readline = require('readline');
|
||||
const assert = require('assert');
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
/* eslint-disable node-core/required-modules */
|
||||
/* eslint-disable node-core/require-common-first, node-core/required-modules */
|
||||
'use strict';
|
||||
|
||||
Object.prototype.xadsadsdasasdxx = function() {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const { Readable } = require('stream');
|
||||
const common = require('../common');
|
||||
const { Readable } = require('stream');
|
||||
|
||||
let ticks = 18;
|
||||
let expectedData = 19;
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
const { internalBinding } = require('internal/test/binding');
|
||||
const common = require('../common');
|
||||
const fixtures = require('../common/fixtures');
|
||||
const { internalBinding } = require('internal/test/binding');
|
||||
const assert = require('assert');
|
||||
const v8 = require('v8');
|
||||
const os = require('os');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
const assert = require('assert');
|
||||
const common = require('../common');
|
||||
const assert = require('assert');
|
||||
const { isMainThread, parentPort, Worker } = require('worker_threads');
|
||||
|
||||
// This test makes sure that we manipulate the references of
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
const assert = require('assert');
|
||||
const common = require('../common');
|
||||
const assert = require('assert');
|
||||
const { Worker, isMainThread, parentPort } = require('worker_threads');
|
||||
|
||||
// Do not use isMainThread directly, otherwise the test would time out in case
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
const common = require('../common');
|
||||
const path = require('path');
|
||||
const assert = require('assert');
|
||||
const common = require('../common');
|
||||
const { Worker, isMainThread, parentPort } = require('worker_threads');
|
||||
|
||||
if (isMainThread) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
const common = require('../common');
|
||||
const path = require('path');
|
||||
const assert = require('assert');
|
||||
const common = require('../common');
|
||||
const { Worker, isMainThread, parentPort } = require('worker_threads');
|
||||
|
||||
if (isMainThread) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const path = require('path');
|
||||
const common = require('../common');
|
||||
const path = require('path');
|
||||
const assert = require('assert');
|
||||
const { Worker } = require('worker_threads');
|
||||
|
||||
|
||||
Reference in new issue
Block a user