Scanner command used: SonarCloud plugin for Azure Pipelines
Languages of the repository: js, ts
Error observed
INFO: Sensor JavaScript analysis [javascript]
INFO: Using TypeScript at: '/home/vsts/work/1/s/node_modules'
INFO: 4808 source files to be analyzed
##[error]ERROR: Failed to parse file [packages/client/(...)/ModuleWebinarEditor.vue] at line 91: 'import' and 'export' may appear only with 'sourceType: module'
Steps to reproduce
I have the sonar scan performed through an Azure Pipeline with the plugin.
The scan runs on code containing .js, .ts and .vue files. I’m aware that SonarTS is deprecated and the .ts analysis is now performed by SonarJS, but I don’t understand why it’s trying to analyse my .vue files even though I have specified the extensions and .vue files don’t contain any TS:
In fact we are not running TS analysis on your vue files. Indeed log INFO: Using TypeScript at: .. might be confusing (and I believe based on it you decided that TS analysis is run), but in fact it’s just preparation set up for future TS file analysis.
We use https://www.npmjs.com/package/vue-eslint-parser to parse vue files. We first try with sourceType: 'module' and then with sourceType: 'script' (source code).
So it’s weird we failed to parse with both configs (error message is displayed for script sourceType as last tried).
Could you share the content of this vue file (I only care about script part)?
Seems like these is some code there which can’t be parsed with sourceType: 'module'.
I got your message about babel-eslint as internal parser. Still I can’t reproduce your initial problem.
On my side const Popup = () => import("./Popup.vue"); produces Unexpected token import. Are you sure that’s the line which makes parsing fail with 'import' and 'export' may appear only with 'sourceType: module'?
Hello, @Lena and @kevin-360! I am also facing this issue, but from my testing it looks like this error shows up when our .vue component uses optional chaining. Do you know if there is a solution for this?