vuejs / eslint-plugin-vue

Official ESLint plugin for Vue.js
https://eslint.vuejs.org/
MIT License
4.38k stars 649 forks source link

New Rule: disallow using deprecated `next` argument in `NavigationGuard` #2426

Open roydukkey opened 2 months ago

roydukkey commented 2 months ago

Please describe what the rule should do:

The rule should warn/error when the next argument is used on Vue Router navigation gaurds.

What category should the rule belong to?

[ ] Enforces code style (layout) [ ] Warns about a potential error (problem) [x] Suggests an alternate way of doing something (suggestion) [x] Other: the feature is deprecated

Provide 2-3 code examples that this rule should warn about:

// BAD
router.beforeEach((to, from, next) => {
  if (to.name !== 'Login' && !isAuthenticated) {
    next({ name: 'Login' })
  } else {
    next()
  }
})
// GOOD
router.beforeEach((to) => {
  if (to.name !== 'Login' && !isAuthenticated) {
    return { name: 'Login' };
  }
})

Additional context