Skip to content

Commit

Permalink
build: react compiler lint
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurlbrjc committed Dec 11, 2024
1 parent 73ca9b4 commit 3a42031
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ function EtablissementPage() {
</div>
</TD>
<TDLink
href={'etablissement/beneficiaires/' + jeune.base.id}
href={'/etablissement/beneficiaires/' + jeune.base.id}
labelPrefix='Accéder à la fiche de'
/>
</TR>
Expand Down
11 changes: 4 additions & 7 deletions components/ModalContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,9 @@ function ModalContainer(
}))
const [isRendered, setIsRendered] = useState(false)
const previousFocusedElement = useRef<HTMLElement | null>(null)
const keyListeners = useRef(
new Map([
['Tab', handleTabKey],
['Escape', handleClose],
])
)
const keyListeners = useRef<{
[key: string]: (e: KeyboardEvent) => void
}>({ Tab: handleTabKey, Escape: handleClose })

function focusClose() {
if (!previousFocusedElement.current)
Expand Down Expand Up @@ -78,7 +75,7 @@ function ModalContainer(
}

function keyListener(e: KeyboardEvent) {
const listener = keyListeners.current.get(e.key)
const listener = keyListeners.current[e.key]
return listener && listener(e)
}

Expand Down
2 changes: 1 addition & 1 deletion components/ui/Table/TDLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default function TDLink({
.filter((cellVisibleText) => cellVisibleText !== null)

setLabel(labelPrefix + ' ' + rowVisibleText.join(' '))
}, [tdRef.current])
}, [])

// a11y card : https://kittygiraudel.com/2022/04/02/accessible-cards/
// absolute position in grandparent : https://stackoverflow.com/a/25768682
Expand Down
9 changes: 9 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { fileURLToPath } from 'node:url'
import { FlatCompat } from '@eslint/eslintrc'
import js from '@eslint/js'
import prettierConfigRecommended from 'eslint-plugin-prettier/recommended'
import reactCompiler from 'eslint-plugin-react-compiler'

