Skip to content

Commit f5daa5d

Browse files
committed
fixup! transform RUI to typescript (#394)
1 parent 34128ec commit f5daa5d

File tree

153 files changed

+435
-345
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

153 files changed

+435
-345
lines changed

.eslintrc

Lines changed: 13 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,27 @@
11
{
22
"extends": [
3-
"@visionappscz/eslint-config-visionapps",
4-
"plugin:deprecation/recommended"
3+
"@visionappscz/eslint-config-visionapps"
4+
],
5+
"env": {
6+
"browser": true,
7+
"jest": true
8+
},
9+
"ignorePatterns": [
10+
"src/docs/_assets/generated"
511
],
612
"overrides": [
713
{
814
"files": [
9-
"**/*.ts",
10-
"**/*.tsx"
15+
"**/*.md"
1116
],
1217
"extends": [
13-
"@visionappscz/eslint-config-visionapps",
14-
"airbnb-typescript",
15-
"plugin:@typescript-eslint/recommended",
16-
"plugin:typescript-sort-keys/recommended"
17-
],
18-
"parser": "@typescript-eslint/parser",
19-
"parserOptions": {
20-
"project": "tsconfig.json"
21-
},
22-
"plugins": ["@typescript-eslint"],
23-
"rules": {
24-
"@typescript-eslint/no-unused-vars": ["error"],
25-
"@typescript-eslint/object-curly-spacing": ["error"],
26-
"import/prefer-default-export": ["off"],
27-
"no-console": ["error"],
28-
"react/default-props-match-prop-types": ["off"],
29-
"react/require-default-props": ["off"]
30-
}
18+
"plugin:markdown/recommended"
19+
]
3120
}
3221
],
33-
"env": {
34-
"browser": true,
35-
"jest": true
36-
},
37-
"parser": "@typescript-eslint/parser",
38-
"parserOptions": {
39-
"project": "./tsconfig.json"
40-
},
41-
"plugins": [
42-
"@typescript-eslint"
43-
],
22+
"parser": "@babel/eslint-parser",
4423
"rules": {
4524
"import/prefer-default-export": "off",
4625
"no-console": "error"
4726
}
48-
}
27+
}

