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.

npm install eslint-plugin-no-typeof-window-undefined
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-NO-T
E
eslint-plugin-no-typeof-window-undefined
testingjavascriptv0.0.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
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.

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 */ }
Debug
Known issues
gotchaRule name is 'no-typeof-window-undefined/no-typeof-window-undefined' – you must prefix with the plugin namespace.
fix
Use 'no-typeof-window-undefined/no-typeof-window-undefined': 'error' in rules.
affects: >=0.0.0
gotchaDoes not support ESLint flat config (ESLint 9+). No updated version.
fix
Manually adapt plugin to flat config format or use legacy eslintrc.
affects: >=9.0.0
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.
fix
npm 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.
fix
Use 'no-typeof-window-undefined/no-typeof-window-undefined': 'error'
Upgrade
Version history
0.0.2latest on npm
Audit
Dependencies
eslintrequiredpeer dependency; the plugin operates as an ESLint rule
Agent activity
4 hits · last 30 days
node
4
Resources
eslint-plugin-no-typeof-window-undefined — npm install eslint-plugin-no-typeof-window-undefined · libregistry