wrap-regex (Rules) – Eslint 中文开发手册

作者: Arvin Chen 分类: JavaScript 来源: Break易站(www.breakyizhan.com)
  •   Eslint 中文开发手册

    wrap-regex (Rules) - Eslint 中文开发手册

    The --fix option on the command line can automatically fix some of the problems reported by this rule.

    When a regular expression is used in certain situations, it can end up looking like a division operator. For example:

    function a() {
        return /foo/.test("bar");
    }

    Rule Details

    This is used to disambiguate the slash operator and facilitates more readable code.

    Example of incorrect code for this rule:

    /*eslint wrap-regex: "error"*/
    
    function a() {
        return /foo/.test("bar");
    }

    Example of correct code for this rule:

    /*eslint wrap-regex: "error"*/
    
    function a() {
        return (/foo/).test("bar");
    }

    Version

    This rule was introduced in ESLint 0.1.0.

    Resources

    Rule sourceDocumentation source

     © JS Foundation and other contributors

    Licensed under the MIT License.

    https://eslint.org/docs/rules/wrap-regex

  •   Eslint 中文开发手册
  •   本文标题:wrap-regex (Rules) – Eslint 中文开发手册 - Break易站
    转载请保留页面地址:https://www.breakyizhan.com/javascript/34630.html
      微信返利机器人
      免费:淘宝,京东,拼多多优惠券
      腾讯,爱奇艺,优酷的VIP视频免费解析,免费看
      即刻扫描二维码,添加微信机器人!

    发表笔记

    电子邮件地址不会被公开。 必填项已用*标注