Skip to content

Commit 9aac748

Browse files
authored
Merge pull request #797 from GetStream/typescript-conversion
Typescript Conversion
2 parents 4a6ee47 + 465db02 commit 9aac748

File tree

512 files changed

+20631
-18435
lines changed

Some content is hidden

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

512 files changed

+20631
-18435
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ babel.i18next-extract.js
1919
/coverage
2020
types/index.d.ts
2121
src/components/Channel/types.ts
22+
src/@types/*

.eslintrc.json

Lines changed: 167 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,76 @@
22
"root": true,
33
"plugins": [
44
"babel",
5+
"jest-dom",
6+
"jest",
57
"markdown",
68
"prettier",
79
"react-hooks",
8-
"jest-dom",
9-
"jest"
10+
"sort-destructure-keys"
1011
],
1112
"extends": [
1213
"eslint:recommended",
1314
"plugin:react/recommended",
14-
"airbnb-base",
1515
"plugin:prettier/recommended",
1616
"plugin:jest/all",
1717
"plugin:jest-dom/recommended"
1818
],
1919
"rules": {
20-
"no-console": 0,
20+
"array-callback-return": 2,
21+
"arrow-body-style": 2,
22+
"comma-dangle": 0,
23+
"babel/no-invalid-this": 2,
24+
"default-case": 2,
2125
"eqeqeq": [2, "smart"],
26+
"jest/expect-expect": 0,
27+
"jest/no-conditional-expect": 0,
28+
"jsx-quotes": ["error", "prefer-single"],
29+
"linebreak-style": [2, "unix"],
30+
"no-console": 0,
31+
"no-mixed-spaces-and-tabs": 1,
32+
"no-self-compare": 2,
2233
"no-underscore-dangle": [2, { "allowAfterThis": true }],
23-
"babel/no-invalid-this": 2,
24-
"valid-typeof": 2,
25-
"require-await": 2,
34+
"no-unused-vars": [1, { "ignoreRestSiblings": true }],
35+
"no-use-before-define": 0, // can throw incorrect errors due to mismatch of @typescript-eslint versions in react-scripts and local package.json
36+
"@typescript-eslint/no-use-before-define": 0,
37+
"no-useless-concat": 2,
38+
"no-var": 2,
39+
"object-shorthand": 1,
40+
"prefer-const": 1,
41+
"react/jsx-sort-props": [
42+
"error",
43+
{
44+
"callbacksLast": false,
45+
"ignoreCase": true,
46+
"noSortAlphabetically": false,
47+
"reservedFirst": false,
48+
"shorthandFirst": false,
49+
"shorthandLast": false
50+
}
51+
],
2652
"react/prop-types": 0,
27-
"linebreak-style": [2, "unix"],
53+
"require-await": 2,
54+
"semi": [1, "always"],
55+
"sort-destructure-keys/sort-destructure-keys": [
56+
2,
57+
{ "caseSensitive": false }
58+
],
59+
"sort-imports": [
60+
"error",
61+
{
62+
"allowSeparatedGroups": true,
63+
"ignoreCase": true,
64+
"ignoreDeclarationSort": true,
65+
"ignoreMemberSort": false,
66+
"memberSyntaxSortOrder": ["none", "all", "multiple", "single"]
67+
}
68+
],
69+
"sort-keys": [
70+
"error",
71+
"asc",
72+
{ "caseSensitive": false, "minKeys": 2, "natural": false }
73+
],
74+
"valid-typeof": 2,
2875
"import/prefer-default-export": 0,
2976
"import/extensions": [0],
3077
"max-classes-per-file": 0,
@@ -45,6 +92,7 @@
4592
},
4693
"parser": "babel-eslint",
4794
"parserOptions": {
95+
// "allowImportExportEverywhere": true,
4896
"sourceType": "module",
4997
"ecmaVersion": 2018,
5098
"ecmaFeatures": {
@@ -53,12 +101,18 @@
53101
},
54102
"settings": {
55103
"react": {
104+
"pragma": "React",
56105
"version": "detect"
57106
},
58107
"import/resolver": {
59108
"alias": {
60109
"map": [["mock-builders", "./src/mock-builders"]],
61-
"extensions": [".js"]
110+
"extensions": [".js", ".jsx", ".ts", ".tsx"]
111+
},
112+
"eslint-import-resolver-babel-module": {},
113+
"node": {
114+
"extensions": [".js", ".jsx", ".ts", ".tsx"],
115+
"paths": ["src"]
62116
}
63117
}
64118
},
@@ -71,6 +125,110 @@
71125
"semi": 0,
72126
"no-undef": 0
73127
}
128+
},
129+
{
130+
"env": {
131+
"es6": true,
132+
"browser": true
133+
},
134+
"extends": [
135+
"eslint:recommended",
136+
"plugin:@typescript-eslint/recommended",
137+
"plugin:jest/recommended",
138+
"plugin:prettier/recommended",
139+
"plugin:react/recommended",
140+
"prettier/@typescript-eslint"
141+
],
142+
"files": ["**/*.ts", "**/*.tsx"],
143+
"parser": "@typescript-eslint/parser",
144+
"parserOptions": {
145+
"ecmaFeatures": {
146+
"modules": true,
147+
"jsx": true
148+
},
149+
"ecmaVersion": 2018,
150+
"sourceType": "module"
151+
},
152+
"plugins": [
153+
"@typescript-eslint",
154+
"babel",
155+
"markdown",
156+
"prettier",
157+
"react",
158+
"typescript-sort-keys",
159+
"sort-destructure-keys"
160+
],
161+
"rules": {
162+
"@typescript-eslint/explicit-module-boundary-types": 0,
163+
"@typescript-eslint/no-empty-interface": 0,
164+
"@typescript-eslint/ban-ts-comment": 0,
165+
"@typescript-eslint/no-unused-vars": 1,
166+
"@typescript-eslint/no-var-requires": 0,
167+
"react-hooks/exhaustive-deps": 0,
168+
"react-native/no-inline-styles": 0,
169+
"array-callback-return": 2,
170+
"arrow-body-style": 2,
171+
"comma-dangle": 0,
172+
"babel/no-invalid-this": 2,
173+
"default-case": 2,
174+
"eqeqeq": [2, "smart"],
175+
"linebreak-style": [2, "unix"],
176+
"jsx-quotes": ["error", "prefer-single"],
177+
"no-console": 0,
178+
"no-mixed-spaces-and-tabs": 1,
179+
"no-self-compare": 2,
180+
"no-shadow": 0,
181+
"no-underscore-dangle": [2, { "allowAfterThis": true }],
182+
"no-unused-vars": [1, { "ignoreRestSiblings": true }],
183+
"no-useless-concat": 2,
184+
"no-var": 2,
185+
"object-shorthand": 1,
186+
"prefer-const": 1,
187+
"react/jsx-sort-props": [
188+
"error",
189+
{
190+
"callbacksLast": false,
191+
"ignoreCase": true,
192+
"noSortAlphabetically": false,
193+
"reservedFirst": false,
194+
"shorthandFirst": false,
195+
"shorthandLast": false
196+
}
197+
],
198+
"react/prop-types": 0,
199+
"require-await": 2,
200+
"semi": [1, "always"],
201+
"sort-destructure-keys/sort-destructure-keys": [
202+
2,
203+
{ "caseSensitive": false }
204+
],
205+
"sort-imports": [
206+
"error",
207+
{
208+
"allowSeparatedGroups": true,
209+
"ignoreCase": true,
210+
"ignoreDeclarationSort": true,
211+
"ignoreMemberSort": false,
212+
"memberSyntaxSortOrder": ["none", "all", "multiple", "single"]
213+
}
214+
],
215+
"sort-keys": [
216+
"error",
217+
"asc",
218+
{ "caseSensitive": false, "minKeys": 2, "natural": false }
219+
],
220+
"typescript-sort-keys/interface": [
221+
"error",
222+
"asc",
223+
{ "caseSensitive": false, "natural": true, "requiredFirst": true }
224+
],
225+
"typescript-sort-keys/string-enum": [
226+
"error",
227+
"asc",
228+
{ "caseSensitive": false, "natural": true }
229+
],
230+
"valid-typeof": 2
231+
}
74232
}
75233
]
76234
}

.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ src/stream-emoji.json
1010
/build/
1111
build
1212
/built
13+
*.md
14+
src/components/docs/

.prettierrc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
2-
"singleQuote": true,
3-
"trailingComma": "all",
42
"arrowParens": "always",
5-
"tabWidth": 2
3+
"jsxSingleQuote": true,
4+
"singleQuote": true,
5+
"tabWidth": 2,
6+
"trailingComma": "all"
67
}

babel.config.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
module.exports = {
2-
presets: ['@babel/preset-typescript', '@babel/env', '@babel/react'],
3-
plugins: [
4-
'@babel/plugin-proposal-class-properties',
5-
'@babel/plugin-transform-runtime',
6-
],
72
env: {
83
production: {
94
presets: [
@@ -16,13 +11,22 @@ module.exports = {
1611
],
1712
},
1813
test: {
19-
presets: ['@babel/preset-env', '@babel/preset-react'],
20-
plugins: [
21-
'@babel/plugin-proposal-class-properties',
22-
'transform-es2015-modules-commonjs',
23-
'babel-plugin-dynamic-import-node',
14+
plugins: ['transform-es2015-modules-commonjs'],
15+
presets: [
16+
[
17+
'@babel/preset-env',
18+
{
19+
modules: 'commonjs',
20+
},
21+
],
2422
],
2523
},
2624
},
2725
ignore: ['src/@types/*'],
26+
plugins: [
27+
'@babel/plugin-proposal-class-properties',
28+
'@babel/plugin-transform-runtime',
29+
'babel-plugin-dynamic-import-node',
30+
],
31+
presets: ['@babel/preset-typescript', '@babel/env', '@babel/preset-react'],
2832
};

babel.i18next-extract.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
module.exports = function (api) {
22
api.cache(true);
33
return {
4-
presets: ['@babel/env', '@babel/react'],
4+
ignore: ['./**/*.d.ts'],
5+
presets: ['@babel/preset-typescript', '@babel/env', '@babel/react'],
56
plugins: [
67
[
78
'i18next-extract',

examples/messaging/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"react-app-polyfill": "^1.0.2",
88
"react-dom": "link:../../node_modules/react-dom",
99
"react-scripts": "2.1.4",
10-
"stream-chat": "3.1.2",
10+
"stream-chat": "3.7.0",
1111
"stream-chat-react": "link:../../"
1212
},
1313
"scripts": {

examples/messaging/src/App.js

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
ChannelList,
88
ChannelListMessenger,
99
ChannelPreviewMessenger,
10-
InfiniteScrollPaginator,
1110
MessageInput,
1211
MessageInputFlat,
1312
MessageList,
@@ -17,29 +16,19 @@ import {
1716
import 'stream-chat-react/dist/css/index.css';
1817
import './App.css';
1918

20-
const urlParams = new URLSearchParams(window.location.search);
21-
const apiKey =
22-
urlParams.get('apiKey') || process.env.REACT_APP_STREAM_KEY || 'qk4nn7rpcn75';
23-
const userId =
24-
urlParams.get('user') || process.env.REACT_APP_USER_ID || 'example-user';
25-
const theme = urlParams.get('theme') || 'light';
26-
const userToken =
27-
urlParams.get('user_token') ||
28-
process.env.REACT_APP_USER_TOKEN ||
29-
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiZXhhbXBsZS11c2VyIn0.HlC0dMKL43y3K_XbfvQS_Yc3V314HU4Z7LrBLil777g';
19+
const apiKey = process.env.REACT_APP_STREAM_KEY;
20+
const userId = process.env.REACT_APP_USER_ID;
21+
const userToken = process.env.REACT_APP_USER_TOKEN;
22+
const theme = 'light';
3023

31-
const filters = { type: 'messaging', example: 1 };
32-
const options = { state: true, watch: true, presence: true };
24+
const filters = { type: 'messaging' };
25+
const options = { state: true, presence: true, limit: 10 };
3326
const sort = {
3427
cid: 1,
3528
last_message_at: -1,
3629
updated_at: -1,
3730
};
3831

39-
const Paginator = (props) => (
40-
<InfiniteScrollPaginator threshold={300} {...props} />
41-
);
42-
4332
const chatClient = StreamChat.getInstance(apiKey);
4433

4534
if (process.env.REACT_APP_CHAT_SERVER_ENDPOINT) {
@@ -56,7 +45,6 @@ const App = () => (
5645
filters={filters}
5746
sort={sort}
5847
options={options}
59-
Paginator={Paginator}
6048
/>
6149
<Channel>
6250
<Window>

0 commit comments

Comments
 (0)