Skip to content

Commit 9fd68e4

Browse files
authored
💥Update node/no-unsupported-features/node-builtins to recognize new async_hooks features (#262)
1 parent a4aa6ad commit 9fd68e4

File tree

2 files changed

+123
-0
lines changed

2 files changed

+123
-0
lines changed

‎lib/rules/no-unsupported-features/node-builtins.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ const trackMap = {
3838
async_hooks: {
3939
[READ]: { supported: "8.0.0" },
4040
createHook: { [READ]: { supported: "8.1.0" } },
41+
AsyncLocalStorage: {
42+
[READ]: { supported: "13.10.0", backported: ["12.17.0"] },
43+
},
4144
},
4245
buffer: {
4346
Buffer: {

‎tests/lib/rules/no-unsupported-features/node-builtins.js

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,26 @@ new RuleTester({
478478
"import { createHook } from 'async_hooks'; createHook()",
479479
options: [{ version: "8.1.0" }],
480480
},
481+
{
482+
code:
483+
"const { AsyncLocalStorage } = require('async_hooks'); new AsyncLocalStorage();",
484+
options: [{ version: "13.10.0" }],
485+
},
486+
{
487+
code:
488+
"import hooks from 'async_hooks'; new hooks.AsyncLocalStorage();",
489+
options: [{ version: "13.10.0" }],
490+
},
491+
{
492+
code:
493+
"const { AsyncLocalStorage } = require('async_hooks'); new AsyncLocalStorage();",
494+
options: [{ version: "12.17.0" }],
495+
},
496+
{
497+
code:
498+
"import hooks from 'async_hooks'; new hooks.AsyncLocalStorage();",
499+
options: [{ version: "12.17.0" }],
500+
},
481501

482502
// Ignores
483503
{
@@ -546,6 +566,46 @@ new RuleTester({
546566
},
547567
],
548568
},
569+
{
570+
code:
571+
"const { AsyncLocalStorage } = require('async_hooks'); new AsyncLocalStorage();",
572+
options: [
573+
{
574+
version: "13.9.0",
575+
ignores: ["async_hooks.AsyncLocalStorage"],
576+
},
577+
],
578+
},
579+
{
580+
code:
581+
"import hooks from 'async_hooks'; new hooks.AsyncLocalStorage();",
582+
options: [
583+
{
584+
version: "13.9.0",
585+
ignores: ["async_hooks.AsyncLocalStorage"],
586+
},
587+
],
588+
},
589+
{
590+
code:
591+
"const { AsyncLocalStorage } = require('async_hooks'); new AsyncLocalStorage();",
592+
options: [
593+
{
594+
version: "12.16.0",
595+
ignores: ["async_hooks.AsyncLocalStorage"],
596+
},
597+
],
598+
},
599+
{
600+
code:
601+
"import hooks from 'async_hooks'; new hooks.AsyncLocalStorage();",
602+
options: [
603+
{
604+
version: "12.16.0",
605+
ignores: ["async_hooks.AsyncLocalStorage"],
606+
},
607+
],
608+
},
549609
],
550610
invalid: [
551611
{
@@ -672,6 +732,66 @@ new RuleTester({
672732
},
673733
],
674734
},
735+
{
736+
code:
737+
"const { AsyncLocalStorage } = require('async_hooks'); new AsyncLocalStorage();",
738+
options: [{ version: "13.9.0" }],
739+
errors: [
740+
{
741+
messageId: "unsupported",
742+
data: {
743+
name: "async_hooks.AsyncLocalStorage",
744+
supported: "13.10.0 (backported: ^12.17.0)",
745+
version: "13.9.0",
746+
},
747+
},
748+
],
749+
},
750+
{
751+
code:
752+
"import hooks from 'async_hooks'; new hooks.AsyncLocalStorage();",
753+
options: [{ version: "13.9.0" }],
754+
errors: [
755+
{
756+
messageId: "unsupported",
757+
data: {
758+
name: "async_hooks.AsyncLocalStorage",
759+
supported: "13.10.0 (backported: ^12.17.0)",
760+
version: "13.9.0",
761+
},
762+
},
763+
],
764+
},
765+
{
766+
code:
767+
"const { AsyncLocalStorage } = require('async_hooks'); new AsyncLocalStorage();",
768+
options: [{ version: "12.16.0" }],
769+
errors: [
770+
{
771+
messageId: "unsupported",
772+
data: {
773+
name: "async_hooks.AsyncLocalStorage",
774+
supported: "13.10.0 (backported: ^12.17.0)",
775+
version: "12.16.0",
776+
},
777+
},
778+
],
779+
},
780+
{
781+
code:
782+
"import hooks from 'async_hooks'; new hooks.AsyncLocalStorage();",
783+
options: [{ version: "12.16.0" }],
784+
errors: [
785+
{
786+
messageId: "unsupported",
787+
data: {
788+
name: "async_hooks.AsyncLocalStorage",
789+
supported: "13.10.0 (backported: ^12.17.0)",
790+
version: "12.16.0",
791+
},
792+
},
793+
],
794+
},
675795
],
676796
},
677797

0 commit comments

Comments
 (0)