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
npm install eslint-plugin-ssr-friendly
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
54 Stars
69 Commits
11 Forks
4 Watching
5 Branches
5 Contributors
Updated on 20 Nov 2024
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
21.6%
12,628
Compared to previous day
Last week
3.5%
67,587
Compared to previous week
Last month
-6.5%
330,872
Compared to previous month
Last year
48.2%
3,994,963
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
5 existing vulnerabilities detected
Details
Reason
Found 5/11 approved changesets -- score normalized to 4
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
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 2024-11-18
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