In my typescript file I want to use regular expression that includes conditional expression but my IDE underscores the part of RegEx with conditional expression reporting:"Conditionals are not supported in this regex dialect". How can I enable dialect that supports conditional regular expressions?
export const phoneRegEx = /^\+?\d*\s?\(?(?(?<=\()\d+\)\s?\d+(-|\s|\.)?(?:\1?\d)*|(\.|\s|-)?(\2?\d)*)$/g;
my package.json file:
{
"private": true,
"scripts": {
"dev": "npm run development",
"development": "mix",
"watch": "mix watch",
"watch-poll": "mix watch -- --watch-options-poll=1000",
"hot": "mix watch --hot",
"prod": "npm run production",
"production": "mix --production"
},
"devDependencies": {
"@babel/preset-react": "^7.13.13",
"@tsconfig/create-react-app": "^1.0.2",
"@types/js-cookie": "^2.2.6",
"@types/react-router-dom": "^5.1.7",
"@typescript-eslint/eslint-plugin": "^4.26.1",
"@typescript-eslint/parser": "^4.26.1",
"axios": "^0.21",
"eslint": "^7.28.0",
"eslint-plugin-react": "^7.24.0",
"eslint-plugin-react-hooks": "^4.2.0",
"file-loader": "^6.2.0",
"laravel-mix": "^6.0.6",
"lodash": "^4.17.19",
"postcss": "^8.1.14",
"ts-loader": "^9.2.3",
"typescript": "^4.3.2"
},
"dependencies": {
"@hookform/resolvers": "^2.5.2",
"@material-ui/core": "^4.11.4",
"@material-ui/icons": "^4.11.2",
"js-cookie": "^2.2.1",
"react-hook-form": "^7.8.3",
"react-paginate": "^7.1.3",
"react-router-dom": "^5.2.0",
"yup": "^0.32.9"
}
}
my tsconfig.json file:
{
"extends": "@tsconfig/create-react-app/tsconfig.json",
"compilerOptions": {
// "module": "CommonJS",
"target": "ES2020",
"sourceMap": true,
"jsx": "react",
"noEmit": false
},
"exclude": ["node_modules"],
"include": ["resources", "index.d.ts"]
}
my .eslintrc.json file:
{
"env": {
"browser": true,
"es2020": true
},
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 2020,
"sourceType": "module",
"project": "./tsconfig.json"
// "tsconfigRootDir": "./resources"
},
"plugins": [
"react",
"@typescript-eslint",
"react-hooks"
],
"rules": {
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn"
}
}