Using esLint scanner for SonarQube 7.9

Hi all,

I am trying to migrate from SonarQube 6.7.7 to SonarQube 7.9.1

I tried to scan using esLint Scanner and the it run. But the result is not as expected. The codes is in javascript and it should have violation. Am I doing it wrong? How to scan with esLint scanner?

Thank you

hello @fanny_tan,

it’s not clear to me what you are trying to achieve. To scan JavaScript project, you should use SonarScanner , to import eslint issues, you should create the report and import it by setting sonar.eslint.reportPaths property.

Hi @saberduck

Sorry, could you please provide me the details about how to create this esLint report?

Have a look here [External Analyzer Reports] Report generation for several languages

Thank you so much @saberduck
I wil try it out :smiley:

Hello @saberduck

I have tried this command, but it failed to create report.json. So I try to find other command which is “npm i eslint -f json > test.json” and it has successfully created the report but I can’t import it to SonarQube.

Do you know why? Thank you

Please provide some details, what are you trying to do (which commands you are executing), and what is the output (logs).

Hi @saberduck

I am trying to create esLint Report and import the report to SonarQube 7.9.1.

Based on your suggestion, I try to create the report this command using eslint -f json -o report.json . I got this error log.

Then I found another command from other sites which is npm i eslint -f json > test2.json , the report is created. Here is the report that has been created using this command.
image

But when I try to import that report, it failed. Here is the log.

What should I do? :persevere:

hello @fanny_tan,

I think you are mixing some things. Command npm i eslint is actually using npm package manager to install eslint into your project. Once you have installed it, you should not launch npm i eslint, because that would just install it again.

You need to run eslint, to run locally installed package you can use npx eslint -f json > report.json

Also have a look at eslint documentation here https://eslint.org/docs/user-guide/getting-started

Hi @saberduck,

From your suggestion, I use this command “npx eslint -f json > report.json” and just get result as shown below :

Any idea? I just scan one file.js in this case.

Thankyou :frowning:

Hi @saberduck,

Do you mind to share your example project that has been successfully scanned using your command? Thank you.