Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
eslint-plugin-react-hooks-ssr
Advanced tools
This plugin helps you to forbid DOM globals within the react server side rendering. - it doesn't support yet React classes - it supports react hooks and custom hooks - it requires some naming conventions to identify other functions where globals may be a
This plugin helps you to forbid DOM globals within the react server side rendering.
You'll first need to install ESLint:
$ npm i eslint --save-dev
Next, install eslint-plugin-react-hooks-ssr
:
$ npm install eslint-plugin-react-hooks-ssr --save-dev
Note: If you installed ESLint globally (using the -g
flag) then you must also install eslint-plugin-react-hooks-ssr
globally.
Add react-hooks-ssr
to the plugins section of your .eslintrc.js
configuration file. You can omit the eslint-plugin-
prefix:
{
"plugins": [
"react-hooks-ssr"
]
}
Optionally configure the regexp to whitelist globals within certain function declarations (by default the async
prefix).
{
"rules": {
"react-hooks-ssr/react-hooks-global-ssr": ["error", { "allowFuncRegExp": /test/ }]
}
}
useEffect
is allowedfunction Component() {
useEffect(() => {
console.log(window.innerWidth);
});
return <div>Hello</div>;
}
useXXX
) is allowedfunction Component() {
useCustomHook(() => {
console.log(window.innerWidth);
});
return <div>Hello</div>;
}
async
(asyncMyFunc
) is allowed. This pattern can be replaced by the allowFuncRegExp
optionfunction asyncMyFunction() {
console.log(window.innerWidth);
}
useState
, useReducer
and useMemo
callback is forbiddenfunction Component() {
const [myState, setMyState] = useState(() => {
return window.innerWidth
});
return <div>Hello</div>;
}
Component
is forbiddenfunction Component() {
console.log(window.innerWidth)
return <div>Hello</div>;
}
FAQs
This plugin helps you to forbid DOM globals within the react server side rendering. - it doesn't support yet React classes - it supports react hooks and custom hooks - it requires some naming conventions to identify other functions where globals may be a
The npm package eslint-plugin-react-hooks-ssr receives a total of 13,360 weekly downloads. As such, eslint-plugin-react-hooks-ssr popularity was classified as popular.
We found that eslint-plugin-react-hooks-ssr demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.