Registry /
testing / eslint-plugin-no-typeof-window-undefined
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.
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
muslnode 18–226 runs
build_error
glibcnode 18–226 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 */ }
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.