@@ -108,6 +108,186 @@ ruleTester.run('prop-name-casing', rule, {
108108 ` ,
109109 options : [ 'snake_case' ] ,
110110 parserOptions
111+ } ,
112+ {
113+ // computed property name
114+ filename : 'test.vue' ,
115+ code : `
116+ export default {
117+ props: {
118+ ['greetingText']: String
119+ }
120+ }
121+ ` ,
122+ parserOptions
123+ } ,
124+ {
125+ // computed property name
126+ filename : 'test.vue' ,
127+ code : `
128+ export default {
129+ props: {
130+ [('greetingText')]: String
131+ }
132+ }
133+ ` ,
134+ parserOptions
135+ } ,
136+ {
137+ // TemplateLiteral computed property does not warn
138+ filename : 'test.vue' ,
139+ code : `
140+ export default {
141+ props: {
142+ [\`greeting-text\`]: String
143+ }
144+ }
145+ ` ,
146+ parserOptions
147+ } ,
148+ {
149+ // TemplateLiteral computed property does not warn
150+ filename : 'test.vue' ,
151+ code : `
152+ export default {
153+ props: {
154+ [\`greeting\${'-'}text\`]: String
155+ }
156+ }
157+ ` ,
158+ parserOptions
159+ } ,
160+ {
161+ // shorthand
162+ filename : 'test.vue' ,
163+ code : `
164+ export default {
165+ props: {
166+ greetingText
167+ }
168+ }
169+ ` ,
170+ parserOptions
171+ } ,
172+ {
173+ // valiable computed property name does not warn
174+ filename : 'test.vue' ,
175+ code : `
176+ export default {
177+ props: {
178+ [greeting_text]: String
179+ }
180+ }
181+ ` ,
182+ parserOptions
183+ } ,
184+ {
185+ // valiable computed property name does not warn
186+ filename : 'test.vue' ,
187+ code : `
188+ export default {
189+ props: {
190+ [greeting.text]: String
191+ }
192+ }
193+ ` ,
194+ parserOptions
195+ } ,
196+ {
197+ // BinaryExpression computed property name does not warn
198+ filename : 'test.vue' ,
199+ code : `
200+ export default {
201+ props: {
202+ ['greeting'+'-text']: String
203+ }
204+ }
205+ ` ,
206+ parserOptions
207+ } ,
208+ {
209+ // CallExpression computed property name does not warn
210+ filename : 'test.vue' ,
211+ code : `
212+ export default {
213+ props: {
214+ [greeting_text()]: String
215+ }
216+ }
217+ ` ,
218+ parserOptions
219+ } ,
220+ {
221+ // ThisExpression computed property name does not warn
222+ filename : 'test.vue' ,
223+ code : `
224+ export default {
225+ props: {
226+ [this]: String
227+ }
228+ }
229+ ` ,
230+ parserOptions
231+ } ,
232+ {
233+ // ArrayExpression computed property name does not warn
234+ filename : 'test.vue' ,
235+ code : `
236+ export default {
237+ props: {
238+ [['greeting-text']]: String
239+ }
240+ }
241+ ` ,
242+ parserOptions
243+ } ,
244+ {
245+ // number Literal computed property name
246+ filename : 'test.vue' ,
247+ code : `
248+ export default {
249+ props: {
250+ [1]: String
251+ }
252+ }
253+ ` ,
254+ parserOptions
255+ } ,
256+ {
257+ // boolean Literal computed property name
258+ filename : 'test.vue' ,
259+ code : `
260+ export default {
261+ props: {
262+ [true]: String
263+ }
264+ }
265+ ` ,
266+ parserOptions
267+ } ,
268+ {
269+ // null Literal computed property name
270+ filename : 'test.vue' ,
271+ code : `
272+ export default {
273+ props: {
274+ [null]: String
275+ }
276+ }
277+ ` ,
278+ parserOptions
279+ } ,
280+ {
281+ // RegExp Literal computed property name
282+ filename : 'test.vue' ,
283+ code : `
284+ export default {
285+ props: {
286+ [/greeting-text/]: String
287+ }
288+ }
289+ ` ,
290+ parserOptions
111291 }
112292 ] ,
113293
@@ -290,25 +470,6 @@ ruleTester.run('prop-name-casing', rule, {
290470 line : 4
291471 } ]
292472 } ,
293- {
294- // valiable computed property name
295- filename : 'test.vue' ,
296- code : `
297- export default {
298- props: {
299- [greeting_text]: String
300- }
301- }
302- ` ,
303- output : null ,
304- parserOptions,
305- errors : [ {
306- // bug ?
307- message : 'Prop "greeting_text" is not in camelCase.' ,
308- type : 'Property' ,
309- line : 4
310- } ]
311- } ,
312473 {
313474 // emoji
314475 filename : 'test.vue' ,
@@ -367,6 +528,24 @@ ruleTester.run('prop-name-casing', rule, {
367528 type : 'Property' ,
368529 line : 4
369530 } ]
531+ } ,
532+ {
533+ // Parentheses computed property name
534+ filename : 'test.vue' ,
535+ code : `
536+ export default {
537+ props: {
538+ [('greeting-text')]: String
539+ }
540+ }
541+ ` ,
542+ output : null ,
543+ parserOptions,
544+ errors : [ {
545+ message : 'Prop "greeting-text" is not in camelCase.' ,
546+ type : 'Property' ,
547+ line : 4
548+ } ]
370549 }
371550 ]
372551} )
0 commit comments