| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -122,6 +122,14 @@ module.exports = { | |||
| 122 | 122 | 'curly': 'error', | |
| 123 | 123 | }, | |
| 124 | 124 | }, | |
| 125 | + { | ||
| 126 | + files: [ | ||
| 127 | + 'lib/internal/test_runner/**/*.js', | ||
| 128 | + ], | ||
| 129 | + rules: { | ||
| 130 | + 'node-core/set-proto-to-null-in-object': 'error', | ||
| 131 | + }, | ||
| 132 | + }, | ||
| 125 | 133 | ], | |
| 126 | 134 | rules: { | |
| 127 | 135 | // ESLint built-in rules | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -250,7 +250,7 @@ class TestCoverage { | |||
| 250 | 250 | let dir; | |
| 251 | 251 | ||
| 252 | 252 | try { | |
| 253 | - mkdirSync(this.originalCoverageDirectory, { recursive: true }); | ||
| 253 | + mkdirSync(this.originalCoverageDirectory, { __proto__: null, recursive: true }); | ||
| 254 | 254 | dir = opendirSync(this.coverageDirectory); | |
| 255 | 255 | ||
| 256 | 256 | for (let entry; (entry = dir.readSync()) !== null;) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -114,6 +114,7 @@ function setup(root) { | |||
| 114 | 114 | const globalOptions = parseCommandLine(); | |
| 115 | 115 | ||
| 116 | 116 | const hook = createHook({ | |
| 117 | + __proto__: null, | ||
| 117 | 118 | init(asyncId, type, triggerAsyncId, resource) { | |
| 118 | 119 | if (resource instanceof Test) { | |
| 119 | 120 | testResources.set(asyncId, resource); | |
@@ -214,7 +215,7 @@ function runInParentContext(Factory) { | |||
| 214 | 215 | ||
| 215 | 216 | const test = (name, options, fn) => run(name, options, fn); | |
| 216 | 217 | ArrayPrototypeForEach(['skip', 'todo', 'only'], (keyword) => { | |
| 217 | - test[keyword] = (name, options, fn) => run(name, options, fn, { [keyword]: true }); | ||
| 218 | + test[keyword] = (name, options, fn) => run(name, options, fn, { __proto__: null, [keyword]: true }); | ||
| 218 | 219 | }); | |
| 219 | 220 | return test; | |
| 220 | 221 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -133,7 +133,7 @@ class MockTracker { | |||
| 133 | 133 | validateObject(options, 'options'); | |
| 134 | 134 | const { times = Infinity } = options; | |
| 135 | 135 | validateTimes(times, 'options.times'); | |
| 136 | - const ctx = new MockFunctionContext(implementation, { original }, times); | ||
| 136 | + const ctx = new MockFunctionContext(implementation, { __proto__: null, original }, times); | ||
| 137 | 137 | return this.#setupMock(ctx, original); | |
| 138 | 138 | } | |
| 139 | 139 | ||
@@ -189,7 +189,7 @@ class MockTracker { | |||
| 189 | 189 | ); | |
| 190 | 190 | } | |
| 191 | 191 | ||
| 192 | - const restore = { descriptor, object: objectOrFunction, methodName }; | ||
| 192 | + const restore = { __proto__: null, descriptor, object: objectOrFunction, methodName }; | ||
| 193 | 193 | const impl = implementation === kDefaultFunction ? | |
| 194 | 194 | original : implementation; | |
| 195 | 195 | const ctx = new MockFunctionContext(impl, restore, times); | |
@@ -238,6 +238,7 @@ class MockTracker { | |||
| 238 | 238 | } | |
| 239 | 239 | ||
| 240 | 240 | return this.method(object, methodName, implementation, { | |
| 241 | + __proto__: null, | ||
| 241 | 242 | ...options, | |
| 242 | 243 | getter, | |
| 243 | 244 | }); | |
@@ -265,6 +266,7 @@ class MockTracker { | |||
| 265 | 266 | } | |
| 266 | 267 | ||
| 267 | 268 | return this.method(object, methodName, implementation, { | |
| 269 | + __proto__: null, | ||
| 268 | 270 | ...options, | |
| 269 | 271 | setter, | |
| 270 | 272 | }); | |
@@ -297,6 +299,7 @@ class MockTracker { | |||
| 297 | 299 | throw err; | |
| 298 | 300 | } finally { | |
| 299 | 301 | FunctionPrototypeCall(trackCall, ctx, { | |
| 302 | + __proto__: null, | ||
| 300 | 303 | arguments: argList, | |
| 301 | 304 | error, | |
| 302 | 305 | result, | |
@@ -321,6 +324,7 @@ class MockTracker { | |||
| 321 | 324 | throw err; | |
| 322 | 325 | } finally { | |
| 323 | 326 | FunctionPrototypeCall(trackCall, ctx, { | |
| 327 | + __proto__: null, | ||
| 324 | 328 | arguments: argList, | |
| 325 | 329 | error, | |
| 326 | 330 | result, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -44,7 +44,7 @@ function setPosition(node, pos) { | |||
| 44 | 44 | } | |
| 45 | 45 | ||
| 46 | 46 | function abortIt(signal) { | |
| 47 | - return new AbortError(undefined, { cause: signal.reason }); | ||
| 47 | + return new AbortError(undefined, { __proto__: null, cause: signal.reason }); | ||
| 48 | 48 | } | |
| 49 | 49 | ||
| 50 | 50 | const SUPPORTED_TIMERS = ['setTimeout', 'setInterval']; | |
@@ -193,7 +193,9 @@ class MockTimers { | |||
| 193 | 193 | ||
| 194 | 194 | #toggleEnableTimers(activate) { | |
| 195 | 195 | const options = { | |
| 196 | + __proto__: null, | ||
| 196 | 197 | toFake: { | |
| 198 | + __proto__: null, | ||
| 197 | 199 | setTimeout: () => { | |
| 198 | 200 | this.#realSetTimeout = globalThis.setTimeout; | |
| 199 | 201 | this.#realClearTimeout = globalThis.clearTimeout; | |
@@ -232,6 +234,7 @@ class MockTimers { | |||
| 232 | 234 | }, | |
| 233 | 235 | }, | |
| 234 | 236 | toReal: { | |
| 237 | + __proto__: null, | ||
| 235 | 238 | setTimeout: () => { | |
| 236 | 239 | globalThis.setTimeout = this.#realSetTimeout; | |
| 237 | 240 | globalThis.clearTimeout = this.#realClearTimeout; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -42,7 +42,7 @@ class SpecReporter extends Transform { | |||
| 42 | 42 | #failedTests = []; | |
| 43 | 43 | ||
| 44 | 44 | constructor() { | |
| 45 | - super({ writableObjectMode: true }); | ||
| 45 | + super({ __proto__: null, writableObjectMode: true }); | ||
| 46 | 46 | } | |
| 47 | 47 | ||
| 48 | 48 | #indent(nesting) { | |
@@ -127,7 +127,7 @@ class SpecReporter extends Transform { | |||
| 127 | 127 | } | |
| 128 | 128 | } | |
| 129 | 129 | _transform({ type, data }, encoding, callback) { | |
| 130 | - callback(null, this.#handleEvent({ type, data })); | ||
| 130 | + callback(null, this.#handleEvent({ __proto__: null, type, data })); | ||
| 131 | 131 | } | |
| 132 | 132 | _flush(callback) { | |
| 133 | 133 | if (this.#failedTests.length === 0) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,7 +18,7 @@ const kDefaultIndent = ' '; // 4 spaces | |||
| 18 | 18 | const kFrameStartRegExp = /^ {4}at /; | |
| 19 | 19 | const kLineBreakRegExp = /\n|\r\n/; | |
| 20 | 20 | const kDefaultTAPVersion = 13; | |
| 21 | - const inspectOptions = { colors: false, breakLength: Infinity }; | ||
| 21 | + const inspectOptions = { __proto__: null, colors: false, breakLength: Infinity }; | ||
| 22 | 22 | let testModule; // Lazy loaded due to circular dependency. | |
| 23 | 23 | ||
| 24 | 24 | function lazyLoadTest() { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -134,7 +134,10 @@ function createTestFileList() { | |||
| 134 | 134 | for (let i = 0; i < testPaths.length; i++) { | |
| 135 | 135 | const absolutePath = resolve(testPaths[i]); | |
| 136 | 136 | ||
| 137 | - processPath(absolutePath, testFiles, { userSupplied: true }); | ||
| 137 | + processPath(absolutePath, testFiles, { | ||
| 138 | + __proto__: null, | ||
| 139 | + userSupplied: true, | ||
| 140 | + }); | ||
| 138 | 141 | } | |
| 139 | 142 | } catch (err) { | |
| 140 | 143 | if (err?.code === 'ENOENT') { | |
@@ -347,9 +350,9 @@ class FileTest extends Test { | |||
| 347 | 350 | function runTestFile(path, root, inspectPort, filesWatcher, testNamePatterns) { | |
| 348 | 351 | const watchMode = filesWatcher != null; | |
| 349 | 352 | const subtest = root.createSubtest(FileTest, path, async (t) => { | |
| 350 | - const args = getRunArgs({ path, inspectPort, testNamePatterns }); | ||
| 353 | + const args = getRunArgs({ __proto__: null, path, inspectPort, testNamePatterns }); | ||
| 351 | 354 | const stdio = ['pipe', 'pipe', 'pipe']; | |
| 352 | - const env = { ...process.env, NODE_TEST_CONTEXT: 'child-v8' }; | ||
| 355 | + const env = { __proto__: null, ...process.env, NODE_TEST_CONTEXT: 'child-v8' }; | ||
| 353 | 356 | if (watchMode) { | |
| 354 | 357 | stdio.push('ipc'); | |
| 355 | 358 | env.WATCH_REPORT_DEPENDENCIES = '1'; | |
@@ -358,7 +361,7 @@ function runTestFile(path, root, inspectPort, filesWatcher, testNamePatterns) { | |||
| 358 | 361 | env.FORCE_COLOR = '1'; | |
| 359 | 362 | } | |
| 360 | 363 | ||
| 361 | - const child = spawn(process.execPath, args, { signal: t.signal, encoding: 'utf8', env, stdio }); | ||
| 364 | + const child = spawn(process.execPath, args, { __proto__: null, signal: t.signal, encoding: 'utf8', env, stdio }); | ||
| 362 | 365 | if (watchMode) { | |
| 363 | 366 | filesWatcher.runningProcesses.set(path, child); | |
| 364 | 367 | filesWatcher.watcher.watchChildProcessModules(child, path); | |
@@ -375,7 +378,7 @@ function runTestFile(path, root, inspectPort, filesWatcher, testNamePatterns) { | |||
| 375 | 378 | subtest.parseMessage(data); | |
| 376 | 379 | }); | |
| 377 | 380 | ||
| 378 | - const rl = createInterface({ input: child.stderr }); | ||
| 381 | + const rl = createInterface({ __proto__: null, input: child.stderr }); | ||
| 379 | 382 | rl.on('line', (line) => { | |
| 380 | 383 | if (isInspectorMessage(line)) { | |
| 381 | 384 | process.stderr.write(line + '\n'); | |
@@ -393,8 +396,8 @@ function runTestFile(path, root, inspectPort, filesWatcher, testNamePatterns) { | |||
| 393 | 396 | }); | |
| 394 | 397 | ||
| 395 | 398 | const { 0: { 0: code, 1: signal } } = await SafePromiseAll([ | |
| 396 | - once(child, 'exit', { signal: t.signal }), | ||
| 397 | - finished(child.stdout, { signal: t.signal }), | ||
| 399 | + once(child, 'exit', { __proto__: null, signal: t.signal }), | ||
| 400 | + finished(child.stdout, { __proto__: null, signal: t.signal }), | ||
| 398 | 401 | ]); | |
| 399 | 402 | ||
| 400 | 403 | if (watchMode) { | |
@@ -427,7 +430,7 @@ function runTestFile(path, root, inspectPort, filesWatcher, testNamePatterns) { | |||
| 427 | 430 | function watchFiles(testFiles, root, inspectPort, signal, testNamePatterns) { | |
| 428 | 431 | const runningProcesses = new SafeMap(); | |
| 429 | 432 | const runningSubtests = new SafeMap(); | |
| 430 | - const watcher = new FilesWatcher({ debounce: 200, mode: 'filter', signal }); | ||
| 433 | + const watcher = new FilesWatcher({ __proto__: null, debounce: 200, mode: 'filter', signal }); | ||
| 431 | 434 | const filesWatcher = { __proto__: null, watcher, runningProcesses, runningSubtests }; | |
| 432 | 435 | ||
| 433 | 436 | watcher.on('changed', ({ owners }) => { | |
@@ -512,7 +515,7 @@ function run(options) { | |||
| 512 | 515 | }); | |
| 513 | 516 | } | |
| 514 | 517 | ||
| 515 | - const root = createTestTree({ concurrency, timeout, signal }); | ||
| 518 | + const root = createTestTree({ __proto__: null, concurrency, timeout, signal }); | ||
| 516 | 519 | let testFiles = files ?? createTestFileList(); | |
| 517 | 520 | ||
| 518 | 521 | if (shard) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -79,7 +79,7 @@ function stopTest(timeout, signal) { | |||
| 79 | 79 | if (timeout === kDefaultTimeout) { | |
| 80 | 80 | return once(signal, 'abort'); | |
| 81 | 81 | } | |
| 82 | - return PromisePrototypeThen(setTimeout(timeout, null, { ref: false, signal }), () => { | ||
| 82 | + return PromisePrototypeThen(setTimeout(timeout, null, { __proto__: null, ref: false, signal }), () => { | ||
| 83 | 83 | throw new ERR_TEST_FAILURE( | |
| 84 | 84 | `test timed out after ${timeout}ms`, | |
| 85 | 85 | kTestTimeoutFailure, | |
@@ -506,7 +506,7 @@ class Test extends AsyncResource { | |||
| 506 | 506 | ||
| 507 | 507 | getRunArgs() { | |
| 508 | 508 | const ctx = new TestContext(this); | |
| 509 | - return { ctx, args: [ctx] }; | ||
| 509 | + return { __proto__: null, ctx, args: [ctx] }; | ||
| 510 | 510 | } | |
| 511 | 511 | ||
| 512 | 512 | async runHook(hook, args) { | |
@@ -540,12 +540,12 @@ class Test extends AsyncResource { | |||
| 540 | 540 | const { args, ctx } = this.getRunArgs(); | |
| 541 | 541 | const after = async () => { | |
| 542 | 542 | if (this.hooks.after.length > 0) { | |
| 543 | - await this.runHook('after', { args, ctx }); | ||
| 543 | + await this.runHook('after', { __proto__: null, args, ctx }); | ||
| 544 | 544 | } | |
| 545 | 545 | }; | |
| 546 | 546 | const afterEach = runOnce(async () => { | |
| 547 | 547 | if (this.parent?.hooks.afterEach.length > 0) { | |
| 548 | - await this.parent.runHook('afterEach', { args, ctx }); | ||
| 548 | + await this.parent.runHook('afterEach', { __proto__: null, args, ctx }); | ||
| 549 | 549 | } | |
| 550 | 550 | }); | |
| 551 | 551 | ||
@@ -554,7 +554,7 @@ class Test extends AsyncResource { | |||
| 554 | 554 | await this.parent.runHook('before', this.parent.getRunArgs()); | |
| 555 | 555 | } | |
| 556 | 556 | if (this.parent?.hooks.beforeEach.length > 0) { | |
| 557 | - await this.parent.runHook('beforeEach', { args, ctx }); | ||
| 557 | + await this.parent.runHook('beforeEach', { __proto__: null, args, ctx }); | ||
| 558 | 558 | } | |
| 559 | 559 | const stopPromise = stopTest(this.timeout, this.signal); | |
| 560 | 560 | const runArgs = ArrayPrototypeSlice(args); | |
@@ -811,7 +811,7 @@ class Suite extends Test { | |||
| 811 | 811 | ||
| 812 | 812 | getRunArgs() { | |
| 813 | 813 | const ctx = new SuiteContext(this); | |
| 814 | - return { ctx, args: [ctx] }; | ||
| 814 | + return { __proto__: null, ctx, args: [ctx] }; | ||
| 815 | 815 | } | |
| 816 | 816 | ||
| 817 | 817 | async run() { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,7 +12,7 @@ class TestsStream extends Readable { | |||
| 12 | 12 | #canPush; | |
| 13 | 13 | ||
| 14 | 14 | constructor() { | |
| 15 | - super({ objectMode: true }); | ||
| 15 | + super({ __proto__: null, objectMode: true }); | ||
| 16 | 16 | this.#buffer = []; | |
| 17 | 17 | this.#canPush = true; | |
| 18 | 18 | } | |
@@ -83,6 +83,8 @@ class TestsStream extends Readable { | |||
| 83 | 83 | ||
| 84 | 84 | [kEmitMessage](type, data) { | |
| 85 | 85 | this.emit(type, data); | |
| 86 | + // Disabling as this going to the user-land | ||
| 87 | + // eslint-disable-next-line node-core/set-proto-to-null-in-object | ||
| 86 | 88 | this.#tryPush({ type, data }); | |
| 87 | 89 | } | |
| 88 | 90 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments