coco icon indicating copy to clipboard operation
coco copied to clipboard

Proposal: warning or error when using an undefined variable

Open andrewrk opened this issue 13 years ago • 3 comments

a = 3
b = a + c

expected output:

SyntaxError: reading from undefined "c" on line 2

andrewrk avatar Jul 30 '12 19:07 andrewrk

Potential issues: using the window or require object.

Possible solutions:

  • whitelist these variables
  • accept a command line argument with whitelisted variables
  • have a predefined set of whitelisted variables in a "node" category and a "browser" category and have a way to select the target output
  • have a config file that coco will look up the directory tree for with the predefined variables listed in them, similar to .jshintrc
  • a way to mark globals in coco source

andrewrk avatar Jul 30 '12 20:07 andrewrk

Whitelisting is the hardest part. Can't you simply use JSHint?

satyr avatar Jul 31 '12 01:07 satyr

Can't you simply use JSHint?

Problems:

  • that's a 2 step process instead of 1. For example, that would ruin the syntastic experience.
  • coco output isn't suited for jshint
  • jshint errors are about the generated source, not the coco source.

andrewrk avatar Jul 31 '12 15:07 andrewrk