/
githubmirror
/
deno
Обзор
Документация
Войти
/
githubmirror
/
deno
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
ext/node/polyfills/internal/process/warning.ts
60 строк
2 KB
Kenta Moriuchi
chore: make prefer-primordials lint an internal plugin (#35978)
23 июл 2026, 11:53
Не верифицирован
23 июл 2026, 11:53
5b55d08
Код
Авторство
О чём код?
// Copyright 2018-2026 the Deno authors. MIT license. // deno-lint-ignore-file no-process-global (function () { const { core, primordials } = __bootstrap; const { getOptionValue } = core.loadExtScript( "ext:deno_node/internal/options.ts", ); const { ErrorPrototype, ErrorPrototypeToString, ObjectPrototypeIsPrototypeOf, SafeSet, } = primordials; let disableWarningSet; function onWarning( warning: Error & { code?: string; name?: string; detail?: string }, ) { if (!disableWarningSet) { disableWarningSet = new SafeSet(); const disableWarningValues = getOptionValue("--disable-warning"); for (let i = 0; i < disableWarningValues?.length; i++) { disableWarningSet.add(disableWarningValues[i]); } } if ( (warning?.code && disableWarningSet.has(warning.code)) || (warning?.name && disableWarningSet.has(warning.name)) ) return; if (!ObjectPrototypeIsPrototypeOf(ErrorPrototype, warning)) return; const isDeprecation = warning.name === "DeprecationWarning"; if (isDeprecation && process.noDeprecation) return; const trace = process.traceProcessWarnings || (isDeprecation && process.traceDeprecation); let msg = `(${process.release.name}:${process.pid}) `; if (warning.code) { msg += `[${warning.code}] `; } if (trace && warning.stack) { msg += `${warning.stack}`; } else { msg += typeof warning.toString === "function" // deno-lint-ignore deno-internal/prefer-primordials ? `${warning.toString()}` : ErrorPrototypeToString(warning); } if (typeof warning.detail === "string") { msg += `\n${warning.detail}`; } process.stderr.write(msg + "\n"); } return { onWarning, }; })();