vscode-standard: Extension doesn't load babel config files with babel-eslint

What version of this package are you using? 1.2.3 What operating system, Node.js, and npm version? W10, 12.7.0, 6.10.0 What happened? Doesn’t load babel config when using babel-eslint Parsing error: No Babel config file detected for filename image

What did you expect to happen? Parsing works in terminal using standard and it should in vscode as well.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 2
  • Comments: 21 (3 by maintainers)

Commits related to this issue

Most upvoted comments

@marcinczenko The solution for me (I’m using a monorepo) was to specify the path to the root babel.config.json:

.eslintrc.js

const path = require('path')

module.exports = {
  root: true,
  parser: '@babel/eslint-parser',
  parserOptions: {
    sourceType: 'module',
    babelOptions: {
      configFile: path.join(__dirname, 'babel.config.json')
    }
  },
  ...
}

For me what did the trick was to add the path of the project I want to lint to eslint.workingDirectories in .vscode/settings.json of the root of the workspace. EDIT: This fix was for vscode-eslint, not vscode-standard (wrong repo)

For others looking for the same problem: When working with mono-repos and different babelrc files in your packages, this also happens with the newer @babel/eslint-parser, and is by design:

https://babeljs.io/docs/en/config-files#root-babelconfigjson-file

Your project now needs a root-level babel.config.js file or similar, with an added babelrcRoots property.

On 10.0.3, this step wasn’t required…

I got this same parsing error because I mistakenly opened a parent directory, with directories inside, each using its own Babel configuration. The solution was just to create a new workspace and then add the folders to the workspace. VSCode then knows to keep the configurations separate. An obvious oversight on my part, but just thought I’d share in case anyone else tried doing the same thing 😅

Okay, the fix is released in version 1.5.1 of the extension. Please make sure you’re using the new extension (https://marketplace.visualstudio.com/items?itemName=standard.vscode-standard) and not the old one. (We changed the owner organization to standard, so you’ll need to reinstall.

I believe I’ve fixed this issue with this PR: https://github.com/standard/vscode-standard/pull/207

If you’re using standard or standardx, etc. with @babel/eslint-parser you’re babel.config.js or babelrc.js file should be automatically detected with that PR.

If you’re using standard with @babel/eslint-parser but don’t have a custom babel config, you’ll still need to add a dummy babel.config.js file since that’s now required by @babel/eslint-parser.

@Divlo can you review and release this as soon as you get the chance?

There is no standard without using eslint https://github.com/standard/standard/blob/master/package.json#L17

I am sorry, I do not understand what you want to say. It is (kind of) obvious that standard uses eslint under the hood. So, do you want to say that using .eslintrc.js with standard is something you would recommend? How does it match the No Configuration principle from https://standardjs.com/#why-should-i-use-javascript-standard-style? Or, did I get everything wrong.

Anyway, as indicated, everything works just fine (and I believe as intended) without .eslintrc.js when used outside of the vscode. It also works good (even with vscode) when using babel-eslint as the parser. Thus, it looks like there is something happening on the interface between @babel/eslint-parser and vscode-standard.

It would be nice to know what makes it hard to fix the problem. Is it difficult to replicate? Is it a low priority issue? The solution is blocked by @babel/eslint-parser?

For me what did the trick was to add the path of the project I want to lint to eslint.workingDirectories in .vscode/settings.json of the root of the workspace. EDIT: This fix was for vscode-eslint, not vscode-standard (wrong repo)

adding the below snippet in the workspace settings worked for me

“eslint.workingDirectories”: [ “put your .eslintrc relative path here” ]

Whoops, my bad. I got the same error but apparently I’m in the wrong github project here because I’m not using vscode-standard

I don’t know if it is related but you should not use babel-eslint, instead you should use @babel/eslint-parser. See: standard/standard#1601

That does not seem to work for me. I checked it in a monorepo and in a “simple” flat project with one package.json and onebabel.config.js in the root. Works from command line, but fails in VSCode.

I don’t know if it is related but you should not use babel-eslint, instead you should use @babel/eslint-parser. See: https://github.com/standard/standard/issues/1601

One way i got it working is by using a lower version of babel-eslint package. I was on the below version which was causing this issue :- "babel-eslint": "^11.0.0-beta.2"

But once i installed ver 10.0.3, this issue got resolved.