问题
I've been struggling with VSCode and JSHint to find out a way to get rid of this syntax highlighting. It seems like JSHint is not able to recognise Async/Await syntax.
Here you can find a screenshot of what I'm talking about.
My JSHint version: jshint-esnext v2.7.0-3
回答1:
I had the same issue and this worked for me. Try using npm uninstall -g jshint to completely unistall jshint, then npm install -g jshint to re-install the latest version. Make sure your package.json has the following information in it:
"jshintConfig": { "esversion": 8, "strict": "implied", "devel": true, "node": true, "globals": {} }
回答2:
In visual studio code, JSHint and ESLint cancels each other out. so if you want to use async functions in vscode then you have to disable Jshint and enable eslint instead.
来源:https://stackoverflow.com/questions/46783809/jshint-does-not-recognise-async-await-syntax-in-visual-studio-code-vscode