Skip to content

Commit b91b48d

Browse files
committedSep 4, 2019
💥 update node/no-unsupported-features/es-builtins rule to recognize bigint and Promise.allSettled
1 parent 9ea67c9 commit b91b48d

File tree

3 files changed

+196
-3
lines changed

3 files changed

+196
-3
lines changed
 

‎docs/rules/no-unsupported-features/es-builtins.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Editor integrations of ESLint would be useful to know it in real-time.
1212

1313
### Supported ECMAScript features
1414

15-
This rule supports ECMAScript 2019.
15+
This rule supports ECMAScript 2019 and proposals that have been approved as Stage 4 by August 2019.
1616
See also [TC39 finished proposals](https://github.com/tc39/proposals/blob/master/finished-proposals.md).
1717

1818
### Configured Node.js version range
@@ -61,6 +61,13 @@ The `"ignores"` option accepts an array of the following strings.
6161

6262
<details>
6363

64+
**ES2020:**
65+
66+
- `"BigInt"`
67+
- `"BigInt64Array"`
68+
- `"BigUint64Array"`
69+
- `"Promise.allSettled"`
70+
6471
**ES2019:**
6572

6673
- `"Object.fromEntries"`

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

+10
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ const trackMap = {
1414
from: { [READ]: { supported: "4.0.0" } },
1515
of: { [READ]: { supported: "4.0.0" } },
1616
},
17+
BigInt: {
18+
[READ]: { supported: "10.4.0" },
19+
},
1720
Map: {
1821
[READ]: { supported: "0.12.0" },
1922
},
@@ -59,6 +62,7 @@ const trackMap = {
5962
},
6063
Promise: {
6164
[READ]: { supported: "0.12.0" },
65+
allSettled: { [READ]: { supported: "12.9.0" } },
6266
},
6367
Proxy: {
6468
[READ]: { supported: "6.0.0" },
@@ -97,6 +101,12 @@ const trackMap = {
97101
Uint32Array: {
98102
[READ]: { supported: "0.10.0" },
99103
},
104+
BigInt64Array: {
105+
[READ]: { supported: "10.4.0" },
106+
},
107+
BigUint64Array: {
108+
[READ]: { supported: "10.4.0" },
109+
},
100110
Float32Array: {
101111
[READ]: { supported: "0.10.0" },
102112
},

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

+178-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"use strict"
66

77
const { RuleTester } = require("eslint")
8-
const globals = require("globals")
8+
const { builtin } = require("globals")
99
const rule = require("../../../../lib/rules/no-unsupported-features/es-builtins")
1010

1111
/**
@@ -56,7 +56,7 @@ function concat(patterns) {
5656

5757
const ruleTester = new RuleTester({
5858
parserOptions: { ecmaVersion: 2018 },
59-
globals: globals.es2017,
59+
globals: builtin,
6060
})
6161
ruleTester.run(
6262
"no-unsupported-features/es-builtins",
@@ -128,6 +128,53 @@ ruleTester.run(
128128
},
129129
],
130130
},
131+
{
132+
keyword: "BigInt",
133+
valid: [
134+
{
135+
code: "bigint",
136+
options: [{ version: "10.3.0" }],
137+
},
138+
{
139+
code: "(function(BigInt) { BigInt }(b))",
140+
options: [{ version: "10.3.0" }],
141+
},
142+
{
143+
code: "BigInt",
144+
options: [{ version: "10.4.0" }],
145+
},
146+
],
147+
invalid: [
148+
{
149+
code: "BigInt",
150+
options: [{ version: "10.3.0" }],
151+
errors: [
152+
{
153+
messageId: "unsupported",
154+
data: {
155+
name: "BigInt",
156+
supported: "10.4.0",
157+
version: "10.3.0",
158+
},
159+
},
160+
],
161+
},
162+
{
163+
code: "(function() { BigInt })()",
164+
options: [{ version: "10.3.0" }],
165+
errors: [
166+
{
167+
messageId: "unsupported",
168+
data: {
169+
name: "BigInt",
170+
supported: "10.4.0",
171+
version: "10.3.0",
172+
},
173+
},
174+
],
175+
},
176+
],
177+
},
131178
{
132179
keyword: "Map",
133180
valid: [
@@ -1110,6 +1157,49 @@ ruleTester.run(
11101157
},
11111158
],
11121159
},
1160+
{
1161+
keyword: "Promise.allSettled",
1162+
valid: [
1163+
{
1164+
code: "(function(Promise) { Promise.allSettled }(a))",
1165+
options: [{ version: "12.8.1" }],
1166+
},
1167+
{
1168+
code: "Promise.allSettled",
1169+
options: [{ version: "12.9.0" }],
1170+
},
1171+
],
1172+
invalid: [
1173+
{
1174+
code: "Promise.allSettled",
1175+
options: [{ version: "12.8.1" }],
1176+
errors: [
1177+
{
1178+
messageId: "unsupported",
1179+
data: {
1180+
name: "Promise.allSettled",
1181+
supported: "12.9.0",
1182+
version: "12.8.1",
1183+
},
1184+
},
1185+
],
1186+
},
1187+
{
1188+
code: "function wrap() { Promise.allSettled }",
1189+
options: [{ version: "12.8.1" }],
1190+
errors: [
1191+
{
1192+
messageId: "unsupported",
1193+
data: {
1194+
name: "Promise.allSettled",
1195+
supported: "12.9.0",
1196+
version: "12.8.1",
1197+
},
1198+
},
1199+
],
1200+
},
1201+
],
1202+
},
11131203
{
11141204
keyword: "Proxy",
11151205
valid: [
@@ -1650,6 +1740,92 @@ ruleTester.run(
16501740
},
16511741
],
16521742
},
1743+
{
1744+
keyword: "BigInt64Array",
1745+
valid: [
1746+
{
1747+
code: "(function(BigInt64Array) { BigInt64Array }(b))",
1748+
options: [{ version: "10.3.0" }],
1749+
},
1750+
{
1751+
code: "BigInt64Array",
1752+
options: [{ version: "10.4.0" }],
1753+
},
1754+
],
1755+
invalid: [
1756+
{
1757+
code: "BigInt64Array",
1758+
options: [{ version: "10.3.0" }],
1759+
errors: [
1760+
{
1761+
messageId: "unsupported",
1762+
data: {
1763+
name: "BigInt64Array",
1764+
supported: "10.4.0",
1765+
version: "10.3.0",
1766+
},
1767+
},
1768+
],
1769+
},
1770+
{
1771+
code: "(function() { BigInt64Array })()",
1772+
options: [{ version: "10.3.0" }],
1773+
errors: [
1774+
{
1775+
messageId: "unsupported",
1776+
data: {
1777+
name: "BigInt64Array",
1778+
supported: "10.4.0",
1779+
version: "10.3.0",
1780+
},
1781+
},
1782+
],
1783+
},
1784+
],
1785+
},
1786+
{
1787+
keyword: "BigUint64Array",
1788+
valid: [
1789+
{
1790+
code: "(function(BigUint64Array) { BigUint64Array }(b))",
1791+
options: [{ version: "10.3.0" }],
1792+
},
1793+
{
1794+
code: "BigUint64Array",
1795+
options: [{ version: "10.4.0" }],
1796+
},
1797+
],
1798+
invalid: [
1799+
{
1800+
code: "BigUint64Array",
1801+
options: [{ version: "10.3.0" }],
1802+
errors: [
1803+
{
1804+
messageId: "unsupported",
1805+
data: {
1806+
name: "BigUint64Array",
1807+
supported: "10.4.0",
1808+
version: "10.3.0",
1809+
},
1810+
},
1811+
],
1812+
},
1813+
{
1814+
code: "(function() { BigUint64Array })()",
1815+
options: [{ version: "10.3.0" }],
1816+
errors: [
1817+
{
1818+
messageId: "unsupported",
1819+
data: {
1820+
name: "BigUint64Array",
1821+
supported: "10.4.0",
1822+
version: "10.3.0",
1823+
},
1824+
},
1825+
],
1826+
},
1827+
],
1828+
},
16531829
{
16541830
keyword: "Float32Array",
16551831
valid: [

0 commit comments

Comments
 (0)
Please sign in to comment.