eslint: Error while running ESLint: Invalid regular expression flags
Tell us about your environment
- ESLint Version: 6.6.0
- Node Version: 12.13.0
- npm Version: 6.12.0
What parser (default, Babel-ESLint, etc.) are you using? default
Please show your full configuration:
Configuration
env:
browser: true
es6: true
node: true
extends:
- standard
globals:
Atomics: readonly
SharedArrayBuffer: readonly
parserOptions:
ecmaFeatures:
jsx: true
ecmaVersion: 2018
sourceType: module
plugins:
- react
rules: {}
What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
Creating any *.js
file trigger the error. My linter in Atom report the following
What did you expect to happen? No linter error flag when a JS file is created
What actually happened? Please include the actual, raw output from ESLint.
Error while running ESLint: Invalid regular expression flags
Invalid regular expression flags
Referenced from: /Users/me/dev/.eslintrc.yml
/Users/me/dev/node_modules/eslint/lib/source-code/source-code.js:426
return /\s/u.test(text.replace(/\/\*.*?\*\//gus, ""));
^
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 11
- Comments: 23 (7 by maintainers)
The related
lint-eslint
plugin issue is at https://github.com/AtomLinter/linter-eslint/issues/1306 . This led me to update Atom to version 1.42, which fixed the problem.I think that I know how to solve the issue, at least with WebStorm it works. It looks like Webstorm grabs on startup default Node/NPM version. If you manage multiple Node/NPM versions by nvm and the default one is
v8.9.1
like in my scenario it won’t work.To fix it you need to go to:
Webstorm -> Preferences -> Languages and Frameworks -> Node.js and NPM
and select correctNode interpreters
, see screenshot below:See also: #12493. Please re-check node version used.
Same issue, using Node v12.8.0. Works fine with
npx eslint *.js
, but there’s an error loading eslint in Atom. But downgrading to eslint@6.5.0 makes Atom work fine.Same here:
I have the same issue when I used create-react-app and opened the app in Atom. The difference is I have an error flag (Error while running ESLint: Invalid regular expression flags) on the first line of every file even if it is empty. The program will run fine but the ugly error is there. What I’ve tried: I updated to Node 12 and it didn’t work. I have another react app I had been working on for a year now that had an older version of ESlint so I decided to downgrade it and see if that would fix it since my old app had no such error. In doing so I got an error telling me I can not manually downgrade when using create-react-app so I had to remove and reinstall the package-lock.json and node modules to make it whole again. I tried using ESlint ignore line but no luck. I don’t want the eyesore and I can’t seem to be able to fix it. If anyone has a solution, hmu.
I have the same issue with Node v12.13.0 using Webstorm
Correct, I’m using Node v12.13.0 through nvm
In the v4.19.1, I experienced the same error from the file and line at /lib/source-code/source-code.js:426
The return statement of the function isSpaceBetweenTokens on the return line the following code
return /\s/u.test(text.replace(/\/\*.*?\*\//gus, ""));
should bereturn /\s/u.test(text.replace(/\/\*.*?\*\//, "gus"));
This solved the problem for me but the function in the most recent src seems to be depreciated.