Rel1cx/javascript-globals

[Feature Request] A drop-in replacement of `globals` package

SukkaW opened this issue · 1 comments

SukkaW commented

A.k.a, Record<string, 'readonly' | 'writable' | 'off' | boolean /** boolean value has been deprecated */>. This can be used with the eslint config's languageOptions.env.globals: https://eslint.org/docs/latest/use/configure/language-options#specifying-globals

SukkaW commented
Object.entries(Object.getOwnPropertyDescriptors(globalThis)).reduce((acc, [key, cur]) => {
  if (cur.value !== undefined) {
    if (cur.writable) {
      acc[key] = 'writable'
    } else {
      acc[key] = 'readonly'
    }
  }
  return acc;
}, {});

Maybe this could help?

Note that the built-in global objects are also writable.