Closure Linter vs. JSON

109 views
Skip to first unread message

Nick Thompson

unread,
Aug 20, 2013, 5:20:26 PM8/20/13
to closure-lin...@googlegroups.com
I have some embedded JSON in my source code, but the linter complains about the double-quotes.
I agree with the linter in general about quotes, but would like to make an exception for JSON: is there any way to suppress the quote warning for a single variable definition?

thanks,
    Nick

Hochhaus, Andrew

unread,
Aug 20, 2013, 5:59:23 PM8/20/13
to Closure Linter Discuss
Which specific error are you receiving?

Some (all?) of the closure-linter errors can be turned off using the
@suppress jsdoc. I normally grep the linter code to locate the
required suppression (eg: extraRequire, extraProvide, missingProvide,
accessControls, underscore, etc)

If it is UNNECESSARY_DOUBLE_QUOTED_STRING I don't see a corresponding
suppress that is supported by the linter.

-Andy
> --
> You received this message because you are subscribed to the Google Groups
> "Closure Linter Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to closure-linter-di...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

Andy Perelson

unread,
Aug 20, 2013, 6:52:21 PM8/20/13
to closure-lin...@googlegroups.com
Unfortunately you cannot suppress the unnecessary double quoted string error on a case by case basis using the @suppress annotation. You can see the list of valid values for the @suppress annotation here: https://code.google.com/p/closure-linter/source/browse/trunk/closure_linter/statetracker.py#108 , though not all those suppressions are used by the linter, some are just there for compatibility with the Closure Compiler.

As of a fairly recent release of the linter you can suppress any error for all occurrences on the command line via the --disable flag. You can see the flag source here: https://code.google.com/p/closure-linter/source/browse/trunk/closure_linter/errorrules.py#28 . We don't allow this blanket suppression internally at Google (don't want to allow us to ignore our own style guide) so if there are issues please report them. But it does sound like this is overkill for your case, unfortunately. You are welcome to file a feature request to allow @suppress of arbitrary errors for case by case suppression but I do not know when it would get addressed.

(another) Andy


Nick Thompson

unread,
Aug 20, 2013, 6:13:55 PM8/20/13
to closure-lin...@googlegroups.com
That's the one I'm afraid: 
   E:0131: Single-quoted string preferred over double-quoted string.

Guess I'll put it in a separate file that doesn't go through the linter, or something along those lines.

Thanks,
    Nick


On Tue, Aug 20, 2013 at 2:59 PM, Hochhaus, Andrew <ahoc...@samegoal.com> wrote:
Reply all
Reply to author
Forward
0 new messages