Unable to publish the errors on ESLint checks for Missing JSDoc Comments

Hi All, I am having an issue with publishing the results on my eslint check to SonarQube. In the check, it is correctly showing that there are errors, but the error is not showing on the published results. Please see the sample of my code below.

Here’s the sample of my pipeline:

- task: NodeTool@0
    inputs:
      versionSpec: "15.x"
      checkLatest: true
    displayName: "Install Node.js"

  - task: Npm@1
    inputs:
      command: "install"
    displayName: "Install NPM"

  - task: CmdLine@2
    inputs:
      script: |
        npm install eslint-plugin-jsdoc@latest
    displayName: "Install JSDoc Plugin"

  - script: |
      npm run lint
      npm run lint:ci
    displayName: "Run Lint"
    continueOnError: true

  - task: SonarQubePrepare@4
    inputs:
      SonarQube: "TEST"
      scannerMode: "CLI"
      configMode: "manual"
      cliProjectKey: "TESTProjectKey"
      cliProjectName: "TESTProjectName"
      extraProperties: |
        # Additional properties that will be passed to the scanner, 
        # Put one key=value per line, example:
        sonar.inclusions=**/*.css, **/*.js, **/*.cls
        sonar.eslint.reportPaths=report.json
        sonar.report.export.path=report.json

  - task: SonarQubeAnalyze@4
  - task: SonarQubePublish@4
    inputs:
      pollingTimeoutSec: "300"

Here’s the eslintrc.json file

{
  "plugins": [
        "jsdoc"
    ],
  "extends": [
    "plugin:jsdoc/recommended",
    "@salesforce/eslint-config-lwc/recommended",
    "prettier"
  ],
  "overrides": [
    {
      "files": [
        "*.test.js"
      ]
    }
  ],
  "rules": {
    "jsdoc/require-jsdoc": [2, {
    "require": {
        "FunctionDeclaration": true,
        "MethodDefinition": false,
        "ClassDeclaration": false
    }
}],
    "jsdoc/valid-jsdoc": 2,
    "indent": [ 1, "tab" ],
    "@lwc/lwc/no-unexpected-wire-adapter-usages": "off"
  }
}

In my logs, I can already see the errors showing like this, but the error doesn’t show on the SonarQube (but the codes are there, as expected):

1:1 error Definition for rule 'jsdoc/valid-jsdoc' was not found jsdoc/valid-jsdoc

Hello Percy,

Without the scanner logs, it’s a bit difficult to say with certainty why the ESLint report was not imported in SonarQube.

Looking at your pipeline, I see that you’re telling the scanner where to find the report with sonar.eslint.reportPaths=report.json. You then need to make sure of the following:

  • your script lint does generate a report.json file (-o report.json option),
  • the format of the report should be JSON (-f json option).

For your reference, here is SonarQube Documentation about Importing Third-Party Issues.

Hope this helps,
Yassin