standard: [standard] Parsing error: Unexpected token =
What version of standard? 11.0.1
What operating system, Node.js, and npm version? OSX 6.1.0 10.3.0
What did you expect to happen? standard --fix to fix arrow functions.
What actually happened? Get a parsing error on arrow functions and standard --fix does not fix them.

All other rules appear to format ok
standard configs in package.json
"standard": {
"parser": "babel-eslint",
"ignore": [
"src/utils/epubjs/**/*.js"
],
"globals": [
"jest",
"expect",
"test",
"describe",
"it",
"beforeEach",
"beforeAll",
"afterAll",
"shallow",
"snapshot",
"localStorage",
"FileReader",
"FormData",
"location",
"all",
"history",
"mount"
]
}
devDeps
"babel-eslint": "^8.2.6",
"babel-jest": "22.4.3",
"babel-loader": "7.1.4",
"babel-plugin-react-component-data-attribute": "^0.5.0",
"babel-plugin-syntax-async-functions": "^6.13.0",
"babel-plugin-syntax-dynamic-import": "^6.18.0",
"babel-plugin-transform-async-to-generator": "6.24.1",
"babel-plugin-transform-class-properties": "6.24.1",
"babel-plugin-transform-do-expressions": "^6.22.0",
"babel-plugin-transform-export-extensions": "^6.22.0",
"babel-plugin-transform-function-bind": "^6.22.0",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-plugin-transform-react-jsx": "^6.24.1",
"babel-plugin-transform-regenerator": "^6.26.0",
babelrc
"presets": [
["env"]
],
"plugins": [
"transform-class-properties",
"transform-decorators",
"transform-react-constant-elements",
"transform-react-inline-elements",
"transform-object-rest-spread",
"transform-function-bind",
"transform-do-expressions",
"transform-react-jsx",
"transform-export-extensions",
"syntax-dynamic-import",
"syntax-async-functions",
"transform-regenerator"
]
}
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 29
- Comments: 33 (5 by maintainers)
I solved the problem by adding these three lines on my
package.jsonsame issue randomly where the first ‘=’ of a file is marked as an invalid token. it’s completely without pattern, and only in about 1/100 files, and doesn’t seem to have any effect. in this example, it’s state… but if i remove that statement, it automatically marks the next = as being the invalid token… doesn’t matter what statement or type of code i place there, if it sees an = sign in absolutely any conceivable code i put there, it marks it invalid.
It appears to be something to do with class level assignments (perhaps tied to React). It happens for me with both:
In any case, it’s the first
=/within the class/ – other equal signs either outside of the class or in other functions are fine.Is there any update? I’m still having this issue.
Seeing the same issue when writing this (including in the online demo):
I’m also having this issue with the latest Create React App boilerplate. Usually adding
"parser": "babel-eslint"would fix it.😕
time traveler here from 2021! i’m so grateful!
@linxuyalun myself and many other future travelers thank you profusely.
@ThomasGoehringer What do you mean by “doesn’t work”? I cloned the repo you linked to, ran
npm install(which installs v12.0.1), and then added a “lint” script to package.json like this:And it worked just fine, outputting the following errors:
When upgrading to v13.0.1, it also works just fine.
Perhaps you have an old version of
standardwhich is installed globally that you are running instead of the up-to-date local copy? Can you try runningsudo npm rm standard --globalto remove the global copy (if one exists)?Then run add a script to
package.json, like I did, and run it withnpm run <script-name>No there shouldn’t be anything else required… but like I said I’m also having this issue, I think it’s a conflict with Create-React-App.