Skip to content

Commit 400e20a

Browse files
committed
Breaking: update no-deprecated-api rule
1 parent 49c060a commit 400e20a

File tree

3 files changed

+86
-0
lines changed

3 files changed

+86
-0
lines changed

docs/rules/no-deprecated-api.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ const {exists} = require("fs"); /*ERROR: 'fs.exists' was deprecated since
2424
This rule reports the following deprecated API.
2525

2626
- _linklist (undocumented)
27+
- async_hooks
28+
- [currentId](https://nodejs.org/dist/v8.2.0/docs/api/deprecations.html#deprecations_dep0070_async_hooks_currentid)
29+
- [triggerId](https://nodejs.org/dist/v8.2.0/docs/api/deprecations.html#deprecations_dep0071_async_hooks_triggerid)
2730
- buffer
2831
- [Buffer constructors](https://nodejs.org/dist/v6.0.0/docs/api/buffer.html#buffer_class_buffer) (Use [safe-buffer](https://www.npmjs.com/package/safe-buffer) module for `Node@<4.5.0`)
2932
- [SlowBuffer class](https://nodejs.org/dist/v6.0.0/docs/api/buffer.html#buffer_class_slowbuffer)
@@ -51,9 +54,12 @@ This rule reports the following deprecated API.
5154
- [createClient](https://nodejs.org/dist/v0.10.0/docs/api/http.html#http_http_createclient_port_host)
5255
- module
5356
- `requireRepl` (undocumented)
57+
- [_debug](https://nodejs.org/dist/v9.0.0/docs/api/deprecations.html#deprecations_dep0077_module_debug)
5458
- os
5559
- `tmpDir` (undocumented)
5660
- `getNetworkInterfaces` (undocumented)
61+
- path
62+
- [_makeLong](https://nodejs.org/dist/v9.0.0/docs/api/deprecations.html#deprecations_dep0080_path_makelong)
5763
- process
5864
- `EventEmitter` (undocumented)
5965
- [punycode](https://nodejs.org/dist/v7.0.0/docs/api/punycode.html)
@@ -71,6 +77,7 @@ This rule reports the following deprecated API.
7177
- [CryptoStream](https://nodejs.org/dist/v0.12.0/docs/api/tls.html#tls_class_cryptostream)
7278
- [SecurePair](https://nodejs.org/dist/v6.0.0/docs/api/tls.html#tls_class_securepair)
7379
- [createSecurePair](https://nodejs.org/dist/v6.0.0/docs/api/tls.html#tls_tls_createsecurepair_context_isserver_requestcert_rejectunauthorized_options)
80+
- [parseCertString](https://nodejs.org/dist/v8.6.0/docs/api/deprecations.html#deprecations_dep0076_tls_parsecertstring)
7481
- tty
7582
- [setRawMode](https://nodejs.org/dist/v0.10.0/docs/api/tty.html#tty_tty_setrawmode_mode)
7683
- util
@@ -127,6 +134,8 @@ This rule ignores APIs that `ignoreModuleItems` includes.
127134
This option can include the following values:
128135

129136
- `_linklist`
137+
- `async_hooks.currentId`
138+
- `async_hooks.triggerId`
130139
- `buffer.Buffer()`
131140
- `new buffer.Buffer()`
132141
- `buffer.SlowBuffer`
@@ -146,7 +155,10 @@ This option can include the following values:
146155
- `http.createClient`
147156
- `module.Module.requireRepl`
148157
- `module.requireRepl`
158+
- `module.Module._debug`
159+
- `module._debug`
149160
- `os.tmpDir`
161+
- `path._makeLong`
150162
- `punycode`
151163
- `readline.codePointAt`
152164
- `readline.getStringWidth`
@@ -157,6 +169,7 @@ This option can include the following values:
157169
- `tls.CryptoStream`
158170
- `tls.SecurePair`
159171
- `tls.createSecurePair`
172+
- `tls.parseCertString`
160173
- `tty.setRawMode`
161174
- `util.debug`
162175
- `util.error`
@@ -220,6 +233,8 @@ This rule cannot report the following cases:
220233

221234
### non-static properties
222235

236+
- async_hooks
237+
- [asyncResource.triggerId](https://nodejs.org/dist/v8.2.0/docs/api/deprecations.html#deprecations_dep0072_async_hooks_asyncresource_triggerid)
223238
- buffer
224239
- [buf.parent](https://nodejs.org/dist/v8.0.0/docs/api/buffer.html#buffer_buf_parent)
225240
- cluster
@@ -232,6 +247,13 @@ This rule cannot report the following cases:
232247
- [server.connections](https://nodejs.org/dist/v0.10.0/docs/api/net.html#net_server_connections)
233248
- repl
234249
- `replServer.convertToContext` (undocumented)
250+
- [replServer.turnOffEditorMode](https://nodejs.org/dist/v9.0.0/docs/api/deprecations.html#deprecations_dep0078_replserver_turnoffeditormode)
251+
- [replServer.memory](https://nodejs.org/dist/v9.0.0/docs/api/deprecations.html#deprecations_dep0082_replserver_prototype_memory)
252+
253+
### types of arguments
254+
255+
- fs
256+
- `fs.truncate()` and `fs.truncateSync()` usage with a file descriptor has been deprecated.
235257

236258
### dynamic things
237259

lib/util/deprecated-apis.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,18 @@ module.exports = {
1616
since: 5,
1717
replacedBy: null,
1818
},
19+
async_hooks: { //eslint-disable-line camelcase
20+
currentId: {
21+
$deprecated: true,
22+
since: 8.2,
23+
replacedBy: "'async_hooks.executionAsyncId()'",
24+
},
25+
triggerId: {
26+
$deprecated: true,
27+
since: 8.2,
28+
replacedBy: "'async_hooks.triggerAsyncId()'",
29+
},
30+
},
1931
buffer: {
2032
Buffer: {
2133
$constructor: {
@@ -122,12 +134,22 @@ module.exports = {
122134
since: 6,
123135
replacedBy: "'require(\"repl\")'",
124136
},
137+
_debug: {
138+
$deprecated: true,
139+
since: 9,
140+
replacedBy: null,
141+
},
125142
},
126143
requireRepl: {
127144
$deprecated: true,
128145
since: 6,
129146
replacedBy: "'require(\"repl\")'",
130147
},
148+
_debug: {
149+
$deprecated: true,
150+
since: 9,
151+
replacedBy: null,
152+
},
131153
},
132154
os: {
133155
getNetworkInterfaces: {
@@ -141,6 +163,13 @@ module.exports = {
141163
replacedBy: "'os.tmpdir()'",
142164
},
143165
},
166+
path: {
167+
_makeLong: {
168+
$deprecated: true,
169+
since: 9,
170+
replacedBy: "'path.toNamespacedPath()'",
171+
},
172+
},
144173
punycode: {
145174
$deprecated: true,
146175
since: 7,
@@ -194,6 +223,11 @@ module.exports = {
194223
since: 6,
195224
replacedBy: "'tls.TLSSocket'",
196225
},
226+
parseCertString: {
227+
$deprecated: true,
228+
since: 8.6,
229+
replacedBy: "'querystring.parse()'",
230+
},
197231
},
198232
tty: {
199233
setRawMode: {

tests/lib/rules/no-deprecated-api.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,16 @@ ruleTester.run("no-deprecated-api", rule, {
243243
env: { node: true },
244244
errors: ["'_linklist' module was deprecated since v5."],
245245
},
246+
{
247+
code: "require('async_hooks').currentId;",
248+
env: { node: true },
249+
errors: ["'async_hooks.currentId' was deprecated since v8.2. Use 'async_hooks.executionAsyncId()' instead."],
250+
},
251+
{
252+
code: "require('async_hooks').triggerId;",
253+
env: { node: true },
254+
errors: ["'async_hooks.triggerId' was deprecated since v8.2. Use 'async_hooks.triggerAsyncId()' instead."],
255+
},
246256
{
247257
code: "require('constants');",
248258
env: { node: true },
@@ -323,6 +333,16 @@ ruleTester.run("no-deprecated-api", rule, {
323333
env: { node: true },
324334
errors: ["'module.Module.requireRepl' was deprecated since v6. Use 'require(\"repl\")' instead."],
325335
},
336+
{
337+
code: "require('module')._debug;",
338+
env: { node: true },
339+
errors: ["'module._debug' was deprecated since v9."],
340+
},
341+
{
342+
code: "require('module').Module._debug;",
343+
env: { node: true },
344+
errors: ["'module.Module._debug' was deprecated since v9."],
345+
},
326346
{
327347
code: "require('os').getNetworkInterfaces;",
328348
env: { node: true },
@@ -333,6 +353,11 @@ ruleTester.run("no-deprecated-api", rule, {
333353
env: { node: true },
334354
errors: ["'os.tmpDir' was deprecated since v7. Use 'os.tmpdir()' instead."],
335355
},
356+
{
357+
code: "require('path')._makeLong;",
358+
env: { node: true },
359+
errors: ["'path._makeLong' was deprecated since v9. Use 'path.toNamespacedPath()' instead."],
360+
},
336361
{
337362
code: "require('punycode');",
338363
env: { node: true },
@@ -383,6 +408,11 @@ ruleTester.run("no-deprecated-api", rule, {
383408
env: { node: true },
384409
errors: ["'tls.createSecurePair' was deprecated since v6. Use 'tls.TLSSocket' instead."],
385410
},
411+
{
412+
code: "require('tls').parseCertString;",
413+
env: { node: true },
414+
errors: ["'tls.parseCertString' was deprecated since v8.6. Use 'querystring.parse()' instead."],
415+
},
386416
{
387417
code: "require('tty').setRawMode;",
388418
env: { node: true },

0 commit comments

Comments
 (0)