Registry /
testing / eslint-plugin-no-typeof-window-undefined
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.
default
✓ module.exports = {
plugins: ['no-typeof-window-undefined'],
rules: { 'no-typeof-window-undefined/no-typeof-window-undefined': 'error' }
};
✗ module.exports = {
plugins: ['no-typeof-window-undefined'],
rules: { 'no-typeof-window-undefined': 'error' }
};
Rule name is the full plugin name; you must prefix with the plugin name.
rules
✓ const plugin = require('eslint-plugin-no-typeof-window-undefined');
// then use plugin.rules['no-typeof-window-undefined']
✗ const { rules } = require('eslint-plugin-no-typeof-window-undefined');
CommonJS; no default export, so destructure from module.exports.
flat config (ESLint 9+)
✓ 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' } }
];
✗ import plugin from 'eslint-plugin-no-typeof-window-undefined';
export default [
{ plugins: ['no-typeof-window-undefined'], ... }
];
ESLint 9+ flat config requires an object with plugin key, not array.
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 */ }
Errors
Common errors & fixes
ESLint couldn't find the plugin "eslint-plugin-no-typeof-window-undefined"
Plugin not installed or not added to plugins array.
fixnpm install --save-dev eslint-plugin-no-typeof-window-undefined and add to plugins: ['no-typeof-window-undefined']
Definition for rule 'no-typeof-window-undefined' was not found
Rule name used without plugin prefix in rules config.
fixUse 'no-typeof-window-undefined/no-typeof-window-undefined': 'error'
Audit
Dependencies
eslintrequiredpeer dependency; the plugin operates as an ESLint rule