[Vuejs]-The arguments ' to ' and ' from ' in vue router beforeEach function is not invoked, ESlint give me the warning ' 'to' is defined but never used '

0👍

Probably the easiest and most intuitive way is to set the rule for no-unused-vars to use after-used for args. This is the default though, so you likely did overwrite it somewhere. Using after-used will disable the check on any arguments of a function that occur before the last used argument. With this, the following code would not cause any issues:

router.beforeEach((to, from, next) => {
  NPgrogress.start();
  next();
});

But the following code would (because two is defined, but never used, and you can just omit it from the parameter list.

function a(one, two) {
  console.log(one);
}

Documentation on eslint.org

Leave a comment