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.

Error when upgrading `babel-eslint` to `@babel/eslint-parser`

See original GitHub issue

babel-eslint is used in the latest ember new https://github.com/ember-cli/ember-new-output/blob/v3.23.0-beta.2/package.json#L27, however, it has moved:

https://babeljs.io/blog/2020/07/13/the-state-of-babel-eslint

module.exports = {
---  parser: "babel-eslint",
+++  parser: "@babel/eslint-parser"
    plugins: [
---   "babel"
+++   "@babel
    ]
};

When I try to replace the default babel-eslint, this error is thrown:

/home/travis/build/xg-wang/test--babel-eslint-parser/.eslintrc.js
  0:0  error  Parsing error: No Babel config file detected for /home/travis/build/xg-wang/test--babel-eslint-parser/.eslintrc.js. Either disable config file checking with requireConfigFile: false, or configure Babel so that it can find the config files

repro: https://github.com/xg-wang/test--babel-eslint-parser/commit/5b7df2998811a0dc213bf6f50d95a53cd43c2dff

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:14
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

98reactions
rwjbluecommented, Nov 17, 2020

You have to set the config flag requireConfigFile:

module.exports = {
  parser: '@babel/eslint',
  parserOptions: {
    requireConfigFile: false,
  },
  // ...snip...
}

I’d love a PR to the ember-cli blueprint to update to latest for folks if you have the time (no worries if not though!).

12reactions
frostyandy2kcommented, Aug 16, 2021

I got it running worked after spending some time trying out different options. Hope this helps anyone else getting stuck.

.eslintrc.json (in root project folder):

{
    "env": {
        "browser": true,
        "es2021": true,
        "jest/globals": true
    },
    "extends": [
        "standard",
        "plugin:jest/all"
    ],
    "parser": "@babel/eslint-parser",
    "parserOptions": {
        "ecmaVersion": 12,
        "sourceType": "module"
    },
    "rules": {
        "jest/no-hooks": [
            "error",
            {
                "allow": [
                    "afterEach",
                    "beforeEach"
                ]
            }
        ]
    },
    "plugins": [
        "jest"
    ]
}

Empty .babelrc (in root project folder):

{}

.package.json (in root project folder):

{
  "scripts": {
    "test": "jest",
    "lint": "npx eslint --format=table .",
    "lintfix": "npx eslint --fix ."
  },
  "devDependencies": {
    "@babel/core": "^7.15.0",
    "@babel/eslint-parser": "^7.15.0",
    "aws-sdk-mock": "^5.2.1",
    "eslint": "^7.32.0",
    "eslint-config-standard": "^16.0.3",
    "eslint-plugin-import": "^2.24.0",
    "eslint-plugin-jest": "^24.4.0",
    "eslint-plugin-node": "^11.1.0",
    "eslint-plugin-promise": "^5.1.0",
    "jest": "^27.0.6"
  }
}

VS Code settings.xml (editor configuration: enables auto fix on save + babel parser):

    "eslint.alwaysShowStatus": true,
    "eslint.format.enable": true,
    "eslint.lintTask.enable": true,
    "eslint.options": {
        "parser": "@babel/eslint-parser"
    },
    "editor.codeActionsOnSave": {
        "source.fixAll.eslint": true
    },
    "eslint.validate": [
        "javascript"
    ]
Read more comments on GitHub >

github_iconTop Results From Across the Web

Updating babel-eslint to @babel/eslint-parser for React apps
As of March 2020, babel-eslint has been deprecated, and is now @babel/eslint-parser . That doesn't stop it (as of March 2021) being ...
Read more >
@babel/eslint-parser - npm
If you have an issue, please first check if it can be reproduced with the default parser and with the latest versions of...
Read more >
Problem with babel-esLint: Parsing error: require() of ES Module
This is probably happening because you, like me, were using the old babel parser. Package babel-eslint has been deprecated since March of ...
Read more >
Switching from babel-eslint to @babel-eslint - Schalk Neethling
Parsing error : No Babel config file detected for [file].js. Either disable config file checking with requireConfigFile: false, or configure Babel so that...
Read more >
ESLint: Parsing error: No Babel config file detected ... - YouTrack
Hello,. Since moving from the deprecated babel-eslint to the recommended @babel/eslint-parser my colleagues using WebStorm and IntelliJ IDEA started getting ...
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