ESlint Import doesnt work because of invalid JSON syntax

Hey!
I tried to include EsLint reports to my Sonarcloud Reports.

According to the documentation i use eslint src -f json -o eslint_report.json to generate my Report. I am trying it locally with sonarScanner and also on Sonarcloud
In the sonar-properties i have the path to the report set and it finds it, but i got an error message, that SonarScanner cannot read the eslint Report.
I get the following exception. How can i solve this problem?

ERROR: Error during SonarScanner execution
java.lang.IllegalStateException: Failed to read external issues report 'C:\Users\XXX\XXX\eslint_report.json': invalid JSON syntax
        at org.sonar.scanner.externalissue.ExternalIssueReportParser.parse(ExternalIssueReportParser.java:42)
        at org.sonar.scanner.externalissue.ExternalIssuesImportSensor.execute(ExternalIssuesImportSensor.java:57)
        at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:62)
        at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:75)
        at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:48)
        at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:66)
        at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:48)
        at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:64)
        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
        at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:192)
        at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:188)
        at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:159)
        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
        at org.sonar.scanner.bootstrap.ScannerContainer.doAfterStart(ScannerContainer.java:399)
        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
        at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:128)
        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
        at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:58)
        at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:52)
        at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.base/java.lang.reflect.Method.invoke(Unknown Source)
        at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
        at jdk.proxy1/jdk.proxy1.$Proxy0.execute(Unknown Source)
        at org.sonarsource.scanner.cli.Main.execute(Main.java:126)
        at org.sonarsource.scanner.cli.Main.execute(Main.java:81)
        at org.sonarsource.scanner.cli.Main.main(Main.java:62)
Caused by: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 2 path $
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:395)
        at com.google.gson.Gson.fromJson(Gson.java:1214)
        at com.google.gson.Gson.fromJson(Gson.java:1124)
        at com.google.gson.Gson.fromJson(Gson.java:1062)
        at org.sonar.scanner.externalissue.ExternalIssueReportParser.parse(ExternalIssueReportParser.java:36)
        ... 34 more
Caused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 2 path $
        at com.google.gson.stream.JsonReader.beginObject(JsonReader.java:393)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:384)
        ... 38 more

Hey there.

Can you upload the JSON report?

Problem solved, sonarCloud needs a custom formatter to be able to read the eslint report.
Please update the documentation, the -f json option doesn’t work.

@julia.viehberger , welcome to the community, and thanks for the report, the log and the solution. What did you have to do on your custom formatter to make the report work properly?

I still couldn’t get it to work completly.
But i need a custom Formatter that sonarcloud doesn’t complain about the report syntax. It is still not showing esLint issues in the overview

Hello Julia,

Are you using the sonar.eslint.reportPaths property to point to your issues report as documented here?