From 9a66223499e3675dc133d427ace24c98fb368fe2 Mon Sep 17 00:00:00 2001 From: Ethan Arrowood Date: Fri, 10 Nov 2023 10:51:22 -0700 Subject: [PATCH] doc: add `--disable-warnings` option to docs --- doc/api/cli.md | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/doc/api/cli.md b/doc/api/cli.md index 1f5136ce69442f..ddabbf137a4df7 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -443,6 +443,48 @@ Affects the default output directory of: * [`--heap-prof-dir`][] * [`--redirect-warnings`][] +### `--disable-warnings=code-or-type` + + + +Disable specific process warnings by `code` or `type`. + +Warnings emitted from [`process.emitWarning()`][emit_warning] may contain a +`code` and a `type`. This option will not-emit warnings that have a matching +`code` or `type`. + +List of [deprecation warnings][]. + +The Node.js core warning types are: `DeprecationWarning` and +`ExperimentalWarning` + +For example, the following script will not emit +[DEP0025 `require('node:sys')`][DEP0025 warning] when executed with +`node --disable-warnings=DEP0025`: + +```js +'use strict'; + +const sys = require('sys'); // eslint-disable-line no-restricted-modules +``` + +For example, the following script will emit the +[DEP0025 `require('node:sys')`][DEP0025 warning], but not any Experimental +Warnings (such as +[ExperimentalWarning: `vm.measureMemory` is an experimental feature][] +in <=v21) when executed with `node --disable-warnings=ExperimentalWarnings`: + +```js +'use strict'; + +const sys = require('sys'); // eslint-disable-line no-restricted-modules +const vm = require('vm'); + +vm.measureMemory(); +``` + ### `--disable-proto=mode` + +Emit all process warnings (including deprecations). Enabled by default. See [`--no-warnings`][] to disable all process warnings. + ### `--watch`