diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index 79060f1db76db8..e56ad042ddf999 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -1129,7 +1129,7 @@ Type: Documentation-only The [`util.isNumber()`][] API is deprecated. -### DEP0053 `util.isObject()` +### DEP0053: `util.isObject()` + + ### DEP0089: `require('assert')` $/; + +const generateDeprecationCode = (codeAsNumber) => + `DEP${codeAsNumber.toString().padStart(4, '0')}`; + +const addMarkdownPathToErrorStack = (error, node) => { + const { line, column } = node.position.start; + const [header, ...lines] = error.stack.split('\n'); + error.stack = + header + + `\n at (${source}:${line}:${column})\n` + + lines.join('\n'); + return error; +}; + +const testAnchor = (anchorNode, expectedDeprecationCode) => { + try { + assert.strictEqual( + anchorNode?.children[0]?.value, + ``, + `Missing or ill-formed anchor for ${expectedDeprecationCode}.` + ); + } catch (e) { + throw addMarkdownPathToErrorStack(e, anchorNode); + } +}; + +const testHeading = (headingNode, expectedDeprecationCode) => { + try { + assert.strictEqual( + headingNode?.children[0]?.value.substring(0, 9), + `${expectedDeprecationCode}: `, + 'Ill-formed or out-of-order deprecation code.' + ); + } catch (e) { + throw addMarkdownPathToErrorStack(e, headingNode); + } +}; + +const testYAMLComment = (commentNode) => { + try { + assert.strictEqual( + commentNode?.value?.substring(0, 19), + '