Sonar javascript scanner fails to parse .jsx files when file has special characters "<>" and "?."

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    SonarQube Server : Version 7.0 (build 36138) Community Version
    Sonar Scanner : 4.1.0.1829-linux
  • what are you trying to achieve
    I am trying to scan a React application using sonarqube
  • what have you tried so far to achieve this
    I am scanning our react codebase using a Jenkins pipeline, I see so many issues like below

ERROR: Unable to parse file: file:///var/lib/jenkins/workspace/Sonarqube-web-test/src/containers/Common/UserProfilePage.jsx
ERROR: Parse error at line 94 column 35:

84:
85: const timezoneMenuItems = Object.values(ct.getAllTimezones()).sort((a, b) => a.utcOffset - b.utcOffset).map(timeZone => ({ key: timeZone.name, value: (UTC ${timeZone.utcOffsetStr}) ${timeZone.name} }));
86:
87: return (
88: <Spin spinning={ loadingPage }>
89: <Row gutter={ [16, 16] } justify=“center”>
90:
91: <Avatar
92: size={ 80 }
93: shape=“square”
94: src={ initialValues?.profileImage?.url }
^
95: />
96:
97:
98: <div style={ { marginBottom: ‘1rem’ } }>
99: <Upload
100: accept=".png,.jpg,.jpeg"
101: showUploadList={ false }
102: beforeUpload={ this.handleLoadImage }
103: style={ { width: ‘100%’ } }
104: >

In above, Sonar complains about “?.” character


ERROR: Unable to parse file: file:///var/lib/jenkins/workspace/Sonarqube-web-test/src/containers/Dashboard/GraphsContainer.jsx
ERROR: Parse error at line 63 column 14:

53: { !!singleNumberCharts.length &&
54:
55: { singleNumberCharts.map(chart => (
56: <Col xs={ 24 } sm={ 24 } md={ 24 } lg={ 6 } key={ chart.id } style={ { padding: ‘0.5rem’ } }>
57: <ConnectedGraph chart={ chart } />
58:
59: )) }
60:
61: }
62: { !!barCharts.length &&
63: <>
^
64:
65:
66: { barCharts.map(chart => (
67: <Col xs={ 24 } sm={ 24 } md={ 24 } lg={ 12 } key={ chart.id } style={ { padding: ‘0.5rem’ } }>
68: <ConnectedGraph chart={ chart } />
69:
70: )) }
71:
72: </>
73: }

In the above block, It complains about “<>”

Any idea why we are getting these parsing issues. Appreciate your support.

Hi,

Your version is past EOL. You should upgrade to either the latest version or the current LTS at your earliest convenience. Your upgrade path is:

7.0 → 7.9.6 → 8.9.8 → 9.4 (last step optional)

You may find the Upgrade Guide and the LTS-to-LTS Upgrade Notes helpful. If you have questions about upgrading, feel free to open a new thread for that here.

If your error persists after upgrade, please come back to us.

Thank you Colin for your answer, will try to upgrade and come back