diff --git a/benchmark/static/static.tsx b/benchmark/static/static.tsx index 334eaf4e..b8d9e71a 100755 --- a/benchmark/static/static.tsx +++ b/benchmark/static/static.tsx @@ -7,13 +7,13 @@ function App() { id: number; }> >([]); - const itemCountRef = React.useRef(0); + const itemCountReference = React.useRef(0); React.useEffect(() => { let timer: NodeJS.Timeout | undefined; const run = () => { - if (itemCountRef.current++ > 1000) { + if (itemCountReference.current++ > 1000) { return; } diff --git a/examples/jest/jest.tsx b/examples/jest/jest.tsx index b144192c..2dddaa7c 100644 --- a/examples/jest/jest.tsx +++ b/examples/jest/jest.tsx @@ -32,8 +32,8 @@ type State = { }; class Jest extends React.Component, State> { - constructor(props: Record) { - super(props); + constructor(properties: Record) { + super(properties); this.state = { startTime: Date.now(), diff --git a/examples/jest/summary.tsx b/examples/jest/summary.tsx index e21654ea..a3ade803 100644 --- a/examples/jest/summary.tsx +++ b/examples/jest/summary.tsx @@ -1,14 +1,14 @@ import React from 'react'; import {Box, Text} from '../../src/index.js'; -type Props = { +type Properties = { readonly isFinished: boolean; readonly passed: number; readonly failed: number; readonly time: string; }; -function Summary({isFinished, passed, failed, time}: Props) { +function Summary({isFinished, passed, failed, time}: Properties) { return ( diff --git a/examples/jest/test.tsx b/examples/jest/test.tsx index 7a31905b..ce80c2db 100644 --- a/examples/jest/test.tsx +++ b/examples/jest/test.tsx @@ -21,12 +21,12 @@ const getBackgroundForStatus = (status: string): string | undefined => { } }; -type Props = { +type Properties = { readonly status: string; readonly path: string; }; -function Test({status, path}: Props) { +function Test({status, path}: Properties) { return ( diff --git a/examples/subprocess-output/subprocess-output.tsx b/examples/subprocess-output/subprocess-output.tsx index a3874b2d..7a6fe0f4 100644 --- a/examples/subprocess-output/subprocess-output.tsx +++ b/examples/subprocess-output/subprocess-output.tsx @@ -14,6 +14,7 @@ function SubprocessOutput() { 'examples/jest', ]); + // eslint-disable-next-line @typescript-eslint/ban-types subProcess.stdout.on('data', (newOutput: Buffer) => { const lines = stripAnsi(newOutput.toString('utf8')).split('\n'); setOutput(lines.slice(-5).join('\n')); diff --git a/examples/use-focus-with-id/use-focus-with-id.tsx b/examples/use-focus-with-id/use-focus-with-id.tsx index c9fdf31d..91b17e8d 100644 --- a/examples/use-focus-with-id/use-focus-with-id.tsx +++ b/examples/use-focus-with-id/use-focus-with-id.tsx @@ -40,12 +40,12 @@ function Focus() { ); } -type ItemProps = { +type ItemProperties = { readonly id: number; readonly label: string; }; -function Item({label, id}: ItemProps) { +function Item({label, id}: ItemProperties) { const {isFocused} = useFocus({id}); return ( diff --git a/package.json b/package.json index f49c4c07..de48ef1d 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ ], "dependencies": { "@alcalzone/ansi-tokenize": "^0.1.3", - "ansi-escapes": "^6.0.0", + "ansi-escapes": "^7.0.0", "ansi-styles": "^6.2.1", "auto-bind": "^5.0.1", "chalk": "^5.3.0", @@ -77,9 +77,9 @@ "@types/node": "^20.10.4", "@types/react": "^18.2.43", "@types/react-reconciler": "^0.28.2", - "@types/scheduler": "^0.16.8", + "@types/scheduler": "^0.23.0", "@types/signal-exit": "^3.0.0", - "@types/sinon": "^10.0.20", + "@types/sinon": "^17.0.3", "@types/stack-utils": "^2.0.2", "@types/ws": "^8.5.10", "@vdemedes/prettier-config": "^2.0.1", @@ -88,18 +88,18 @@ "delay": "^6.0.0", "eslint-config-xo-react": "0.27.0", "eslint-plugin-react": "^7.33.2", - "eslint-plugin-react-hooks": "4.6.0", + "eslint-plugin-react-hooks": "^4.6.2", "ms": "^2.1.3", "node-pty": "^1.0.0", "p-queue": "^8.0.0", "prettier": "^3.1.1", "react": "^18.0.0", "react-devtools-core": "^5.0.0", - "sinon": "^17.0.0", + "sinon": "^18.0.0", "strip-ansi": "^7.1.0", "ts-node": "^10.9.2", "typescript": "^5.3.3", - "xo": "^0.56.0" + "xo": "^0.58.0" }, "peerDependencies": { "@types/react": ">=18.0.0", diff --git a/src/components/App.tsx b/src/components/App.tsx index 0638612c..7ad36a6a 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -251,7 +251,7 @@ export default class App extends PureComponent { focusNext = (): void => { this.setState(previousState => { const firstFocusableId = previousState.focusables.find( - focusable => focusable.isActive + focusable => focusable.isActive, )?.id; const nextFocusableId = this.findNextFocusable(previousState); @@ -264,7 +264,7 @@ export default class App extends PureComponent { focusPrevious = (): void => { this.setState(previousState => { const lastFocusableId = previousState.focusables.findLast( - focusable => focusable.isActive + focusable => focusable.isActive, )?.id; const previousFocusableId = this.findPreviousFocusable(previousState); diff --git a/src/devtools-window-polyfill.ts b/src/devtools-window-polyfill.ts index 50f486b4..7ce82850 100644 --- a/src/devtools-window-polyfill.ts +++ b/src/devtools-window-polyfill.ts @@ -5,17 +5,11 @@ import ws from 'ws'; const customGlobal = global as any; // These things must exist before importing `react-devtools-core` -if (!customGlobal.WebSocket) { - customGlobal.WebSocket = ws; -} +customGlobal.WebSocket ||= ws; -if (!customGlobal.window) { - customGlobal.window = global; -} +customGlobal.window ||= global; -if (!customGlobal.self) { - customGlobal.self = global; -} +customGlobal.self ||= global; // Filter out Ink's internal components from devtools for a cleaner view. // Also, ince `react-devtools-shared` package isn't published on npm, we can't diff --git a/src/ink.tsx b/src/ink.tsx index 223c82fa..8f816112 100644 --- a/src/ink.tsx +++ b/src/ink.tsx @@ -291,12 +291,10 @@ export default class Ink { } async waitUntilExit(): Promise { - if (!this.exitPromise) { - this.exitPromise = new Promise((resolve, reject) => { - this.resolveExitPromise = resolve; - this.rejectExitPromise = reject; - }); - } + this.exitPromise ||= new Promise((resolve, reject) => { + this.resolveExitPromise = resolve; + this.rejectExitPromise = reject; + }); return this.exitPromise; } diff --git a/src/reconciler.ts b/src/reconciler.ts index dc09247d..dd40e56c 100644 --- a/src/reconciler.ts +++ b/src/reconciler.ts @@ -59,7 +59,7 @@ const diff = (before: AnyObject, after: AnyObject): AnyObject | undefined => { let isChanged = false; for (const key of Object.keys(before)) { - const isDeleted = after ? !Object.hasOwnProperty.call(after, key) : true; + const isDeleted = after ? !Object.hasOwn(after, key) : true; if (isDeleted) { changed[key] = undefined; diff --git a/test/focus.tsx b/test/focus.tsx index 1d186377..78d405de 100644 --- a/test/focus.tsx +++ b/test/focus.tsx @@ -455,14 +455,14 @@ test('focuses first non-disabled component', async t => { render(, { stdout, stdin, - debug: true + debug: true, }); await delay(100); t.is( (stdout.write as any).lastCall.args[0], - ['First', 'Second', 'Third ✔'].join('\n') + ['First', 'Second', 'Third ✔'].join('\n'), ); }); @@ -472,7 +472,7 @@ test('skips disabled elements when wrapping around', async t => { render(, { stdout, stdin, - debug: true + debug: true, }); await delay(100); @@ -483,7 +483,7 @@ test('skips disabled elements when wrapping around', async t => { t.is( (stdout.write as any).lastCall.args[0], - ['First', 'Second ✔', 'Third'].join('\n') + ['First', 'Second ✔', 'Third'].join('\n'), ); }); @@ -493,7 +493,7 @@ test('skips disabled elements when wrapping around from the front', async t => { render(, { stdout, stdin, - debug: true + debug: true, }); await delay(100); @@ -502,6 +502,6 @@ test('skips disabled elements when wrapping around from the front', async t => { t.is( (stdout.write as any).lastCall.args[0], - ['First', 'Second ✔', 'Third'].join('\n') + ['First', 'Second ✔', 'Third'].join('\n'), ); });