Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

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

Closed

Conversation

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

jtwaleson, chiawendt, aberonni, skjnldsv, and inker reacted with thumbs up emoji
@MisRob MisRob changed the title (削除) New: add vue/no-unused-properties rule (#631) (削除ここまで) (追記) New: add vue/no-unused-properties rule (追記ここまで) Apr 9, 2019
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.

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 reacted with thumbs up emoji
Copy link

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

vperron and Ouradze reacted with thumbs up emoji

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

@ota-meshi ota-meshi Aug 14, 2019

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

Copy link

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

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.

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'
}),

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

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 👍🏼

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.

skjnldsv reacted with heart emoji

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 :)

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
Reviewers

@ota-meshi ota-meshi ota-meshi requested changes

@kazupon kazupon kazupon approved these changes

+1 more reviewer

@chiawendt chiawendt chiawendt approved these changes

Reviewers whose approvals may not affect merge requirements
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /