Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to ESLint flat config #583

Merged
merged 3 commits into from
Jan 7, 2025

Conversation

sergei-maertens
Copy link
Member

@sergei-maertens sergei-maertens commented Jan 3, 2025

ESLint 8/9 flat config, with more plugins/strictness based on config from open-forms-sdk

TODO:

  • Figure out type import issues (eslint-plugin-import)
  • Check if we can enable hook checks nope
  • Clean up
  • Abstract preset into shared maykin package

resolves #582

@codecov-commenter
Copy link

codecov-commenter commented Jan 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.19%. Comparing base (b6c5ed0) to head (729e216).
Report is 15 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #583      +/-   ##
==========================================
+ Coverage   84.14%   84.19%   +0.05%     
==========================================
  Files         214      214              
  Lines        5777     5772       -5     
  Branches      587      586       -1     
==========================================
- Hits         4861     4860       -1     
+ Misses        916      912       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sergei-maertens
Copy link
Member Author

I don't think enabling the hooks check is going to be realistic in this project 😬

/home/bbt/code/open-archiefbeheer/frontend/src/components/DestructionListReviewer/DestructionListReviewer.tsx
   78:6   warning  React Hook useEffect has missing dependencies: 'assignCoReviewersFormValuesState' and 'assignedCoReviewers'. Either include them or remove the dependency array. You can also do a functional update 'setAssignCoReviewersFormValuesState(a => ...)' if you only need 'assignCoReviewersFormValuesState' in the 'setAssignCoReviewersFormValuesState' call  react-hooks/exhaustive-deps
   78:7   warning  React Hook useEffect has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked                                                                                                                                                                                                                    react-hooks/exhaustive-deps
  224:6   warning  React Hook useMemo has a missing dependency: 'coReviewers'. Either include it or remove the dependency array                                                                                                                                                                                                                                                react-hooks/exhaustive-deps
  283:6   warning  React Hook useEffect has missing dependencies: 'fields', 'formDialog', 'handleSubmit', and 'handleValidate'. Either include them or remove the dependency array                                                                                                                                                                                             react-hooks/exhaustive-deps
  283:39  warning  React Hook useEffect has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked                                                                                                                                                                                                                    react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/contexts/ZaakSelectionContext.test.tsx
  36:6  warning  React Hook useEffect has a missing dependency: 'context'. Either include it or remove the dependency array                   react-hooks/exhaustive-deps
  56:6  warning  React Hook useEffect has missing dependencies: 'context' and 'expected'. Either include them or remove the dependency array  react-hooks/exhaustive-deps
  77:6  warning  React Hook useEffect has a missing dependency: 'context'. Either include it or remove the dependency array                   react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/hooks/useAuditLog.ts
  29:6  warning  React Hook useEffect has missing dependencies: 'alertOnError' and 'destructionList'. Either include them or remove the dependency array  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/hooks/useCoReviewers.ts
  20:6  warning  React Hook useEffect has a missing dependency: 'alertOnError'. Either include it or remove the dependency array  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/hooks/useDestructionListCoReviewers.ts
  29:6  warning  React Hook useEffect has a missing dependency: 'alertOnError'. Either include it or remove the dependency array  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/hooks/useFields.ts
  66:9  warning  The 'fields' array makes the dependencies of useCallback Hook (at line 219) change on every render. Move it inside the useCallback callback. Alternatively, wrap the initialization of 'fields' in its own useMemo() Hook  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/hooks/useLatestReviewResponse.ts
  30:6  warning  React Hook useEffect has missing dependencies: 'alertOnError' and 'review'. Either include them or remove the dependency array  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/hooks/usePoll.ts
  45:6  warning  React Hook useEffect was passed a dependency list that is not an array literal. This means we can't statically verify whether you've passed the correct dependencies                                                                          react-hooks/exhaustive-deps
  45:6  warning  React Hook useEffect has missing dependencies: 'fn' and 'options?.timeout'. Either include them or remove the dependency array. If 'fn' changes too often, find the parent component that defines it and wrap that definition in useCallback  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/hooks/useRecordManagers.ts
  20:6  warning  React Hook useEffect has a missing dependency: 'alertOnError'. Either include it or remove the dependency array  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/hooks/useReviewers.ts
  20:6  warning  React Hook useEffect has a missing dependency: 'alertOnError'. Either include it or remove the dependency array  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/hooks/useSelectielijstKlasseChoices.ts
  22:6  warning  React Hook useEffect has a missing dependency: 'alertOnError'. Either include it or remove the dependency array  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/hooks/useSubmitAction.ts
  77:6  warning  React Hook useEffect has a missing dependency: 'alert'. Either include it or remove the dependency array  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/hooks/useUsers.ts
  20:6  warning  React Hook useEffect has a missing dependency: 'alertOnError'. Either include it or remove the dependency array  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/hooks/useWhoAmI.ts
  21:6  warning  React Hook useEffect has a missing dependency: 'alertOnError'. Either include it or remove the dependency array  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/hooks/useZaakSelection.ts
  137:6  warning  React Hook useEffect has missing dependencies: '_updatePageSpecificZaakSelectionState', 'allPagesSelected', 'backend', 'selectionSize', 'setAllPagesSelected', and 'setSelectionSize'. Either include them or remove the dependency array  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/hooks/useZaaktypeChoices.ts
  30:6   warning  React Hook useEffect has missing dependencies: 'alertOnError' and 'searchParams'. Either include them or remove the dependency array      react-hooks/exhaustive-deps
  30:42  warning  React Hook useEffect has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/pages/destructionlist/abstract/BaseListView.tsx
  180:6  warning  React Hook useCallback has a missing dependency: 'handleClearZaakSelection'. Either include it or remove the dependency array  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/pages/destructionlist/detail/DestructionListDetail.tsx
  30:6  warning  React Hook useEffect has missing dependencies: 'destructionList.status' and 'navigate'. Either include them or remove the dependency array  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/pages/destructionlist/detail/hooks/useSecondaryNavigation.tsx
  445:6  warning  React Hook useMemo has missing dependencies: 'BUTTON_ABORT_PROCESS', 'BUTTON_CANCEL_DESTROY', 'BUTTON_DESTROY', 'BUTTON_MAKE_FINAL', 'BUTTON_PROCESS_REVIEW', 'BUTTON_READY_TO_REVIEW', 'getPermittedToolbarItem', and 'isPlannedForDestruction'. Either include them or remove the dependency array  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/pages/destructionlist/detail/pages/DestructionListEditPage/DestructionListEditPage.tsx
  135:5  warning  React Hook useMemo has missing dependencies: 'destructionList.status', 'handleSetEditing', and 'handleUpdate'. Either include them or remove the dependency array  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/pages/destructionlist/detail/pages/DestructionListProcessReviewPage/DestructionListProcessReviewPage.tsx
  138:6  warning  React Hook useMemo has missing dependencies: 'handleProcessReviewZaakSelect' and 'zakenOnPage'. Either include them or remove the dependency array  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/pages/destructionlist/detail/pages/DestructionListProcessReviewPage/components/DestructionListProcessZaakReviewModal/DestructionListProcessZaakReviewModal.tsx
  130:6  warning  React Hook useEffect has missing dependencies: 'getSelectielijstklasseValue' and 'initialFormState'. Either include them or remove the dependency array  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/pages/destructionlist/review/DestructionListReview.tsx
  154:6  warning  React Hook useMemo has a missing dependency: 'getActionsToolbarForZaak'. Either include it or remove the dependency array  react-hooks/exhaustive-deps

