Registry / testing / eslint-plugin-no-typeof-window-undefined

eslint-plugin-no-typeof-window-undefined

JSON →
library0.0.2jsnpmunverified

ESLint rule (version 0.0.2) that flags typeof window === 'undefined' patterns used for SSR checks. Encourages using a helper like `import { isBrowser } from 'some-ssr-helper'` for cleaner and more maintainable code. No updates since initial release. Minimal, single-rule plugin with peer dependency on ESLint ^4-^8.

testing
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Rule name is the full plugin name; you must prefix with the plugin name.

module.exports = { plugins: ['no-typeof-window-undefined'], rules: { 'no-typeof-window-undefined/no-typeof-window-undefined': 'error' } };

CommonJS; no default export, so destructure from module.exports.

const plugin = require('eslint-plugin-no-typeof-window-undefined'); // then use plugin.rules['no-typeof-window-undefined']

ESLint 9+ flat config requires an object with plugin key, not array.

import noTypeofWindowUndefined from 'eslint-plugin-no-typeof-window-undefined'; export default [ { plugins: { 'no-typeof-window-undefined': noTypeofWindowUndefined }, rules: { 'no-typeof-window-undefined/no-typeof-window-undefined': 'error' } } ];

Shows how to install and configure the ESLint plugin to flag typeof window === 'undefined' and suggests using a helper function instead.

// .eslintrc.js (ESLint <=8) module.exports = { plugins: ['no-typeof-window-undefined'], rules: { 'no-typeof-window-undefined/no-typeof-window-undefined': 'error' } }; // Example of flagged code: if (typeof window === 'undefined') { /* server code */ } // Suggested fix: import { isBrowser } from 'some-helper'; if (!isBrowser) { /* server code */ }
Debug
Known footguns
gotchaRule name is 'no-typeof-window-undefined/no-typeof-window-undefined' – you must prefix with the plugin namespace.
gotchaDoes not support ESLint flat config (ESLint 9+). No updated version.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
9 hits · last 30 days
gptbot
4
ahrefsbot
4
script
1
Resources