Skip to content

Commit bcb204b

Browse files
committed
Just run flow-to-ts command
1 parent e391aae commit bcb204b

Some content is hidden

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

51 files changed

+859
-11375
lines changed

.eslintrc.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
module.exports = {
2-
extends: ['algolia', 'algolia/jest', 'algolia/react'],
2+
extends: ['airbnb-typescript', 'prettier'],
3+
4+
parserOptions: {
5+
project: './tsconfig.eslint.json',
6+
},
7+
8+
// ecmaFeatures: {
9+
// jsx: true,
10+
// },
311

412
env: {
513
es6: true,
@@ -11,12 +19,12 @@ module.exports = {
1119
},
1220
},
1321

14-
rules: {
15-
'max-params': ['error', 10],
16-
'no-warning-comments': 'error',
22+
// rules: {
23+
// 'max-params': ['error', 10],
24+
// 'no-warning-comments': 'error',
1725

18-
'import/no-commonjs': 'off',
19-
},
26+
// 'import/no-commonjs': 'off',
27+
// },
2028

2129
overrides: [
2230
{

.flowconfig

Lines changed: 0 additions & 18 deletions
This file was deleted.

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
**/dist/**/*
22
**/node_modules/**/*
3+
src/**/*.js

.prettierrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"parser": "flow",
2+
"parser": "babel-ts",
33
"singleQuote": true,
44
"trailingComma": "es5",
55
"overrides": [

index.d.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
declare module 'react-element-to-jsx-string' {
22
import { ReactNode } from 'react';
33

4-
type FilterPropsFunction = (value: any, key: string) => boolean
4+
type FilterPropsFunction = (value: any, key: string) => boolean;
55

66
interface ReactElementToJSXStringOptions {
77
displayName?: (element: ReactNode) => string;
@@ -16,7 +16,10 @@ declare module 'react-element-to-jsx-string' {
1616
useFragmentShortSyntax?: boolean;
1717
}
1818

19-
const reactElementToJSXString: (element: ReactNode, options?: ReactElementToJSXStringOptions) => string;
19+
const reactElementToJSXString: (
20+
element: ReactNode,
21+
options?: ReactElementToJSXStringOptions
22+
) => string;
2023

2124
export { ReactElementToJSXStringOptions as Options };
2225

package.json

Lines changed: 35 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,15 @@
99
"types": "index.d.ts",
1010
"scripts": {
1111
"build": "rollup -c",
12-
"build:flow": "flow-copy-source -v --ignore=*.spec.js src/ dist/cjs",
1312
"prebuild": "rm -rf dist/",
14-
"postbuild": "npm run build:flow",
15-
"prepare": "npm run build",
16-
"lint": "eslint .",
17-
"lint:fix": "npm run lint -- --fix",
18-
"flow": "flow",
19-
"precommit": "lint-staged",
20-
"prepublishOnly": "npm run build",
21-
"prettier:fix": "prettier --write \"**/*.{js,json}\"",
13+
"lint": "eslint --ext ts --ext tsx src/",
14+
"lint:fix": "yarn run lint -- --fix",
15+
"prettier:fix": "prettier --write \"**/*.{ts,tsx,js}\"",
2216
"test": "jest",
2317
"test:watch": "jest --watch",
2418
"release": "./release.sh",
25-
"smoke": "node tests/smoke/run"
26-
},
27-
"lint-staged": {
28-
"*.js": [
29-
"prettier --write \"**/*.{js,json}\"",
30-
"git add"
31-
]
19+
"smoke": "node tests/smoke/run",
20+
"ts:progress": "tsc > tserrors.txt"
3221
},
3322
"author": {
3423
"name": "Algolia, Inc.",
@@ -37,28 +26,34 @@
3726
"license": "MIT",
3827
"repository": "algolia/react-element-to-jsx-string",
3928
"devDependencies": {
40-
"@babel/cli": "7.24.1",
41-
"@babel/core": "7.24.4",
42-
"@babel/preset-env": "7.24.4",
43-
"@babel/preset-flow": "7.24.1",
44-
"@babel/preset-react": "7.24.1",
45-
"@commitlint/cli": "8.3.6",
46-
"@commitlint/config-angular": "8.3.6",
47-
"@testing-library/dom": "10.4.0",
48-
"@testing-library/jest-dom": "5.17.0",
49-
"@testing-library/react": "16.1.0",
29+
"@babel/cli": "7.15.7",
30+
"@babel/core": "7.15.5",
31+
"@babel/preset-env": "7.15.6",
32+
"@babel/preset-flow": "7.14.5",
33+
"@babel/preset-react": "7.14.5",
34+
"@commitlint/cli": "8.3.5",
35+
"@commitlint/config-angular": "8.3.4",
36+
"@khanacademy/flow-to-ts": "^0.5.2",
37+
"@types/enzyme": "^3.10.9",
38+
"@types/enzyme-adapter-react-16": "^1.0.6",
39+
"@types/react": "^17.0.26",
40+
"@types/react-is": "^17.0.2",
5041
"babel-eslint": "10.1.0",
5142
"babel-jest": "24.9.0",
5243
"babel-register": "6.26.0",
5344
"conventional-changelog-cli": "2.2.2",
5445
"doctoc": "1.4.0",
55-
"eslint": "6.8.0",
46+
"enzyme": "3.11.0",
47+
"enzyme-adapter-react-16": "1.15.6",
48+
"eslint": "7.25.0",
49+
"eslint-config-airbnb-typescript": "12.3.1",
5650
"eslint-config-algolia": "14.0.1",
57-
"eslint-config-prettier": "6.15.0",
58-
"eslint-plugin-import": "2.29.1",
51+
"eslint-config-prettier": "8.3.0",
52+
"eslint-plugin-import": "2.22.1",
5953
"eslint-plugin-jest": "22.21.0",
60-
"eslint-plugin-prettier": "3.4.1",
61-
"eslint-plugin-react": "7.31.1",
54+
"eslint-plugin-jsx-a11y": "6.4.1",
55+
"eslint-plugin-react": "7.23.2",
56+
"eslint-plugin-react-hooks": "4.2.0",
6257
"esm": "3.2.25",
6358
"expect": "27.5.1",
6459
"flow-bin": "0.119.1",
@@ -68,29 +63,27 @@
6863
"json": "10.0.0",
6964
"lint-staged": "10.5.4",
7065
"mversion": "2.0.1",
71-
"prettier": "1.19.1",
72-
"react": "19.0.0",
73-
"react-dom": "19.0.0",
74-
"react-is": "19.0.0",
75-
"rollup": "2.79.1",
66+
"prettier": "2.4.1",
67+
"react": "16.14.0",
68+
"react-dom": "16.14.0",
69+
"react-test-renderer": "16.14.0",
70+
"rollup": "2.57.0",
7671
"rollup-plugin-babel": "4.4.0",
7772
"rollup-plugin-node-builtins": "2.1.2",
7873
"rollup-plugin-node-globals": "1.4.0",
7974
"rollup-plugin-node-resolve": "5.2.0",
80-
"rollup-plugin-sourcemaps": "0.6.3"
75+
"rollup-plugin-sourcemaps": "0.6.3",
76+
"typescript": "4.2.4"
8177
},
8278
"peerDependencies": {
8379
"react": "^19.0.0",
8480
"react-dom": "^19.0.0",
8581
"react-is": "^19.0.0"
8682
},
8783
"dependencies": {
88-
"@base2/pretty-print-object": "1.0.2",
89-
"is-plain-object": "5.0.0"
84+
"@base2/pretty-print-object": "1.0.2"
9085
},
9186
"jest": {
92-
"setupFilesAfterEnv": [
93-
"<rootDir>tests/setupTests.js"
94-
]
87+
"setupFilesAfterEnv": ["<rootDir>tests/setupTests.js"]
9588
}
9689
}

src/AnonymousStatelessComponent.js

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/AnonymousStatelessComponent.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import React from 'react'; // eslint-disable-next-line react/display-name
2+
3+
export default function (props) {
4+
const { children } = props; // eslint-disable-line react/prop-types
5+
6+
return <div>{children}</div>;
7+
}

src/formatter/createPropFilter.spec.js renamed to src/formatter/createPropFilter.spec.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,30 @@
1-
/* @flow */
2-
31
import createPropFilter from './createPropFilter';
42

53
describe('createPropFilter', () => {
64
it('should filter based on an array of keys', () => {
7-
const props = { a: 1, b: 2, c: 3 };
8-
const filter = createPropFilter(props, ['b']);
5+
const props = {
6+
a: 1,
7+
b: 2,
8+
c: 3,
9+
};
910

11+
const filter = createPropFilter(props, ['b']);
1012
const filteredPropKeys = Object.keys(props).filter(filter);
1113

1214
expect(filteredPropKeys).toEqual(['a', 'c']);
1315
});
1416

1517
it('should filter based on a callback', () => {
16-
const props = { a: 1, b: 2, c: 3 };
18+
const props = {
19+
a: 1,
20+
b: 2,
21+
c: 3,
22+
};
23+
1724
const filter = createPropFilter(
1825
props,
1926
(val, key) => key !== 'b' && val < 3
2027
);
21-
2228
const filteredPropKeys = Object.keys(props).filter(filter);
2329

2430
expect(filteredPropKeys).toEqual(['a']);

src/formatter/createPropFilter.js renamed to src/formatter/createPropFilter.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
/* @flow */
2-
31
export default function createPropFilter(
42
props: {},
5-
filter: string[] | ((any, string) => boolean)
3+
filter: string[] | ((propValue: any, key: string) => boolean)
64
) {
75
if (Array.isArray(filter)) {
86
return (key: string) => filter.indexOf(key) === -1;

0 commit comments

Comments
 (0)