Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MM-944]: Typescript migration and converting github_label_selector to TS #851

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions webapp/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
{
"extends": [
"eslint:recommended",
"plugin:react-hooks/recommended"
"eslint:recommended",
"plugin:react-hooks/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 8,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true,
"impliedStrict": true,
"modules": true,
"experimentalObjectRestSpread": true
}
"project": "./tsconfig.json",
"tsconfigRootDir": "./"
},
"parser": "babel-eslint",
"plugins": [
"react",
"@typescript-eslint",
"import"
],
"env": {
Expand All @@ -35,7 +30,12 @@
"beforeEach": true
},
"settings": {
"import/resolver": "webpack"
"import/resolver": {
"typescript": {}
},
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"]
}
},
"rules": {
"array-bracket-spacing": [
Expand Down Expand Up @@ -639,7 +639,7 @@
],
"rules": {
"@typescript-eslint/ban-ts-ignore": 0,
"@typescript-eslint/ban-types": 1,
"@typescript-eslint/ban-types": 0,
"@typescript-eslint/ban-ts-comment": 0,
"@typescript-eslint/no-var-requires": 0,
"@typescript-eslint/prefer-interface": 0,
Expand Down
140 changes: 140 additions & 0 deletions webapp/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"@types/react-intl": "3.0.0",
"@types/react-redux": "7.1.9",
"@types/react-router-dom": "5.1.5",
"@types/react-select": "3.1.0",
"@types/react-transition-group": "4.4.0",
"@typescript-eslint/eslint-plugin": "4.1.1",
"@typescript-eslint/parser": "4.1.1",
Expand All @@ -46,6 +47,7 @@
"enzyme-adapter-react-16": "1.15.4",
"enzyme-to-json": "3.5.0",
"eslint": "7.9.0",
"eslint-import-resolver-typescript": "3.6.1",
"eslint-import-resolver-webpack": "0.12.2",
"eslint-plugin-import": "2.22.0",
"eslint-plugin-react": "7.20.6",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import React, {PureComponent} from 'react';
import PropTypes from 'prop-types';

import IssueAttributeSelector from 'components/issue_attribute_selector';
import IssueAttributeSelector from '@/components/issue_attribute_selector';

export default class GithubAssigneeSelector extends PureComponent {
static propTypes = {
Expand Down
4 changes: 2 additions & 2 deletions webapp/src/components/github_issue_selector.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import PropTypes from 'prop-types';
import debounce from 'debounce-promise';
import AsyncSelect from 'react-select/async';

import {getStyleForReactSelect} from 'utils/styles';
import Client from 'client';
import {getStyleForReactSelect} from '@/utils/styles';
import Client from '@/client';

const searchDebounceDelay = 400;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
// See LICENSE.txt for license information.

import React, {PureComponent} from 'react';
import PropTypes from 'prop-types';

import IssueAttributeSelector from 'components/issue_attribute_selector';

export default class GithubLabelSelector extends PureComponent {
static propTypes = {
repoName: PropTypes.string.isRequired,
theme: PropTypes.object.isRequired,
selectedLabels: PropTypes.array.isRequired,
onChange: PropTypes.func.isRequired,
actions: PropTypes.shape({
getLabelOptions: PropTypes.func.isRequired,
}).isRequired,
};

import {Theme} from 'mattermost-redux/types/preferences';

import IssueAttributeSelector, {IssueAttributeSelectorSelection} from '../issue_attribute_selector';

import {GitHubLabelSelectorDispatchProps} from '.';

type Props = GitHubLabelSelectorDispatchProps & {
repoName: string;
theme: Theme;
selectedLabels: string[];
onChange: (selection: string[]) => void;
};

export default class GithubLabelSelector extends PureComponent<Props> {
loadLabels = async () => {
if (this.props.repoName === '') {
return [];
Expand All @@ -32,13 +32,19 @@ export default class GithubLabelSelector extends PureComponent {
return [];
}

return options.data.map((option) => ({
return options.data.map((option: any) => ({
value: option.name,
label: option.name,
}));
};

onChange = (selection) => this.props.onChange(selection.map((s) => s.value));
onChange = (selection: IssueAttributeSelectorSelection) => {
if (!selection || !Array.isArray(selection)) {
return;
}

this.props.onChange(selection.map((s) => s.value));
}

render() {
return (
Expand Down
18 changes: 0 additions & 18 deletions webapp/src/components/github_label_selector/index.js

This file was deleted.

Loading
Loading