Skip to content

Commit

Permalink
revert(jsx): ⏪ revert jsx with type syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
navin-moorthy committed Aug 5, 2021
1 parent 4c79755 commit 5642397
Show file tree
Hide file tree
Showing 127 changed files with 111 additions and 198 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"extends": ["react-app", "react-app/jest", "plugin:prettier/recommended"],
"rules": {
"no-console": "off",
"react/jsx-uses-react": "off",
"react/react-in-jsx-scope": "off",
"testing-library/prefer-explicit-assert": ["error"],
"testing-library/consistent-data-testid": [
2,
Expand Down
1 change: 0 additions & 1 deletion .storybook/preview.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import "focus-visible";
import * as React from "react";

import "./tailwind.css";
import theme from "../renderlesskit.config.ts";
Expand Down
7 changes: 6 additions & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ module.exports = function (api) {
},
},
],
"@babel/preset-react",
[
"@babel/preset-react",
{
runtime: "automatic",
},
],
"@babel/preset-typescript",
];

Expand Down
1 change: 0 additions & 1 deletion src/alert/AlertActionButton.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from "react";
import { cx } from "@renderlesskit/react";

import { useTheme } from "../index";
Expand Down
1 change: 0 additions & 1 deletion src/alert/AlertActions.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from "react";
import { cx } from "@renderlesskit/react";

import { useTheme } from "../index";
Expand Down
1 change: 0 additions & 1 deletion src/alert/AlertBody.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from "react";
import { cx } from "@renderlesskit/react";

import { useTheme } from "../index";
Expand Down
1 change: 0 additions & 1 deletion src/alert/AlertCloseButton.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from "react";
import { cx } from "@renderlesskit/react";

import { useTheme } from "../index";
Expand Down
1 change: 0 additions & 1 deletion src/alert/AlertDescription.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from "react";
import { cx } from "@renderlesskit/react";

import { useTheme } from "../index";
Expand Down
1 change: 0 additions & 1 deletion src/alert/AlertIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from "react";
import { cx } from "@renderlesskit/react";

