Node has many deprecated API. The community is going to remove those API from Node in future, so we should not use those.
The following patterns are considered problems:
/*eslint no-deprecated-api: 2*/
var fs = require("fs");
fs.exists("./foo.js", function() {}); /*ERROR: 'fs.exists' was deprecated since v4. Use 'fs.stat()' or 'fs.access()' instead.*/
// Also, it can report the following patterns.
var exists = require("fs").exists; /*ERROR: 'fs.exists' was deprecated since v4. Use 'fs.stat()' or 'fs.access()' instead.*/
const {exists} = require("fs"); /*ERROR: 'fs.exists' was deprecated since v4. Use 'fs.stat()' or 'fs.access()' instead.*/
// And other deprecated API below.This rule reports the following deprecated API.
- buffer
- crypto
- domain
- events
- fs
- globals
- http
- REPL
- tls
- CleartextStream (this class was removed on v0.11.3, but never deprecated in documents)
- CryptoStream
- SecurePair
- createSecurePair
- tty
- util
- cluster
- crypto
- net
require(foo).aDeprecatedProperty;
require("http")[A_DEPRECATED_PROPERTY]();var obj = {
Buffer: require("buffer").Buffer
};
new obj.Buffer(); /* missing. */var obj = {};
obj.Buffer = require("buffer").Buffer
new obj.Buffer(); /* missing. */(function(Buffer) {
new Buffer(); /* missing. */
})(require("buffer").Buffer);var Buffer = require("buffer").Buffer;
Buffer = require("another-buffer");
new Buffer(); /*ERROR: 'buffer.Buffer' constructor was deprecated.*/If you don't want to be warned on deprecated API, then it's safe to disable this rule.