const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
Expand Down Expand Up @@ -43,6 +44,14 @@ const eslintConfig = [
],
},
},
{
plugins: {
'react-compiler': reactCompiler,
},
rules: {
'react-compiler/react-compiler': 'error',
},
},
{
settings: {
'jsx-a11y': {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"eslint-config-next": "^15.0.4",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-react-compiler": "19.0.0-beta-37ed2a7-20241206",
"jest": "^29.7.0",
"jest-axe": "^9.0.0",
"jest-environment-jsdom": "^29.7.0",
Expand Down
2 changes: 1 addition & 1 deletion tests/pages/EtablissementPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ describe('EtablissementPage client side', () => {
screen.getByRole('link', {
name: 'Accéder à la fiche de Page 1 Albert Emploi Le 01/03/2023 à 15:11 Carlo Le Calamar',
})
).toHaveAttribute('href', 'etablissement/beneficiaires/id-jeune')
).toHaveAttribute('href', '/etablissement/beneficiaires/id-jeune')
expect(
within(tableauDeBeneficiaires).getByText(`Page 1 Albert`)
).toBeInTheDocument()
Expand Down
86 changes: 84 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ __metadata:
languageName: node
linkType: hard

"@babel/core@npm:^7.11.6, @babel/core@npm:^7.12.3, @babel/core@npm:^7.21.3, @babel/core@npm:^7.23.9":
"@babel/core@npm:^7.11.6, @babel/core@npm:^7.12.3, @babel/core@npm:^7.21.3, @babel/core@npm:^7.23.9, @babel/core@npm:^7.24.4":
version: 7.26.0
resolution: "@babel/core@npm:7.26.0"
dependencies:
Expand Down Expand Up @@ -115,7 +115,7 @@ __metadata:
languageName: node
linkType: hard

"@babel/helper-create-class-features-plugin@npm:^7.25.9":
"@babel/helper-create-class-features-plugin@npm:^7.18.6, @babel/helper-create-class-features-plugin@npm:^7.25.9":
version: 7.25.9
resolution: "@babel/helper-create-class-features-plugin@npm:7.25.9"
dependencies:
Expand Down Expand Up @@ -308,6 +308,17 @@ __metadata:
languageName: node
linkType: hard

"@babel/parser@npm:^7.24.4":
version: 7.26.3
resolution: "@babel/parser@npm:7.26.3"
dependencies:
"@babel/types": "npm:^7.26.3"
bin:
parser: ./bin/babel-parser.js
checksum: 10c0/48f736374e61cfd10ddbf7b80678514ae1f16d0e88bc793d2b505d73d9b987ea786fc8c2f7ee8f8b8c467df062030eb07fd0eb2168f0f541ca1f542775852cad
languageName: node
linkType: hard

"@babel/plugin-bugfix-firefox-class-in-computed-class-key@npm:^7.25.9":
version: 7.25.9
resolution: "@babel/plugin-bugfix-firefox-class-in-computed-class-key@npm:7.25.9"
Expand Down Expand Up @@ -367,6 +378,18 @@ __metadata:
languageName: node
linkType: hard

"@babel/plugin-proposal-private-methods@npm:^7.18.6":
version: 7.18.6
resolution: "@babel/plugin-proposal-private-methods@npm:7.18.6"
dependencies:
"@babel/helper-create-class-features-plugin": "npm:^7.18.6"
"@babel/helper-plugin-utils": "npm:^7.18.6"
peerDependencies:
"@babel/core": ^7.0.0-0
checksum: 10c0/1c273d0ec3d49d0fe80bd754ec0191016e5b3ab4fb1e162ac0c014e9d3c1517a5d973afbf8b6dc9f9c98a8605c79e5f9e8b5ee158a4313fa68d1ff7b02084b6a
languageName: node
linkType: hard

"@babel/plugin-proposal-private-property-in-object@npm:7.21.0-placeholder-for-preset-env.2":
version: 7.21.0-placeholder-for-preset-env.2
resolution: "@babel/plugin-proposal-private-property-in-object@npm:7.21.0-placeholder-for-preset-env.2"
Expand Down Expand Up @@ -1418,6 +1441,16 @@ __metadata:
languageName: node
linkType: hard

"@babel/types@npm:^7.26.3":
version: 7.26.3
resolution: "@babel/types@npm:7.26.3"
dependencies:
"@babel/helper-string-parser": "npm:^7.25.9"
"@babel/helper-validator-identifier": "npm:^7.25.9"
checksum: 10c0/966c5242c5e55c8704bf7a7418e7be2703a0afa4d19a8480999d5a4ef13d095dd60686615fe5983cb7593b4b06ba3a7de8d6ca501c1d78bdd233a10d90be787b
languageName: node
linkType: hard

"@bcoe/v8-coverage@npm:^0.2.3":
version: 0.2.3
resolution: "@bcoe/v8-coverage@npm:0.2.3"
Expand Down Expand Up @@ -5563,6 +5596,22 @@ __metadata:
languageName: node
linkType: hard

"eslint-plugin-react-compiler@npm:19.0.0-beta-37ed2a7-20241206":
version: 19.0.0-beta-37ed2a7-20241206
resolution: "eslint-plugin-react-compiler@npm:19.0.0-beta-37ed2a7-20241206"
dependencies:
"@babel/core": "npm:^7.24.4"
"@babel/parser": "npm:^7.24.4"
"@babel/plugin-proposal-private-methods": "npm:^7.18.6"
hermes-parser: "npm:^0.25.1"
zod: "npm:^3.22.4"
zod-validation-error: "npm:^3.0.3"
peerDependencies:
eslint: ">=7"
checksum: 10c0/072413c7a9a4959fc5e7bb65e1107498c0d940acd993112be338719138fada20f3dcf21900e6a17978a3de6a700ad8f1b9073f873b97ed6ca5be9c63ca32ed06
languageName: node
linkType: hard

"eslint-plugin-react-hooks@npm:^5.0.0":
version: 5.1.0
resolution: "eslint-plugin-react-hooks@npm:5.1.0"
Expand Down Expand Up @@ -6338,6 +6387,22 @@ __metadata:
languageName: node
linkType: hard

"hermes-estree@npm:0.25.1":
version: 0.25.1
resolution: "hermes-estree@npm:0.25.1"
checksum: 10c0/48be3b2fa37a0cbc77a112a89096fa212f25d06de92781b163d67853d210a8a5c3784fac23d7d48335058f7ed283115c87b4332c2a2abaaccc76d0ead1a282ac
languageName: node
linkType: hard

"hermes-parser@npm:^0.25.1":
version: 0.25.1
resolution: "hermes-parser@npm:0.25.1"
dependencies:
hermes-estree: "npm:0.25.1"
checksum: 10c0/3abaa4c6f1bcc25273f267297a89a4904963ea29af19b8e4f6eabe04f1c2c7e9abd7bfc4730ddb1d58f2ea04b6fee74053d8bddb5656ec6ebf6c79cc8d14202c
languageName: node
linkType: hard

"hoist-non-react-statics@npm:^3.3.0":
version: 3.3.2
resolution: "hoist-non-react-statics@npm:3.3.2"
Expand Down Expand Up @@ -8958,6 +9023,7 @@ __metadata:
eslint-config-next: "npm:^15.0.4"
eslint-config-prettier: "npm:^9.1.0"
eslint-plugin-prettier: "npm:^5.2.1"
eslint-plugin-react-compiler: "npm:19.0.0-beta-37ed2a7-20241206"
firebase: "npm:11.0.2"
html-react-parser: "npm:5.2.0"
jest: "npm:^29.7.0"
Expand Down Expand Up @@ -11534,3 +11600,19 @@ __metadata:
checksum: 10c0/dceb44c28578b31641e13695d200d34ec4ab3966a5729814d5445b194933c096b7ced71494ce53a0e8820685d1d010df8b2422e5bf2cdea7e469d97ffbea306f
languageName: node
linkType: hard

"zod-validation-error@npm:^3.0.3":
version: 3.4.0
resolution: "zod-validation-error@npm:3.4.0"
peerDependencies:
zod: ^3.18.0
checksum: 10c0/aaadb0e65c834aacb12fa088663d52d9f4224b5fe6958f09b039f4ab74145fda381c8a7d470bfddf7ddd9bbb5fdfbb52739cd66958ce6d388c256a44094d1fba
languageName: node
linkType: hard

"zod@npm:^3.22.4":
version: 3.24.1
resolution: "zod@npm:3.24.1"
checksum: 10c0/0223d21dbaa15d8928fe0da3b54696391d8e3e1e2d0283a1a070b5980a1dbba945ce631c2d1eccc088fdbad0f2dfa40155590bf83732d3ac4fcca2cc9237591b
languageName: node
linkType: hard

0 comments on commit 3a42031

Please sign in to comment.