1

SonarJS 4.0 ignored FlowType annotations, but with SonarJS 4.1 they are marked as reference error (Rule: javascript:S3827).

I just want to clearify if this is intended behaviour and what is the intended "workflow" regarding this.

if it is not a bug, do i need to add all those References to the globals, or what is the best practice to handle this behaviour?

enter image description here

Thank you

Simon Schrottner
  • 4,146
  • 1
  • 24
  • 36
  • However, I stumbled upon https://github.com/facebook/flow/issues/1609 . I am not very familiar with react, can you confirm that it is possible to import `SyntheticInputEvent` , or perhaps they should be also added to the global scope? – Tibor Blenessy Feb 19 '18 at 10:36
  • actually there are multiple events "SyntheticEvent", "SyntheticInputEvent", "SyntheticMouseEvent", which are right now popping up -> but i am not sure if there are more, and well the work arround would be adding them to the global scope - but still a lot of effort to maintain such a list, if it extends – Simon Schrottner Feb 19 '18 at 11:43

1 Answers1

1

This is intended behavior, SonarJS version 4.1 now treats Flow Types as symbols, and core flow types are automatically resolved because they are available in the new flow environment. Types should be resolved automatically when they are correctly imported with import type syntax.

An issue was created to include React Flow Types in globals by default.

Tibor Blenessy
  • 4,254
  • 29
  • 35
  • 1
    `SyntheticInputEvent` actually seems to be a core type bundled with Flowtype as part of the react-dom integration. Does this require some additional configuration inside Sonar? – Horst Gutmann Feb 19 '18 at 11:26
  • 2
    Globals can be set with property `sonar.javascript.globals` . However I created https://github.com/SonarSource/SonarJS/issues/947 to fix this in SonarJS – Tibor Blenessy Feb 19 '18 at 15:09