✖ 31 problems (0 errors, 31 warnings)

Copy link
Member Author

@sergei-maertens sergei-maertens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, conclusions of this POC:

  • IMO it's viable to switch to flat config
  • I see quite some opportunities to expose the configs from a centralized @maykin/eslint-config package with sufficient room for overrides
  • in combination with (unmaintained) CRA you end up with some duplicated dependencies/eslint plugins because CRA itself pulls in older versions. I'm afraid the long-term solution for this is migrating from CRA to ViteJS if the node_modules size is a problem.
  • eslint isn't the fastest, might be an option to enable the cache (it's disabled by default)

frontend/.eslintrc.json Show resolved Hide resolved
frontend/.eslintrc.json Show resolved Hide resolved
frontend/.eslintrc.json Show resolved Hide resolved
frontend/.eslintrc.json Show resolved Hide resolved
frontend/.eslintrc.json Show resolved Hide resolved
frontend/package.json Show resolved Hide resolved
frontend/src/hooks/useZaakSelection.test.ts Show resolved Hide resolved
frontend/src/hooks/useZaakSelection.ts Show resolved Hide resolved
frontend/src/lib/api/zaakSelection.ts Show resolved Hide resolved
Comment on lines 25 to 31
"start": "DISABLE_ESLINT_PLUGIN=true react-scripts start",
"build": "DISABLE_ESLINT_PLUGIN=true react-scripts build",
"test": "react-scripts test",
"test:coverage": "npm test -- --coverage --watchAll=false",
"eject": "react-scripts eject",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build",
"storybook": "DISABLE_ESLINT_PLUGIN=true storybook dev -p 6006",
"build-storybook": "DISABLE_ESLINT_PLUGIN=true storybook build",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so, I don't really like "stuffing" package.json with envars like this. The .env fie is already use to control environment settings on development and I see a .env.production.template so we might need to align this to get this working properly without breaking stuff.

