- SonarQube: 10.6, self hosted
- Eslint: 7.32.0 Is this version supported???
- New code rule: Previous version
- how is SonarQube deployed: zip, sonar-scanner-cli version 6.1.0.4477
I’m trying to apply eslint error on sonarcloud, like those from eslint-plugin-import
, but it never generates any issue on SonarQube.
Example of change I expected to see an issue from eslint but SonarQube does not report it in my PR.
- I’ve configured
sonar.eslint.reportPaths=reports/eslint-report.json
- I’ve generated and persisted this file in CI (CircleCI) before running the sonarcloud job.
- The sonarcloud seems to import it correctly and the file has a comment in there which should trigger the new code rule, but it does not show as an issue in the the Sonarcloud website and neither the PR.
CI log
00:02:13.181 INFO Sensor JavaScript/TypeScript analysis [javascript] (done) | time=13296ms
00:02:13.182 INFO Sensor CSS Rules [javascript]
00:02:13.182 INFO Sensor CSS Rules is restricted to changed files only
00:02:13.185 INFO No CSS, PHP, HTML or VueJS files are found in the project. CSS analysis is skipped.
00:02:13.185 INFO Sensor CSS Rules [javascript] (done) | time=4ms
00:02:13.186 INFO Sensor Import of ESLint issues [javascript]
00:02:13.186 INFO Importing /home/circleci/neutron/reports/eslint-report.json
00:02:13.208 INFO Sensor Import of ESLint issues [javascript] (done) | time=23ms
00:02:13.208 INFO Sensor IaC Docker Sensor [iac]
00:02:13.209 INFO Sensor IaC Docker Sensor is restricted to changed files only
00:02:13.214 INFO 0 source files to be analyzed
00:02:13.258 INFO 0/0 source files have been analyzed
00:02:13.259 INFO Sensor IaC Docker Sensor [iac] (done) | time=50ms
00:02:13.259 INFO Sensor TextAndSecretsSensor [text]
00:02:13.259 INFO Sensor TextAndSecretsSensor is restricted to changed files only
00:02:13.259 INFO Available processors: 16
00:02:13.259 INFO Using 16 threads for analysis.
Example of report from eslint
[
{
"filePath": "/home/circleci/neutron/src/app/constants/test-selectors/index.js",
"messages": [
{
"ruleId": "import/named",
"severity": 2,
"message": "ACCOUNT_SELECTORS not found in './account-selectors'",
"line": 4,
"column": 35,
"nodeType": "Identifier",
"endLine": 4,
"endColumn": 52
},
{
"ruleId": "import/named",
"severity": 2,
"message": "SHIPT_IDENTIFIER_SELECTORS not found in './my-orders-selectors'",
"line": 18,
"column": 3,
"nodeType": "Identifier",
"endLine": 18,
"endColumn": 29
},
{
"ruleId": "import/export",
"severity": 2,
"message": "Multiple exports of name 'DELIVERY_DETAILS_SELECTORS'.",
"line": 53,
"column": 1,
"nodeType": "ExportAllDeclaration",
"endLine": 53,
"endColumn": 50
},
{
"ruleId": "import/named",
"severity": 2,
"message": "AVAILABLE_ROUTES_SELECTORS not found in './available-routes-selectors'",
"line": 60,
"column": 10,
"nodeType": "Identifier",
"endLine": 60,
"endColumn": 36
},
{
"ruleId": "import/export",
"severity": 2,
"message": "Multiple exports of name 'DELIVERY_DETAILS_SELECTORS'.",
"line": 80,
"column": 42,
"nodeType": "Identifier",
"endLine": 80,
"endColumn": 68
}
],
"errorCount": 5,
"fatalErrorCount": 0,
"warningCount": 0,
"fixableErrorCount": 0,
"fixableWarningCount": 0,
"source": "I OMMITED THIS PART TO NOT SHOW SOURCE CODE OF THE PROJECT IN HERE",
"usedDeprecatedRules": []
}
]
sonar-project.properties
sonar.projectKey=A_VALID_PROJECT_KEY_OMMITED
sonar.host.url=A_VALID_SERVER_URL_OMMITED
sonar.sources=src
sonar.exclusions=**/*.java,**/*.kt,**/*.e2e.js
sonar.eslint.reportPaths=reports/eslint-report.json
Activating verbose, it seems the files are being uploaded, but somehow it is never generated an issue
01:24:14.515 INFO Sensor JavaScript/TypeScript Coverage [javascript] (done) | time=312ms
01:24:14.515 INFO Sensor Import of ESLint issues [javascript]
01:24:14.515 INFO Importing /home/circleci/neutron/reports/eslint-report.json
01:24:14.529 DEBUG Saving external ESLint issue { file:"/home/circleci/neutron/src/app/constants/test-selectors/index.js", id:import/named, message:"ACCOUNT_SELECTORS not found in './account-selectors'", line:4, offset:34, type: BUG, severity:MAJOR, remediation:5 }
01:24:14.536 DEBUG Saving external ESLint issue { file:"/home/circleci/neutron/src/app/constants/test-selectors/index.js", id:import/named, message:"SHIPT_IDENTIFIER_SELECTORS not found in './my-orders-selectors'", line:18, offset:2, type: BUG, severity:MAJOR, remediation:5 }
01:24:14.536 DEBUG Saving external ESLint issue { file:"/home/circleci/neutron/src/app/constants/test-selectors/index.js", id:import/export, message:"Multiple exports of name 'DELIVERY_DETAILS_SELECTORS'.", line:53, offset:0, type: BUG, severity:MAJOR, remediation:5 }
01:24:14.537 DEBUG Saving external ESLint issue { file:"/home/circleci/neutron/src/app/constants/test-selectors/index.js", id:import/named, message:"AVAILABLE_ROUTES_SELECTORS not found in './available-routes-selectors'", line:60, offset:9, type: BUG, severity:MAJOR, remediation:5 }
01:24:14.537 DEBUG Saving external ESLint issue { file:"/home/circleci/neutron/src/app/constants/test-selectors/index.js", id:import/export, message:"Multiple exports of name 'DELIVERY_DETAILS_SELECTORS'.", line:80, offset:41, type: BUG, severity:MAJOR, remediation:5 }
01:24:14.537 INFO Sensor Import of ESLint issues [javascript] (done) | time=22ms
01:24:14.537 INFO Sensor IaC Docker Sensor [iac]
01:24:14.537 INFO Sensor IaC Docker Sensor is restricted to changed files only
01:24:14.542 INFO 0 source files to be analyzed
01:24:14.588 INFO 0/0 source files have been analyzed