jshint-eclipse icon indicating copy to clipboard operation
jshint-eclipse copied to clipboard

No support for comments in config file

Open voelzmo opened this issue 12 years ago • 4 comments

The used JSON parser doesn't support comments within the configuration JSON file.

Steps to reproduce:

  • Take a working example configuration file and use it
  • Add a comment with "//" either at the end of a line or at the beginning of a line

Expected:

  • The plugin still uses the configuration file

Actual:

  • Parsing error, configuration file is not accepted

My use case is that I'd like to add comments what an option actually means. Some of them are very cryptic or at least not intuitive to understand. Being able to use comments within a JSON file should be possible.

voelzmo avatar Jan 08 '14 07:01 voelzmo

This works for me with version 0.9.10. Could you post a configuration that leads to the parsing error and ideally a stack trace of the parsing error?

ralfstx avatar Jan 18 '14 10:01 ralfstx

I have the same problem with comments in configuration. The configuration file I want to use is https://gist.github.com/haschek/2595796/raw/500806cafd239ace8dc94c998a8d4f7270947b12/.jshintrc

It works when I remove all comments from the file.

Stacktrace from Error Log is: com.eclipsesource.json.ParseException: Expected name at 2:4 at com.eclipsesource.json.JsonParser.error(JsonParser.java:371) at com.eclipsesource.json.JsonParser.expected(JsonParser.java:364) at com.eclipsesource.json.JsonParser.readName(JsonParser.java:145) at com.eclipsesource.json.JsonParser.readObject(JsonParser.java:128) at com.eclipsesource.json.JsonParser.readValue(JsonParser.java:83) at com.eclipsesource.json.JsonParser.parse(JsonParser.java:62) at com.eclipsesource.json.JsonValue.readFrom(JsonValue.java:105) at com.eclipsesource.json.JsonObject.readFrom(JsonObject.java:133) at com.eclipsesource.jshint.ui.internal.builder.ConfigLoader.getWorkspaceConfig(ConfigLoader.java:43) at com.eclipsesource.jshint.ui.internal.builder.ConfigLoader.getConfiguration(ConfigLoader.java:38) at com.eclipsesource.jshint.ui.internal.builder.JSHintBuilderVisitor.createJSHint(JSHintBuilderVisitor.java:93) at com.eclipsesource.jshint.ui.internal.builder.JSHintBuilderVisitor.(JSHintBuilderVisitor.java:55) at com.eclipsesource.jshint.ui.internal.builder.JSHintBuilder.incrementalBuild(JSHintBuilder.java:60) at com.eclipsesource.jshint.ui.internal.builder.JSHintBuilder.build(JSHintBuilder.java:40) at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:733) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:206) at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:246) at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:299) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:302) at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:358) at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:381) at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:143) at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:241) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)

twostone avatar Jan 20 '14 13:01 twostone

Similar error. Config:


{
/*
  "curly": true,
  "eqeqeq": true,
  "immed": true,
  "freeze": true,
  "latedef": true,
  "noempty": true,
  "nonew": true,
  "undef": true,
  "unused": true,
  //ENVIRONMENT
  "globals": {
    "Ext":true
  },
*/
  "browser": true,
  "devel": true
}

It turns out I'm using "JSHint Eclipse Integration 0.9.9.20131029-1050", but when I update, "No updates [are] found".

ssaunders avatar Jan 24 '14 20:01 ssaunders

Thanks, I can reproduce it now. The problem exists only with the workbench preferences, not with project-specific settings.

ralfstx avatar Jan 25 '14 13:01 ralfstx