Hello,
I have the error: Parsing error: Unexpected character '@'. I am not sure what is wrong.
the code is:
import ui from 'redux-ui';
@ui({})
my configuration is:
{
"parser": "babel-eslint",
"extends": ["eslint:recommended", "plugin:react/recommended"],
"env": {
"es6": true,
"browser": true,
"node": true
},
"plugins": ["react"],
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"modules": true,
"jsx": true
}
},
"rules": {
"eqeqeq": [2, "allow-null"],
"jsx-quotes": 2,
"react/display-name": 2,
"react/jsx-curly-spacing": [2, "never"],
"react/self-closing-comp": 2,
"react/jsx-indent-props": [2, 2],
"react/jsx-no-duplicate-props": 2,
"no-console":0,
"strict": 0
}
}
I am using this plugins and presets:
presets: ["es2015", "react", "stage-0"],
"plugins": ["babel-plugin-transform-decorators-legacy", "transform-runtime"]
i seem to be experiencing similar, but it seemed to have cropped up recently...
yes is recently the error for me.
It's probably the same as https://github.com/babel/babel-eslint/issues/311, etc.
There is currently a regression in ESLint 2.10.0. Pin to ESLint 2.9.x for now until there's a bug fix (or try 2.10.1)
eslint 2.9.0 works!
eslint 2.10.1 doesn't work.
pinning to eslint 2.9.0 didn't help me...
in my case, npm run lint works, but npm run build-dev doesn't work 馃槩
"scripts": {
"build-dev": "webpack --config webpack/webpack.dev.config.js",
"lint": "eslint --ext .js --ext .jsx app"
},
so must be something around webpack, it seems like babel-eslint isn't running at all because i'm getting errors on async, decorators and class-vars (in both jsx and js files alike fwiw):
34:16 error Parsing error: Unexpected token =
15:1 error Parsing error: Unexpected character '@'
6:8 error Parsing error: Unexpected token async
here is a relevant snippets from relevant files (edited for brevity) (i also tried with both node 5.8.0 and 6.1.0, but same)...
module.exports = {
extends: 'eslint:recommended',
parser: 'babel-eslint',
env: {
es6: true,
browser: true,
node: true
},
parserOptions: {
ecmaVersion: 7,
sourceType: 'module',
ecmaFeatures: {
jsx: true,
experimentalObjectRestSpread: true
}
}
}
"devDependencies": {
"babel-cli": "^6.8.0",
"babel-core": "^6.8.0",
"babel-eslint": "^6.0.4",
"babel-loader": "^6.2.4",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-preset-es2015": "^6.6.0",
"babel-preset-es2015-native-modules": "^6.6.0",
"babel-preset-react": "^6.5.0",
"babel-preset-stage-0": "^6.5.0",
"eslint": "^2.9.0",
"eslint-loader": "^1.3.0",
"eslint-plugin-react": "^5.0.1",
"webpack": "^1.13.0"
},
module.exports = {
resolve: {
extensions: ['', '.js', '.jsx'],
alias: {
underscore: 'lodash'
}
},
module: {
preLoaders: [
{
test: /\.jsx?$/,
loader: 'eslint-loader',
exclude: /node_modules/
}
],
loaders: [
{
test: /\.jsx?$/,
loader: 'babel-loader',
exclude: /node_modules/,
query: {
presets: [
'es2015',
'stage-0',
'react'
],
plugins: [
'transform-decorators-legacy'
]
}
}
]
},
eslint: {
test: /\.jsx?$/,
loaders: ['eslint-loader'],
exclude: /node_modules/
}
}
can anyone spot anything fishy or different about my setup than a working one...?
I get the same with 2.10.1. Not sure what is wrong.
Anyone that has a fix for this.
It seems to work in eslint 2.9.0
It works on eslint 2.9.0 like I mentioned above because there was a commit in ESLint 2.10.0 that removed the parser option and thus ran eslint with the default parser even if you were using babel-eslint - so just pin to 2.9.0 until there's a fix that works for you.
eslint 2.10.2 just magically appeared and it seems to have resolved my issue (knock-on-wood)... :metal:
Not magic 馃槃 - https://github.com/eslint/eslint/commit/bda5de56d13e5aea3857dd9c78d2edde59d3dffa, but great.
Facing same issue on 7.1.1. Any workaround?
same 6.1.2/7.1.1
this combination seems to work for me (edited out packages i don't think are relevant), not sure how it might differ from the setups of failing combinations:
package.json:
"devDependencies": {
"babel-cli": "^6.22.2",
"babel-eslint": "^7.1.1",
"babel-loader": "^6.2.10",
"babel-plugin-transform-class-properties": "^6.22.0",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-object-rest-spread": "^6.22.0",
"babel-preset-env": "^1.1.8",
"babel-preset-react": "^6.22.0",
"eslint-config-xo-react": "^0.10.0",
"eslint-plugin-react": "^6.9.0",
"html-webpack-plugin": "^2.28.0",
"webpack": "^1.14.0",
"webpack-dev-server": "^1.16.3"
},
.babelrc:
{
"presets": [
"react",
[
"env",
{
"debug": false
}
]
],
"plugins": [
"transform-decorators-legacy",
"transform-class-properties",
[
"transform-object-rest-spread",
{
"useBuiltIns": true
}
]
]
}
tried every combination without luck...
Getting this error with [email protected]
@forrest-akin have you been able to find a workaround?
Any updates to this??
Most helpful comment
Getting this error with [email protected]