Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eslint Error: Parsing error: Unexpected character '@' #13502

Closed
MurlinGao opened this issue Jul 18, 2020 · 2 comments
Closed

Eslint Error: Parsing error: Unexpected character '@' #13502

MurlinGao opened this issue Jul 18, 2020 · 2 comments
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion question This issue asks a question about ESLint

Comments

@MurlinGao
Copy link

I want use decorators in my react project and there is an error just show out.I had read a lot of docs for this, but it's not help.This has been bothering me for a long time., please help me.

My project used: create-react-app + craco + eslint.

There is some configs in my files:

package.json:

{
  "name": "xxx",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@craco/craco": "^5.6.4",
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.3.2",
    "@testing-library/user-event": "^7.1.2",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-scripts": "3.4.1"
  },
  "scripts": {
    "start": "craco start",
    "build": "craco build",
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "@babel/plugin-proposal-decorators": "^7.10.5",
    "@babel/plugin-proposal-nullish-coalescing-operator": "^7.10.4",
    "@babel/plugin-proposal-optional-chaining": "^7.10.4",
    "@babel/plugin-transform-regenerator": "^7.10.4",
    "@babel/plugin-transform-runtime": "^7.10.5",
    "@commitlint/cli": "^8.1.0",
    "babel-eslint": "10.1.0",
    "cz-conventional-changelog": "^2.1.0",
    "eslint-config-airbnb": "^18.2.0",
    "eslint-plugin-import": "^2.22.0",
    "eslint-plugin-jsx-a11y": "^6.3.1",
    "eslint-plugin-react": "^7.20.3"
  }
}

craco.config.js:

eslint: {
    enable: true /* (default value) */,
    mode: 'file',
  },
  babel: {
    // presets: ['react-app'],
    plugins: [
      '@babel/plugin-transform-runtime',
      [
        '@babel/plugin-proposal-decorators',
        {
          'legacy': true
        }
      ],
      '@babel/plugin-transform-regenerator',
      '@babel/plugin-proposal-optional-chaining',
      '@babel/plugin-proposal-nullish-coalescing-operator'
    ],
  },

.eslintrc.js:

module.exports = {
  root: true,
  env: {
    'es6': true,
    'browser': true,
    'commonjs': true
  },

  extends: ['airbnb', 'react-app'],
  globals: {
    Babel: true,
    React: true
  },
  parserOptions: {
    ecmaVersion: 2020,
    parser: 'babel-eslint',
    sourceType: 'module'
  },

};

@eslint-deprecated eslint-deprecated bot added the triage An ESLint team member will look at this issue soon label Jul 18, 2020
@mdjermanovic
Copy link
Member

Hi @MurlinGao, thanks for the issue!

parserOptions: {
ecmaVersion: 2020,
parser: 'babel-eslint',
sourceType: 'module'
},

parser is a top-level property in the configuration. It should be:

parser: 'babel-eslint',
parserOptions: {
    ecmaVersion: 2020,
    sourceType: 'module'
}

@kaicataldo kaicataldo added question This issue asks a question about ESLint and removed triage An ESLint team member will look at this issue soon labels Jul 18, 2020
@nzakas
Copy link
Member

nzakas commented Aug 10, 2020

Questions has been answered, so closing.

@nzakas nzakas closed this as completed Aug 10, 2020
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 7, 2021
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Feb 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion question This issue asks a question about ESLint
Projects
None yet
Development

No branches or pull requests

4 participants