nodejs / node

Node.js JavaScript runtime ✨🐢🚀✨
https://nodejs.org
Other
107.24k stars 29.42k forks source link

JSON is not in the primordials list #33293

Closed trevnorris closed 4 years ago

trevnorris commented 4 years ago

The JSON object does not appear in the primordials list, but make jslint will display a no-restricted-globals error.

addaleax commented 4 years ago

@trevnorris Not sure what you’re going for here, but JSONParse and JSONStringify do exist and should generally be used rather than grabbing the primordial JSON and using JSON.parse and JSON.stringify on that.

trevnorris commented 4 years ago

And that would explain why my search for git grep "\<JSON\>" -- lib/ didn't help. Well that solves this issue. Thanks.

On a side note; lib/internal/v8_prof_polyfill.js still uses JSON.stringify() in a template literal (possibly why lint doesn't catch it).

Also, might be nice to update lib/.eslintrc.yaml with better instructions on what to use. Instead of

Use const { JSON } = primordials; instead of the global.