Disable Unnecessary escape character: \/ no-useless-escape

前端 未结 4 1784
隐瞒了意图╮
隐瞒了意图╮ 2021-01-31 15:38

I have this regex of mine that will check the string if it contains link or url (i.e. https://eslint.org/docs/rules/no-useless-escape). Using this regex /(\\b

4条回答
  •  失恋的感觉
    2021-01-31 16:00

    \ gives error from below code in my NodeJS typescript project, code editor is VS Code -

    Code -

    if (!(/^[\-0-9a-zA-Z\.\+_]+@[\-0-9a-zA-Z\.\+_]+\.[a-zA-Z]{2,}$/).test(String(req.body.email))) { ... }
    

    Error -

    Unnecessary escape character: \+. (eslintno-useless-escape)
    

    Solution -

    //eslint-disable-next-line
    

    Final code -

    //eslint-disable-next-line
    if (!(/^[\-0-9a-zA-Z\.\+_]+@[\-0-9a-zA-Z\.\+_]+\.[a-zA-Z]{2,}$/).test(String(req.body.email))) { ... }
    

提交回复
热议问题