0

I'm working on a small project but I'm really tired to follow Eslint issues, each time I have to fix a bug since I change my package.json rules, I have another problem now I need your help please :

This is the error that i get :

error  Unnecessary escape character: \+  no-useless-escape

This is my package.json rules :

    "eslintConfig": {
    "root": false,
    "env": {
      "node": true
    },
    "extends": [
      "plugin:vue/essential",
      "eslint:recommended"
    ],
    "parserOptions": {
      "parser": "babel-eslint"
    },
    "rules": {
      "no-unused-vars": "off",
      "@typescript-eslint/no-unused-vars": "off",
      "no-control-regex": 0
    }
   },

This is my code :

    var expression = /[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)?/gi; 
  var regex = new RegExp(expression);
  if(value.match(regex)){
    return true;
  }
Alice Munin
  • 511
  • 2
  • 13
  • still need a help – Alice Munin Feb 14 '21 at 18:55
  • 1
    What else do you need help with? The accepted answer tells you that `\+` doesn‘t need to be escaped; other answers tell you how to disable this rule. See the [rule documentation](https://eslint.org/docs/rules/no-useless-escape) and more context on why this may become a problem: [Why does `/\:/u` throw an “invalid escape” error?](https://stackoverflow.com/a/63007777/4642212). – Sebastian Simon Feb 14 '21 at 18:56
  • 1
    Why do you have `//` in the character class? The duplication is unnecessary. Did you mean ``\\``? – Sebastian Simon Feb 14 '21 at 18:58
  • @SebastianSimon thank you fo your help firstly, i'm not strong in regex i just copied the expression from a website to validate a url – Alice Munin Feb 14 '21 at 18:59
  • @SebastianSimon do you have any suggestion for me :) – Alice Munin Feb 14 '21 at 18:59
  • 1
    I really don’t know what else you need. It’s all explained in the duplicate target and in the other links. Do you know what “[escaping](https://stackoverflow.com/q/37064290/4642212)” means? – Sebastian Simon Feb 14 '21 at 19:03

0 Answers0