Can you align with @SilviaAmAm

frontend/package.json Outdated Show resolved Hide resolved
frontend/src/hooks/useZaakSelection.ts Show resolved Hide resolved
@svenvandescheur
Copy link
Contributor

I don't think enabling the hooks check is going to be realistic in this project 😬

/home/bbt/code/open-archiefbeheer/frontend/src/components/DestructionListReviewer/DestructionListReviewer.tsx
   78:6   warning  React Hook useEffect has missing dependencies: 'assignCoReviewersFormValuesState' and 'assignedCoReviewers'. Either include them or remove the dependency array. You can also do a functional update 'setAssignCoReviewersFormValuesState(a => ...)' if you only need 'assignCoReviewersFormValuesState' in the 'setAssignCoReviewersFormValuesState' call  react-hooks/exhaustive-deps
   78:7   warning  React Hook useEffect has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked                                                                                                                                                                                                                    react-hooks/exhaustive-deps
  224:6   warning  React Hook useMemo has a missing dependency: 'coReviewers'. Either include it or remove the dependency array                                                                                                                                                                                                                                                react-hooks/exhaustive-deps
  283:6   warning  React Hook useEffect has missing dependencies: 'fields', 'formDialog', 'handleSubmit', and 'handleValidate'. Either include them or remove the dependency array                                                                                                                                                                                             react-hooks/exhaustive-deps
  283:39  warning  React Hook useEffect has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked                                                                                                                                                                                                                    react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/contexts/ZaakSelectionContext.test.tsx
  36:6  warning  React Hook useEffect has a missing dependency: 'context'. Either include it or remove the dependency array                   react-hooks/exhaustive-deps
  56:6  warning  React Hook useEffect has missing dependencies: 'context' and 'expected'. Either include them or remove the dependency array  react-hooks/exhaustive-deps
  77:6  warning  React Hook useEffect has a missing dependency: 'context'. Either include it or remove the dependency array                   react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/hooks/useAuditLog.ts
  29:6  warning  React Hook useEffect has missing dependencies: 'alertOnError' and 'destructionList'. Either include them or remove the dependency array  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/hooks/useCoReviewers.ts
  20:6  warning  React Hook useEffect has a missing dependency: 'alertOnError'. Either include it or remove the dependency array  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/hooks/useDestructionListCoReviewers.ts
  29:6  warning  React Hook useEffect has a missing dependency: 'alertOnError'. Either include it or remove the dependency array  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/hooks/useFields.ts
  66:9  warning  The 'fields' array makes the dependencies of useCallback Hook (at line 219) change on every render. Move it inside the useCallback callback. Alternatively, wrap the initialization of 'fields' in its own useMemo() Hook  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/hooks/useLatestReviewResponse.ts
  30:6  warning  React Hook useEffect has missing dependencies: 'alertOnError' and 'review'. Either include them or remove the dependency array  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/hooks/usePoll.ts
  45:6  warning  React Hook useEffect was passed a dependency list that is not an array literal. This means we can't statically verify whether you've passed the correct dependencies                                                                          react-hooks/exhaustive-deps
  45:6  warning  React Hook useEffect has missing dependencies: 'fn' and 'options?.timeout'. Either include them or remove the dependency array. If 'fn' changes too often, find the parent component that defines it and wrap that definition in useCallback  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/hooks/useRecordManagers.ts
  20:6  warning  React Hook useEffect has a missing dependency: 'alertOnError'. Either include it or remove the dependency array  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/hooks/useReviewers.ts
  20:6  warning  React Hook useEffect has a missing dependency: 'alertOnError'. Either include it or remove the dependency array  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/hooks/useSelectielijstKlasseChoices.ts
  22:6  warning  React Hook useEffect has a missing dependency: 'alertOnError'. Either include it or remove the dependency array  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/hooks/useSubmitAction.ts
  77:6  warning  React Hook useEffect has a missing dependency: 'alert'. Either include it or remove the dependency array  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/hooks/useUsers.ts
  20:6  warning  React Hook useEffect has a missing dependency: 'alertOnError'. Either include it or remove the dependency array  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/hooks/useWhoAmI.ts
  21:6  warning  React Hook useEffect has a missing dependency: 'alertOnError'. Either include it or remove the dependency array  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/hooks/useZaakSelection.ts
  137:6  warning  React Hook useEffect has missing dependencies: '_updatePageSpecificZaakSelectionState', 'allPagesSelected', 'backend', 'selectionSize', 'setAllPagesSelected', and 'setSelectionSize'. Either include them or remove the dependency array  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/hooks/useZaaktypeChoices.ts
  30:6   warning  React Hook useEffect has missing dependencies: 'alertOnError' and 'searchParams'. Either include them or remove the dependency array      react-hooks/exhaustive-deps
  30:42  warning  React Hook useEffect has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/pages/destructionlist/abstract/BaseListView.tsx
  180:6  warning  React Hook useCallback has a missing dependency: 'handleClearZaakSelection'. Either include it or remove the dependency array  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/pages/destructionlist/detail/DestructionListDetail.tsx
  30:6  warning  React Hook useEffect has missing dependencies: 'destructionList.status' and 'navigate'. Either include them or remove the dependency array  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/pages/destructionlist/detail/hooks/useSecondaryNavigation.tsx
  445:6  warning  React Hook useMemo has missing dependencies: 'BUTTON_ABORT_PROCESS', 'BUTTON_CANCEL_DESTROY', 'BUTTON_DESTROY', 'BUTTON_MAKE_FINAL', 'BUTTON_PROCESS_REVIEW', 'BUTTON_READY_TO_REVIEW', 'getPermittedToolbarItem', and 'isPlannedForDestruction'. Either include them or remove the dependency array  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/pages/destructionlist/detail/pages/DestructionListEditPage/DestructionListEditPage.tsx
  135:5  warning  React Hook useMemo has missing dependencies: 'destructionList.status', 'handleSetEditing', and 'handleUpdate'. Either include them or remove the dependency array  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/pages/destructionlist/detail/pages/DestructionListProcessReviewPage/DestructionListProcessReviewPage.tsx
  138:6  warning  React Hook useMemo has missing dependencies: 'handleProcessReviewZaakSelect' and 'zakenOnPage'. Either include them or remove the dependency array  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/pages/destructionlist/detail/pages/DestructionListProcessReviewPage/components/DestructionListProcessZaakReviewModal/DestructionListProcessZaakReviewModal.tsx
  130:6  warning  React Hook useEffect has missing dependencies: 'getSelectielijstklasseValue' and 'initialFormState'. Either include them or remove the dependency array  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/pages/destructionlist/review/DestructionListReview.tsx
  154:6  warning  React Hook useMemo has a missing dependency: 'getActionsToolbarForZaak'. Either include it or remove the dependency array  react-hooks/exhaustive-deps

