Escribir una instancia incompleta arroja Cannot read property 'id' of undefined
.
El siguiente código de entrada debería reproducir el problema:
var something = [];
if(something instanceof) {
// Notice the instanceof is missing the class name
}
Actualmente estoy usando JSHint 2.9.3
Tengo este problema a través del paquete atom linter-jshint con jshint v2.9.3.
Error: C:\Users\emile.bergeron.CAMINO\.atom\packages\linter-jshint\node_modules\jshint\src\jshint.js:5386
throw err;
^
TypeError: Cannot read property 'id' of undefined
at C:\Users\emile.bergeron.CAMINO\.atom\packages\linter-jshint\node_modules\jshint\src\jshint.js:2131:14
at Object.x.led (C:\Users\emile.bergeron.CAMINO\.atom\packages\linter-jshint\node_modules\jshint\src\jshint.js:1155:16)
at expression (C:\Users\emile.bergeron.CAMINO\.atom\packages\linter-jshint\node_modules\jshint\src\jshint.js:926:36)
at C:\Users\emile.bergeron.CAMINO\.atom\packages\linter-jshint\node_modules\jshint\src\jshint.js:2051:18
at Object.x.led (C:\Users\emile.bergeron.CAMINO\.atom\packages\linter-jshint\node_modules\jshint\src\jshint.js:1155:16)
at expression (C:\Users\emile.bergeron.CAMINO\.atom\packages\linter-jshint\node_modules\jshint\src\jshint.js:926:36)
at Object.fud (C:\Users\emile.bergeron.CAMINO\.atom\packages\linter-jshint\node_modules\jshint\src\jshint.js:4423:22)
at expression (C:\Users\emile.bergeron.CAMINO\.atom\packages\linter-jshint\node_modules\jshint\src\jshint.js:885:32)
at statement (C:\Users\emile.bergeron.CAMINO\.atom\packages\linter-jshint\node_modules\jshint\src\jshint.js:1636:9)
at statements (C:\Users\emile.bergeron.CAMINO\.atom\packages\linter-jshint\node_modules\jshint\src\jshint.js:1681:16)
at ChildProcess.<anonymous> (C:\Users\emile.bergeron.CAMINO\.atom\packages\linter-jshint\node_modules\atom-linter\node_modules\sb-exec\lib\index.js:56:20)
at emitTwo (events.js:100:13)
at ChildProcess.emit (events.js:185:7)
at maybeClose (internal/child_process.js:850:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:215:5)
Mismo error al abrir un comentario como este:
module.exports = {
attributes: {},
/*sth: {},
sth2: function(){}
};
¿Esto se debe a una herramienta que se ejecuta automáticamente en el código que se está editando actualmente?
En atom uso linter-jshint. Pero también cuando guardo un archivo con ese contenido y ejecuto jshint desde CLI obtuve el mismo error.
jshint test.js
en archivo
module.exports = {
attributes: {},
/*sth: {}
};
genera error:
/usr/local/lib/node_modules/jshint/src/jshint.js:5386
throw err;
^
TypeError: Cannot read property 'id' of null
at Object.x.nud (/usr/local/lib/node_modules/jshint/src/jshint.js:3240:26)
at expression (/usr/local/lib/node_modules/jshint/src/jshint.js:888:34)
at /usr/local/lib/node_modules/jshint/src/jshint.js:1389:20
at Object.x.led (/usr/local/lib/node_modules/jshint/src/jshint.js:1155:16)
at expression (/usr/local/lib/node_modules/jshint/src/jshint.js:926:36)
at statement (/usr/local/lib/node_modules/jshint/src/jshint.js:1636:9)
at statements (/usr/local/lib/node_modules/jshint/src/jshint.js:1681:16)
at itself (/usr/local/lib/node_modules/jshint/src/jshint.js:5365:9)
at lint (/usr/local/lib/node_modules/jshint/src/cli.js:495:8)
at /usr/local/lib/node_modules/jshint/src/cli.js:656:7
Creo que debería haber un error de análisis como 'comentario no cerrado'.
Parece relacionado con #2932.
Y para atom linter-jshint , todavía están en jshint v2.9.2. Abriendo el problema AtomLinter/linter-jshint#353 allí para actualizar jshint.
En realidad, está usando un rango, pero como la actualización requiere la reinstalación del paquete para la mayoría de los usuarios, solo voy a fijarlo.
Puedo confirmar que arroja el mismo error en la demostración de JSHint .
Confirmado; gracias por el informe! Envié un parche para corregir este error: https://github.com/jshint/jshint/pull/3046.
Comentario más útil
Confirmado; gracias por el informe! Envié un parche para corregir este error: https://github.com/jshint/jshint/pull/3046.