-
-
Notifications
You must be signed in to change notification settings - Fork 669
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
Add Vuex support to vue/no-unused-properties
#2276
Conversation
The issue was created on October 22, 2021, but I am unable to find a way to check Vuex map methods today. To refactor my personal project, I am adding checks now. Maybe it would be useful to you |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the late review. Thanks for your pull request! I have some comments, see below.
vue/no-unused-properties
- reduce duplicated code - improve error message - remove duplicated test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some suggestions. Please try them out locally and see if there are any type errors now.
- add jsdoc - reuse code from utils
Done. No type errors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me 🙂
It is worth mentioning that Pinia also provides For reference, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thank you! Sorry for the late review.
@fuale Thanks for this! Would it be easy to also add support for Pinia |
I'm afraid that's not possible, since the name of the resulting properties can't be easily deduced. |
@FloEdelmann allright, thanks! |
I really appreciate this feature, thanks @fuale ! While using I found a edge case, Im using Nuxt 2 and mapping a Pinia action to my page but this action is called with a methods: {
...mapActions(useStatementStore, {
resetStatement: '$reset'
}),
},
...
beforeRouteEnter (to, from, next) {
next(vm => vm.resetStatement())
} I keep receiving the error |
@luizotcarvalho please create a new issue following the bug template, so this can be addressed properly. |
I've upgraded the Here is my
// .eslintrc.js
module.exports = {
...
parser: "vue-eslint-parser",
parserOptions: {
parser: '@babel/eslint-parser',
},
env: {
browser: true,
},
extends: [
'plugin:vue/recommended',
'airbnb-base'
],
plugins: [
'vue',
'import',
'import-helpers'
],
rules: {
...,
"vue/no-unused-properties": ["error", {
"groups": [
'props',
'computed',
'data',
'methods',
],
"deepData": true,
}]
} |
Please open a new issue with your exact setup and sample code. But before that, please try upgrading your ESLint version, you're a major version behind there. |
OK, Thanks |
Changes are aimed at improving Vuex support.
Following Vuex methods will be checked:
mapGetters
,mapState
,mapActions
,mapMutations
, whenno-unused-properties
will be enabledexample:
Changes will affect #1675 (Vuex and Pinia support)