✖ 31 problems (0 errors, 31 warnings)

I don't think enabling the hooks check is going to be realistic in this project 😬

/home/bbt/code/open-archiefbeheer/frontend/src/components/DestructionListReviewer/DestructionListReviewer.tsx
   78:6   warning  React Hook useEffect has missing dependencies: 'assignCoReviewersFormValuesState' and 'assignedCoReviewers'. Either include them or remove the dependency array. You can also do a functional update 'setAssignCoReviewersFormValuesState(a => ...)' if you only need 'assignCoReviewersFormValuesState' in the 'setAssignCoReviewersFormValuesState' call  react-hooks/exhaustive-deps
   78:7   warning  React Hook useEffect has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked                                                                                                                                                                                                                    react-hooks/exhaustive-deps
  224:6   warning  React Hook useMemo has a missing dependency: 'coReviewers'. Either include it or remove the dependency array                                                                                                                                                                                                                                                react-hooks/exhaustive-deps
  283:6   warning  React Hook useEffect has missing dependencies: 'fields', 'formDialog', 'handleSubmit', and 'handleValidate'. Either include them or remove the dependency array                                                                                                                                                                                             react-hooks/exhaustive-deps
  283:39  warning  React Hook useEffect has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked                                                                                                                                                                                                                    react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/contexts/ZaakSelectionContext.test.tsx
  36:6  warning  React Hook useEffect has a missing dependency: 'context'. Either include it or remove the dependency array                   react-hooks/exhaustive-deps
  56:6  warning  React Hook useEffect has missing dependencies: 'context' and 'expected'. Either include them or remove the dependency array  react-hooks/exhaustive-deps
  77:6  warning  React Hook useEffect has a missing dependency: 'context'. Either include it or remove the dependency array                   react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/hooks/useAuditLog.ts
  29:6  warning  React Hook useEffect has missing dependencies: 'alertOnError' and 'destructionList'. Either include them or remove the dependency array  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/hooks/useCoReviewers.ts
  20:6  warning  React Hook useEffect has a missing dependency: 'alertOnError'. Either include it or remove the dependency array  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/hooks/useDestructionListCoReviewers.ts
  29:6  warning  React Hook useEffect has a missing dependency: 'alertOnError'. Either include it or remove the dependency array  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/hooks/useFields.ts
  66:9  warning  The 'fields' array makes the dependencies of useCallback Hook (at line 219) change on every render. Move it inside the useCallback callback. Alternatively, wrap the initialization of 'fields' in its own useMemo() Hook  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/hooks/useLatestReviewResponse.ts
  30:6  warning  React Hook useEffect has missing dependencies: 'alertOnError' and 'review'. Either include them or remove the dependency array  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/hooks/usePoll.ts
  45:6  warning  React Hook useEffect was passed a dependency list that is not an array literal. This means we can't statically verify whether you've passed the correct dependencies                                                                          react-hooks/exhaustive-deps
  45:6  warning  React Hook useEffect has missing dependencies: 'fn' and 'options?.timeout'. Either include them or remove the dependency array. If 'fn' changes too often, find the parent component that defines it and wrap that definition in useCallback  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/hooks/useRecordManagers.ts
  20:6  warning  React Hook useEffect has a missing dependency: 'alertOnError'. Either include it or remove the dependency array  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/hooks/useReviewers.ts
  20:6  warning  React Hook useEffect has a missing dependency: 'alertOnError'. Either include it or remove the dependency array  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/hooks/useSelectielijstKlasseChoices.ts
  22:6  warning  React Hook useEffect has a missing dependency: 'alertOnError'. Either include it or remove the dependency array  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/hooks/useSubmitAction.ts
  77:6  warning  React Hook useEffect has a missing dependency: 'alert'. Either include it or remove the dependency array  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/hooks/useUsers.ts
  20:6  warning  React Hook useEffect has a missing dependency: 'alertOnError'. Either include it or remove the dependency array  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/hooks/useWhoAmI.ts
  21:6  warning  React Hook useEffect has a missing dependency: 'alertOnError'. Either include it or remove the dependency array  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/hooks/useZaakSelection.ts
  137:6  warning  React Hook useEffect has missing dependencies: '_updatePageSpecificZaakSelectionState', 'allPagesSelected', 'backend', 'selectionSize', 'setAllPagesSelected', and 'setSelectionSize'. Either include them or remove the dependency array  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/hooks/useZaaktypeChoices.ts
  30:6   warning  React Hook useEffect has missing dependencies: 'alertOnError' and 'searchParams'. Either include them or remove the dependency array      react-hooks/exhaustive-deps
  30:42  warning  React Hook useEffect has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/pages/destructionlist/abstract/BaseListView.tsx
  180:6  warning  React Hook useCallback has a missing dependency: 'handleClearZaakSelection'. Either include it or remove the dependency array  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/pages/destructionlist/detail/DestructionListDetail.tsx
  30:6  warning  React Hook useEffect has missing dependencies: 'destructionList.status' and 'navigate'. Either include them or remove the dependency array  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/pages/destructionlist/detail/hooks/useSecondaryNavigation.tsx
  445:6  warning  React Hook useMemo has missing dependencies: 'BUTTON_ABORT_PROCESS', 'BUTTON_CANCEL_DESTROY', 'BUTTON_DESTROY', 'BUTTON_MAKE_FINAL', 'BUTTON_PROCESS_REVIEW', 'BUTTON_READY_TO_REVIEW', 'getPermittedToolbarItem', and 'isPlannedForDestruction'. Either include them or remove the dependency array  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/pages/destructionlist/detail/pages/DestructionListEditPage/DestructionListEditPage.tsx
  135:5  warning  React Hook useMemo has missing dependencies: 'destructionList.status', 'handleSetEditing', and 'handleUpdate'. Either include them or remove the dependency array  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/pages/destructionlist/detail/pages/DestructionListProcessReviewPage/DestructionListProcessReviewPage.tsx
  138:6  warning  React Hook useMemo has missing dependencies: 'handleProcessReviewZaakSelect' and 'zakenOnPage'. Either include them or remove the dependency array  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/pages/destructionlist/detail/pages/DestructionListProcessReviewPage/components/DestructionListProcessZaakReviewModal/DestructionListProcessZaakReviewModal.tsx
  130:6  warning  React Hook useEffect has missing dependencies: 'getSelectielijstklasseValue' and 'initialFormState'. Either include them or remove the dependency array  react-hooks/exhaustive-deps

