-
-
Notifications
You must be signed in to change notification settings - Fork 681
False negative with vue/no-unused-properties #1462
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Same issue here - Rule configuration"vue/no-unused-properties": ["warn", {
"groups": ["props", "data", "computed", "methods"]
}] Example<template>
<MyComponent @highlight="onHighlight" />
</template>
<script>
export default {
methods: {
// No warning (expected)
onHighlight () { },
// No warning (unexpected)
notused () { }
}
}
</script> |
code like above is hard to static analyze, the
|
I agree—that is why I think _both_ methods should be marked unused, just as
externally called methods are. Then I can manually label the ones I know
I’m using with JSDoc public comments.
…On Sat, 29 May 2021 at 03:27, IWANABETHATGUY ***@***.***> wrote:
<script>
export default {
mounted () {
const handlerName = 'eventHandler'
// Event registration code ommitted, but would end up calling via:
this[handlerName]
},
methods: {
eventHandler () {
// Used
},
notused () {
// should show as error
}
}
}
</script>
code like above is hard to static analyze, the handlerName is runtime
determistic, for example , what if your handlerName is
concatenation during runtime like below.
<script>
export default {
mounted () {
const handlerName = ''
for(let i = 0; i < 5; i++) {
handlerName += 'r';
}
// Event registration code ommitted, but would end up calling via:
this[handlerName]
},
methods: {
rrrrr() {
// Used
},
notused () {
// should show as error
}
}
}
</script>
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1462 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAG33PWS7WCBZTRYCSUN6UTTQBGJZANCNFSM4ZTTKGBA>
.
|
so this should be a feature request instead of a bug, |
Currently, you could use |
I will check out the |
I tried the plugin you mentioned, but (a) I prefer the single underline warning of the method name over the large yellow 'block' highlight (and I couldn't see a way to configure this from the docs), and (b) it specifically does not appear to pick up |
I close this issue because #1636 was suggested to add an option. |
Checklist
Tell us about your environment
Please show your full configuration:
What did you do?
I have a number of components using an event bus, which contain code such as this:
Note that neither of the methods are flagged as unused. One of them would be called via the event handler, but any use of
this[variable]
appears to completely defeat any unused method checking (i.e. all methods are assumed as used).What did you expect to happen?
That any methods not explicitly called would be flagged as unused. Note, this may be the intended behaviour, but I couldn't find anything in the documentation about this use case, or if there was a configuration option for it.
What actually happened?
No output from eslint.
I am using
/** @public */
to mark methods that are called externally, and was hoping that internal methods could be handled in the same way—i.e. that all methods used by this event handling approach would be flagged by eslint as unused, and I would manually label each one that is actually used by the event handling code.The text was updated successfully, but these errors were encountered: