csslint icon indicating copy to clipboard operation
csslint copied to clipboard

writing comments inside .csslintrc throws warning

Open zafar-saleem opened this issue 10 years ago • 8 comments

Writing comments inside .csslintrc throws following warning which aborts the process

Running "csslint:target" (csslint) task Warning: Unable to parse ".csslintrc" file (Unexpected token /). Use --force to continue.

Aborted due to warnings.

zafar-saleem avatar Mar 31 '14 08:03 zafar-saleem

csslintrc is a data file in JSON. Comments in JSON are not allowed per the spec.

What people often do as a workaround is to add a key "_comment" for instance and hide the comment in the value.

hartman avatar Mar 31 '14 08:03 hartman

In .jshintrc file, comments are allowed and it is also a JSON file.

zafar-saleem avatar Mar 31 '14 08:03 zafar-saleem

It seems jshint uses strip-json-comments:

https://github.com/jshint/jshint/search?q=strip-json-comments&type=Code

hartman avatar Mar 31 '14 08:03 hartman

Therefore, would be good to add strip-json-comments as csslint dependency. I prefer to write comments inside .csslintrc rather than going online and search for different options every now and then to find out what do they mean and how to set them up.

zafar-saleem avatar Mar 31 '14 08:03 zafar-saleem

Agreed. This would be very helpful in keeping my .csslintrc file organized.

cparker15 avatar Jun 09 '14 21:06 cparker15

Does someone have time to test https://github.com/sindresorhus/strip-json-comments to see if it will work in Rhino and WSH?

nschonni avatar Aug 19 '14 04:08 nschonni

@nschonni If #18 is merged in, it should work in both.

jawshooah avatar Jan 18 '15 07:01 jawshooah

Looks like the maintainer isn't interested in supporting Rhino.

However, he did point me to something that could help: Rhino-Require.

Edit: Well, not really. Since we're building a single portable csslint-rhino.js artifact, Rhino-Require doesn't help.

jawshooah avatar Jan 18 '15 07:01 jawshooah