diff --git a/docs/rules/no-unsupported-features/es-builtins.md b/docs/rules/no-unsupported-features/es-builtins.md index 80e852a5..05020767 100644 --- a/docs/rules/no-unsupported-features/es-builtins.md +++ b/docs/rules/no-unsupported-features/es-builtins.md @@ -12,7 +12,7 @@ Editor integrations of ESLint would be useful to know it in real-time. ### Supported ECMAScript features -This rule supports ECMAScript 2019. +This rule supports ECMAScript 2019 and proposals that have been approved as Stage 4 by August 2019. See also [TC39 finished proposals](https://github.com/tc39/proposals/blob/master/finished-proposals.md). ### Configured Node.js version range @@ -61,6 +61,13 @@ The `"ignores"` option accepts an array of the following strings.
+**ES2020:** + +- `"BigInt"` +- `"BigInt64Array"` +- `"BigUint64Array"` +- `"Promise.allSettled"` + **ES2019:** - `"Object.fromEntries"` diff --git a/lib/rules/no-unsupported-features/es-builtins.js b/lib/rules/no-unsupported-features/es-builtins.js index 1463ea21..81a733c7 100644 --- a/lib/rules/no-unsupported-features/es-builtins.js +++ b/lib/rules/no-unsupported-features/es-builtins.js @@ -14,6 +14,9 @@ const trackMap = { from: { [READ]: { supported: "4.0.0" } }, of: { [READ]: { supported: "4.0.0" } }, }, + BigInt: { + [READ]: { supported: "10.4.0" }, + }, Map: { [READ]: { supported: "0.12.0" }, }, @@ -59,6 +62,7 @@ const trackMap = { }, Promise: { [READ]: { supported: "0.12.0" }, + allSettled: { [READ]: { supported: "12.9.0" } }, }, Proxy: { [READ]: { supported: "6.0.0" }, @@ -97,6 +101,12 @@ const trackMap = { Uint32Array: { [READ]: { supported: "0.10.0" }, }, + BigInt64Array: { + [READ]: { supported: "10.4.0" }, + }, + BigUint64Array: { + [READ]: { supported: "10.4.0" }, + }, Float32Array: { [READ]: { supported: "0.10.0" }, }, diff --git a/tests/lib/rules/no-unsupported-features/es-builtins.js b/tests/lib/rules/no-unsupported-features/es-builtins.js index 3183d272..8d4236d8 100644 --- a/tests/lib/rules/no-unsupported-features/es-builtins.js +++ b/tests/lib/rules/no-unsupported-features/es-builtins.js @@ -5,7 +5,7 @@ "use strict" const { RuleTester } = require("eslint") -const globals = require("globals") +const { builtin } = require("globals") const rule = require("../../../../lib/rules/no-unsupported-features/es-builtins") /** @@ -56,7 +56,7 @@ function concat(patterns) { const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: 2018 }, - globals: globals.es2017, + globals: builtin, }) ruleTester.run( "no-unsupported-features/es-builtins", @@ -128,6 +128,53 @@ ruleTester.run( }, ], }, + { + keyword: "BigInt", + valid: [ + { + code: "bigint", + options: [{ version: "10.3.0" }], + }, + { + code: "(function(BigInt) { BigInt }(b))", + options: [{ version: "10.3.0" }], + }, + { + code: "BigInt", + options: [{ version: "10.4.0" }], + }, + ], + invalid: [ + { + code: "BigInt", + options: [{ version: "10.3.0" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "BigInt", + supported: "10.4.0", + version: "10.3.0", + }, + }, + ], + }, + { + code: "(function() { BigInt })()", + options: [{ version: "10.3.0" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "BigInt", + supported: "10.4.0", + version: "10.3.0", + }, + }, + ], + }, + ], + }, { keyword: "Map", valid: [ @@ -1110,6 +1157,49 @@ ruleTester.run( }, ], }, + { + keyword: "Promise.allSettled", + valid: [ + { + code: "(function(Promise) { Promise.allSettled }(a))", + options: [{ version: "12.8.1" }], + }, + { + code: "Promise.allSettled", + options: [{ version: "12.9.0" }], + }, + ], + invalid: [ + { + code: "Promise.allSettled", + options: [{ version: "12.8.1" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Promise.allSettled", + supported: "12.9.0", + version: "12.8.1", + }, + }, + ], + }, + { + code: "function wrap() { Promise.allSettled }", + options: [{ version: "12.8.1" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Promise.allSettled", + supported: "12.9.0", + version: "12.8.1", + }, + }, + ], + }, + ], + }, { keyword: "Proxy", valid: [ @@ -1650,6 +1740,92 @@ ruleTester.run( }, ], }, + { + keyword: "BigInt64Array", + valid: [ + { + code: "(function(BigInt64Array) { BigInt64Array }(b))", + options: [{ version: "10.3.0" }], + }, + { + code: "BigInt64Array", + options: [{ version: "10.4.0" }], + }, + ], + invalid: [ + { + code: "BigInt64Array", + options: [{ version: "10.3.0" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "BigInt64Array", + supported: "10.4.0", + version: "10.3.0", + }, + }, + ], + }, + { + code: "(function() { BigInt64Array })()", + options: [{ version: "10.3.0" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "BigInt64Array", + supported: "10.4.0", + version: "10.3.0", + }, + }, + ], + }, + ], + }, + { + keyword: "BigUint64Array", + valid: [ + { + code: "(function(BigUint64Array) { BigUint64Array }(b))", + options: [{ version: "10.3.0" }], + }, + { + code: "BigUint64Array", + options: [{ version: "10.4.0" }], + }, + ], + invalid: [ + { + code: "BigUint64Array", + options: [{ version: "10.3.0" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "BigUint64Array", + supported: "10.4.0", + version: "10.3.0", + }, + }, + ], + }, + { + code: "(function() { BigUint64Array })()", + options: [{ version: "10.3.0" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "BigUint64Array", + supported: "10.4.0", + version: "10.3.0", + }, + }, + ], + }, + ], + }, { keyword: "Float32Array", valid: [