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

Feature Request: floating call expressions in vue/no-side-effects-in-computed-properties #2542

Open
ylc395 opened this issue Sep 3, 2024 · 2 comments

Comments

@ylc395
Copy link
Contributor

ylc395 commented Sep 3, 2024

What rule do you want to change?
vue/no-side-effects-in-computed-properties

Does this change cause the rule to produce more or fewer warnings?
More warnings

How will the change be implemented? (New option, new default behavior, etc.)?
Add a option to this rule, for example: { noFloatingCall: true }

Please provide some example code that this change will affect:
Examples from here: #97

export default {
  computed: {
    foo () {
      this.$store.commit({}) // Mutations
      this.$store.dispatch('', {}) // Actions
      return true
    },
    bar () {
      this.$router.go(-1)
      this.$router.push({})
      this.$router.replace({})
      return true
    }
  }
}

and composition-api:

const foo = computed(() => {
  callSomething();
});

What does the rule currently do for this code?
Do nothing.

What will the rule do after it's changed?
Report a side-effect-in-computed warning.

Additional context
#58 (comment)
#97

@ylc395 ylc395 changed the title Feature Request: floating call expressions in vue/no-side-effects-in-computed-properties Feature Request: floating call expressions in vue/no-side-effects-in-computed-properties Sep 3, 2024
@ylc395
Copy link
Contributor Author

ylc395 commented Sep 3, 2024

I can commit a PR if this feature request is acceptable.

@FloEdelmann
Copy link
Member

FloEdelmann commented Sep 3, 2024

I actually don't think that an option is required; this should be the rule's default behavior.

All call expressions that are not used in return statements, variable assignments or function parameters are probably side effects and thus should be reported. PR is welcome for that!

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

No branches or pull requests

2 participants