.eslintrc-ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"plugin:@typescript-eslint/recommended",
66
"plugin:@typescript-eslint/recommended-type-checked",
77
"plugin:deprecation/recommended",
8-
"plugin:typescript-sort-keys/recommended",
8+
"plugin:typescript-sort-keys/recommended"
99
],
1010
"env": {
1111
"browser": true,
@@ -15,7 +15,7 @@
1515
{
1616
"files": [
1717
"*.spec.tsx",
18-
"*.story.tsx",
18+
"*.story.tsx"
1919
],
2020
"rules": {
2121
"@typescript-eslint/unbound-method": "off"

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ It is possible to run React UI in your app in development mode. This is useful
8080
because:
8181

8282
- In production mode React UI uses non-human-readable class names.
83-
- Runtime check (i.e. PropTypes) are suppressed in production mode.
8483

8584
To enable development mode, add the following code to the `webpack.config.js`
8685
file in your app:

declaration.d.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
1-
declare module '*.css';
2-
declare module '*.scss';
1+
declare module '*.css' {
2+
const classes: { [key: string]: string };
3+
export default classes;
4+
}
5+
6+
declare module '*.scss' {
7+
const classes: { [key: string]: string };
8+
export default classes;
9+
}

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@
121121
"mini-css-extract-plugin": "^2.9.0",
122122
"postcss": "^8.4.39",
123123
"postcss-loader": "^8.1.1",
124-
"prop-types": "^15.8.1",
125124
"react": "~18.2.0",
126125
"react-dom": "~18.2.0",
127126
"sass": "^1.77.6",

src/components/Alert/Alert.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { classNames } from '../../helpers/classNames/classNames';
55
import { transferProps } from '../../helpers/transferProps';
66
import { getRootColorClassName } from '../_helpers/getRootColorClassName';
77
import styles from './Alert.module.scss';
8-
import { AlertProps } from './Alert.types';
8+
import type { AlertProps } from './Alert.types';
99

1010
export const Alert: React.FunctionComponent<AlertProps> = ({
1111
children,

src/components/Alert/Alert.types.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import { ReactNode } from 'react';
2-
import {
1+
import type { ReactNode } from 'react';
2+
import type {
3+
CleanedComponentProps,
34
FeedbackColor,
45
NeutralColor,
56
} from '../../types';
67

7-
export type AlertProps = React.ComponentProps<'div'> & {
8+
export type AlertProps = CleanedComponentProps<'div'> & {
89
/**
910
* Alert body.
1011
*/

src/components/Badge/Badge.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { classNames } from '../../helpers/classNames/classNames';
44
import { transferProps } from '../../helpers/transferProps';
55
import { getRootColorClassName } from '../_helpers/getRootColorClassName';
66
import { getRootPriorityClassName } from '../_helpers/getRootPriorityClassName';
7-
import { BadgeProps } from './Badge.types';
7+
import type { BadgeProps } from './Badge.types';
88
import styles from './Badge.module.scss';
99

1010
export const Badge: React.FunctionComponent<BadgeProps> = ({

src/components/Badge/Badge.types.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import {
1+
import type {
2+
CleanedComponentProps,
23
FeedbackColor,
34
NeutralColor,
45
Priority,
56
} from '../../types';
67

7-
export type BadgeProps = React.ComponentProps<'div'> & {
8+
export type BadgeProps = CleanedComponentProps<'div'> & {
89
/**
910
* Color to clarify importance and meaning of the badge. Implements
1011
* [Feedback and Neutral color collections](/docs/foundation/collections#colors).

src/components/Badge/__tests__/Badge.test.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
} from '@testing-library/react';
66
import { feedbackColorPropTest } from '../../../../tests/jest/propTests/feedbackColorPropTest';
77
import { neutralColorPropTest } from '../../../../tests/jest/propTests/neutralColorPropTest';
8-
import { Badge } from '../Badge';
8+
import { Badge } from '../Badge.tsx';
99

1010
const mandatoryProps = {
1111
label: 'label',

src/components/Button/Button.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import React, { useContext } from 'react';
1+
import React, {
2+
useContext,
3+
forwardRef,
4+
} from 'react';
25
import { withGlobalProps } from '../../providers/globalProps';
36
import { classNames } from '../../helpers/classNames/classNames';
47
import { transferProps } from '../../helpers/transferProps';
@@ -9,10 +12,10 @@ import { resolveContextOrProp } from '../_helpers/resolveContextOrProp';
912
import { ButtonGroupContext } from '../ButtonGroup';
1013
import { InputGroupContext } from '../InputGroup/InputGroupContext';
1114
import getRootLabelVisibilityClassName from './helpers/getRootLabelVisibilityClassName';
12-
import { ButtonProps } from './Button.types';
15+
import type { ButtonProps } from './Button.types';
1316
import styles from './Button.module.scss';
1417

15-
export const Button = React.forwardRef<HTMLButtonElement, ButtonProps>((props, ref) => {
18+
export const Button = forwardRef<HTMLButtonElement, ButtonProps>((props, ref) => {
1619
const {
1720
afterLabel,
1821
beforeLabel,

src/components/Button/Button.types.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
import {
1+
import type {
22
ButtonHTMLAttributes,
33
ReactNode,
44
} from 'react';
5-
import {
5+
import type {
66
Breakpoint,
7+
CleanedComponentProps,
78
Color,
89
Priority,
910
Size,
1011
} from '../../types';
1112

12-
export type ButtonProps = React.ComponentProps<'button'> & {
13+
export type ButtonProps = CleanedComponentProps<'button'> & {
1314
/**
1415
* Element to be displayed after label, eg. an icon.
1516
*/

src/components/Button/helpers/getRootLabelVisibilityClassName.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Breakpoint } from '../../../types';
1+
import type { Breakpoint } from '../../../types';
22

33
export default (labelVisibility: Breakpoint, styles: Record<string, string>) => {
44
// Intentionally omitting `xs` which means label is visible on all screen sizes.

src/components/Button/helpers/getRootPriorityClassName.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Priority } from '../../../types';
1+
import type { Priority } from '../../../types';
22

33
export default (priority: Priority, styles: Record<string, string>) => {
44
if (priority === 'filled') {

src/components/ButtonGroup/ButtonGroup.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import {
1010
ButtonGroupContext,
1111
defaultValues,
1212
} from './ButtonGroupContext';
13-
import { ButtonGroupProps } from './ButtonGroup.types';
14-
import { ButtonGroupContextType } from './ButtonGroupContext.types';
13+
import type { ButtonGroupProps } from './ButtonGroup.types';
14+
import type { ButtonGroupContextType } from './ButtonGroupContext.types';
1515
import styles from './ButtonGroup.module.scss';
1616

1717
export const ButtonGroup: React.FunctionComponent<ButtonGroupProps> = ({

src/components/ButtonGroup/ButtonGroup.types.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import { ReactNode } from 'react';
2-
import {
1+
import type { ReactNode } from 'react';
2+
import type {
3+
CleanedComponentPropsWithChildren,
34
Priority,
45
Size,
56
} from '../../types';
67

7-
export type ButtonGroupProps = React.ComponentProps<'fieldset'> & {
8+
export type ButtonGroupProps = CleanedComponentPropsWithChildren<'fieldset'> & {
89
/**
910
* If `true`, the button group will span the full width of its parent.
1011
*/
Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
import React from 'react';
2-
import {
3-
Priority,
4-
Size,
5-
} from '../../types';
6-
import { ButtonGroupContextType } from './ButtonGroupContext.types';
2+
import type { ButtonGroupContextType } from './ButtonGroupContext.types';
73

84
export const defaultValues: ButtonGroupContextType = {
95
block: false,
106
disabled: false,
11-
priority: 'filled' as Priority,
12-
size: 'medium' as Size,
7+
priority: 'filled',
8+
size: 'medium',
139
};
1410

1511
export const ButtonGroupContext = React.createContext <ButtonGroupContextType>(defaultValues);

src/components/ButtonGroup/ButtonGroupContext.types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {
1+
import type {
22
Priority,
33
Size,
44
} from '../../types';

src/components/Card/Card.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { withGlobalProps } from '../../providers/globalProps';
33
import { classNames } from '../../helpers/classNames';
44
import { transferProps } from '../../helpers/transferProps';
55
import { getRootColorClassName } from '../_helpers/getRootColorClassName';
6-
import { CardProps } from './Card.types';
6+
import type { CardProps } from './Card.types';
77
import styles from './Card.module.scss';
88

99
export const Card: React.FunctionComponent<CardProps> = ({

src/components/Card/Card.types.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
import {
1+
import type {
2+
CleanedComponentPropsWithChildren,
23
FeedbackColor,
34
NeutralColor,
45
} from '../../types';
5-
import { ScrollViewProps } from '../ScrollView/ScrollView.types';
6-
import { CardBodyProps } from './CardBody.types';
7-
import { CardFooterProps } from './CardFooter.types';
6+
import type { ScrollViewProps } from '../ScrollView/ScrollView.types';
7+
import type { CardBodyProps } from './CardBody.types';
8+
import type { CardFooterProps } from './CardFooter.types';
89

9-
export type CardProps = React.ComponentProps<'div'> & {
10+
export type CardProps = CleanedComponentPropsWithChildren<'div'> & {
1011
/**
1112
* Slot for individual card elements that build up the inner layout:
1213
* * `CardBody`

src/components/Card/CardBody.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import { withGlobalProps } from '../../providers/globalProps';
33
import { transferProps } from '../../helpers/transferProps';
4-
import { CardBodyProps } from './CardBody.types';
4+
import type { CardBodyProps } from './CardBody.types';
55
import styles from './Card.module.scss';
66

77
export const CardBody: React.FunctionComponent<CardBodyProps> = ({

src/components/Card/CardBody.types.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { ReactNode } from 'react';
1+
import type { ReactNode } from 'react';
2+
import type { CleanedComponentPropsWithChildren } from '../../types';
23

3-
export type CardBodyProps = React.ComponentProps<'div'> & {
4+
export type CardBodyProps = CleanedComponentPropsWithChildren<'div'> & {
45
/**
56
* Content of the card.
67
*/

src/components/Card/CardFooter.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import { transferProps } from '../../helpers/transferProps';
33
import { withGlobalProps } from '../../providers/globalProps';
44
import { isChildrenEmpty } from '../_helpers/isChildrenEmpty';
5-
import { CardFooterProps } from './CardFooter.types';
5+
import type { CardFooterProps } from './CardFooter.types';
66
import styles from './Card.module.scss';
77

88
export const CardFooter: React.FunctionComponent<CardFooterProps> = ({

src/components/Card/CardFooter.types.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { ReactNode } from 'react';
1+
import type { ReactNode } from 'react';
2+
import type { CleanedComponentPropsWithChildren } from '../../types';
23

3-
export type CardFooterProps = React.ComponentProps<'div'> & {
4+
export type CardFooterProps = CleanedComponentPropsWithChildren<'div'> & {
45
/**
56
* Card actions, usually buttons.
67
*/

src/components/Card/__tests__/Card.test.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import {
55
} from '@testing-library/react';
66
import { feedbackColorPropTest } from '../../../../tests/jest/propTests/feedbackColorPropTest';
77
import { raisedPropTest } from '../../../../tests/jest/propTests/raisedPropTest';
8-
import { ScrollView } from '../../ScrollView';
9-
import { Card } from '../Card';
10-
import { CardBody } from '../CardBody';
11-
import { CardFooter } from '../CardFooter';
8+
import { ScrollView } from '../../ScrollView/index.ts';
9+
import { Card } from '../Card.tsx';
10+
import { CardBody } from '../CardBody.tsx';
11+
import { CardFooter } from '../CardFooter.tsx';
1212
import { densePropTest } from '../../../../tests/jest/propTests/densePropTest';
1313

1414
const mandatoryProps = {

src/components/Card/__tests__/CardBody.test.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
render,
44
within,
55
} from '@testing-library/react';
6-
import { CardBody } from '../CardBody';
6+
import { CardBody } from '../CardBody.tsx';
77

88
const defaultProps = {
99
children: 'content',

src/components/Card/__tests__/CardFooter.test.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
within,
55
} from '@testing-library/react';
66
import { childrenEmptyPropTest } from '../../../../tests/jest/propTests/childrenEmptyPropTest';
7-
import { CardFooter } from '../CardFooter';
7+
import { CardFooter } from '../CardFooter.tsx';
88

99
const defaultProps = {
1010
children: 'content',

src/components/CheckboxField/CheckboxField.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
import React, { useContext } from 'react';
1+
import React, {
2+
useContext,
3+
forwardRef,
4+
} from 'react';
25
import { withGlobalProps } from '../../providers/globalProps';
36
import { classNames } from '../../helpers/classNames/classNames';
47
import { transferProps } from '../../helpers/transferProps';
58
import { getRootValidationStateClassName } from '../_helpers/getRootValidationStateClassName';
69
import { FormLayoutContext } from '../FormLayout';
7-
import { CheckboxFieldProps } from './CheckboxField.types';
10+
import type { CheckboxFieldProps } from './CheckboxField.types';
811
import styles from './CheckboxField.module.scss';
912

10-
export const CheckboxField = React.forwardRef<HTMLInputElement, CheckboxFieldProps>((props, ref) => {
13+
export const CheckboxField = forwardRef<HTMLInputElement, CheckboxFieldProps>((props, ref) => {
1114
const {
1215
disabled = false,
1316
helpText,

0 commit comments

Comments
 (0)