eslint-plugin-sonarjs
eslint-plugin-sonarjs copied to clipboard
Turn off a rule from SonarJS
I want to know how to turn off a certain rule in Sonar.
So there are more than a few rules I want disabled in my source code. I have sonarqube integration done. I have sonarlint installed in my vscode. I have this plugin installed so eslint can tell me when I break a rule. But there are some rules which i do not want to be warned about
Can someone help me as to how to do this?
eslint-plugin-sonarjs version: 0.12.0 eslint version: 8.10.0 Node.js version: 16.13.2
Rule key: javascript:S1301 (I think this is the Id)
Why do you want to disable the rule? Could you provide a code example when this rule is not working for you?
Do you want to disable rule in SonarLint (do you use connected mode)? or in Sonar as well?
In my project, I run into a lot of cases where we have JSX where we are forced to use cascaded ternary operators. Of course, those are getting flagged with warnings and in those cases, I would like to disable that rule only for that block of lines. The particular rule at hand is typescript:S3358.
Wondering myself too if it's possible to use SonarJS ESLint to disable SonarCloud/SonarQube rules that are also reported via SonarLint... But I do understand if that is more of a question for SonarCloud/SonarQube & SonarLint.
You can try to overrides the rules you want to turn off like this
overrides: [ { files: ['*.test.{ts,tsx}', '*.js'], rules: { 'sonarjs/no-duplicate-string': 'off', }, }, ],
This issue has been migrated to Jira. ESLINTJS-21