Skip to content

Commit

Permalink
💥 add check of bigint literal property names to node/no-unsupported-f…
Browse files Browse the repository at this point in the history
…eatures/es-syntax
  • Loading branch information
mysticatea committed Dec 26, 2019
1 parent 4f74fbf commit fb9ce15
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/rules/no-unsupported-features/es-syntax.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,16 @@ const features = {
test: info => info.node.type === "Literal",
messageId: "no-bigint",
},
{
supported: null,
test: ({ node }) =>
node.type === "Literal" &&
(node.parent.type === "Property" ||
node.parent.type === "MethodDefinition") &&
!node.parent.computed &&
node.parent.key === node,
messageId: "no-bigint-property-names",
},
],
},
dynamicImport: {
Expand Down Expand Up @@ -615,6 +625,8 @@ module.exports = {
//------------------------------------------------------------------
"no-bigint":
"Bigint literals are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.",
"no-bigint-property-names":
"Bigint literal property names are not supported yet.",
"no-dynamic-import":
"'import()' expressions are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.",
},
Expand Down
34 changes: 34 additions & 0 deletions tests/lib/rules/no-unsupported-features/es-syntax.js
Original file line number Diff line number Diff line change
Expand Up @@ -2450,6 +2450,14 @@ ruleTester.run(
code: "var n = new BigUint64Array()",
options: [{ version: "10.3.0" }],
},
{
code: "var n = { [0n]: 0 }",
options: [{ version: "10.4.0" }],
},
{
code: "var n = class { [0n]() {} }",
options: [{ version: "10.4.0" }],
},
],
invalid: [
{
Expand All @@ -2465,6 +2473,32 @@ ruleTester.run(
},
],
},
{
code: "var n = { 0n: 0 }",
options: [{ version: "12.0.0" }],
errors: [
{
messageId: "no-bigint-property-names",
data: {
supported: null,
version: "12.0.0",
},
},
],
},
{
code: "var n = class { 0n() {} }",
options: [{ version: "12.0.0" }],
errors: [
{
messageId: "no-bigint-property-names",
data: {
supported: null,
version: "12.0.0",
},
},
],
},
],
},
{
Expand Down

0 comments on commit fb9ce15

Please sign in to comment.