Suppress `Expected an identifier and instead saw 'default' (a reserved word)` in JSLint with Mongoose

五迷三道 提交于 2019-12-04 06:26:51

You can also use the "es5" option to disable this from occurring.

See: http://jslinterrors.com/expected-an-identifier-and-instead-saw-a-a-reserved-word/

default is indeed a reserved word in JavaScript (https://developer.mozilla.org/en/JavaScript/Reference/Reserved_Words). While technically you can use default in an object property name without any problems, you could end up having problems with that notation if your interpreter is strict (like lint is).

Simplest way to go forward: fix the problem by adding quotes. Lint won't whine you any longer. The code is two characters longer, but so what - linting passes and you are guaranteed to not have problems due to use of a reserved keyword.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!