Skip to content

Commit 69f0725

Browse files
committed
refactor: drop jsx pragma
1 parent 6f9c175 commit 69f0725

File tree

12 files changed

+34
-61
lines changed

12 files changed

+34
-61
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"react-dom": ">=16.7.0-alpha.1"
4141
},
4242
"dependencies": {
43+
"@emotion/core": "^10.0.10",
4344
"@fortawesome/free-solid-svg-icons": "5.6.x",
4445
"@stoplight/json": "1.9.x",
4546
"lodash": "4.17.x"

src/JsonSchemaViewer.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
/* @jsx jsx */
2-
3-
import { jsx } from '@emotion/core';
41
import { Omit } from '@stoplight/types';
5-
import { Component } from 'react';
2+
import * as React from 'react';
63
import { ErrorMessage } from './common/ErrorMessage';
74
import { MutedText } from './common/MutedText';
85
import { ISchemaView, SchemaView } from './SchemaView';
@@ -17,7 +14,7 @@ export interface IJsonSchemaViewerState {
1714
error: null | string;
1815
}
1916

20-
export class JsonSchemaViewer extends Component<IJsonSchemaViewer, IJsonSchemaViewerState> {
17+
export class JsonSchemaViewer extends React.PureComponent<IJsonSchemaViewer, IJsonSchemaViewerState> {
2118
public state = {
2219
error: null,
2320
};

src/SchemaView.tsx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
/* @jsx jsx */
2-
3-
import { jsx } from '@emotion/core';
41
import { Dictionary, ISchema } from '@stoplight/types';
52
import { Box, Button, IBox } from '@stoplight/ui-kit';
63
import dropRight = require('lodash/dropRight');
7-
import { FunctionComponent, MouseEventHandler, ReactNodeArray, useCallback, useState } from 'react';
4+
import * as React from 'react';
85
import { MutedText } from './common/MutedText';
96
import { renderSchema } from './renderers/renderSchema';
107
import { useTheme } from './theme';
@@ -24,7 +21,7 @@ export interface ISchemaViewProps {
2421

2522
export interface ISchemaView extends ISchemaViewProps, IBox {}
2623

27-
export const SchemaView: FunctionComponent<ISchemaView> = props => {
24+
export const SchemaView: React.FunctionComponent<ISchemaView> = props => {
2825
const {
2926
defaultExpandedDepth = 1,
3027
emptyText,
@@ -38,17 +35,17 @@ export const SchemaView: FunctionComponent<ISchemaView> = props => {
3835
} = props;
3936

4037
const theme = useTheme();
41-
const [showExtra, setShowExtra] = useState<boolean>(false);
42-
const [expandedRows, setExpandedRows] = useState<Dictionary<boolean>>({ all: expanded });
38+
const [showExtra, setShowExtra] = React.useState<boolean>(false);
39+
const [expandedRows, setExpandedRows] = React.useState<Dictionary<boolean>>({ all: expanded });
4340

44-
const toggleExpandRow = useCallback<(rowKey: string, expanded: boolean) => void>(
41+
const toggleExpandRow = React.useCallback<(rowKey: string, expanded: boolean) => void>(
4542
(rowKey, expandRow) => {
4643
setExpandedRows({ ...expandedRows, [rowKey]: expandRow });
4744
},
4845
[expandedRows]
4946
);
5047

51-
const toggleShowExtra = useCallback<MouseEventHandler<HTMLElement>>(
48+
const toggleShowExtra = React.useCallback<React.MouseEventHandler<HTMLElement>>(
5249
() => {
5350
setShowExtra(!showExtra);
5451
},
@@ -73,7 +70,7 @@ export const SchemaView: FunctionComponent<ISchemaView> = props => {
7370
actualSchema = buildAllOfSchema(schemaProps);
7471
}
7572

76-
let rowElems: ReactNodeArray = [];
73+
let rowElems: React.ReactNodeArray = [];
7774

7875
renderSchema({
7976
schemas,

src/__tests__/JsonSchemaViewer.spec.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
/* @jsx jsx */
2-
import { jsx } from '@emotion/core';
31
import { shallow } from 'enzyme';
42
import 'jest-enzyme';
3+
import * as React from 'react';
54
import { MutedText } from '../common/MutedText';
65
import { JsonSchemaViewer } from '../JsonSchemaViewer';
76
import { SchemaView } from '../SchemaView';

src/__tests__/SchemaView.spec.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* @jsx jsx */
2-
import { jsx } from '@emotion/core';
31
import { Button } from '@stoplight/ui-kit';
42
import { shallow } from 'enzyme';
53
import 'jest-enzyme';

src/common/ErrorMessage.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
/* @jsx jsx */
2-
3-
import { jsx } from '@emotion/core';
41
import { Box, IBox } from '@stoplight/ui-kit';
5-
import { FunctionComponent } from 'react';
2+
import * as React from 'react';
63
import { useTheme } from '../theme';
74

8-
export const ErrorMessage: FunctionComponent<IErrorMessage> = props => {
5+
export const ErrorMessage: React.FunctionComponent<IErrorMessage> = props => {
96
const { children, ...rest } = props;
107
const css = errorMessageStyles();
118

src/common/MutedText.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
/* @jsx jsx */
2-
3-
import { jsx } from '@emotion/core';
41
import { Box, IBox } from '@stoplight/ui-kit';
5-
import { FunctionComponent } from 'react';
2+
import * as React from 'react';
63
import { useTheme } from '../theme';
74

8-
export const MutedText: FunctionComponent<IMutedText> = props => {
5+
export const MutedText: React.FunctionComponent<IMutedText> = props => {
96
const { children, ...rest } = props;
107
const css = mutedTextStyles();
118

src/common/Row.tsx

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
/* @jsx jsx */
2-
3-
import { css, jsx } from '@emotion/core';
4-
import { Box, IBox } from '@stoplight/ui-kit';
5-
import { FunctionComponent } from 'react';
1+
import { css } from '@emotion/core';
2+
import { Box, IBox, IBoxCSS } from '@stoplight/ui-kit';
3+
import * as React from 'react';
64
import { DEFAULT_PADDING, GUTTER_WIDTH } from '../consts';
75
import { useTheme } from '../theme';
86

9-
export const Row: FunctionComponent<IRow> = props => {
7+
export const Row: React.FunctionComponent<IRow> = props => {
108
const { children, level, ...rest } = props;
119
const styles = rowStyles({ level });
1210

@@ -23,13 +21,11 @@ export interface IRowProps {
2321

2422
export interface IRow extends IRowProps, IBox {}
2523

26-
export const rowStyles = ({ level }: IRowProps) => {
24+
export const rowStyles = ({ level }: IRowProps): IBoxCSS => {
2725
const theme = useTheme();
2826

2927
return [
30-
{
31-
...(level !== undefined && { paddingLeft: DEFAULT_PADDING + GUTTER_WIDTH * level }),
32-
},
28+
level !== undefined && { paddingLeft: DEFAULT_PADDING + GUTTER_WIDTH * level },
3329
css`
3430
user-select none;
3531
line-height: 1rem;

src/common/RowType.tsx

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
/* @jsx jsx */
2-
3-
import { jsx } from '@emotion/core';
4-
import { Box, IBox } from '@stoplight/ui-kit';
5-
import { FunctionComponent } from 'react';
1+
import { Box, IBox, IBoxCSS } from '@stoplight/ui-kit';
2+
import * as React from 'react';
63
import { useTheme } from '../theme';
74

8-
export const RowType: FunctionComponent<IRowType> = props => {
5+
export const RowType: React.FunctionComponent<IRowType> = props => {
96
const { children, type, ...rest } = props;
107
const css = rowStyles({ type });
118

@@ -22,10 +19,8 @@ export interface IRowTypeProps {
2219

2320
export interface IRowType extends IRowTypeProps, IBox {}
2421

25-
export const rowStyles = ({ type }: IRowTypeProps) => {
22+
export const rowStyles = ({ type }: IRowTypeProps): IBoxCSS => {
2623
const theme = useTheme();
2724

28-
return {
29-
...(type !== undefined && type in theme.types && { color: theme.types[type] }),
30-
};
25+
return type !== undefined && type in theme.types && { color: theme.types[type] };
3126
};

src/renderers/renderProp.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
/* @jsx jsx */
2-
import { jsx } from '@emotion/core';
31
import { Box, Flex, Icon, IconLibrary } from '@stoplight/ui-kit';
42
import has = require('lodash/has');
53
import isEmpty = require('lodash/isEmpty');
64
import isString = require('lodash/isString');
7-
import { ReactNode, ReactNodeArray } from 'react';
5+
import * as React from 'react';
86

97
import { faCaretDown } from '@fortawesome/free-solid-svg-icons/faCaretDown';
108
import { faCaretRight } from '@fortawesome/free-solid-svg-icons/faCaretRight';
@@ -113,9 +111,9 @@ export const renderProp = ({
113111
types = propType;
114112
}
115113

116-
let typeElems: ReactNodeArray = [];
114+
let typeElems: React.ReactNodeArray = [];
117115
if (!isEmpty(types)) {
118-
typeElems = types.reduce((acc: ReactNode[], type: string, i) => {
116+
typeElems = types.reduce((acc: React.ReactNode[], type: string, i) => {
119117
acc.push(
120118
<RowType as="span" type={type} key={i}>
121119
{type === 'array' && childPropType && childPropType !== 'array' ? `array[${childPropType}]` : type}

0 commit comments

Comments
 (0)