Five oxlint warnings remain, set to warn in .oxlintrc.json.
LiveProvider effect deps
useEffect(() => {
transpileAsync(code).catch(onError);
}, [code, scope, noInline, transformCode]);
Do not apply the suggested fix as-is. The linter calls scope, noInline, and transformCode unnecessary because they are not in the effect body. They are used by transpileAsync, which closes over them. Removing them stops re-transpiling when scope or transformCode changes.
Real bug the linter misses: transpileAsync also closes over enableTypeScript, which is not in the deps, so toggling it at runtime does not re-transpile.
Fix: make transpileAsync a useCallback with deps scope, noInline, transformCode, enableTypeScript, and depend on it. Changes when transpilation runs, notably for an inline scope={{ ... }}.
jsx-no-constructed-context-values
New context object every render re-renders all consumers. Needs useCallback on onError/onChange as well as useMemo, and onChange depends on transpileAsync — so entangled with the above.
set-state-in-effect in Editor
useEffect(() => setCode(props.code), [props.code]) syncs state from props. Both standard fixes change the controlled/uncontrolled contract of a contentEditable editor.
Order
- Add tests that changing
scope, noInline, transformCode, and enableTypeScript re-transpiles. Only code is covered today. The enableTypeScript one should fail, confirming the bug above.
- Fix the stale closure.
useCallback/useMemo refactor.
Editor prop sync, separately.
Worth holding until #415 is understood.
Five oxlint warnings remain, set to
warnin.oxlintrc.json.LiveProvidereffect depsDo not apply the suggested fix as-is. The linter calls
scope,noInline, andtransformCodeunnecessary because they are not in the effect body. They are used bytranspileAsync, which closes over them. Removing them stops re-transpiling whenscopeortransformCodechanges.Real bug the linter misses:
transpileAsyncalso closes overenableTypeScript, which is not in the deps, so toggling it at runtime does not re-transpile.Fix: make
transpileAsyncauseCallbackwith depsscope,noInline,transformCode,enableTypeScript, and depend on it. Changes when transpilation runs, notably for an inlinescope={{ ... }}.jsx-no-constructed-context-valuesNew context object every render re-renders all consumers. Needs
useCallbackononError/onChangeas well asuseMemo, andonChangedepends ontranspileAsync— so entangled with the above.set-state-in-effectinEditoruseEffect(() => setCode(props.code), [props.code])syncs state from props. Both standard fixes change the controlled/uncontrolled contract of a contentEditable editor.Order
scope,noInline,transformCode, andenableTypeScriptre-transpiles. Onlycodeis covered today. TheenableTypeScriptone should fail, confirming the bug above.useCallback/useMemorefactor.Editorprop sync, separately.Worth holding until #415 is understood.