Skip to content

Commit

Permalink
💥 update node/no-deprecated-api
Browse files Browse the repository at this point in the history
Now it warns:
- Module.createRequireFromPath
  • Loading branch information
mysticatea committed Sep 5, 2019
1 parent 644e999 commit 4b9c4d7
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
3 changes: 3 additions & 0 deletions docs/rules/no-deprecated-api.md
Expand Up @@ -75,6 +75,7 @@ This rule reports the following deprecated API.
- http
- [createClient](https://nodejs.org/dist/v0.10.0/docs/api/http.html#http_http_createclient_port_host)
- module
- [createRequireFromPath](https://nodejs.org/dist/v12.2.0/docs/api/deprecations.html#deprecations_dep0130_module_createrequirefrompath)
- `requireRepl` (undocumented)
- [_debug](https://nodejs.org/dist/v9.0.0/docs/api/deprecations.html#deprecations_dep0077_module_debug)
- net
Expand Down Expand Up @@ -226,6 +227,8 @@ This option can include the following values:
- `fs.lchown`
- `fs.lchownSync`
- `http.createClient`
- `module.Module.createRequireFromPath`
- `module.createRequireFromPath`
- `module.Module.requireRepl`
- `module.requireRepl`
- `module.Module._debug`
Expand Down
22 changes: 22 additions & 0 deletions lib/rules/no-deprecated-api.js
Expand Up @@ -257,6 +257,17 @@ const modules = {
},
module: {
Module: {
createRequireFromPath: {
[READ]: {
since: "12.2.0",
replacedBy: [
{
name: "'module.createRequire()'",
supported: "12.2.0",
},
],
},
},
requireRepl: {
[READ]: {
since: "6.0.0",
Expand All @@ -267,6 +278,17 @@ const modules = {
[READ]: { since: "9.0.0", replacedBy: null },
},
},
createRequireFromPath: {
[READ]: {
since: "12.2.0",
replacedBy: [
{
name: "'module.createRequire()'",
supported: "12.2.0",
},
],
},
},
requireRepl: {
[READ]: {
since: "6.0.0",
Expand Down
16 changes: 16 additions & 0 deletions tests/lib/rules/no-deprecated-api.js
Expand Up @@ -875,6 +875,22 @@ ruleTester.run("no-deprecated-api", rule, {
"'buffer.Buffer()' was deprecated since v6.0.0. Use 'buffer.Buffer.alloc()' or 'buffer.Buffer.from()' instead.",
],
},
{
code: "require('module').createRequireFromPath()",
options: [{ version: "12.0.0" }],
env: { node: true },
errors: [
"'module.createRequireFromPath' was deprecated since v12.2.0.",
],
},
{
code: "require('module').createRequireFromPath()",
options: [{ version: "12.2.0" }],
env: { node: true },
errors: [
"'module.createRequireFromPath' was deprecated since v12.2.0. Use 'module.createRequire()' instead.",
],
},

//----------------------------------------------------------------------
// Global Variables
Expand Down

0 comments on commit 4b9c4d7

Please sign in to comment.