question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Invalid regular expression flags catch on no-octal-escape rule

See original GitHub issue

Tell us about your environment

  • ESLint Version: 6.7.1
  • Node Version: 10.16.3
  • npm Version: 6.12.1

What parser (default, Babel-ESLint, etc.) are you using? babel-eslint

Please show your full configuration:

Configuration
{
  "extends": ["airbnb", "prettier"],
  "parser": "babel-eslint",
  "env": {
    "jest": true,
    "browser": true
  },
  "rules": {
    "no-restricted-syntax": ["error", "LabeledStatement", "WithStatement"],
    "no-console": "off",
    "react/prop-types": "off",
    "react/destructuring-assignment": "off",
    "react/jsx-filename-extension": "off",
    "no-param-reassign": "off",
    "spaced-comment": "off",
    "no-nested-ternary": "off",
    "no-return-assign": "off",
    "no-else-return": "off"
  }
}

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

Linter is catching an invalid regular expressions error in the no-octal-escape rule file. Changing the regular expression flags to /u seems to fix the issue.

What did you expect to happen?

ESLint to operate as usual

What actually happened? Please include the actual, raw output from ESLint. image

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
trevjnelscommented, Jan 3, 2020

Howdy - know this has been closed - but if anyone is experiencing this error in prettier-atom a simple update to atom fixed it. I was running 1.3.something

1reaction
nkas17commented, Dec 2, 2019

I am also seeing this exact error in VSCode when using the extension - https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint

Changing the regular expression flags to /u seems to fix the issue for me as well

  • ESLint Version: 6.7.2
  • Node Version: 10.15.0
  • npm Version: 6.10.0
[Info  - 1:43:07 PM] ESLint server stopped.
[Info  - 1:43:10 PM] ESLint server running in node v8.9.3
[Info  - 1:43:10 PM] ESLint server is running.
[Info  - 1:43:19 PM] ESLint library loaded from: c:\Users\E008950\desktop\projects\personal\quick-start\node_modules\eslint\lib\api.js
[Error - 1:43:23 PM] ESLint stack trace:
[Error - 1:43:23 PM] c:\Users\E008950\desktop\projects\personal\quick-start\node_modules\eslint\lib\rules\no-octal-escape.js:41
                    /^(?:[^\\]|\\.)*?\\([0-3][0-7]{1,2}|[4-7][0-7]|0(?=[89])|[1-7])/us
                    ^

SyntaxError: Invalid regular expression flags
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:606:28)
    at Object.Module._extensions..js (module.js:653:10)
    at Module.load (module.js:561:32)
    at tryModuleLoad (module.js:504:12)
    at Function.Module._load (module.js:496:3)
    at Module.require (module.js:586:17)
    at require (internal/module.js:11:18)
    at no-octal-escape (c:\Users\E008950\desktop\projects\personal\quick-start\node_modules\eslint\lib\rules\index.js:171:30)
Read more comments on GitHub >

github_iconTop Results From Across the Web

SyntaxError: invalid regular expression flag "x" - MDN Web Docs
The JavaScript exception "invalid regular expression flag" occurs when the flags in a regular expression contain any flag that is not one ...
Read more >
Error while running ESLint: Invalid regular expression flags
I went to node_modules/eslint/lib/rules/no-octal-escape.js and replaced the line in the screen shot with: /^(?:[^\\]|\\.)*?
Read more >
disallow invalid regular expression strings in RegExp ...
This rule disallows invalid regular expression strings in RegExp constructors. ... ECMAScript 6 adds the following flag arguments to the RegExp constructor:.
Read more >
SyntaxError: invalid regular expression flag "x"
They can also be defined in the constructor function of the RegExp object (second parameter). Regular expression flags can be used separately or ......
Read more >
在使用vue-cli脚手架工具进行项目搭建时,按照官方教程完成 ...
[89])|[1-7])/su ^ SyntaxError: Invalid regular expression flags at ... F:\test\node_modules\eslint\lib\rules\no-octal-escape.js:41 /$(?
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found