Skip to content
Advertisement

I get this error Unexpected constant condition no-constant-condition and cant figure our how to pass this ,

I have this simple middleware but i keep getting this error

    export default function auth({ next }) {
    
        if (false) {
            return next({
                name: 'loginPage'
            })
        }
    
        return next()

}

any help would be appreciated.

Advertisement

Answer

That’s a linter warning, telling you that the block:

if (false) {

will never be entered (or will always be entered), so there’s no point to it.

Either remove the block entirely:

export default function auth({ next }) {
  return next();
}

If you’re planning to add stuff to the block later, comment it out instead of putting in a runtime test:

export default function auth({ next }) {
  /*
  return next({
    name: 'loginPage'
  })
  */
  return next()
}
Advertisement