JavaScript Function Parens Rule

javascript

(Jeff Mathers) #1

SonarQube 7+
Rule Error/Deviation javascript:S3524 is inconsistent with ES2015
Hi All,

Hoping this is the right place for this question.

https://rules.sonarsource.com/javascript/tag/es2015/RSPEC-3524

This rule is not exactly consistent with ES2015. The standard says that when a single parameter arrow function has a function with parens, then the parens around the argument should be included. The rule is missing that nuance and my developers are complaining. Basically I think this rule needs a couple of more true/false options so that it could be configured to be this rule.

The rule includes this option: { "requireForBlockBody": true }, but this is not in the SQ rule as far as I can tell.

What is the best way to proceed with seeing if this can be fixed/updated?

Jeff


(Elena Vilchik) #3

Hello @Jeff_Mathers,

Thanks for this feedback. Are you referencing airbnb standard? (https://github.com/airbnb/javascript#arrows--one-arg-parens)

I created ticket in SonarJS to fix your problem https://github.com/SonarSource/SonarJS/issues/1148. But I’m not sure it will be implemented soon.

One option for you will be to deactivate SonarJS rule and import ESLint issues as external (see docs).

Regards,
Elena


(Jeff Mathers) #4

Yes - but I think the AirBNB standard is the same as ES2015 in this case. It is really only a minor issue so as long as it is corrected at some point that would be fantastic.

jeff