-
-
Notifications
You must be signed in to change notification settings - Fork 681
/
Copy pathvalid-v-on.js
108 lines (103 loc) · 2.95 KB
/
valid-v-on.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/**
* @author Toru Nagashima
* @copyright 2017 Toru Nagashima. All rights reserved.
* See LICENSE file in root directory for full license.
*/
'use strict'
// ------------------------------------------------------------------------------
// Requirements
// ------------------------------------------------------------------------------
const RuleTester = require('eslint').RuleTester
const rule = require('../../../lib/rules/valid-v-on')
// ------------------------------------------------------------------------------
// Tests
// ------------------------------------------------------------------------------
const tester = new RuleTester({
parser: 'vue-eslint-parser',
parserOptions: { ecmaVersion: 2015 }
})
tester.run('valid-v-on', rule, {
valid: [
{
filename: 'test.vue',
code: ''
},
{
filename: 'test.vue',
code: '<template><div v-on:click="foo"></div></template>'
},
{
filename: 'test.vue',
code: '<template><div @click="foo"></div></template>'
},
{
filename: 'test.vue',
code: '<template><div @click.prevent.ctrl.left="foo"></div></template>'
},
{
filename: 'test.vue',
code: '<template><div @keydown.27="foo"></div></template>'
},
{
filename: 'test.vue',
code: '<template><div @keydown.enter="foo"></div></template>'
},
{
filename: 'test.vue',
code: '<template><div @keydown.arrow-down="foo"></div></template>'
},
{
filename: 'test.vue',
code: '<template><div @keydown.esc="foo"></div></template>'
},
{
filename: 'test.vue',
code: '<template><div @keydown.a="foo"></div></template>'
},
{
filename: 'test.vue',
code: '<template><div @keydown.b="foo"></div></template>'
},
{
filename: 'test.vue',
code: '<template><div @keydown.a.b.c="foo"></div></template>'
},
{
filename: 'test.vue',
code: '<template><el-from @submit.native.prevent></el-form></template>'
},
{
filename: 'test.vue',
code: '<template><div v-on:click.prevent></div></template>'
},
{
filename: 'test.vue',
code: '<template><div v-on:click.native.stop></div></template>'
},
{
filename: 'test.vue',
code: '<template><div v-on="$listeners"></div></template>'
},
{
filename: 'test.vue',
code: '<template><div v-on="{a, b, c: d}"></div></template>'
}
],
invalid: [
{
filename: 'test.vue',
code: '<template><div v-on:click.aaa="foo"></div></template>',
errors: ["'v-on' directives don't support the modifier 'aaa'."]
},
{
filename: 'test.vue',
code: '<template><div v-on:click></div></template>',
errors: ["'v-on' directives require that attribute value or verb modifiers."]
},
{
filename: 'test.vue',
code: '<template><div @click></div></template>',
errors: ["'v-on' directives require that attribute value or verb modifiers."]
}
]
})