Skip to content

Commit 48fc3be

Browse files
[MM-944]: Typescript migration and converting github_label_selector to TS (#851)
* [MM-944]: Typescript migration and converting github_label_selector to TS * [MM-944] * [MM-944]: removed the use of any * [MM-944]: fixed lint
1 parent 803494b commit 48fc3be

File tree

25 files changed

+298
-113
lines changed

25 files changed

+298
-113
lines changed

webapp/.eslintrc.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
11
{
22
"extends": [
3-
"eslint:recommended",
4-
"plugin:react-hooks/recommended"
3+
"eslint:recommended",
4+
"plugin:react-hooks/recommended"
55
],
6+
"parser": "@typescript-eslint/parser",
67
"parserOptions": {
7-
"ecmaVersion": 8,
8-
"sourceType": "module",
9-
"ecmaFeatures": {
10-
"jsx": true,
11-
"impliedStrict": true,
12-
"modules": true,
13-
"experimentalObjectRestSpread": true
14-
}
8+
"project": "./tsconfig.json",
9+
"tsconfigRootDir": "./"
1510
},
16-
"parser": "babel-eslint",
1711
"plugins": [
1812
"react",
13+
"@typescript-eslint",
1914
"import"
2015
],
2116
"env": {
@@ -35,7 +30,12 @@
3530
"beforeEach": true
3631
},
3732
"settings": {
38-
"import/resolver": "webpack"
33+
"import/resolver": {
34+
"typescript": {}
35+
},
36+
"import/parsers": {
37+
"@typescript-eslint/parser": [".ts", ".tsx"]
38+
}
3939
},
4040
"rules": {
4141
"array-bracket-spacing": [
@@ -639,7 +639,7 @@
639639
],
640640
"rules": {
641641
"@typescript-eslint/ban-ts-ignore": 0,
642-
"@typescript-eslint/ban-types": 1,
642+
"@typescript-eslint/ban-types": 0,
643643
"@typescript-eslint/ban-ts-comment": 0,
644644
"@typescript-eslint/no-var-requires": 0,
645645
"@typescript-eslint/prefer-interface": 0,

webapp/package-lock.json

Lines changed: 140 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webapp/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"@types/react-intl": "3.0.0",
3535
"@types/react-redux": "7.1.9",
3636
"@types/react-router-dom": "5.1.5",
37+
"@types/react-select": "3.1.0",
3738
"@types/react-transition-group": "4.4.0",
3839
"@typescript-eslint/eslint-plugin": "4.1.1",
3940
"@typescript-eslint/parser": "4.1.1",
@@ -46,6 +47,7 @@
4647
"enzyme-adapter-react-16": "1.15.4",
4748
"enzyme-to-json": "3.5.0",
4849
"eslint": "7.9.0",
50+
"eslint-import-resolver-typescript": "3.6.1",
4951
"eslint-import-resolver-webpack": "0.12.2",
5052
"eslint-plugin-import": "2.22.0",
5153
"eslint-plugin-react": "7.20.6",

webapp/src/components/github_assignee_selector/github_assignee_selector.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import React, {PureComponent} from 'react';
55
import PropTypes from 'prop-types';
66

7-
import IssueAttributeSelector from 'components/issue_attribute_selector';
7+
import IssueAttributeSelector from '@/components/issue_attribute_selector';
88

99
export default class GithubAssigneeSelector extends PureComponent {
1010
static propTypes = {

webapp/src/components/github_issue_selector.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import PropTypes from 'prop-types';
77
import debounce from 'debounce-promise';
88
import AsyncSelect from 'react-select/async';
99

10-
import {getStyleForReactSelect} from 'utils/styles';
11-
import Client from 'client';
10+
import {getStyleForReactSelect} from '@/utils/styles';
11+
import Client from '@/client';
1212

1313
const searchDebounceDelay = 400;
1414

webapp/src/components/github_label_selector/github_label_selector.jsx renamed to webapp/src/components/github_label_selector/github_label_selector.tsx

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,25 @@
22
// See LICENSE.txt for license information.
33

44
import React, {PureComponent} from 'react';
5-
import PropTypes from 'prop-types';
6-
7-
import IssueAttributeSelector from 'components/issue_attribute_selector';
8-
9-
export default class GithubLabelSelector extends PureComponent {
10-
static propTypes = {
11-
repoName: PropTypes.string.isRequired,
12-
theme: PropTypes.object.isRequired,
13-
selectedLabels: PropTypes.array.isRequired,
14-
onChange: PropTypes.func.isRequired,
15-
actions: PropTypes.shape({
16-
getLabelOptions: PropTypes.func.isRequired,
17-
}).isRequired,
18-
};
195

6+
import {Theme} from 'mattermost-redux/types/preferences';
7+
8+
import IssueAttributeSelector, {IssueAttributeSelectorSelection} from '../issue_attribute_selector';
9+
10+
import {GitHubLabelSelectorDispatchProps} from '.';
11+
12+
type Props = GitHubLabelSelectorDispatchProps & {
13+
repoName: string;
14+
theme: Theme;
15+
selectedLabels: string[];
16+
onChange: (selection: string[]) => void;
17+
};
18+
19+
type Option = {
20+
name: string;
21+
};
22+
23+
export default class GithubLabelSelector extends PureComponent<Props> {
2024
loadLabels = async () => {
2125
if (this.props.repoName === '') {
2226
return [];
@@ -32,13 +36,19 @@ export default class GithubLabelSelector extends PureComponent {
3236
return [];
3337
}
3438

35-
return options.data.map((option) => ({
39+
return options.data.map((option: Option) => ({
3640
value: option.name,
3741
label: option.name,
3842
}));
3943
};
4044

41-
onChange = (selection) => this.props.onChange(selection.map((s) => s.value));
45+
onChange = (selection: IssueAttributeSelectorSelection) => {
46+
if (!selection || !Array.isArray(selection)) {
47+
return;
48+
}
49+
50+
this.props.onChange(selection.map((s) => s.value));
51+
}
4252

4353
render() {
4454
return (

webapp/src/components/github_label_selector/index.js

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

0 commit comments

Comments
 (0)