Skip to content

Commit 8ea98e7

Browse files
authored
Report missing prop types only for assigned arrays and objects (#318)
1 parent 7faf1a4 commit 8ea98e7

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

Diff for: lib/rules/require-prop-types.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ function create (context) {
6464

6565
if (node.value.type === 'ObjectExpression') {
6666
checkProperties(node.value.properties)
67-
} else {
67+
}
68+
69+
if (node.value.type === 'ArrayExpression') {
6870
context.report({
6971
node,
7072
message: 'Props should at least define their types.'

Diff for: tests/lib/rules/require-prop-types.js

+18
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,24 @@ ruleTester.run('require-prop-types', rule, {
6969
}
7070
`,
7171
parserOptions: { ecmaVersion: 6, sourceType: 'module' }
72+
},
73+
{
74+
filename: 'test.vue',
75+
code: `
76+
export default {
77+
props
78+
}
79+
`,
80+
parserOptions: { ecmaVersion: 6, sourceType: 'module' }
81+
},
82+
{
83+
filename: 'test.vue',
84+
code: `
85+
export default {
86+
props: externalProps
87+
}
88+
`,
89+
parserOptions: { ecmaVersion: 6, sourceType: 'module' }
7290
}
7391
],
7492

0 commit comments

Comments
 (0)