Skip to content
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

New: add vue/no-unused-properties rule #871

Closed

Conversation

MisRob
Copy link
Contributor

@MisRob MisRob commented Apr 9, 2019

Hello,

we've implemented vue/no-unused-properties (disallows any unused properties, data and computed properties) as our custom internal rule recently and noticed that there's an accepted rule proposition for this logic already (#631) so we're sharing what we have.

Refs: #631

@MisRob MisRob changed the title New: add vue/no-unused-properties rule (#631) New: add vue/no-unused-properties rule Apr 9, 2019
@MisRob
Copy link
Contributor Author

MisRob commented Apr 23, 2019

Hello, recently we also added properties usage detection when a component instance accessed via a parameter in beforeRouteEnter guard to this rule.

I'm not yet sure if you're interested in this rule and also it's possible that we'll need to add more updates/fixes in the future, so instead of copying it here every time, I'm inserting a link to a location where you can always find up-to-date codes: https://github.com/learningequality/kolibri/tree/develop/packages/eslint-plugin-kolibri.

Also, we have similar rules available for component methods, mapped Vuex state, getters, mutations and actions there.

@jtwaleson
Copy link

We're using eslint-plugin-vue extensively on our code base and would love to have this implemented. Using these rules on our code base of +/- 1 year old, we found about 5% of our props to be unused.

Copy link
Member

@kazupon kazupon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job!
LGTM!

@aberonni
Copy link

Friendly ping - really looking forward to using this, any idea when it will be merged?

@vperron
Copy link

vperron commented Aug 5, 2019

Friendly ping as well !!! I'm extremely looking forward to this being merged !

Copy link
Member

@ota-meshi ota-meshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this PR! I like your idea.
I have some requests.

const scriptVisitor = Object.assign(
{},
{
'MemberExpression[object.type="ThisExpression"][property.type="Identifier"][property.name]' (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you change to support the destructuring assignment?

const {prop} = this

Also could you change to support the track the this?
I want to support assignment expressions as follows:

const vm = this
vm.prop

@rholic-openpath
Copy link

Can someone please make the changes requested? Would love to have this part of eslint!!

@MisRob
Copy link
Contributor Author

MisRob commented Dec 16, 2019

Hi, I had already started working on it and then went on a long sick leave. Right now I need to catch up on other tasks I am responsible for so I think I will get to this rather after Christmas.

@maddocnc
Copy link
Contributor

maddocnc commented Mar 5, 2020

Also interested.
By the way, current rule also can't find unused data property if data defined like this:

data: () => ({
   neverUsed: 'but'
}),

@IWANABETHATGUY
Copy link
Contributor

Can someone please make the changes requested? Would love to have this part of eslint!!

i have wrote a unofficial eslint plugin for no-unused-properties and pass the all official test, maybe you can try it.eslint-plugin-vueunused

@ibarsi
Copy link

ibarsi commented Mar 17, 2020

@MisRob Would you like some support on this PR? My team is looking forward to this rule so I would be happy to help 👍🏼

@MisRob
Copy link
Contributor Author

MisRob commented Mar 18, 2020

@ibarsi Hi thanks a lot. I believe I will eventually get to that though this year has been really busy so far. So if you can resolve @ota-meshi requests sooner than I can get back to it, you are more than welcome to do so. I briefly checked what needs to be done but don't have any codes yet.

@alb3rtuk
Copy link

Guys, our team is also very much in need of this rule. If someone could get this merged I believe a lot of ppl would be very happy :)

@IWANABETHATGUY
Copy link
Contributor

Guys, our team is also very much in need of this rule. If someone could get this merged I believe a lot of ppl would be very happy :)

here is a choice, eslint-plugin-vueunused, the same effect as this pull request , pass all this pr unit test and finish the #871 (comment) feature.

ota-meshi added a commit that referenced this pull request May 21, 2020
* New: add vue/no-unused-properties rule (#631)

* Update

* Updated to trace function calls.

Co-authored-by: Michaela Robosova <robosova.michaela@seznam.cz>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet