Gathering detailed insights and metrics for eslint-plugin-ssr-friendly
Gathering detailed insights and metrics for eslint-plugin-ssr-friendly
Gathering detailed insights and metrics for eslint-plugin-ssr-friendly
Gathering detailed insights and metrics for eslint-plugin-ssr-friendly
ESLint plugin to detect inappropriate use of DOM globals properties
npm install eslint-plugin-ssr-friendly
Typescript
Module System
Node Version
NPM Version
93.7
Supply Chain
92.3
Quality
73.5
Maintenance
100
Vulnerability
98.6
License
JavaScript (100%)
Total Downloads
10,620,881
Last Day
7,719
Last Week
69,822
Last Month
316,473
Last Year
3,891,085
MIT License
54 Stars
81 Commits
13 Forks
3 Watchers
4 Branches
7 Contributors
Updated on Jun 11, 2025
Minified
Minified + Gzipped
Latest Version
1.3.0
Package Id
eslint-plugin-ssr-friendly@1.3.0
Unpacked Size
12.07 kB
Size
3.80 kB
File Count
4
NPM Version
9.5.1
Node Version
18.16.0
Published on
Nov 14, 2023
Cumulative downloads
Total Downloads
Last Day
5.7%
7,719
Compared to previous day
Last Week
-12.3%
69,822
Compared to previous week
Last Month
-1%
316,473
Compared to previous month
Last Year
19.3%
3,891,085
Compared to previous year
1
1
ESLint plugin that detects incorrect use of DOM globals in order to properly do SSR and in general share code between client-side JS and Node.js modules.
1npm i --save-dev eslint-plugin-ssr-friendly
Then add these to your eslintrc configuration:
1{ 2 "plugins": ["ssr-friendly"], 3 "extends": ["plugin:ssr-friendly/recommended"] 4}
no-dom-globals-in-module-scope
Disallow use of DOM globals in module and global scope,
as this will break any import/require
in a NodeJS environment.
To fix it, wrap it in a function that will call when on client-side.
Please note that we can't detect if you're still calling this function without
properly checking upfront if typeof window !== "undefined"
.
1const retina = devicePixelRatio > 2;
1const isRetina = () => devicePixelRatio >= 2;
no-dom-globals-in-constructor
Disallow use of DOM globals in class constructors, as this will break SSR if you're instantiating this class as singleton or you're rendering this component.
To fix it, move this statement in a initOnBrowser()
like-method or componentDidMount()
if you're using React.
Please note that we can't detect if you're still calling this function in your constructor without
properly checking upfront if typeof window !== "undefined"
.
1class myClass { 2 constructor() { 3 document.title = "Otto"; 4 } 5}
1class myClass { 2 componentDidMount() { 3 document.title = "Otto"; 4 } 5}
no-dom-globals-in-react-cc-render
Disallow use of DOM globals in render() method of a React class-component, as this will break SSR if you're rendering this component.
To fix it, move this statement to componentDidMount()
Please note that we can't detect if you're still calling this function in your constructor without
properly checking upfront if typeof window !== "undefined"
.
1class Header extends React.Component { 2 render() { 3 const width = window.innerWidth; 4 return <div style={{ width }} />; 5 } 6}
1class Header extends React.Component { 2 componentDidMount() { 3 this.setState({ width: window.innerWidth }); 4 } 5 render() { 6 return <div style={{ width }} />; 7 } 8}
no-dom-globals-in-react-fc
Disallow use of DOM globals in the render-cycle of a React FC, as this will break SSR if you're rendering this component.
To fix it, move this statement into a useEffect())
1const Header = () => { 2 window.addEventListener("resize", () => {}); 3 return <div />; 4};
1const Header = () => { 2 useEffect(() => { 3 window.addEventListener("resize", () => {}); 4 }, []); 5 return <div />; 6};
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
10 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 8
Reason
3 existing vulnerabilities detected
Details
Reason
Found 6/9 approved changesets -- score normalized to 6
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-06-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More