SonarEsLintPlugin
SonarEsLintPlugin copied to clipboard
EsLint Custom Rules
I have these three other eslint plugins that I want to integrate into sonarqube v.6.7.2. A. redux-saga B. react C. jsx-a11y
and below is my sonar-project.propeties file:
sonar.projectKey=abc sonar.projectName=xyz sonar.projectVersion=0.0.0.1 sonar.sources=app/ sonar.exclusions= app/utils/**/*, sonar.language=js sonar.javascript.file.suffixes=.js,.jsx sonar.profile=ReactJs sonar.eslint.eslintpath=node_modules/eslint/bin/eslint.js sonar.eslint.eslintconfigpath=package.json sonar.eslint.eslintrulesdir=react,redux-saga,jsx-a11y sonar.sourceEncoding=UTF-8 sonar.login=pqr sonar.password=jkl
These three plugins rules are specified on eslint-rules.properties file and it is showing these rules on sonarqube also. but the problem here is that sonarqube is not generating any report related to these three rules even I have intentionally made a mistake.
can you please check whether I have specified "sonar.eslint.eslintrulesdir" path right or I am missing something. Please help me with this I am into this issue since past 3 days.
I hava the same problem
I have these three other eslint plugins that I want to integrate into sonarqube v.6.7.2. A. redux-saga B. react C. jsx-a11y
and below is my sonar-project.propeties file:
sonar.projectKey=abc sonar.projectName=xyz sonar.projectVersion=0.0.0.1 sonar.sources=app/ sonar.exclusions= app/utils/**/*, sonar.language=js sonar.javascript.file.suffixes=.js,.jsx sonar.profile=ReactJs sonar.eslint.eslintpath=node_modules/eslint/bin/eslint.js sonar.eslint.eslintconfigpath=package.json sonar.eslint.eslintrulesdir=react,redux-saga,jsx-a11y sonar.sourceEncoding=UTF-8 sonar.login=pqr sonar.password=jkl
These three plugins rules are specified on eslint-rules.properties file and it is showing these rules on sonarqube also. but the problem here is that sonarqube is not generating any report related to these three rules even I have intentionally made a mistake.
can you please check whether I have specified "sonar.eslint.eslintrulesdir" path right or I am missing something. Please help me with this I am into this issue since past 3 days.
Have you found the problem? Can you let me know?
Hi,
As I wrote in the README recently, you have a native support of ESLint in the latest versions of SonarQube. Therefore, if you have the possibility, I would recommend to use this preferred alternative.
If for some reason, you cannot use it, let me know, I will fix this issue, once for good.
Thanks,
Sylvain
On Wed, Aug 28, 2019 at 11:20 AM double-yaya [email protected] wrote:
I have these three other eslint plugins that I want to integrate into sonarqube v.6.7.2. A. redux-saga B. react C. jsx-a11y
and below is my sonar-project.propeties file:
sonar.projectKey=abc sonar.projectName=xyz sonar.projectVersion=0.0.0.1 sonar.sources=app/ sonar.exclusions= app/utils/**/*, sonar.language=js sonar.javascript.file.suffixes=.js,.jsx sonar.profile=ReactJs sonar.eslint.eslintpath=node_modules/eslint/bin/eslint.js sonar.eslint.eslintconfigpath=package.json sonar.eslint.eslintrulesdir=react,redux-saga,jsx-a11y sonar.sourceEncoding=UTF-8 sonar.login=pqr sonar.password=jkl
These three plugins rules are specified on eslint-rules.properties file and it is showing these rules on sonarqube also. but the problem here is that sonarqube is not generating any report related to these three rules even I have intentionally made a mistake.
can you please check whether I have specified "sonar.eslint.eslintrulesdir" path right or I am missing something. Please help me with this I am into this issue since past 3 days.
Have you found the problem? Can you let me know?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/sleroy/SonarEsLintPlugin/issues/3?email_source=notifications&email_token=ABL7XERPKYL4RHJ7JA5XJGDQGY7NLA5CNFSM4EZGG7TKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5KOZNA#issuecomment-525659316, or mute the thread https://github.com/notifications/unsubscribe-auth/ABL7XETZW7CGPIVNPSQ4KMTQGY7NLANCNFSM4EZGG7TA .
My environment is as follows: sonar:6.1 sonareslintplugin:0.1.1 jdk:1.8
sonar-project.properties: sonar.projectKey=company:my-application sonar.projectName=My Application sonar.projectVersion=1.0 sonar.sourceEncoding=UTF-8 sonar.sources=src sonar.exclusions=/node_modules/ #sonar.tests=src/app #sonar.test.inclusions=**/*.spec.ts sonar.eslint.eslintconfigpath=.eslintrc.js sonar.eslint.eslintrulesdir=rule
sonar web configuration:
sonar analysis log: 16:04:30.403 DEBUG - Split 2 files into 1 batches for processing 16:04:30.403 DEBUG - Executing EsLint with command: node C:\Users\Administrator.DCITSDC-LKIU0SB\AppData\Roaming\npm\node_modules\eslint\bin\eslint.js -f json --rules-dir E:\eslint\Test\rule --output-file E:\eslint\Test.sonar.sonartmp\2287655680825963988.tmp --config E:\eslint\Test.eslintrc.js E:/eslint/Test/src/index.js E:/eslint/Test/src/merge.js 16:04:30.403 DEBUG - Executing EsLint with command: node C:\Users\Administrator.DCITSDC-LKIU0SB\AppData\Roaming\npm\node_modules\eslint\bin\eslint.js -f json --rules-dir E:\eslint\Test\rule --output-file E:\eslint\Test.sonar.sonartmp\2287655680825963988.tmp --config E:\eslint\Test.eslintrc.js E:/eslint/Test/src/index.js E:/eslint/Test/src/merge.js 16:04:31.316 INFO - Sensor Linting sensor for Javascript files (done) | time=922ms
Execution results under eslint command line:
OK thanks for the complete report. I will treat it this week.
OK thanks for the complete report. I will treat it this week.
Do you have any results?
SonarQube version 6.1 is not available for Download. I am beginning the tests with the LTS 6.7
Here are my explanations.
I created a project exampleApp into the github project for demonstration.
Here : https://github.com/sleroy/SonarEsLintPlugin/tree/master/exampleProject
First preliminary steps are :
- Copy the plugin jar into the
extensions/plugin
folder of your SonarQube installation - Creates a profile including the plugin rules (javascript language)
- If you do not see your custom rules availables for the Javascript language it means that your custom definitions have not been loaded.
If your custom rules have not been loaded, the sonar-scanner log will display messages as such :
INFO: Rule react-jsx-filename-extension has not yet being defined into the EsLint plugin
INFO: Rule react-jsx-filename-extension has not yet being defined into the EsLint plugin
INFO: Rule react-jsx-filename-extension has not yet being defined into the EsLint plugin
INFO: Rule react-jsx-one-expression-per-line has not yet being defined into the EsLint plugin
INFO: Rule react-jsx-one-expression-per-line has not yet being defined into the EsLint plugin
INFO: Sensor Linting sensor for Javascript files [eslintplugin] (done) | time=1118ms
It means that the SonarEsLint plugin does not have a Sonar definition for these eslint rlues.
You need to add them.
Now the explanation on how to add them :
By default the plugin is loading a default set of rules defined here :
https://github.com/sleroy/SonarEsLintPlugin/blob/master/src/main/resources/eslint/eslint-rules.properties
As you can see, for each rule of eslint, you have to define a set of properties to populate the Sonar Javascript profile. Without these informations the new rules are not being imported.
I cannot add dynamically rules form ESLint since it is not supported by SonarQube. Rules have to be defined and loaded at the SonarQube startup.
How to add the eslint plugin extra rules ?
a) Fork the file eslint-rules.properties
and send me the modifications to merge
The plugin will integrate the new rules for the other users.
b) Pass the definitions through the admin tab in SonarQube
We have a bug : what has been implemented in the TSLint package is not working..
I will fix it now.
Important : when a rule from an ESLint plugin is detected by the plugin, I am assigning the ESLint violation to the rule "Unknown rule" like in the caption below :
Therefore unless you provide the proper definition for this rule, you will have several violations with this description :
ok ,I'll test,thank you