{"id":15466956,"url":"https://github.com/correttojs/eslint-plugin-react-hooks-ssr","last_synced_at":"2025-05-07T14:24:33.523Z","repository":{"id":44018413,"uuid":"231545624","full_name":"correttojs/eslint-plugin-react-hooks-ssr","owner":"correttojs","description":"eslint plugin to forbid globals within the react server side rendering","archived":false,"fork":false,"pushed_at":"2022-12-30T19:23:56.000Z","size":200,"stargazers_count":7,"open_issues_count":5,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-07T14:24:26.322Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/correttojs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-01-03T08:31:04.000Z","updated_at":"2023-08-05T21:50:18.000Z","dependencies_parsed_at":"2023-01-31T14:16:14.409Z","dependency_job_id":null,"html_url":"https://github.com/correttojs/eslint-plugin-react-hooks-ssr","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/correttojs%2Feslint-plugin-react-hooks-ssr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/correttojs%2Feslint-plugin-react-hooks-ssr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/correttojs%2Feslint-plugin-react-hooks-ssr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/correttojs%2Feslint-plugin-react-hooks-ssr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/correttojs","download_url":"https://codeload.github.com/correttojs/eslint-plugin-react-hooks-ssr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252893154,"owners_count":21820770,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-02T01:16:05.388Z","updated_at":"2025-05-07T14:24:33.503Z","avatar_url":"https://github.com/correttojs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# eslint-plugin-react-hooks-ssr\n\nThis plugin helps you to forbid DOM globals within the react server side rendering. \n- it doesn't support yet React classes\n- it supports react hooks and custom hooks\n- it requires some naming conventions to identify other functions where globals may be allowed\n\n\n## Installation\n\nYou'll first need to install [ESLint](http://eslint.org):\n\n```\n$ npm i eslint --save-dev\n```\n\nNext, install `eslint-plugin-react-hooks-ssr`:\n\n```\n$ npm install eslint-plugin-react-hooks-ssr --save-dev\n```\n\n**Note:** If you installed ESLint globally (using the `-g` flag) then you must also install `eslint-plugin-react-hooks-ssr` globally.\n\n## Usage\n\nAdd `react-hooks-ssr` to the plugins section of your `.eslintrc.js` configuration file. You can omit the `eslint-plugin-` prefix:\n\n```javascript\n{\n    \"plugins\": [\n        \"react-hooks-ssr\"\n    ]\n}\n```\n\nOptionally configure the regexp to whitelist globals within certain function declarations (by default the `async` prefix).\n\n```javascript\n{\n    \"rules\": {\n        \"react-hooks-ssr/react-hooks-global-ssr\": [\"error\", { \"allowFuncRegExp\": /test/ }]\n    }\n}\n```\n\n## Documentation\n\n- a global within `useEffect` is allowed \n\n```javascript\nfunction Component() {\n    useEffect(() =\u003e {\n        console.log(window.innerWidth);\n    });\n    return \u003cdiv\u003eHello\u003c/div\u003e;\n}\n```\n\n- a global within a custom hook (`useXXX`) is allowed \n\n```javascript\nfunction Component() {\n    useCustomHook(() =\u003e {\n        console.log(window.innerWidth);\n    });\n    return \u003cdiv\u003eHello\u003c/div\u003e;\n}\n```\n\n\n- a global within a function prefixed by `async` (`asyncMyFunc`) is allowed. This pattern can be replaced by the `allowFuncRegExp` option\n\n```javascript\nfunction asyncMyFunction() {\n  console.log(window.innerWidth);\n}\n```\n\n- a global within a `useState`, `useReducer` and `useMemo` callback is forbidden\n\n```javascript\nfunction Component() {\n    const [myState, setMyState] = useState(() =\u003e {\n        return window.innerWidth\n    });\n    return \u003cdiv\u003eHello\u003c/div\u003e;\n}\n```\n\n- a global within a React `Component` is forbidden\n\n```javascript\nfunction Component() {\n    console.log(window.innerWidth)\n    return \u003cdiv\u003eHello\u003c/div\u003e;\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcorrettojs%2Feslint-plugin-react-hooks-ssr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcorrettojs%2Feslint-plugin-react-hooks-ssr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcorrettojs%2Feslint-plugin-react-hooks-ssr/lists"}