Skip to content

Commit 3b77c4e

Browse files
committed
feat: support return statement return nothing
1 parent c082183 commit 3b77c4e

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

lib/rules/no-use-computed-property-like-method.js

+6
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,15 @@ const getValueType = ({ property, propertyMap }) => {
9292
const returnStatement = blockStatement.body.find(
9393
(b) => b.type === 'ReturnStatement'
9494
)
95+
9596
if (!returnStatement || returnStatement.type !== 'ReturnStatement')
9697
return
9798

99+
if (returnStatement.argument === null)
100+
return {
101+
type: 'ReturnStatementHasNotArgument'
102+
}
103+
98104
if (
99105
property.groupName === 'computed' &&
100106
propertyMap &&

tests/lib/rules/no-use-computed-property-like-method.js

+22
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,28 @@ tester.run('no-use-computed-property-like-method', rule, {
662662
errors: [
663663
'Use this.computedReturnObject instead of this.computedReturnObject().'
664664
]
665+
},
666+
{
667+
filename: 'test.vue',
668+
code: `
669+
<script>
670+
export default {
671+
computed: {
672+
computedReturnNothing() {
673+
return
674+
},
675+
},
676+
methods: {
677+
fn() {
678+
this.computedReturnNothing()
679+
}
680+
}
681+
}
682+
</script>
683+
`,
684+
errors: [
685+
'Use this.computedReturnNothing instead of this.computedReturnNothing().'
686+
]
665687
}
666688
]
667689
})

0 commit comments

Comments
 (0)