Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 99c69be

Browse files
Just run flow-to-ts command
1 parent 68c3c3e commit 99c69be

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

+1591
-1287
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: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,15 @@
88
"types": "index.d.ts",
99
"scripts": {
1010
"build": "rollup -c",
11-
"build:flow": "flow-copy-source -v --ignore=*.spec.js src/ dist/cjs",
1211
"prebuild": "rm -rf dist/",
13-
"postbuild": "npm run build:flow",
14-
"prepare": "npm run build",
15-
"lint": "eslint .",
16-
"lint:fix": "npm run lint -- --fix",
17-
"flow": "flow",
18-
"precommit": "lint-staged",
19-
"prepublishOnly": "npm run build",
20-
"prettier:fix": "prettier --write \"**/*.{js,json}\"",
12+
"lint": "eslint --ext ts --ext tsx src/",
13+
"lint:fix": "yarn run lint -- --fix",
14+
"prettier:fix": "prettier --write \"**/*.{ts,tsx,js}\"",
2115
"test": "jest",
2216
"test:watch": "jest --watch",
2317
"release": "./release.sh",
24-
"smoke": "node tests/smoke/run"
25-
},
26-
"lint-staged": {
27-
"*.js": ["prettier --write \"**/*.{js,json}\"", "git add"]
18+
"smoke": "node tests/smoke/run",
19+
"ts:progress": "tsc > tserrors.txt"
2820
},
2921
"author": {
3022
"name": "Algolia, Inc.",
@@ -40,20 +32,27 @@
4032
"@babel/preset-react": "7.14.5",
4133
"@commitlint/cli": "8.3.5",
4234
"@commitlint/config-angular": "8.3.4",
35+
"@khanacademy/flow-to-ts": "^0.5.2",
36+
"@types/enzyme": "^3.10.9",
37+
"@types/enzyme-adapter-react-16": "^1.0.6",
38+
"@types/react": "^17.0.26",
39+
"@types/react-is": "^17.0.2",
4340
"babel-eslint": "10.1.0",
4441
"babel-jest": "24.9.0",
4542
"babel-register": "6.26.0",
4643
"conventional-changelog-cli": "2.1.1",
4744
"doctoc": "1.4.0",
4845
"enzyme": "3.11.0",
4946
"enzyme-adapter-react-16": "1.15.6",
50-
"eslint": "6.8.0",
47+
"eslint": "7.25.0",
48+
"eslint-config-airbnb-typescript": "12.3.1",
5149
"eslint-config-algolia": "14.0.1",
52-
"eslint-config-prettier": "6.15.0",
53-
"eslint-plugin-import": "2.24.2",
50+
"eslint-config-prettier": "8.3.0",
51+
"eslint-plugin-import": "2.22.1",
5452
"eslint-plugin-jest": "22.21.0",
55-
"eslint-plugin-prettier": "3.4.1",
56-
"eslint-plugin-react": "7.22.0",
53+
"eslint-plugin-jsx-a11y": "6.4.1",
54+
"eslint-plugin-react": "7.23.2",
55+
"eslint-plugin-react-hooks": "4.2.0",
5756
"esm": "3.2.25",
5857
"expect": "27.2.3",
5958
"flow-bin": "0.119.1",
@@ -63,7 +62,7 @@
6362
"json": "10.0.0",
6463
"lint-staged": "10.5.4",
6564
"mversion": "2.0.1",
66-
"prettier": "1.19.1",
65+
"prettier": "2.4.1",
6766
"react": "16.14.0",
6867
"react-dom": "16.14.0",
6968
"react-test-renderer": "16.14.0",
@@ -72,7 +71,8 @@
7271
"rollup-plugin-node-builtins": "2.1.2",
7372
"rollup-plugin-node-globals": "1.4.0",
7473
"rollup-plugin-node-resolve": "5.2.0",
75-
"rollup-plugin-sourcemaps": "0.6.3"
74+
"rollup-plugin-sourcemaps": "0.6.3",
75+
"typescript": "4.2.4"
7676
},
7777
"peerDependencies": {
7878
"react": "^0.14.8 || ^15.0.1 || ^16.0.0 || ^17.0.1",
@@ -81,9 +81,11 @@
8181
"dependencies": {
8282
"@base2/pretty-print-object": "1.0.1",
8383
"is-plain-object": "5.0.0",
84-
"react-is": "^17.0.2"
84+
"react-is": "17.0.2"
8585
},
8686
"jest": {
87-
"setupFilesAfterEnv": ["<rootDir>tests/setupTests.js"]
87+
"setupFilesAfterEnv": [
88+
"<rootDir>tests/setupTests.js"
89+
]
8890
}
8991
}

‎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)

AltStyle によって変換されたページ (->オリジナル) /