Skip to content

Commit

Permalink
feat: react 19 support. (#80)
Browse files Browse the repository at this point in the history
* chore: upgrade to react 19 rc.

* chore: babel changes.

* chore: upgrade lint and test.

* test: markWordsSpoken passing.

* ci: build first.
  • Loading branch information
morganney authored Jul 18, 2024
1 parent 8b292a1 commit 3316d00
Show file tree
Hide file tree
Showing 26 changed files with 4,144 additions and 2,869 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
dist
build
coverage
node_modules
41 changes: 0 additions & 41 deletions .eslintrc.json

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ jobs:
with:
name: npm-debug-log-${{ hashFiles('package-lock.json') }}
path: npm-debug.log
- name: Pack
run: npm pack --pack-destination=packages/tts-react --workspace=tts-react
- name: Lint
run: npm run lint
- name: Test
Expand All @@ -35,7 +37,5 @@ jobs:
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: Pack
run: npm pack --pack-destination=packages/tts-react --workspace=tts-react
- name: Build Story
run: npm run build:story
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ jobs:
with:
name: npm-debug-log-${{ hashFiles('package-lock.json') }}
path: npm-debug.log
- name: Pack
run: npm pack --pack-destination=packages/tts-react --workspace=tts-react
- name: Lint
run: npm run lint
- name: Test
run: npm test
- name: Pack
run: npm pack --pack-destination=packages/tts-react --workspace=tts-react
- name: Push to NPM registry
uses: JS-DevTools/[email protected]
with:
Expand Down
16 changes: 1 addition & 15 deletions babel.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,5 @@
["@babel/preset-react", {
"runtime": "automatic"
}]
],
"env": {
"dual": {
"presets": [
["@babel/preset-env", {
"modules": false
}]
],
"plugins": [
["react-remove-properties", {
"properties": ["data-testid"]
}]
]
}
}
]
}
85 changes: 85 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import js from '@eslint/js'
import tseslint from 'typescript-eslint'
import react from 'eslint-plugin-react'
import reactHooks from 'eslint-plugin-react-hooks'
/**
* Lack of support for eslint@9 is why this package is still on eslint 8.
* @see https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/issues/978
*/
import jsxA11y from 'eslint-plugin-jsx-a11y'
import globals from 'globals'

const config = tseslint.config(
js.configs.recommended,
...tseslint.configs.recommendedTypeChecked,
{
languageOptions: {
parserOptions: {
project: true,
ecmaFeatures: {
jsx: true
}
},
globals: {
...globals.browser,
...globals.node,
...globals.jest,
...globals.es2015
}
},
settings: {
react: {
version: 'detect'
}
},
plugins: {
react,
'react-hooks': reactHooks,
'jsx-a11y': jsxA11y,
},
rules: {
...react.configs.recommended.rules,
...reactHooks.configs.recommended.rules,
...jsxA11y.configs.recommended.rules,
'no-console': 'error',
'react/react-in-jsx-scope': 'off'
}
},
{
files: ['**/__tests__/*'],
rules: {
'@typescript-eslint/unbound-method': 'off'
}
},
{
files: ['**/__tests__/hook.tsx', '**/__tests__/component.tsx'],
rules: {
/**
* Turn off until @types/react supports v19. Possibly will fix this issue.
* Need to use await act(async) but triggers lint error.
*/
'@typescript-eslint/require-await': 'off'
}
},
{
files: ['**/src/component.tsx', '**/src/story.tsx'],
rules: {
/**
* Allow onClick handlers for the player controls to return Promise<void>.
*/
'@typescript-eslint/no-misused-promises': [
'error',
{
checksVoidReturn: {
attributes: false
}
}
]
}
},
{
ignores: ['dist', 'build', 'coverage'],
}
)

export default config
2 changes: 1 addition & 1 deletion jest.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ beforeEach(() => {
jest.useFakeTimers()
})

afterEach(async () => {
afterEach(() => {
jest.clearAllMocks()
jest.clearAllTimers()
})
Loading

0 comments on commit 3316d00

Please sign in to comment.