import {
Expand Down
1 change: 0 additions & 1 deletion src/alert/AlertTitle.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from "react";
import { cx } from "@renderlesskit/react";

import { useTheme } from "../index";
Expand Down
1 change: 0 additions & 1 deletion src/alert/stories/Alert.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from "react";
import { Meta } from "@storybook/react";

import {
Expand Down
4 changes: 2 additions & 2 deletions src/avatar/AvatarGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as React from "react";
import { useMemo } from "react";
import { cx } from "@renderlesskit/react";

import { useTheme } from "../theme";
Expand Down Expand Up @@ -39,7 +39,7 @@ export const AvatarGroup = forwardRefWithAs<
...rest
} = props;
const theme = useTheme();
const context = React.useMemo(
const context = useMemo(
() => ({ size, showBorder, borderColor }),
[size, showBorder, borderColor],
);
Expand Down
6 changes: 3 additions & 3 deletions src/avatar/AvatarIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as React from "react";
import { isValidElement, cloneElement } from "react";
import { Box, BoxProps } from "reakit";
import { cx } from "@renderlesskit/react";

Expand All @@ -16,8 +16,8 @@ export const AvatarIcon = forwardRefWithAs<
const { className, children, ...rest } = props;
const theme = useTheme();
const { size = "md" } = useAvatarContext();
const _children = React.isValidElement(children)
? React.cloneElement(children, {
const _children = isValidElement(children)
? cloneElement(children, {
role: "img",
focusable: false,
"aria-hidden": true,
Expand Down
1 change: 0 additions & 1 deletion src/avatar/AvatarImage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from "react";
import { cx } from "@renderlesskit/react";

import { useTheme } from "../theme";
Expand Down
1 change: 0 additions & 1 deletion src/avatar/AvatarName.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from "react";
import { cx } from "@renderlesskit/react";

import { useTheme } from "../theme";
Expand Down
1 change: 0 additions & 1 deletion src/avatar/__tests__/Avatar.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from "react";
import { screen } from "@testing-library/react";

import { Avatar } from "../index";
Expand Down
2 changes: 0 additions & 2 deletions src/avatar/__tests__/AvatarGroup.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import * as React from "react";

import { Avatar } from "../Avatar";
import { AvatarGroup } from "../AvatarGroup";
import { screen } from "@testing-library/react";
Expand Down
4 changes: 2 additions & 2 deletions src/avatar/stories/Avatar.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import { useState } from "react";
import { Meta } from "@storybook/react";

import {
Expand Down Expand Up @@ -72,7 +72,7 @@ export const TypingBadge = base({

export const BadgeExample = storyTemplate<AvatarProps>(
args => {
const [isTyping, setTyping] = React.useState(false);
const [isTyping, setTyping] = useState(false);

return (
<>
Expand Down
1 change: 0 additions & 1 deletion src/badge/Badge.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from "react";
import { cx } from "@renderlesskit/react";

import { useTheme } from "../theme";
Expand Down
1 change: 0 additions & 1 deletion src/badge/__tests__/Badge.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from "react";
import { Badge } from "../Badge";

import { render } from "../../utils/testUtils";
Expand Down
1 change: 0 additions & 1 deletion src/box/Box.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from "react";
import { Role, RoleProps } from "reakit";

import { forwardRefWithAs } from "../utils/types";
Expand Down
1 change: 0 additions & 1 deletion src/box/stories/Box.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from "react";
import { Story, Meta } from "@storybook/react";

import { Box, BoxProps } from "../index";
Expand Down
1 change: 0 additions & 1 deletion src/button/__tests__/Button.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from "react";
import { Button } from "../Button";

import { screen } from "@testing-library/react";
Expand Down
6 changes: 3 additions & 3 deletions src/button/stories/Button.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as React from "react";
import { useState, useEffect } from "react";
import { ComponentStory, ComponentMeta } from "@storybook/react";
// @ts-ignore
import { withPseudoState } from "storybook-addon-pseudo-states/dist/withPseudoState";
Expand Down Expand Up @@ -250,9 +250,9 @@ export const CustomSpinner: ComponentStory<typeof Button> = {
};

export const LoadingAlly = () => {
const [state, setState] = React.useState(false);
const [state, setState] = useState(false);

React.useEffect(() => {
useEffect(() => {
let timeout: number;
if (state) {
timeout = window.setTimeout(() => setState(prev => !prev), 3000);
Expand Down
2 changes: 0 additions & 2 deletions src/calendar/Icons.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import * as React from "react";

export const CalendarIcon = () => (
<svg
style={{ width: 16 }}
Expand Down
1 change: 0 additions & 1 deletion src/calendar/stories/Calendar.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from "react";
import { Story, Meta } from "@storybook/react";

import {
Expand Down
1 change: 0 additions & 1 deletion src/checkbox/CheckboxDescription.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from "react";
import { cx } from "@renderlesskit/react";

import { useTheme } from "../theme";
Expand Down
1 change: 0 additions & 1 deletion src/checkbox/CheckboxIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from "react";
import { cx } from "@renderlesskit/react";

import { useTheme } from "../theme";
Expand Down
1 change: 0 additions & 1 deletion src/checkbox/CheckboxInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {
Checkbox as ReakitCheckbox,
CheckboxProps as ReakitCheckboxProps,
} from "reakit";
import * as React from "react";
import { cx } from "@renderlesskit/react";

import { useTheme } from "../theme";
Expand Down
1 change: 0 additions & 1 deletion src/checkbox/CheckboxLabel.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from "react";
import { cx } from "@renderlesskit/react";

import { useTheme } from "../theme";
Expand Down
1 change: 0 additions & 1 deletion src/checkbox/CheckboxText.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from "react";
import { cx } from "@renderlesskit/react";

import { useTheme } from "../theme";
Expand Down
10 changes: 5 additions & 5 deletions src/checkbox/__tests__/Checkbox.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as React from "react";
import { useState } from "react";
import { press } from "reakit-test-utils";

import {
Expand All @@ -15,7 +15,7 @@ import { cleanup, fireEvent, render, screen } from "../../utils/testUtils";
afterEach(cleanup);

const CheckboxCustom = (props: CheckboxProps) => {
const [state, onStateChange] = React.useState<CheckboxStatus>(true);
const [state, onStateChange] = useState<CheckboxStatus>(true);

return (
<Checkbox state={state} onStateChange={onStateChange} {...props}>
Expand Down Expand Up @@ -137,7 +137,7 @@ describe("<Checkbox />", () => {

it("should support controlled state", () => {
const Controlled = () => {
const [state, setState] = React.useState(false);
const [state, setState] = useState(false);

return (
<Checkbox state={state} onStateChange={() => setState(!state)}>
Expand All @@ -154,7 +154,7 @@ describe("<Checkbox />", () => {

it("should support custom checkbox", () => {
const Custom = () => {
const [state, setState] = React.useState(false);
const [state, setState] = useState(false);

return (
<CheckboxCustom state={state} onStateChange={() => setState(!state)}>
Expand All @@ -171,7 +171,7 @@ describe("<Checkbox />", () => {

it("should support group checkboxes", () => {
const Group = () => {
const [state, onStateChange] = React.useState<CheckboxStatus>([]);
const [state, onStateChange] = useState<CheckboxStatus>([]);

return (
<>
Expand Down
22 changes: 11 additions & 11 deletions src/checkbox/stories/Checkbox.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import { useState, useMemo, useEffect } from "react";
import { cx } from "@renderlesskit/react";
import { Meta } from "@storybook/react";

Expand Down Expand Up @@ -162,7 +162,7 @@ export const Invalid = storyTemplate<CheckboxProps>(args => {
})({ size: "md" });

export const Controlled = storyTemplate<CheckboxProps>(args => {
const [state, onStateChange] = React.useState<CheckboxStatus>(false);
const [state, onStateChange] = useState<CheckboxStatus>(false);

return (
<>
Expand All @@ -175,7 +175,7 @@ export const Controlled = storyTemplate<CheckboxProps>(args => {
})({ size: "md" });

export const Group = storyTemplate<CheckboxProps>(args => {
const [state, onStateChange] = React.useState<CheckboxStatus>([]);
const [state, onStateChange] = useState<CheckboxStatus>([]);

return (
<>
Expand Down Expand Up @@ -211,7 +211,7 @@ export const Group = storyTemplate<CheckboxProps>(args => {
})({ size: "md" });

export const GroupIndeterminateSimple = storyTemplate<CheckboxProps>(args => {
const [checkedItems, setCheckedItems] = React.useState<CheckboxStatus[]>([
const [checkedItems, setCheckedItems] = useState<CheckboxStatus[]>([
false,
false,
]);
Expand Down Expand Up @@ -248,12 +248,12 @@ export const GroupIndeterminateSimple = storyTemplate<CheckboxProps>(args => {
})({ size: "md" });

export const GroupIndeterminateComplex = storyTemplate<CheckboxProps>(args => {
const values = React.useMemo(() => ["Apple", "Orange", "Watermelon"], []);
const [itemState, setItemState] = React.useState<CheckboxStatus>([]);
const [groupState, setGroupState] = React.useState<CheckboxStatus>(false);
const values = useMemo(() => ["Apple", "Orange", "Watermelon"], []);
const [itemState, setItemState] = useState<CheckboxStatus>([]);
const [groupState, setGroupState] = useState<CheckboxStatus>(false);

// updates items when group is toggled
React.useEffect(() => {
useEffect(() => {
if (groupState === true) {
setItemState(values);
} else if (groupState === false) {
Expand All @@ -262,7 +262,7 @@ export const GroupIndeterminateComplex = storyTemplate<CheckboxProps>(args => {
}, [groupState, values]);

// updates group when items is toggled
React.useEffect(() => {
useEffect(() => {
if (!Array.isArray(itemState)) return;

if (itemState.length === values.length) {
Expand Down Expand Up @@ -299,7 +299,7 @@ export const GroupIndeterminateComplex = storyTemplate<CheckboxProps>(args => {
})({ size: "md" });

const CheckboxCustom = (props: CheckboxProps) => {
const [state, onStateChange] = React.useState<CheckboxStatus>(true);
const [state, onStateChange] = useState<CheckboxStatus>(true);

return (
<Checkbox state={state} onStateChange={onStateChange} {...props}>
Expand Down Expand Up @@ -353,7 +353,7 @@ const CheckboxCustomComplete = (props: CheckboxProps) => {
};

export const CompleteCustomCheckbox = storyTemplate<CheckboxProps>(args => {
const [state, onStateChange] = React.useState<CheckboxStatus>([]);
const [state, onStateChange] = useState<CheckboxStatus>([]);

return (
<>
Expand Down
4 changes: 2 additions & 2 deletions src/circular-progress/CircularProgress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
ProgressInitialState,
ProgressStateReturn,
} from "@renderlesskit/react";
import * as React from "react";
import { useMemo } from "react";

import { BoxProps } from "../box";
import { createContext, runIfFn } from "../utils";
Expand Down Expand Up @@ -42,7 +42,7 @@ export const CircularProgress = forwardRefWithAs<
>((props, ref) => {
const { value, min, max, size = "md", children, ...rest } = props;
const state = useProgressState({ value, min, max });
const context = React.useMemo(() => ({ state, size }), [state, size]);
const context = useMemo(() => ({ state, size }), [state, size]);

return (
<CircularProgressProvider value={context}>
Expand Down
1 change: 0 additions & 1 deletion src/circular-progress/CircularProgressBar.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from "react";
import { cx } from "@renderlesskit/react";

import { useTheme } from "../theme";
Expand Down
1 change: 0 additions & 1 deletion src/circular-progress/CircularProgressWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
ProgressProps,
Progress as RenderlesskitProgress,
} from "@renderlesskit/react";
import * as React from "react";

import { useTheme } from "../theme";
import { forwardRefWithAs } from "../utils/types";
Expand Down
2 changes: 1 addition & 1 deletion src/circular-progress/stories/CircularProgress.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import * as React from "react";
import { isNull } from "@renderlesskit/react";
import { Meta } from "@storybook/react";

Expand Down
1 change: 0 additions & 1 deletion src/datepicker/stories/DatePicker.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from "react";
import { Story, Meta } from "@storybook/react";

import {
Expand Down
1 change: 0 additions & 1 deletion src/form-field/FormErrorText.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from "react";
import { cx } from "@renderlesskit/react";

import { useTheme } from "../theme";
Expand Down
2 changes: 1 addition & 1 deletion src/form-field/FormField.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import * as React from "react";
import { cx } from "@renderlesskit/react";

import { useTheme } from "../theme";
Expand Down
1 change: 0 additions & 1 deletion src/form-field/FormHelperText.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from "react";
import { cx } from "@renderlesskit/react";

import { useTheme } from "../theme";
Expand Down
Loading

0 comments on commit 5642397

Please sign in to comment.