Skip to content

Commit 789a2fc

Browse files
committed
Add more tests and fix edge case scenario
1 parent 17d8c2b commit 789a2fc

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

lib/rules/prop-name-casing.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ function create (context) {
2525
const node = obj.properties.find(p =>
2626
p.type === 'Property' &&
2727
p.key.type === 'Identifier' &&
28-
p.key.name === 'props'
28+
p.key.name === 'props' &&
29+
(p.value.type === 'ObjectExpression' || p.value.type === 'ArrayExpression')
2930
)
31+
3032
if (!node) return
3133

3234
const items = node.value.type === 'ObjectExpression' ? node.value.properties : node.value.elements

tests/lib/rules/prop-name-casing.js

+20
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,26 @@ ruleTester.run('prop-name-casing', rule, {
3434
`,
3535
parserOptions
3636
},
37+
{
38+
filename: 'test.vue',
39+
code: `
40+
export default {
41+
props: some_props
42+
}
43+
`,
44+
parserOptions
45+
},
46+
{
47+
filename: 'test.vue',
48+
code: `
49+
export default {
50+
props: {
51+
...some_props,
52+
}
53+
}
54+
`,
55+
parserOptions
56+
},
3757
{
3858
filename: 'test.vue',
3959
code: `

0 commit comments

Comments
 (0)