Skip to content

Commit 4b9c4d7

Browse files
committedSep 5, 2019
💥 update node/no-deprecated-api
Now it warns: - Module.createRequireFromPath
1 parent 644e999 commit 4b9c4d7

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed
 

‎docs/rules/no-deprecated-api.md

+3
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ This rule reports the following deprecated API.
7575
- http
7676
- [createClient](https://nodejs.org/dist/v0.10.0/docs/api/http.html#http_http_createclient_port_host)
7777
- module
78+
- [createRequireFromPath](https://nodejs.org/dist/v12.2.0/docs/api/deprecations.html#deprecations_dep0130_module_createrequirefrompath)
7879
- `requireRepl` (undocumented)
7980
- [_debug](https://nodejs.org/dist/v9.0.0/docs/api/deprecations.html#deprecations_dep0077_module_debug)
8081
- net
@@ -226,6 +227,8 @@ This option can include the following values:
226227
- `fs.lchown`
227228
- `fs.lchownSync`
228229
- `http.createClient`
230+
- `module.Module.createRequireFromPath`
231+
- `module.createRequireFromPath`
229232
- `module.Module.requireRepl`
230233
- `module.requireRepl`
231234
- `module.Module._debug`

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

+22
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,17 @@ const modules = {
257257
},
258258
module: {
259259
Module: {
260+
createRequireFromPath: {
261+
[READ]: {
262+
since: "12.2.0",
263+
replacedBy: [
264+
{
265+
name: "'module.createRequire()'",
266+
supported: "12.2.0",
267+
},
268+
],
269+
},
270+
},
260271
requireRepl: {
261272
[READ]: {
262273
since: "6.0.0",
@@ -267,6 +278,17 @@ const modules = {
267278
[READ]: { since: "9.0.0", replacedBy: null },
268279
},
269280
},
281+
createRequireFromPath: {
282+
[READ]: {
283+
since: "12.2.0",
284+
replacedBy: [
285+
{
286+
name: "'module.createRequire()'",
287+
supported: "12.2.0",
288+
},
289+
],
290+
},
291+
},
270292
requireRepl: {
271293
[READ]: {
272294
since: "6.0.0",

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

+16
Original file line numberDiff line numberDiff line change
@@ -875,6 +875,22 @@ ruleTester.run("no-deprecated-api", rule, {
875875
"'buffer.Buffer()' was deprecated since v6.0.0. Use 'buffer.Buffer.alloc()' or 'buffer.Buffer.from()' instead.",
876876
],
877877
},
878+
{
879+
code: "require('module').createRequireFromPath()",
880+
options: [{ version: "12.0.0" }],
881+
env: { node: true },
882+
errors: [
883+
"'module.createRequireFromPath' was deprecated since v12.2.0.",
884+
],
885+
},
886+
{
887+
code: "require('module').createRequireFromPath()",
888+
options: [{ version: "12.2.0" }],
889+
env: { node: true },
890+
errors: [
891+
"'module.createRequireFromPath' was deprecated since v12.2.0. Use 'module.createRequire()' instead.",
892+
],
893+
},
878894

879895
//----------------------------------------------------------------------
880896
// Global Variables

0 commit comments

Comments
 (0)
Please sign in to comment.