Skip to content

Commit

Permalink
[Linting] Eslint v9 dependency upgrades (#3248)
Browse files Browse the repository at this point in the history
* update: eslint-plugin-react-hooks v5 update

* update: Valid React-component names used for useDescendants

* update: Bumped eslint packages to support v9

* change: Rename hooknames

* update: lock sync
  • Loading branch information
KenAJoh authored Oct 18, 2024
1 parent 1730b2e commit 7138b52
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 30 deletions.
8 changes: 8 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
* - We should add "plugin:react/jsx-runtime", but not sure if this will cause problems for projects not using the new JSX transform
* - Consider adding the rule "id-length"
*/

/**
* V9 migration WIP
* - eslint-plugin-storybook does not support v9 yet: https://github.com/storybookjs/eslint-plugin-storybook/issues/157
* - eslint-plugin-testing-library does not support v9 yet: https://github.com/testing-library/eslint-plugin-testing-library/issues?q=is%3Aissue+is%3Aopen+v9
* - @vitest/eslint-plugin supports v9, just need to replace @vitest/legacy-recommended: https://github.com/vitest-dev/eslint-plugin-vitest?tab=readme-ov-file#usage
* - Looks like @typescript-eslint/eslint-plugin and @typescript-eslint/parser can both be replaced by just typescript-eslint in v9: https://typescript-eslint.io/getting-started#step-2-configuration
*/
module.exports = {
env: {
browser: true,
Expand Down
10 changes: 5 additions & 5 deletions @navikt/core/react/src/util/hooks/descendants/useDescendant.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function createDescendantContext<
K extends Record<string, any> = object,
>() {
const [DescendantsContextProvider, useDescendantsContext] = createContext<
ReturnType<typeof _useDescendants>
ReturnType<typeof useDescendants>
>({
name: "DescendantsProvider",
errorMessage:
Expand All @@ -38,7 +38,7 @@ export function createDescendantContext<
* - ref callback to register the descendant
* - Its enabled index compared to other enabled descendants
*/
function _useDescendant(options?: DescendantOptions<K>) {
function useDescendant(options?: DescendantOptions<K>) {
const descendants = useDescendantsContext();
const [index, setIndex] = useState(-1);
const ref = useRef<T>(null);
Expand Down Expand Up @@ -74,7 +74,7 @@ export function createDescendantContext<
* @internal
* Initializing DescendantsManager
*/
function _useDescendants() {
function useDescendants() {
const descendants = useRef(new DescendantsManager<T, K>()).current;

return descendants;
Expand All @@ -86,8 +86,8 @@ export function createDescendantContext<
// call this when you need to read from context
useDescendantsContext,
// descendants state information, to be called and passed to `ContextProvider`
_useDescendants,
useDescendants,
// descendant index information
_useDescendant,
useDescendant,
] as const;
}
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,12 @@
"cross-env": "^7.0.0",
"eslint": "^8.50.0",
"eslint-plugin-aksel-local": "*",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-jsx-a11y": "^6.7.1",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-jsx-a11y": "^6.10.0",
"eslint-plugin-react": "^7.37.1",
"eslint-plugin-react-hooks": "^5.0.0",
"eslint-plugin-storybook": "^0.9.0",
"eslint-plugin-testing-library": "^6.0.2",
"eslint-plugin-testing-library": "^6.3.2",
"fast-glob": "3.2.11",
"husky": "^8.0.0",
"lint-staged": "13.0.3",
Expand Down
40 changes: 20 additions & 20 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6928,7 +6928,7 @@ __metadata:
languageName: node
linkType: hard

"@typescript-eslint/utils@npm:^5.58.0, @typescript-eslint/utils@npm:^5.62.0":
"@typescript-eslint/utils@npm:^5.62.0":
version: 5.62.0
resolution: "@typescript-eslint/utils@npm:5.62.0"
dependencies:
Expand Down Expand Up @@ -7725,12 +7725,12 @@ __metadata:
cross-env: "npm:^7.0.0"
eslint: "npm:^8.50.0"
eslint-plugin-aksel-local: "npm:*"
eslint-plugin-import: "npm:^2.28.1"
eslint-plugin-jsx-a11y: "npm:^6.7.1"
eslint-plugin-react: "npm:^7.33.2"
eslint-plugin-react-hooks: "npm:^4.6.0"
eslint-plugin-import: "npm:^2.31.0"
eslint-plugin-jsx-a11y: "npm:^6.10.0"
eslint-plugin-react: "npm:^7.37.1"
eslint-plugin-react-hooks: "npm:^5.0.0"
eslint-plugin-storybook: "npm:^0.9.0"
eslint-plugin-testing-library: "npm:^6.0.2"
eslint-plugin-testing-library: "npm:^6.3.2"
fast-glob: "npm:3.2.11"
husky: "npm:^8.0.0"
lint-staged: "npm:13.0.3"
Expand Down Expand Up @@ -11684,7 +11684,7 @@ __metadata:
languageName: unknown
linkType: soft

"eslint-plugin-import@npm:^2.28.1":
"eslint-plugin-import@npm:^2.31.0":
version: 2.31.0
resolution: "eslint-plugin-import@npm:2.31.0"
dependencies:
Expand Down Expand Up @@ -11713,7 +11713,7 @@ __metadata:
languageName: node
linkType: hard

"eslint-plugin-jsx-a11y@npm:^6.7.1":
"eslint-plugin-jsx-a11y@npm:^6.10.0":
version: 6.10.0
resolution: "eslint-plugin-jsx-a11y@npm:6.10.0"
dependencies:
Expand All @@ -11739,16 +11739,16 @@ __metadata:
languageName: node
linkType: hard

"eslint-plugin-react-hooks@npm:^4.6.0":
version: 4.6.2
resolution: "eslint-plugin-react-hooks@npm:4.6.2"
"eslint-plugin-react-hooks@npm:^5.0.0":
version: 5.0.0
resolution: "eslint-plugin-react-hooks@npm:5.0.0"
peerDependencies:
eslint: ^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0
checksum: 10/5a0680941f34e70cf505bcb6082df31a3e445d193ee95a88ff3483041eb944f4cefdaf7e81b0eb1feb4eeceee8c7c6ddb8a2a6e8c4c0388514a42e16ac7b7a69
eslint: ^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0 || ^9.0.0
checksum: 10/b762789832806b6981e2d910994e72aa7a85136fe0880572334b26cf1274ba37bd3b1365e77d2c2f92465337c4a65c84ef647bc499d33b86fc1110f2df7ef1bb
languageName: node
linkType: hard

"eslint-plugin-react@npm:^7.33.2":
"eslint-plugin-react@npm:^7.37.1":
version: 7.37.1
resolution: "eslint-plugin-react@npm:7.37.1"
dependencies:
Expand Down Expand Up @@ -11790,14 +11790,14 @@ __metadata:
languageName: node
linkType: hard

"eslint-plugin-testing-library@npm:^6.0.2":
version: 6.3.0
resolution: "eslint-plugin-testing-library@npm:6.3.0"
"eslint-plugin-testing-library@npm:^6.3.2":
version: 6.4.0
resolution: "eslint-plugin-testing-library@npm:6.4.0"
dependencies:
"@typescript-eslint/utils": "npm:^5.58.0"
"@typescript-eslint/utils": "npm:^5.62.0"
peerDependencies:
eslint: ^7.5.0 || ^8.0.0
checksum: 10/192b112f84f90cc7eee28965b3e7792e8d4cda71aa29690d8180f1ae9cd0e8d6a8851ee992d37285a76750f8638c04e76f768e1885168f060ca169b72ac9ec6c
eslint: ^7.5.0 || ^8.0.0 || ^9.0.0
checksum: 10/b9461e6662542fbfb3c0b768e6038bbaa56e345cb0600c7f07e26ff8154166abb9f7dcdc08d565c314cd9ccf0416eca8c3ce3c235b375c5fbf3f152a81142969
languageName: node
linkType: hard

Expand Down

0 comments on commit 7138b52

Please sign in to comment.