Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jsHint throws a TypeError on some .js files #3092

Closed
GarryFlemings opened this issue Jan 18, 2017 · 2 comments
Closed

jsHint throws a TypeError on some .js files #3092

GarryFlemings opened this issue Jan 18, 2017 · 2 comments

Comments

@GarryFlemings
Copy link

GarryFlemings commented Jan 18, 2017

EDIT: 11 hours after the original post, I read my post again. Where you now see (path to global), I had used a different notation (less thans and greater thans) that didn't show. Very confusing.

I'll consistently call two directories on my C: drive "(path to global)" and "(path to dev)". Neither is relative; both start with C:\ and list directories. (path to dev) is longer; it is a child of (path to global).

expected behavior: jsHint analysis of my .js file
actual behavior: I get this report:

(path to global)\node_modules\jshint\src\jshint.js:5438
        throw err;
        ^

TypeError: Cannot read property 'id' of undefined
    at Object.nud (<path to global>\node_modules\jshint\src\jshint.js:2570:38)
    at expression (<path to global>\node_modules\jshint\src\jshint.js:888:34)
    at statement (<path to global>\node_modules\jshint\src\jshint.js:1633:9)
    at statements (<path to global>\node_modules\jshint\src\jshint.js:1678:16)
    at block <path to global>\node_modules\jshint\src\jshint.js:1773:13)
    at doFunction (<path to global>\node_modules\jshint\src\jshint.js:3078:5)
    at Object.fud (<path to global>\node_modules\jshint\src\jshint.js:3907:5)
    at expression (<path to global>\node_modules\jshint\src\jshint.js:885:32)
    at statement (<path to global>\node_modules\jshint\src\jshint.js:1633:9)
    at statements (<path to global>\node_modules\jshint\src\jshint.js:1678:16)

Sadly, I don't get this for all .js files. Of the two I've tried, one works and one doesn't. Both are modules. The file that causes the report imports from the file that jsHint analyzes without error. Maybe that's relevant.

environment: Windows 10. My .js file includes ES6 syntax. Babel v6.16.0 makes it ES5. Node.js v6.9.2 runs it.

node.js is in C:\Program Files\nodejs.

jshint was 2.9.3. I upgraded to 2.9.4 and got the same behavior.

jsHint is at (path to global)\node_modules\jshint.

A batch file starts jsHint with the command

call (path to global)\jshint (path to dev)\(file).js

In (path to global) are (among others) two files, jshint and jshint.cmd.
jshint

#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")

case `uname` in
    *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac

if [ -x "$basedir/node" ]; then
  "$basedir/node"  "$basedir/node_modules/jshint/bin/jshint" "$@"
  ret=$?
else 
  node  "$basedir/node_modules/jshint/bin/jshint" "$@"
  ret=$?
fi
exit $ret

jshint.cmd

@IF EXIST "%~dp0\node.exe" (
  "%~dp0\node.exe"  "%~dp0\node_modules\jshint\bin\jshint" %*
) ELSE (
  @SETLOCAL
  @SET PATHEXT=%PATHEXT:;.JS;=;%
  node  "%~dp0\node_modules\jshint\bin\jshint" %*
)

The lowest .jshintrc in a directory that is parent to the .js file:

{
  "bitwise": true,
  "curly": false,
  "eqeqeq": false,
  "esversion": 6,
  "forin": true,
  "freeze": true,
  "funcscope": false,
  "futurehostile": true,
  "iterator": false,
  "latedef": "nofunc",
  "maxcomplexity": 15,
  "maxdepth": 10,
  "maxerr": 150,
  "maxparams": 4,
  "maxstatements": 50,
  "noarg": true,
  "nocomma": true,
  "nonbsp": true,
  "nonew": true,
  "notypeof": true,
  "predef": ["Buffer", "console", "module", "process", "promise",
    "require", "setInterval", "window"],
  "shadow": false,
  "singleGroups": true,
  "strict": "global",
  "undef": true,
  "unused": true,
  "varstmt": true,
  "asi": true,
  "boss": false,
  "debug": false,
  "eqnull": true,
  "evil": false,
  "expr": false,
  "lastsemic": true,
  "loopfunc": false,
  "noyield": false,
  "plusplus": false,
  "proto": false,
  "scripturl": false,
  "supernew": false,
  "withstmt": false
}

(path to global) is a parent directory to this file.

I'd like to be as helpful as possible in providing any additional information!

@jugglinmike
Copy link
Member

Can you please provide the source code that triggers this warning? Please remove all but the lines necessary to reproduce the TypeError.

@jugglinmike
Copy link
Member

It's been a few months, so I'm assuming you've worked this out. Let me know if that's not the case, and we can re-open this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants