Skip to content

Commit 5536cb6

Browse files
committed
npx react-codemod update-react-imports nusmods/website/src --force
1 parent 0f1c804 commit 5536cb6

File tree

117 files changed

+136
-175
lines changed

Some content is hidden

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

117 files changed

+136
-175
lines changed

website/src/__mocks__/svgMock.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
import * as React from 'react';
2-
31
module.exports = () => <svg />;

website/src/entry/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Store } from 'redux';
22
import { State } from 'types/state';
33
import { Persistor } from 'storage/persistReducer';
44

5-
import React from 'react';
5+
import * as React from 'react';
66
import { hot } from 'react-hot-loader/root';
77
import { BrowserRouter as Router } from 'react-router-dom';
88
import { Provider } from 'react-redux';

website/src/entry/export/TimetableOnly.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Store } from 'redux';
2-
import * as React from 'react';
2+
import { Component } from 'react';
33
import { MemoryRouter } from 'react-router-dom';
44
import { Provider } from 'react-redux';
55

@@ -20,7 +20,7 @@ type State = {
2020
colors: ColorMapping;
2121
};
2222

23-
export default class TimetableOnly extends React.Component<Props, State> {
23+
export default class TimetableOnly extends Component<Props, State> {
2424
state = {
2525
semester: 1,
2626
timetable: {},

website/src/entry/export/main.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as React from 'react';
1+
import { createRef } from 'react';
22
import ReactDOM from 'react-dom';
33
import { Store } from 'redux';
44

@@ -27,7 +27,7 @@ const { store } = configureStore();
2727
window.store = store;
2828

2929
// For Puppeteer to import data
30-
const timetableRef = React.createRef<TimetableOnly>();
30+
const timetableRef = createRef<TimetableOnly>();
3131
window.setData = function setData(modules, data, callback) {
3232
const { semester, timetable, colors } = data;
3333

website/src/entry/main.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import 'bootstrapping/sentry';
66
// See: https://github.com/zloirock/core-js/issues/579#issuecomment-504325213
77
import 'core-js/es/promise/finally';
88

9-
import React from 'react';
109
import ReactDOM from 'react-dom';
1110
import ReactModal from 'react-modal';
1211

website/src/utils/react.test.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as React from 'react';
1+
import { Component, PureComponent } from 'react';
22
import { render } from 'enzyme';
33
import { highlight, wrapComponentName, Counter } from './react';
44

@@ -32,9 +32,9 @@ describe(highlight, () => {
3232

3333
describe('wrapComponentName()', () => {
3434
/* eslint-disable react/prefer-stateless-function */
35-
class TestComponent extends React.Component {}
36-
class TestPureComponent extends React.PureComponent {}
37-
class TestComponentWithDisplayName extends React.Component {
35+
class TestComponent extends Component {}
36+
class TestPureComponent extends PureComponent {}
37+
class TestComponentWithDisplayName extends Component {
3838
static displayName = 'TestComponentName';
3939
}
4040
const FunctionalComponent = () => null;

website/src/views/AppShell.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import * as React from 'react';
22
import { SemTimetableConfig, TimetableConfig } from 'types/timetables';
33
import { ModuleList, NotificationOptions } from 'types/reducers';
44
import { Semester } from 'types/modules';

website/src/views/components/ColorPicker.test.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as React from 'react';
21
import { mount, ReactWrapper } from 'enzyme';
32
import ColorPicker from 'views/components/ColorPicker';
43
import { ColorIndex } from 'types/timetables';

website/src/views/components/ColorPicker.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as React from 'react';
1+
import { memo } from 'react';
22
import classnames from 'classnames';
33
import Downshift, { ChildrenFunction } from 'downshift';
44
import _ from 'lodash';
@@ -20,7 +20,7 @@ type Props = {
2020
*
2121
* For use in places like changing module colors
2222
*/
23-
const ColorPicker = React.memo<Props>((props) => {
23+
const ColorPicker = memo<Props>((props) => {
2424
const renderColorPicker: ChildrenFunction<ColorIndex> = ({
2525
getToggleButtonProps,
2626
getItemProps,

website/src/views/components/ExternalLink.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import React, { ReactNode } from 'react';
1+
import { ReactNode } from 'react';
2+
import * as React from 'react';
23

34
type Props = React.AnchorHTMLAttributes<HTMLAnchorElement> & { href: string; children: ReactNode };
45

website/src/views/components/LinkModuleCodes.test.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as React from 'react';
21
import { MemoryRouter } from 'react-router-dom';
32
import { mount } from 'enzyme';
43
import { entries } from 'lodash';

website/src/views/components/Online.test.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as React from 'react';
21
import { shallow } from 'enzyme';
32
import { OnlineComponent } from './Online';
43

website/src/views/components/RandomKawaii.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import * as React from 'react';
22
import { sample } from 'lodash';
33
import { SpeechBubble, Mug, Browser, Ghost, KawaiiMood, KawaiiProps } from 'react-kawaii';
44

website/src/views/components/ScrollToTop.test.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as React from 'react';
21
import { MemoryRouter } from 'react-router-dom';
32
import { mount, ReactWrapper } from 'enzyme';
43
import mockDom from 'test-utils/mockDom';

website/src/views/components/ScrollToTop.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as React from 'react';
1+
import { Component } from 'react';
22
import { withRouter, RouteComponentProps } from 'react-router-dom';
33
import { scrollToHash } from 'utils/react';
44

@@ -12,7 +12,7 @@ function scrollToTop() {
1212
window.scrollTo(0, 0);
1313
}
1414

15-
export class ScrollToTopComponent extends React.Component<Props> {
15+
export class ScrollToTopComponent extends Component<Props> {
1616
static defaultProps = {
1717
onComponentDidMount: false,
1818
onPathChange: false,

website/src/views/components/SearchBox.test.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as React from 'react';
21
import { shallow } from 'enzyme';
32
import SearchBox from './SearchBox';
43

website/src/views/components/SearchkitSearchBox.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react';
21
import {
32
QueryAccessor,
43
SearchkitComponent,

website/src/views/components/SemesterBadge.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import * as React from 'react';
22
import classnames from 'classnames';
33
import config from 'config';
44
import { Semester } from 'types/modules';

website/src/views/components/Title.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import * as React from 'react';
22
import { Helmet } from 'react-helmet';
33
import config from 'config';
44

website/src/views/components/Tooltip/Tooltip.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import * as React from 'react';
22
import Tippy, { TippyProps, TippySingleton, TippySingletonProps } from '@tippy.js/react';
33
import { animateFill } from 'tippy.js'; // eslint-disable-line import/no-extraneous-dependencies
44

website/src/views/components/Tooltip/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import * as React from 'react';
22

33
import { retryImport } from 'utils/error';
44

website/src/views/components/disqus/CommentCount.test.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react';
21
import { mount } from 'enzyme';
32
import insertScript from 'utils/insertScript';
43
import { CommentCountComponent } from './CommentCount';

website/src/views/components/disqus/CommentCount.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import React, { useEffect } from 'react';
1+
import { useEffect } from 'react';
2+
import * as React from 'react';
23
import { connect } from 'react-redux';
34

45
import config from 'config';

website/src/views/components/disqus/DisqusComments.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { DisqusConfig } from 'types/views';
2-
import * as React from 'react';
2+
import { PureComponent } from 'react';
33
import classnames from 'classnames';
44
import { connect } from 'react-redux';
55

@@ -26,7 +26,7 @@ type State = {
2626

2727
const SCRIPT_ID = 'dsq-embed-scr';
2828

29-
class DisqusComments extends React.PureComponent<Props, State> {
29+
class DisqusComments extends PureComponent<Props, State> {
3030
state = {
3131
allowDisqus: false,
3232
};

website/src/views/components/filters/CheckboxItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import * as React from 'react';
22
import classnames from 'classnames';
33
import { NBSP } from 'utils/react';
44
import styles from './styles.scss';

website/src/views/components/filters/CheckboxItemFilter.test.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react';
21
import { mount } from 'enzyme';
32
import { SearchkitManager } from 'searchkit';
43

website/src/views/components/filters/CheckboxItemFilter.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import * as React from 'react';
22
import { CheckboxFilterAccessor, SearchkitComponent, SearchkitComponentProps } from 'searchkit';
33

44
import { ElasticSearchFilter } from 'types/vendor/elastic-search';

website/src/views/components/filters/ChecklistFilter.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import { memo } from 'react';
22

33
import { ElasticSearchFilter } from 'types/vendor/elastic-search';
44
import FilterContainer from './FilterContainer';
@@ -17,7 +17,7 @@ interface ChecklistFilterProps {
1717
disabled?: boolean;
1818
}
1919

20-
const ChecklistFilter = React.memo<ChecklistFilterProps>(
20+
const ChecklistFilter = memo<ChecklistFilterProps>(
2121
({ title, items, disabled = false, showCount = true }) => {
2222
return (
2323
<FilterContainer title={title} disabled={disabled}>

website/src/views/components/filters/DropdownListFilters.test.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as React from 'react';
21
import { mount } from 'enzyme';
32

43
import { RefinementItem } from 'types/views';

website/src/views/components/filters/DropdownListFilters.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import React, { useState, useRef } from 'react';
1+
import { useState, useRef } from 'react';
2+
import * as React from 'react';
23
import Downshift, { DownshiftState, StateChangeOptions } from 'downshift';
34
import { ListProps } from 'searchkit';
45
import classnames from 'classnames';

website/src/views/components/filters/FilterContainer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import * as React from 'react';
22
import { PanelProps } from 'searchkit';
33

44
import styles from './styles.scss';

website/src/views/components/icons/weather.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import * as React from 'react';
22

33
import Cloudy from 'img/weather/cloudy.svg';
44
import Rain from 'img/weather/rain.svg';

website/src/views/components/map/ArrivalTimes.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as React from 'react';
1+
import { memo } from 'react';
22
import classnames from 'classnames';
33
import { entries, sortBy } from 'lodash';
44

@@ -46,7 +46,7 @@ function fixRouteName(name: string) {
4646
return name.replace(/\s?\(/, ' (');
4747
}
4848

49-
export const ArrivalTimes = React.memo<Props>((props: Props) => {
49+
export const ArrivalTimes = memo<Props>((props: Props) => {
5050
if (props.error) {
5151
return (
5252
<>

website/src/views/components/map/BusStops.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import { PureComponent } from 'react';
22
import { DivIcon, DragEndEvent } from 'leaflet';
33
import { Marker, Popup } from 'react-leaflet';
44
import classnames from 'classnames';
@@ -39,7 +39,7 @@ busStops.forEach((stop: BusStop) => {
3939
/**
4040
* Displays bus stop routes as markers, and timings in a popup when they are clicked
4141
*/
42-
export default class BusStops extends React.PureComponent<Props, State> {
42+
export default class BusStops extends PureComponent<Props, State> {
4343
constructor(props: Props) {
4444
super(props);
4545

website/src/views/components/map/ExpandMap.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as React from 'react';
1+
import { PureComponent } from 'react';
22
import { withLeaflet, ContextProps } from 'react-leaflet';
33
import Control from 'react-leaflet-control';
44
import { Maximize, Minimize } from 'react-feather';
@@ -9,7 +9,7 @@ type Props = ContextProps & {
99
readonly onToggleExpand: (boolean: boolean) => void;
1010
};
1111

12-
class ExpandMap extends React.PureComponent<Props> {
12+
class ExpandMap extends PureComponent<Props> {
1313
componentDidUpdate() {
1414
if (this.props.leaflet && this.props.leaflet.map) {
1515
const { map } = this.props.leaflet;

website/src/views/components/map/LocationMap.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import * as React from 'react';
22
import { Map as LeafletMap } from 'leaflet';
33
import { Map, Marker, TileLayer, Polygon, Tooltip } from 'react-leaflet';
44
import { GestureHandling } from 'leaflet-gesture-handling';

website/src/views/components/map/MapContext.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as React from 'react';
1+
import { createContext } from 'react';
22

33
type MapContextValue = Readonly<{
44
toggleMapExpanded: (boolean: boolean) => void;
@@ -13,6 +13,6 @@ const defaultValue: MapContextValue = {
1313
},
1414
};
1515

16-
const MapContext = React.createContext<MapContextValue>(defaultValue);
16+
const MapContext = createContext<MapContextValue>(defaultValue);
1717

1818
export default MapContext;

website/src/views/components/map/withVenueLocations.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { ComponentType } from 'react';
1+
import { ComponentType } from 'react';
22
import Loadable, { LoadingComponentProps } from 'react-loadable';
33

44
import { VenueLocationMap } from 'types/venues';

website/src/views/components/module-info/AddModuleDropdown.test.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as React from 'react';
21
import { mount } from 'enzyme';
32

43
import { TimetableConfig } from 'types/timetables';

website/src/views/components/module-info/AddModuleDropdown.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as React from 'react';
1+
import { PureComponent } from 'react';
22
import Downshift from 'downshift';
33
import classnames from 'classnames';
44
import { connect } from 'react-redux';
@@ -36,7 +36,7 @@ function isModuleOnTimetable(
3636
return !!get(timetables, [String(semester), module.moduleCode]);
3737
}
3838

39-
export class AddModuleDropdownComponent extends React.PureComponent<Props, State> {
39+
export class AddModuleDropdownComponent extends PureComponent<Props, State> {
4040
static getDerivedStateFromProps(nextProps: Props, prevState: State) {
4141
const { timetables, module } = nextProps;
4242
const { loading } = prevState;

website/src/views/components/module-info/ModuleExamClash.test.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as React from 'react';
21
import { shallow } from 'enzyme';
32

43
import { Module, ModuleCode } from 'types/modules';

website/src/views/components/module-info/ModuleSemesterInfo.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as React from 'react';
1+
import { Component } from 'react';
22

33
import { ModuleCode, Semester, SemesterDataCondensed } from 'types/modules';
44

@@ -17,7 +17,7 @@ type State = {
1717
selected: Semester;
1818
};
1919

20-
export default class ModuleSemesterInfo extends React.Component<Props, State> {
20+
export default class ModuleSemesterInfo extends Component<Props, State> {
2121
constructor(props: Props) {
2222
super(props);
2323

website/src/views/components/module-info/ModuleWorkload.test.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as React from 'react';
21
import { shallow, ShallowWrapper } from 'enzyme';
32
import _ from 'lodash';
43

website/src/views/components/module-info/SemesterPicker.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as React from 'react';
1+
import { memo } from 'react';
22
import { each } from 'lodash';
33

44
import { Semester } from 'types/modules';
@@ -18,7 +18,7 @@ type Props = {
1818
onSelectSemester: (semester: Semester) => void;
1919
};
2020

21-
const SemesterPicker = React.memo<Props>(
21+
const SemesterPicker = memo<Props>(
2222
({
2323
semesters,
2424
showDisabled = false,

website/src/views/components/notfications/Announcements.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { memo, useState, useCallback } from 'react';
1+
import { memo, useState, useCallback } from 'react';
22
import classnames from 'classnames';
33
import { Sun } from 'react-feather';
44

0 commit comments

Comments
 (0)