@@ -12,15 +12,17 @@ module.exports = api => {
12
12
package : 'eslintConfig'
13
13
} ,
14
14
onRead : ( { data } ) => {
15
+ console . log ( 'rules' , data . rules )
15
16
return {
16
17
prompts : [
17
18
{
18
- name : 'rules.commaDangle ' ,
19
+ name : 'vue/attribute-hyphenation ' ,
19
20
type : 'list' ,
20
- message : 'Trailing commas' ,
21
- description : 'Enforce or disallow trailing commas at the end of the lines' ,
22
- link : 'https://eslint.org/docs/rules/comma-dangle' ,
23
- default : JSON . stringify ( [ 'error' , 'never' ] ) ,
21
+ message : 'Attribute hyphenation' ,
22
+ group : 'Strongly recommended' ,
23
+ description : 'Enforce attribute naming style in template (`my-prop` or `myProp`)' ,
24
+ link : 'https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/attribute-hyphenation.md' ,
25
+ default : JSON . stringify ( 'off' ) ,
24
26
choices : [
25
27
{
26
28
name : 'Off' ,
@@ -33,25 +35,140 @@ module.exports = api => {
33
35
{
34
36
name : 'Always' ,
35
37
value : JSON . stringify ( [ 'error' , 'always' ] )
38
+ }
39
+ ] ,
40
+ value : data . rules && JSON . stringify ( data . rules [ 'vue/attribute-hyphenation' ] )
41
+ } ,
42
+ {
43
+ name : 'vue/html-end-tags' ,
44
+ type : 'confirm' ,
45
+ message : 'Template end tags style' ,
46
+ group : 'Strongly recommended' ,
47
+ description : 'End tag on Void elements, end tags and self-closing opening tags' ,
48
+ link : 'https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/html-end-tags.md' ,
49
+ default : false ,
50
+ value : data . rules && data . rules [ 'vue/html-end-tags' ] === 'error' ,
51
+ filter : input => JSON . stringify ( input ? 'error' : 'off' )
52
+ } ,
53
+ {
54
+ name : 'vue/html-indent' ,
55
+ type : 'list' ,
56
+ message : 'Template indentation' ,
57
+ group : 'Strongly recommended' ,
58
+ description : 'Enforce indentation in template' ,
59
+ link : 'https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/html-indent.md' ,
60
+ default : JSON . stringify ( 'off' ) ,
61
+ choices : [
62
+ {
63
+ name : 'Off' ,
64
+ value : JSON . stringify ( 'off' )
65
+ } ,
66
+ {
67
+ name : 'Tabs' ,
68
+ value : JSON . stringify ( [ 'error' , 'tabs' ] )
69
+ } ,
70
+ {
71
+ name : '2 spaces' ,
72
+ value : JSON . stringify ( [ 'error' , 2 ] )
73
+ } ,
74
+ {
75
+ name : '4 spaces' ,
76
+ value : JSON . stringify ( [ 'error' , 4 ] )
36
77
} ,
37
78
{
38
- name : 'Always on multiline' ,
39
- value : JSON . stringify ( [ 'error' , 'always-multiline' ] )
79
+ name : '8 spaces' ,
80
+ value : JSON . stringify ( [ 'error' , 8 ] )
81
+ }
82
+ ] ,
83
+ value : data . rules && JSON . stringify ( data . rules [ 'vue/html-indent' ] )
84
+ } ,
85
+ {
86
+ name : 'vue/html-self-closing' ,
87
+ type : 'confirm' ,
88
+ message : 'Template tag self-closing style' ,
89
+ group : 'Strongly recommended' ,
90
+ description : 'Self-close any component or non-Void element tags' ,
91
+ link : 'https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/html-self-closing.md' ,
92
+ default : false ,
93
+ value : data . rules && data . rules [ 'vue/html-self-closing' ] === 'error' ,
94
+ filter : input => JSON . stringify ( input ? 'error' : 'off' )
95
+ } ,
96
+ {
97
+ name : 'vue/require-default-prop' ,
98
+ type : 'confirm' ,
99
+ message : 'Require default in required props' ,
100
+ group : 'Strongly recommended' ,
101
+ description : 'This rule requires default value to be set for each props that are not marked as `required`' ,
102
+ link : 'https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/require-default-prop.md' ,
103
+ default : false ,
104
+ value : data . rules && data . rules [ 'vue/require-default-prop' ] === 'error' ,
105
+ filter : input => JSON . stringify ( input ? 'error' : 'off' )
106
+ } ,
107
+ {
108
+ name : 'vue/require-prop-types' ,
109
+ type : 'confirm' ,
110
+ message : 'Require types for props' ,
111
+ group : 'Strongly recommended' ,
112
+ description : 'In committed code, prop definitions should always be as detailed as possible, specifying at least type(s)' ,
113
+ link : 'https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/require-prop-types.md' ,
114
+ default : false ,
115
+ value : data . rules && data . rules [ 'vue/require-prop-types' ] === 'error' ,
116
+ filter : input => JSON . stringify ( input ? 'error' : 'off' )
117
+ } ,
118
+ {
119
+ name : 'vue/attributes-order' ,
120
+ type : 'confirm' ,
121
+ message : 'Attribute order' ,
122
+ group : 'Recommended' ,
123
+ description : 'This rule aims to enforce ordering of component attributes (the default order is specified in the Vue style guide)' ,
124
+ link : 'https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/attributes-order.md' ,
125
+ default : false ,
126
+ value : data . rules && data . rules [ 'vue/attributes-order' ] === 'error' ,
127
+ filter : input => JSON . stringify ( input ? 'error' : 'off' )
128
+ } ,
129
+ {
130
+ name : 'vue/html-quotes' ,
131
+ type : 'list' ,
132
+ message : 'Attribute quote style' ,
133
+ group : 'Recommended' ,
134
+ description : 'Enforce style of the attribute quotes in templates' ,
135
+ link : 'https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/html-quotes.md' ,
136
+ default : JSON . stringify ( 'off' ) ,
137
+ choices : [
138
+ {
139
+ name : 'Off' ,
140
+ value : JSON . stringify ( 'off' )
40
141
} ,
41
142
{
42
- name : 'Only on multiline' ,
43
- value : JSON . stringify ( [ 'error' , 'only-multiline' ] )
143
+ name : 'Double quotes' ,
144
+ value : JSON . stringify ( [ 'error' , 'double' ] )
145
+ } ,
146
+ {
147
+ name : 'Single quotes' ,
148
+ value : JSON . stringify ( [ 'error' , 'single' ] )
44
149
}
45
150
] ,
46
- value : JSON . stringify ( data . rules && data . rules [ 'comma-dangle' ] )
151
+ value : data . rules && JSON . stringify ( data . rules [ 'vue/html-quotes' ] )
152
+ } ,
153
+ {
154
+ name : 'vue/order-in-components' ,
155
+ type : 'confirm' ,
156
+ message : 'Component options order' ,
157
+ group : 'Recommended' ,
158
+ description : 'This rule aims to enforce ordering of component options (the default order is specified in the Vue style guide)' ,
159
+ link : 'https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/order-in-components.md' ,
160
+ default : false ,
161
+ value : data . rules && data . rules [ 'vue/order-in-components' ] === 'error' ,
162
+ filter : input => JSON . stringify ( input ? 'error' : 'off' )
47
163
}
48
164
]
49
165
}
50
166
} ,
51
- onWrite : ( { api } ) => {
52
- api . setData ( {
53
- 'rules.comma-dangle' : api . getAnswer ( 'rules.commaDangle' , JSON . parse )
54
- } )
167
+ onWrite : ( { api, prompts } ) => {
168
+ api . setData ( prompts . reduce ( ( obj , prompt ) => {
169
+ obj [ `rules.${ prompt . id } ` ] = api . getAnswer ( prompt . id , JSON . parse )
170
+ return obj
171
+ } , { } ) )
55
172
}
56
173
} )
57
174
0 commit comments