diff options
author | Kenta Moriuchi <moriken@kimamass.com> | 2024-09-06 19:52:59 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-06 12:52:59 +0200 |
commit | f0a3d206422af3177e0f36ed22802c1ccc6f7654 (patch) | |
tree | 57ad718cc47b7b98c0bbd869d6c070adee3bf30a /ext/node | |
parent | 8ef08f1d294dbe7e3771202084ecbede73ca28aa (diff) |
fix(runtime): use more null proto objects again (#25040)
proceed with #23921
This PR is a preparation for
https://github.com/denoland/deno_lint/pull/1307
---------
Signed-off-by: Kenta Moriuchi <moriken@kimamass.com>
Co-authored-by: Luca Casonato <hello@lcas.dev>
Diffstat (limited to 'ext/node')
-rw-r--r-- | ext/node/benchmarks/child_process_ipc.mjs | 1 | ||||
-rw-r--r-- | ext/node/polyfills/_brotli.js | 4 | ||||
-rw-r--r-- | ext/node/polyfills/_process/streams.mjs | 6 | ||||
-rw-r--r-- | ext/node/polyfills/_util/async.ts | 2 | ||||
-rw-r--r-- | ext/node/polyfills/_util/std_testing_diff.ts | 9 | ||||
-rw-r--r-- | ext/node/polyfills/string_decoder.ts | 2 | ||||
-rw-r--r-- | ext/node/polyfills/timers.ts | 1 | ||||
-rw-r--r-- | ext/node/polyfills/util.ts | 1 | ||||
-rw-r--r-- | ext/node/polyfills/vm.js | 11 | ||||
-rw-r--r-- | ext/node/polyfills/worker_threads.ts | 2 |
10 files changed, 28 insertions, 11 deletions
diff --git a/ext/node/benchmarks/child_process_ipc.mjs b/ext/node/benchmarks/child_process_ipc.mjs index 7a5c992bd..fa671d76f 100644 --- a/ext/node/benchmarks/child_process_ipc.mjs +++ b/ext/node/benchmarks/child_process_ipc.mjs @@ -29,6 +29,7 @@ if (process.env.CHILD) { const start = performance.now(); const options = { + __proto__: null, "stdio": ["inherit", "inherit", "inherit", "ipc"], "env": { "CHILD": len.toString() }, }; diff --git a/ext/node/polyfills/_brotli.js b/ext/node/polyfills/_brotli.js index 0dcb58e04..ebd035156 100644 --- a/ext/node/polyfills/_brotli.js +++ b/ext/node/polyfills/_brotli.js @@ -60,7 +60,7 @@ export class BrotliDecompress extends Transform { #context; // TODO(littledivy): use `options` argument - constructor(_options = {}) { + constructor(_options = { __proto__: null }) { super({ // TODO(littledivy): use `encoding` argument transform(chunk, _encoding, callback) { @@ -91,7 +91,7 @@ export class BrotliDecompress extends Transform { export class BrotliCompress extends Transform { #context; - constructor(options = {}) { + constructor(options = { __proto__: null }) { super({ // TODO(littledivy): use `encoding` argument transform(chunk, _encoding, callback) { diff --git a/ext/node/polyfills/_process/streams.mjs b/ext/node/polyfills/_process/streams.mjs index fa24bd155..19c1c9c18 100644 --- a/ext/node/polyfills/_process/streams.mjs +++ b/ext/node/polyfills/_process/streams.mjs @@ -65,22 +65,26 @@ export function createWritableStdioStream(writer, name, warmup = false) { stream.once("close", () => writer?.close()); ObjectDefineProperties(stream, { columns: { + __proto__: null, enumerable: true, configurable: true, get: () => writer?.isTerminal() ? Deno.consoleSize?.().columns : undefined, }, rows: { + __proto__: null, enumerable: true, configurable: true, get: () => writer?.isTerminal() ? Deno.consoleSize?.().rows : undefined, }, isTTY: { + __proto__: null, enumerable: true, configurable: true, get: () => writer?.isTerminal(), }, getWindowSize: { + __proto__: null, enumerable: true, configurable: true, value: () => @@ -203,6 +207,7 @@ export const initStdin = (warmup = false) => { stdin.on("close", () => io.stdin?.close()); stdin.fd = io.stdin ? io.STDIN_RID : -1; ObjectDefineProperty(stdin, "isTTY", { + __proto__: null, enumerable: true, configurable: true, get() { @@ -216,6 +221,7 @@ export const initStdin = (warmup = false) => { return stdin; }; ObjectDefineProperty(stdin, "isRaw", { + __proto__: null, enumerable: true, configurable: true, get() { diff --git a/ext/node/polyfills/_util/async.ts b/ext/node/polyfills/_util/async.ts index cc116412c..0cacccacc 100644 --- a/ext/node/polyfills/_util/async.ts +++ b/ext/node/polyfills/_util/async.ts @@ -13,7 +13,7 @@ import { clearTimeout, setTimeout } from "ext:deno_web/02_timers.js"; /** Resolve a Promise after a given amount of milliseconds. */ export function delay( ms: number, - options: { signal?: AbortSignal } = {}, + options: { signal?: AbortSignal } = { __proto__: null }, ): Promise<void> { const { signal } = options; if (signal?.aborted) { diff --git a/ext/node/polyfills/_util/std_testing_diff.ts b/ext/node/polyfills/_util/std_testing_diff.ts index 74e396b0c..5155fd242 100644 --- a/ext/node/polyfills/_util/std_testing_diff.ts +++ b/ext/node/polyfills/_util/std_testing_diff.ts @@ -325,7 +325,10 @@ export function diffstr(A: string, B: string) { ); } - function tokenize(string: string, { wordDiff = false } = {}): string[] { + function tokenize( + string: string, + { wordDiff = false } = { __proto__: null }, + ): string[] { if (wordDiff) { // Split string on whitespace symbols const tokens = StringPrototypeSplit(string, WHITESPACE_SYMBOL_PATTERN); @@ -450,7 +453,7 @@ export function diffstr(A: string, B: string) { */ function createColor( diffType: DiffType, - { background = false } = {}, + { background = false } = { __proto__: null }, ): (s: string) => string { // TODO(@littledivy): Remove this when we can detect // true color terminals. @@ -484,7 +487,7 @@ function createSign(diffType: DiffType): string { export function buildMessage( diffResult: ReadonlyArray<DiffResult<string>>, - { stringDiff = false } = {}, + { stringDiff = false } = { __proto__: null }, ): string[] { const messages: string[] = [], diffMessages: string[] = []; ArrayPrototypePush(messages, ""); diff --git a/ext/node/polyfills/string_decoder.ts b/ext/node/polyfills/string_decoder.ts index 4a49c2e3e..b4a422e4b 100644 --- a/ext/node/polyfills/string_decoder.ts +++ b/ext/node/polyfills/string_decoder.ts @@ -403,6 +403,7 @@ StringDecoder.prototype.text = function text( ObjectDefineProperties(StringDecoder.prototype, { lastNeed: { + __proto__: null, configurable: true, enumerable: true, get(this: StringDecoder): number { @@ -410,6 +411,7 @@ ObjectDefineProperties(StringDecoder.prototype, { }, }, lastTotal: { + __proto__: null, configurable: true, enumerable: true, get(this: StringDecoder): number { diff --git a/ext/node/polyfills/timers.ts b/ext/node/polyfills/timers.ts index b96f448da..613b87427 100644 --- a/ext/node/polyfills/timers.ts +++ b/ext/node/polyfills/timers.ts @@ -33,6 +33,7 @@ export function setTimeout( } ObjectDefineProperty(setTimeout, promisify.custom, { + __proto__: null, value: (timeout: number, ...args: unknown[]) => { return new Promise((cb) => setTimeout(cb, timeout, ...new SafeArrayIterator(args)) diff --git a/ext/node/polyfills/util.ts b/ext/node/polyfills/util.ts index c94d0f14b..586fae17e 100644 --- a/ext/node/polyfills/util.ts +++ b/ext/node/polyfills/util.ts @@ -177,6 +177,7 @@ export function inherits<T, U>( ); } ObjectDefineProperty(ctor, "super_", { + __proto__: null, value: superCtor, writable: true, configurable: true, diff --git a/ext/node/polyfills/vm.js b/ext/node/polyfills/vm.js index bc1a25045..eb9a0375d 100644 --- a/ext/node/polyfills/vm.js +++ b/ext/node/polyfills/vm.js @@ -34,7 +34,7 @@ const kParsingContext = Symbol("script parsing context"); export class Script { #inner; - constructor(code, options = {}) { + constructor(code, options = { __proto__: null }) { code = `${code}`; if (typeof options === "string") { options = { filename: options }; @@ -80,7 +80,7 @@ export class Script { : undefined; } - #runInContext(contextifiedObject, options = {}) { + #runInContext(contextifiedObject, options = { __proto__: null }) { validateObject(options, "options"); let timeout = options.timeout; @@ -181,7 +181,10 @@ function getContextOptions(options) { } let defaultContextNameIndex = 1; -export function createContext(contextObject = {}, options = {}) { +export function createContext( + contextObject = {}, + options = { __proto__: null }, +) { if (isContext(contextObject)) { return contextObject; } @@ -276,7 +279,7 @@ export function isContext(object) { return op_vm_is_context(object); } -export function compileFunction(code, params, options = {}) { +export function compileFunction(code, params, options = { __proto__: null }) { validateString(code, "code"); if (params !== undefined) { validateStringArray(params, "params"); diff --git a/ext/node/polyfills/worker_threads.ts b/ext/node/polyfills/worker_threads.ts index 24bcbe057..5ff4446f7 100644 --- a/ext/node/polyfills/worker_threads.ts +++ b/ext/node/polyfills/worker_threads.ts @@ -267,7 +267,7 @@ class NodeWorker extends EventEmitter { } }; - postMessage(message, transferOrOptions = {}) { + postMessage(message, transferOrOptions = { __proto__: null }) { const prefix = "Failed to execute 'postMessage' on 'MessagePort'"; webidl.requiredArguments(arguments.length, 1, prefix); message = webidl.converters.any(message); |