admin管理员组文章数量:1312636
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.
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.
Share Improve this question asked Sep 2, 2020 at 2:16 CYBERSIXCYBERSIX 3771 gold badge7 silver badges21 bronze badges 1-
Why do you have
if (false) {
? Remove that whole block. – CertainPerformance Commented Sep 2, 2020 at 2:17
2 Answers
Reset to default 5If you want the keep the if (false)
for a proper purpose, say debugging, try put the following ment above it to get it to bypass eslint.
/* eslint-disable no-constant-condition */
Make sure you remove this before your code goes to production.
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, ment it out instead of putting in a runtime test:
export default function auth({ next }) {
/*
return next({
name: 'loginPage'
})
*/
return next()
}
本文标签:
版权声明:本文标题:javascript - I get this error Unexpected constant condition no-constant-condition and cant figure our how to pass this , - Stack 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741920054a2404958.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论