Skip to content

Commit

Permalink
Breaking: update 'no-deprecated-api' rule
Browse files Browse the repository at this point in the history
  • Loading branch information
mysticatea committed Jul 16, 2018
1 parent 7137055 commit 069efe9
Show file tree
Hide file tree
Showing 3 changed files with 157 additions and 28 deletions.
29 changes: 29 additions & 0 deletions docs/rules/no-deprecated-api.md
Expand Up @@ -24,6 +24,11 @@ const {exists} = require("fs"); /*ERROR: 'fs.exists' was deprecated since
This rule reports the following deprecated API.

- _linklist (undocumented)
- assert
- [deepEqual](https://nodejs.org/dist/v10.0.0/docs/api/assert.html#assert_assert_deepequal_actual_expected_message)
- [equal](https://nodejs.org/dist/v10.0.0/docs/api/assert.html#assert_assert_equal_actual_expected_message)
- [notDeepEqual](https://nodejs.org/dist/v10.0.0/docs/api/assert.html#assert_assert_notdeepequal_actual_expected_message)
- [notEqual](https://nodejs.org/dist/v10.0.0/docs/api/assert.html#assert_assert_notequal_actual_expected_message)
- async_hooks
- [currentId](https://nodejs.org/dist/v8.2.0/docs/api/deprecations.html#deprecations_dep0070_async_hooks_currentid)
- [triggerId](https://nodejs.org/dist/v8.2.0/docs/api/deprecations.html#deprecations_dep0071_async_hooks_triggerid)
Expand All @@ -33,7 +38,11 @@ This rule reports the following deprecated API.
- constants (undocumented)
- crypto
- `Credentials` (undocumented)
- [DEFAULT_ENCODING](https://nodejs.org/dist/v10.0.0/docs/api/crypto.html#crypto_crypto_default_encoding)
- [createCredentials](https://nodejs.org/dist/v0.12.0/docs/api/crypto.html#crypto_crypto_createcredentials_details)
- [createCipher](https://nodejs.org/dist/v10.0.0/docs/api/crypto.html#crypto_crypto_createcipher_algorithm_password_options)
- [createDecipher](https://nodejs.org/dist/v10.0.0/docs/api/crypto.html#crypto_crypto_createdecipher_algorithm_password_options)
- [fips](https://nodejs.org/dist/v10.0.0/docs/api/crypto.html#crypto_crypto_fips)
- [domain](https://nodejs.org/dist/v4.0.0/docs/api/domain.html#domain_domain)
- events
- [EventEmitter.listenerCount](https://nodejs.org/dist/v4.0.0/docs/api/events.html#events_class_method_eventemitter_listenercount_emitter_event)
Expand Down Expand Up @@ -62,6 +71,7 @@ This rule reports the following deprecated API.
- [_makeLong](https://nodejs.org/dist/v9.0.0/docs/api/deprecations.html#deprecations_dep0080_path_makelong)
- process
- `EventEmitter` (undocumented)
- `assert` (undocumented)
- [punycode](https://nodejs.org/dist/v7.0.0/docs/api/punycode.html)
- readline
- `codePointAt` (undocumented)
Expand All @@ -71,11 +81,15 @@ This rule reports the following deprecated API.
- repl
- [process.env.NODE_REPL_HISTORY_FILE](https://nodejs.org/dist/v4.0.0/docs/api/repl.html#repl_node_repl_history_file)
- [sys](https://nodejs.org/api/deprecations.html#deprecations_dep0025_require_sys)
- timers
- `enroll` (undocumented)
- `unenroll` (undocumented)
- tls
- [CleartextStream](https://nodejs.org/dist/v0.10.0/docs/api/tls.html#tls_class_tls_cleartextstream)
(this class was removed on v0.11.3, but never deprecated in documents)
- [CryptoStream](https://nodejs.org/dist/v0.12.0/docs/api/tls.html#tls_class_cryptostream)
- [SecurePair](https://nodejs.org/dist/v6.0.0/docs/api/tls.html#tls_class_securepair)
- `convertNPNProtocols` (undocumented)
- [createSecurePair](https://nodejs.org/dist/v6.0.0/docs/api/tls.html#tls_tls_createsecurepair_context_isserver_requestcert_rejectunauthorized_options)
- [parseCertString](https://nodejs.org/dist/v8.6.0/docs/api/deprecations.html#deprecations_dep0076_tls_parsecertstring)
- tty
Expand Down Expand Up @@ -134,14 +148,22 @@ This rule ignores APIs that `ignoreModuleItems` includes.
This option can include the following values:

- `_linklist`
- `assert.deepEqual`
- `assert.equal`
- `assert.notDeepEqual`
- `assert.notEqual`
- `async_hooks.currentId`
- `async_hooks.triggerId`
- `buffer.Buffer()`
- `new buffer.Buffer()`
- `buffer.SlowBuffer`
- `constants`
- `crypto.Credentials`
- `crypto.DEFAULT_ENCODING`
- `crypto.createCipher`
- `crypto.createCredentials`
- `crypto.createDecipher`
- `crypto.fips`
- `domain`
- `events.EventEmitter.listenerCount`
- `events.listenerCount`
Expand All @@ -159,15 +181,21 @@ This option can include the following values:
- `module._debug`
- `os.tmpDir`
- `path._makeLong`
- `process.EventEmitter`
- `process.assert`
- `process.env.NODE_REPL_HISTORY_FILE`
- `punycode`
- `readline.codePointAt`
- `readline.getStringWidth`
- `readline.isFullWidthCodePoint`
- `readline.stripVTControlCharacters`
- `sys`
- `timers.enroll`
- `timers.unenroll`
- `tls.CleartextStream`
- `tls.CryptoStream`
- `tls.SecurePair`
- `tls.convertNPNProtocols`
- `tls.createSecurePair`
- `tls.parseCertString`
- `tty.setRawMode`
Expand Down Expand Up @@ -217,6 +245,7 @@ This option can include the following values:
- `Intl.v8BreakIterator`
- `require.extensions`
- `process.EventEmitter`
- `process.assert`
- `process.env.NODE_REPL_HISTORY_FILE`

Examples of :+1: **correct** code for the `{"ignoreGlobalItems": ["new Buffer()"]}`:
Expand Down
112 changes: 106 additions & 6 deletions lib/util/deprecated-apis.js
Expand Up @@ -14,6 +14,36 @@ module.exports = {
replacedBy: null,
},
},
assert: {
// https://github.com/nodejs/node/commit/a319e90807bbc74b6d0e85ee9bec697acb68ebcb
deepEqual: {
[READ]: {
since: 10.0,
replacedBy:
"'assert.deepStrictEqual' or 'assert.strict.deepEqual'",
},
},
equal: {
[READ]: {
since: 10.0,
replacedBy: "'assert.strictEqual' or 'assert.strict.equal'",
},
},
notDeepEqual: {
[READ]: {
since: 10.0,
replacedBy:
"'assert.notDeepStrictEqual' or 'assert.strict.notDeepEqual'",
},
},
notEqual: {
[READ]: {
since: 10.0,
replacedBy:
"'assert.notStrictEqual' or 'assert.strict.notEqual'",
},
},
},
//eslint-disable-next-line camelcase
async_hooks: {
currentId: {
Expand All @@ -34,12 +64,12 @@ module.exports = {
[CONSTRUCT]: {
since: 6,
replacedBy:
"'buffer.Buffer.alloc()' or 'buffer.Buffer.from()' (use 'https://www.npmjs.com/package/safe-buffer' for '<4.5.0')",
"'buffer.Buffer.alloc()' or 'buffer.Buffer.from()'",
},
[CALL]: {
since: 6,
replacedBy:
"'buffer.Buffer.alloc()' or 'buffer.Buffer.from()' (use 'https://www.npmjs.com/package/safe-buffer' for '<4.5.0')",
"'buffer.Buffer.alloc()' or 'buffer.Buffer.from()'",
},
},
SlowBuffer: {
Expand All @@ -62,12 +92,36 @@ module.exports = {
replacedBy: "'tls.SecureContext'",
},
},
DEFAULT_ENCODING: {
[READ]: {
since: 10.0,
replacedBy: null,
},
},
createCipher: {
[READ]: {
since: 10.0,
replacedBy: "'tls.createCipheriv()'",
},
},
createCredentials: {
[READ]: {
since: 0.12,
replacedBy: "'tls.createSecureContext()'",
},
},
createDecipher: {
[READ]: {
since: 10.0,
replacedBy: "'tls.createDecipheriv()'",
},
},
fips: {
[READ]: {
since: 10.0,
replacedBy: "'crypto.getFips()' and 'crypto.setFips()'",
},
},
},
domain: {
[READ]: {
Expand Down Expand Up @@ -193,6 +247,28 @@ module.exports = {
},
},
},
process: {
EventEmitter: {
[READ]: {
since: 0.6,
replacedBy: "'require(\"events\")'",
},
},
assert: {
[READ]: {
since: 10.0,
replacedBy: "'require(\"assert\")'",
},
},
env: {
NODE_REPL_HISTORY_FILE: {
[READ]: {
since: 4,
replacedBy: "'NODE_REPL_HISTORY'",
},
},
},
},
punycode: {
[READ]: {
since: 7,
Expand Down Expand Up @@ -253,6 +329,20 @@ module.exports = {
replacedBy: "'util' module",
},
},
timers: {
enroll: {
[READ]: {
since: 10.0,
replacedBy: "'setTimeout()' or 'setInterval()'",
},
},
unenroll: {
[READ]: {
since: 10.0,
replacedBy: "'clearTimeout()' or 'clearInterval()'",
},
},
},
tls: {
CleartextStream: {
[READ]: {
Expand All @@ -272,6 +362,12 @@ module.exports = {
replacedBy: "'tls.TLSSocket'",
},
},
convertNPNProtocols: {
[READ]: {
since: 10.0,
replacedBy: null,
},
},
createSecurePair: {
[READ]: {
since: 6,
Expand Down Expand Up @@ -441,13 +537,11 @@ module.exports = {
Buffer: {
[CONSTRUCT]: {
since: 6,
replacedBy:
"'Buffer.alloc()' or 'Buffer.from()' (use 'https://www.npmjs.com/package/safe-buffer' for '<4.5.0')",
replacedBy: "'Buffer.alloc()' or 'Buffer.from()'",
},
[CALL]: {
since: 6,
replacedBy:
"'Buffer.alloc()' or 'Buffer.from()' (use 'https://www.npmjs.com/package/safe-buffer' for '<4.5.0')",
replacedBy: "'Buffer.alloc()' or 'Buffer.from()'",
},
},
GLOBAL: {
Expand Down Expand Up @@ -485,6 +579,12 @@ module.exports = {
replacedBy: "'require(\"events\")'",
},
},
assert: {
[READ]: {
since: 10.0,
replacedBy: "'require(\"assert\")'",
},
},
env: {
NODE_REPL_HISTORY_FILE: {
[READ]: {
Expand Down

0 comments on commit 069efe9

Please sign in to comment.