Skip to content

Commit

Permalink
refactor: improve R17-R18 interop, drop jsx-runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
arjunvegda committed Feb 9, 2023
1 parent 7d9554f commit 3c44378
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 19 deletions.
9 changes: 4 additions & 5 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@ module.exports = {
es6: true,
},
parserOptions: {
project: './tsconfig.json',
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
},
rules: {
eqeqeq: 'error',
Expand Down Expand Up @@ -92,8 +90,9 @@ module.exports = {
pathGroupsExcludedImportTypes: ['builtin'],
},
],
'react/jsx-uses-react': 'off',
'react/react-in-jsx-scope': 'off',
// Disable it until we start supporting `react-jsx` again.
// 'react/jsx-uses-react': 'off',
// 'react/react-in-jsx-scope': 'off',
'sort-imports': [
'error',
{
Expand Down
13 changes: 7 additions & 6 deletions src/DevTools/DevTools.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { StrictMode, useEffect, useState } from 'react';
import * as React from 'react';
import {
ColorScheme,
ColorSchemeProvider,
Expand Down Expand Up @@ -53,17 +53,18 @@ const DevTools_ = ({
theme: userColorScheme = 'light',
options,
}: DevToolsProps): JSX.Element => {
const [colorScheme, setColorScheme] = useState<ColorScheme>(userColorScheme);
const [colorScheme, setColorScheme] =
React.useState<ColorScheme>(userColorScheme);
const setDevToolsOptions = useSetDevToolsOptions();

const toggleColorScheme = (value?: ColorScheme) =>
setColorScheme(value || (colorScheme === 'dark' ? 'light' : 'dark'));

useEffect(() => {
React.useEffect(() => {
setColorScheme(userColorScheme);
}, [userColorScheme]);

useEffect(() => {
React.useEffect(() => {
// Should we consider caching these options in the future instead of allowing users to change these?
setDevToolsOptions(options);
}, [setDevToolsOptions, options]);
Expand All @@ -74,7 +75,7 @@ const DevTools_ = ({
};

return (
<StrictMode>
<React.StrictMode>
<ColorSchemeProvider
colorScheme={colorScheme}
toggleColorScheme={toggleColorScheme}
Expand All @@ -85,7 +86,7 @@ const DevTools_ = ({
</InternalDevToolsContext.Provider>
</MantineProvider>
</ColorSchemeProvider>
</StrictMode>
</React.StrictMode>
);
};

Expand Down
6 changes: 3 additions & 3 deletions src/DevTools/Extension/Extension.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { forwardRef, useEffect } from 'react';
import * as React from 'react';
import { ActionIcon, Sx } from '@mantine/core';
import { useAtom, useSetAtom } from 'jotai/react';
import { Store } from 'src/types';
Expand All @@ -23,7 +23,7 @@ const shellTriggerButtonStyles: Sx = () => ({
},
});

const ShellTriggerButton = forwardRef<HTMLButtonElement>((_, ref) => {
const ShellTriggerButton = React.forwardRef<HTMLButtonElement>((_, ref) => {
const setIsShellOpen = useSetAtom(isShellOpenAtom, devtoolsJotaiStoreOptions);

return (
Expand Down Expand Up @@ -55,7 +55,7 @@ export const Extension = ({
useDevtoolsJotaiStoreOptions(),
);

useEffect(() => {
React.useEffect(() => {
// Avoid setting the initial value if the value is found in the local storage
if (typeof isShellOpen !== 'boolean') {
setIsShellOpen(isInitialOpen);
Expand Down
2 changes: 1 addition & 1 deletion src/DevTools/Extension/components/Shell/Shell.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect, useRef } from 'react';
import React, { useEffect, useRef } from 'react';
import { Tabs } from '@mantine/core';
import { useAtomValue } from 'jotai/react';
import { Store } from 'src/types';
Expand Down
4 changes: 2 additions & 2 deletions src/stories/Default/Demos/Random.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ export const Random = () => {
// We're not displaying these values on the UI
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const nestedObject = useAtomValue(nestedObjectAtom, demoStoreOptions);
const text = useAtomValue(textAtom, demoStoreOptions);
const bigint = useAtomValue(bigintAtom, demoStoreOptions);
const _text = useAtomValue(textAtom, demoStoreOptions);
const _bigint = useAtomValue(bigintAtom, demoStoreOptions);
// const circular = useAtomValue(circularAtom, demoStoreOptions);
// console.log(circular);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"compilerOptions": {
"strict": true,
"target": "ESNext",
"jsx": "react-jsx",
"jsx": "react",
"module": "es2015",
"downlevelIteration": true,
"esModuleInterop": true,
Expand Down
2 changes: 1 addition & 1 deletion tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const baseConfig: Options = {
splitting: true,
tsconfig: './tsconfig.build.json',
dts: true,
external: ['jotai', 'React'],
external: ['jotai', 'react', 'react-dom'],
platform: 'node',
outExtension: defaultOutExtension,
esbuildPlugins: defaultEsBuildPlugins,
Expand Down

0 comments on commit 3c44378

Please sign in to comment.