Skip to content

Commit 266e9e1

Browse files
authored
Merge pull request #3553 from clairep94/pr05/migrate_client_utils_folder
pr05 Typescript #3: Migrate client/utils folder
2 parents 34123d5 + ec8de0a commit 266e9e1

Some content is hidden

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

64 files changed

+1442
-511
lines changed

.eslintrc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"tsx": "never"
3030
}
3131
],
32+
"import/prefer-default-export": "off",
3233
"react/jsx-filename-extension": [1, { "extensions": [".jsx", ".tsx"] }],
3334
"comma-dangle": 0, // not sure why airbnb turned this on. gross!
3435
"default-param-last": 0,
@@ -41,6 +42,7 @@
4142
"no-restricted-exports": 1,
4243
"no-underscore-dangle": 0,
4344
"no-useless-catch": 2,
45+
"no-plusplus": "off",
4446
"prefer-object-spread": 0,
4547
"max-len": [1, 120, 2, {"ignoreComments": true, "ignoreTemplateLiterals": true}],
4648
"max-classes-per-file": 0,
@@ -131,7 +133,9 @@
131133
"rules": {
132134
"no-use-before-define": "off",
133135
"import/no-extraneous-dependencies": "off",
134-
"no-unused-vars": "off"
136+
"no-unused-vars": "off",
137+
"import/no-default-export": "warn",
138+
"no-underscore-dangle": "warn",
135139
}
136140
},
137141
{

.prettierrc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"insertPragma": false,
66
"jsxBracketSameLine": false,
77
"jsxSingleQuote": false,
8-
"parser": "babel",
98
"printWidth": 80,
109
"proseWrap": "never",
1110
"requirePragma": false,

client/common/useKeyDownHandlers.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { mapKeys } from 'lodash';
22
import PropTypes from 'prop-types';
33
import { useCallback, useEffect, useRef } from 'react';
4+
import { isMac } from '../utils/device';
45

56
/**
67
* Attaches keydown handlers to the global document.
@@ -30,8 +31,7 @@ export default function useKeyDownHandlers(keyHandlers) {
3031
*/
3132
const handleEvent = useCallback((e) => {
3233
if (!e.key) return;
33-
const isMac = navigator.userAgent.toLowerCase().indexOf('mac') !== -1;
34-
const isCtrl = isMac ? e.metaKey : e.ctrlKey;
34+
const isCtrl = isMac() ? e.metaKey : e.ctrlKey;
3535
if (e.shiftKey && isCtrl) {
3636
handlers.current[
3737
`ctrl-shift-${

client/components/SkipLink.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { render, screen, fireEvent } from '@testing-library/react';
22
import React from 'react';
33
import { useTranslation } from 'react-i18next';
44
import '@testing-library/jest-dom';
5-
import SkipLink from './SkipLink';
5+
import { SkipLink } from './SkipLink';
66

77
jest.mock('react-i18next', () => ({
88
useTranslation: () => ({

client/components/SkipLink.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import React, { useState } from 'react';
22
import classNames from 'classnames';
33
import { useTranslation } from 'react-i18next';
44

5-
type SkipLinkProps = {
6-
targetId: string,
7-
text: string
8-
};
5+
interface SkipLinkProps {
6+
targetId: string;
7+
text: string;
8+
}
99

10-
const SkipLink = ({ targetId, text }: SkipLinkProps) => {
10+
export const SkipLink = ({ targetId, text }: SkipLinkProps) => {
1111
const [focus, setFocus] = useState(false);
1212
const { t } = useTranslation();
1313
const handleFocus = () => {
@@ -30,5 +30,3 @@ const SkipLink = ({ targetId, text }: SkipLinkProps) => {
3030
</a>
3131
);
3232
};
33-
34-
export default SkipLink;

client/i18n.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {
2121
enIN
2222
} from 'date-fns/locale';
2323

24-
import getPreferredLanguage from './utils/language-utils';
24+
import { getPreferredLanguage } from './utils/language-utils';
2525

2626
const fallbackLng = ['en-US'];
2727

client/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import Routing from './routes';
99
import ThemeProvider from './modules/App/components/ThemeProvider';
1010
import Loader from './modules/App/components/loader';
1111
import './i18n';
12-
import SkipLink from './components/SkipLink';
12+
import { SkipLink } from './components/SkipLink';
1313

1414
require('./styles/main.scss');
1515

client/modules/IDE/actions/assets.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import apiClient from '../../../utils/apiClient';
1+
import { apiClient } from '../../../utils/apiClient';
22
import * as ActionTypes from '../../../constants';
33
import { startLoader, stopLoader } from '../reducers/loading';
44
import { assetsActions } from '../reducers/assets';

client/modules/IDE/actions/collections.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import browserHistory from '../../../browserHistory';
2-
import apiClient from '../../../utils/apiClient';
2+
import { apiClient } from '../../../utils/apiClient';
33
import * as ActionTypes from '../../../constants';
44
import { startLoader, stopLoader } from '../reducers/loading';
55
import { setToastText, showToast } from './toast';

client/modules/IDE/actions/files.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import objectID from 'bson-objectid';
22
import blobUtil from 'blob-util';
3-
import apiClient from '../../../utils/apiClient';
3+
import { apiClient } from '../../../utils/apiClient';
44
import * as ActionTypes from '../../../constants';
55
import {
66
setUnsavedChanges,

0 commit comments

Comments
 (0)