Eslint report does not work

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    sonar: 7.9.4.35981
    eslint: 7.20.0

  • what are you trying to achieve
    Sonar can analyze the reported eslint-report.json normally

  • eslint-report.json

[{"filePath":"/Users/lijianru/github/next-native/src/lib/css/color.ts","messages":[],"errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[{"ruleId":"handle-callback-err","replacedBy":[]},{"ruleId":"no-negated-in-lhs","replacedBy":["no-unsafe-negation"]},{"ruleId":"no-new-require","replacedBy":[]},{"ruleId":"no-path-concat","replacedBy":[]}]},{"filePath":"/Users/lijianru/github/next-native/src/lib/css/gridSpacing.ts","messages":[],"errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[{"ruleId":"handle-callback-err","replacedBy":[]},{"ruleId":"no-negated-in-lhs","replacedBy":["no-unsafe-negation"]},{"ruleId":"no-new-require","replacedBy":[]},{"ruleId":"no-path-concat","replacedBy":[]}]},{"filePath":"/Users/lijianru/github/next-native/src/lib/css/typography.ts","messages":[{"ruleId":"@typescript-eslint/no-unused-vars","severity":2,"message":"'a' is assigned a value but never used.","line":24,"column":7,"nodeType":"Identifier","messageId":"unusedVar","endLine":24,"endColumn":8}],"errorCount":1,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"source":"export const basicFontSize = {\n  /**\n   * 12\n   */\n  xs: 12,\n  /**\n   * 14\n   */\n  sm: 14,\n  /**\n   * 16\n   */\n  md: 16,\n  /**\n   * 20\n   */\n  lg: 20,\n  /**\n   * 24\n   */\n  xl: 24,\n};\n\nconst a = 1;\n\nexport const basicFontWeight: {\n  normal: '400';\n  semiBold: '600';\n  bold: '700';\n} = {\n  normal: '400',\n  semiBold: '600',\n  bold: '700',\n};\n\nexport const basicHeight = {\n  /**\n   * 18\n   */\n  xs: 18,\n  /**\n   * 20\n   */\n  sm: 20,\n  /**\n   * 24\n   */\n  md: 24,\n  /**\n   * 26\n   */\n  lg: 26,\n  /**\n   * 32\n   */\n  xl: 32,\n};\n","usedDeprecatedRules":[{"ruleId":"handle-callback-err","replacedBy":[]},{"ruleId":"no-negated-in-lhs","replacedBy":["no-unsafe-negation"]},{"ruleId":"no-new-require","replacedBy":[]},{"ruleId":"no-path-concat","replacedBy":[]}]}]
  • log
03:51:11.800 WARN: No input file found for /Users/lijianru/github/next-native/src/lib/components/NextSlider/styles.ts. No ESLint issues will be imported on this file.
03:51:11.800 WARN: No input file found for /Users/lijianru/github/next-native/src/lib/css/color.ts. No ESLint issues will be imported on this file.
03:51:11.801 WARN: No input file found for /Users/lijianru/github/next-native/src/lib/css/gridSpacing.ts. No ESLint issues will be imported on this file.
03:51:11.801 WARN: No input file found for /Users/lijianru/github/next-native/src/lib/css/typography.ts. No ESLint issues will be imported on this file.
03:51:11.801 INFO: Sensor Import of ESLint issues [javascript] (done) | time=627ms
03:51:11.801 INFO: Sensor TypeScript analysis [javascript]
03:51:11.803 DEBUG: SonarJS eslint-bridge server is up, no need to start.

Hi,

Welcome to the community!

First, your version is past EOL. You should upgrade to either the latest version or the current LTS at your earliest convenience. Your upgrade path is:

7.9.4 → 8.9.3 → 9.2.1 (last step optional)

You may find the Upgrade Guide and the LTS-to-LTS Upgrade Notes helpful. If you have questions about upgrading, feel free to open a new thread for that here.

If your error persists after upgrade, please come back to us.

 
HTH,
Ann

I came across a similar requirement and the following are the steps that I followed to achieve the ESLint report output integration into the Sonarqube dashboard:

  1. Switch to the project directory.
  2. Run: npx eslint <source_code_to_be_scanned> --format json --output-file <file_name>.json

For e.g. npx eslint ./src/**/*.js --format json --output-file eslint-result.json

  1. Cope the relative path of the generated report.
  2. Add an additional property in your sonar-project.properties file as below:

sonar.eslint.reportPaths=app/eslint-result.json

  1. Perform the sonar scan

Output: I was able to see the expected output within my Sonarqbue dashboard.

I hope this helps

2 Likes