/home/bbt/code/open-archiefbeheer/frontend/src/pages/destructionlist/review/DestructionListReview.tsx
  154:6  warning  React Hook useMemo has a missing dependency: 'getActionsToolbarForZaak'. Either include it or remove the dependency array  react-hooks/exhaustive-deps

✖ 31 problems (0 errors, 31 warnings)

I suggeset enabling it then comment it out, I might want to have a go at this.

@svenvandescheur
Copy link
Contributor

So, conclusions of this POC:

  • IMO it's viable to switch to flat config
  • I see quite some opportunities to expose the configs from a centralized @maykin/eslint-config package with sufficient room for overrides
  • in combination with (unmaintained) CRA you end up with some duplicated dependencies/eslint plugins because CRA itself pulls in older versions. I'm afraid the long-term solution for this is migrating from CRA to ViteJS if the node_modules size is a problem.
  • eslint isn't the fastest, might be an option to enable the cache (it's disabled by default)

Nice work

  • IMO it's viable to switch to flat config

Lets roll

  • I see quite some opportunities to expose the configs from a centralized @maykin/eslint-config package with sufficient room for overrides

The overrides are a requirements so cool. One thing too may attention to is that these packages should remains thin. We don't want to end up with a default project that contains lots of stuff we might have used 8 years ago but not anymore. Lets keep it bare bones only.

  • in combination with (unmaintained) CRA you end up with some duplicated dependencies/eslint plugins because CRA itself pulls in older versions. I'm afraid the long-term solution for this is migrating from CRA to ViteJS if the node_modules size is a problem.

