/
no-property-shorthands.js
52 lines (50 loc) · 1.53 KB
/
no-property-shorthands.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const RuleTester = require("../../tester")
const rule = require("../../../lib/rules/no-property-shorthands.js")
new RuleTester().run("no-property-shorthands", rule, {
valid: [
"({})",
"({ a: 1 })",
"({ a: function(){} })",
"({ get a() {}, set a(value) {} })",
"({ [a]: 1 })",
"({ ...a })",
"({ a } = obj)",
],
invalid: [
{
code: "({ a })",
output: "({ a: a })",
errors: ["ES2015 property shorthands are forbidden."],
},
{
code: "({ a() {} })",
output: "({ a: function() {} })",
errors: ["ES2015 property shorthands are forbidden."],
},
{
code: "({ * a() {} })",
output: "({ a: function*() {} })",
errors: ["ES2015 property shorthands are forbidden."],
},
{
code: "({ [a]() {} })",
output: "({ [a]: function() {} })",
errors: ["ES2015 property shorthands are forbidden."],
},
{
code: "({ async a() {} })",
output: "({ a: async function() {} })",
errors: ["ES2015 property shorthands are forbidden."],
},
{
code: "({ async * [a]() {} })",
output: "({ [a]: async function*() {} })",
errors: ["ES2015 property shorthands are forbidden."],
},
],
})