SonarJS fails parsing a file: Unexpected character '#'

This is because SonarJS relies on babel-eslint which fails to recognize the “@babel/plugin-proposal-class-properties” plugin properly and thus doesn’t understand the private property JS syntax.

babel-eslint has been archived for a few months now so it’s no longer in development. SonarJS should now use @babel/eslint-parser

Hello @fabis94,

Welcome to our community, and thank you for reporting this problem.

Indeed, we need to update babel’s dependency so that we no longer rely on an archived project, and use an up-to-date parser from now on. I created this ticket in that regard.

Note that we are soon releasing a new version of SonarJS that will attempt first to parse JavaScript code with TypeScript ESLint parser, which happens to support JavaScript syntax for private property.


@Yassin_Kammoun I think it’s important that SonarJS uses the same ESLint/Babel config that the project being scanned uses. Projects can have all kinds of weird Babel plugins that allow writing code in a syntax that the standard parser w/o plugins wouldn’t understand.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.