Yes, out of scope for now I would like to migrate in the future.

  • eslint isn't the fastest, might be an option to enable the cache (it's disabled by default)

Lets keep it disabled as I see various caching issues in various tools/softwares quite regularly which are incredible difficult to debug if you don't know where to look (removing node_modules/.cache/) typically works.

@sergei-maertens sergei-maertens force-pushed the experiment/582-eslint-flat-config branch 4 times, most recently from 7fd21a1 to 7e80c8a Compare January 6, 2025 11:54
@sergei-maertens sergei-maertens changed the title Experiment: eslint flat config Migrate to ESLint flat config Jan 6, 2025
@sergei-maertens sergei-maertens marked this pull request as ready for review January 6, 2025 11:59
Copy link
Contributor

@svenvandescheur svenvandescheur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 minor questions, can your address/comment? Otherwise approved

.gitignore Outdated Show resolved Hide resolved
frontend/.env Outdated Show resolved Hide resolved
CRA ships with a default ESLint config, which is overridden in the
project to disable some bits. ESLint is moving towards flat config,
and CRA (unmaintained) is not compatible with it, so we set up our own
flows.

The envvar disables the CRA integration in react-scripts, as it does
not pick up the new config file. The pre-commit checks and CI pipeline
ensure that code is properly linted before being committed.

We also use the shared config from Maykin for consistency across
projects.
Addressed the linter errors to minimize the impact on the project.

Some lines are ignored because they are valid and consistent in the
project, but ignoring the rule as a whole would allow other mistakes to
fall through/go undetected.
@sergei-maertens sergei-maertens force-pushed the experiment/582-eslint-flat-config branch from 7e80c8a to 729e216 Compare January 7, 2025 07:40
@svenvandescheur svenvandescheur merged commit 7ba0203 into main Jan 7, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Experiment: convert eslint to flat config
3 participants