Vize

script/no-restricted-globals

Disallow references to runtime-environment globals that must go through a typed wrapper.

Default severity Presets Automatic fix Options
error None No Rule options

Applies to: JS/TS scripts in Vue SFCs; examples show the relevant Options API or script setup form.

Bad

The example reads the default restricted globals process, localStorage, and sessionStorage directly, bypassing the project’s explicit config and storage helpers.

<script setup lang="ts">
const flag = process.env.FEATURE_FLAG
const token = localStorage.getItem('auth.token')
sessionStorage.setItem('view.scroll', String(window.scrollY))
</script>

Good

useFeatureFlag, authStorage.read, and viewStorage.write remove those direct restricted-global references. The remaining window.scrollY is not a default restriction of this rule; SSR safety is a separate concern.

<script setup lang="ts">
// Use a typed config helper that distinguishes server vs. client.
const flag = useFeatureFlag('FEATURE_FLAG')

// Use a typed wrapper that scopes keys and handles SSR / disabled storage.
const token = authStorage.read('auth.token')
viewStorage.write('view.scroll', String(window.scrollY))
</script>

Configuration (Vite+)

import { defineConfig } from "@vizejs/vite-plugin/vite-plus";

export default defineConfig({}).withVue({
  linter: {
    "preset": "incremental",
    "rules": {
      "script/no-restricted-globals": "error"
    }
  },
});

Then run vp run lint.