Skip to content

Commit

Permalink
add tests for quote-props
Browse files Browse the repository at this point in the history
  • Loading branch information
mdjermanovic committed Aug 18, 2020
1 parent 371e46a commit 1c10aa7
Showing 1 changed file with 43 additions and 1 deletion.
44 changes: 43 additions & 1 deletion tests/lib/rules/quote-props.js
Expand Up @@ -79,7 +79,13 @@ ruleTester.run("quote-props", rule, {
{ code: "({ 1n: 1 })", options: ["consistent"], parserOptions: { ecmaVersion: 2020 } },
{ code: "({ 1n: 1 })", options: ["consistent-as-needed"], parserOptions: { ecmaVersion: 2020 } },
{ code: "({ '99999999999999999': 1 })", options: ["as-needed"], parserOptions: { ecmaVersion: 2020 } },
{ code: "({ '1n': 1 })", options: ["as-needed"], parserOptions: { ecmaVersion: 2020 } }
{ code: "({ '1n': 1 })", options: ["as-needed"], parserOptions: { ecmaVersion: 2020 } },
{ code: "({ 1_0: 1 })", options: ["as-needed"], parserOptions: { ecmaVersion: 2021 } },
{ code: "({ 1_0: 1 })", options: ["as-needed", { numbers: false }], parserOptions: { ecmaVersion: 2021 } },
{ code: "({ '1_0': 1 })", options: ["as-needed"], parserOptions: { ecmaVersion: 2021 } },
{ code: "({ '1_0': 1 })", options: ["as-needed", { numbers: false }], parserOptions: { ecmaVersion: 2021 } },
{ code: "({ '1_0': 1 })", options: ["as-needed", { numbers: true }], parserOptions: { ecmaVersion: 2021 } },
{ code: "({ 1_0: 1, 1: 1 })", options: ["consistent-as-needed"], parserOptions: { ecmaVersion: 2021 } }
],
invalid: [{
code: "({ a: 0 })",
Expand Down Expand Up @@ -380,5 +386,41 @@ ruleTester.run("quote-props", rule, {
messageId: "unquotedNumericProperty",
data: { property: "1" }
}]
}, {
code: "({ 1_0: 1 })",
output: "({ \"10\": 1 })",
options: ["as-needed", { numbers: true }],
parserOptions: { ecmaVersion: 2021 },
errors: [{
messageId: "unquotedNumericProperty",
data: { property: "10" }
}]
}, {
code: "({ 1_2.3_4e0_2: 1 })",
output: "({ \"1234\": 1 })",
options: ["always"],
parserOptions: { ecmaVersion: 2021 },
errors: [{
messageId: "unquotedPropertyFound",
data: { property: "1234" }
}]
}, {
code: "({ 0b1_000: 1 })",
output: "({ \"8\": 1 })",
options: ["always"],
parserOptions: { ecmaVersion: 2021 },
errors: [{
messageId: "unquotedPropertyFound",
data: { property: "8" }
}]
}, {
code: "({ 1_000: a, '1_000': b })",
output: "({ \"1000\": a, '1_000': b })",
options: ["consistent-as-needed"],
parserOptions: { ecmaVersion: 2021 },
errors: [{
messageId: "inconsistentlyQuotedProperty",
data: { key: "1000" }
}]
}]
});

0 comments on commit 1c10aa7

Please sign in to comment.