No SonarJS rule key found for an eslint-based rule [max-len]

sonarjs
scanner
javascript

(Alain O'Dea) #1
  • versions used (SonarQube, Scanner, Plugin, and any relevant extension)
    SonarQube server 7.3.0 (Enterprise Edition)
    SonarQube Scanner 3.2.0.1227
    SonarQube Scanner for Jenkins 2.8.1

  • error observed

java.lang.IllegalStateException: No SonarJS rule key found for an eslint-based rule [max-len]
	at org.sonar.plugins.javascript.eslint.EslintBasedRulesSensor.ruleKey(EslintBasedRulesSensor.java:147)
	at org.sonar.plugins.javascript.eslint.EslintBasedRulesSensor.saveIssue(EslintBasedRulesSensor.java:139)
	at org.sonar.plugins.javascript.eslint.EslintBasedRulesSensor.analyze(EslintBasedRulesSensor.java:109)
	at org.sonar.plugins.javascript.eslint.EslintBasedRulesSensor.execute(EslintBasedRulesSensor.java:90)
	at org.sonar.scanner.sensor.SensorWrapper.analyse(SensorWrapper.java:45)
	at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:88)
	at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:62)
	at org.sonar.scanner.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:74)
	at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:166)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
	at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:300)
	at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:295)
	at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:269)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
	at org.sonar.scanner.task.ScanTask.execute(ScanTask.java:48)
	at org.sonar.scanner.task.TaskContainer.doAfterStart(TaskContainer.java:82)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
	at org.sonar.scanner.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:131)
	at org.sonar.batch.bootstrapper.Batch.doExecuteTask(Batch.java:116)
	at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:71)
	at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
	at com.sun.proxy.$Proxy0.execute(Unknown Source)
	at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:171)
	at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:128)
	at org.sonarsource.scanner.cli.Main.execute(Main.java:111)
	at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
	at org.sonarsource.scanner.cli.Main.main(Main.java:61)
  • steps to reproduce
    Run a scan. I’m really not sure. We don’t use ESLint right now.

  • potential workaround
    None I know of. It isn’t fatal, but it does concern me.


(Jose Maria Cubel) #2

I’ve got a similar error

  • versions used (SonarQube, Scanner, Plugin, and any relevant extension)
    • SonarQube server 6.7.5 (Community Edition)
    • SonarJS plugin 5.0
    • SonarQube Scanner 3.5.0.1254
    • SonarQube Scanner for Jenkins 2.6.1
[ERROR] Failure during analysis, Node.js command to start eslint-bridge was: node XXXX/workspace/target/sonar/.sonartmp/eslint-bridge-bundle/node_modules/eslint-bridge/bin/server 42910
java.lang.IllegalStateException: No SonarJS rule key found for an eslint-based rule [no-magic-numbers]
	at org.sonar.plugins.javascript.eslint.EslintBasedRulesSensor.ruleKey(EslintBasedRulesSensor.java:147)
	at org.sonar.plugins.javascript.eslint.EslintBasedRulesSensor.saveIssue(EslintBasedRulesSensor.java:139)
	at org.sonar.plugins.javascript.eslint.EslintBasedRulesSensor.analyze(EslintBasedRulesSensor.java:109)
	at org.sonar.plugins.javascript.eslint.EslintBasedRulesSensor.execute(EslintBasedRulesSensor.java:90)
	at org.sonar.scanner.sensor.SensorWrapper.analyse(SensorWrapper.java:53)

Any workaround?


(Radomir) #3

I get the same error. Any workaround?


(Tibor Blenessy) #6

Hello,

sorry for the delayed reaction. I think I managed to reproduce the problem, can you confirm that it happens on the file which is using eslint configuration comments, like following?

/*eslint no-magic-numbers: "error"*/

var dutyFreePrice = 100,
    finalPrice = dutyFreePrice + (dutyFreePrice * 0.25);

As a workaround, you can either remove the comment or exclude the file. Sorry for the inconvenience.


(Alain O'Dea) #7

We don’t use eslint comments like this directly.

It’s possible this is triggered by our vendoring of okta-signin-widget. It has a lot of eslint comments.

I’ll see if I can specifically exclude its JS files.