Skip to content

Commit 8961fb4

Browse files
authored
More fixes for README and small lint fixes (#3472)
* Small lints from ts5 branch * Fix website README * Update scraper README
1 parent 1d231d2 commit 8961fb4

File tree

5 files changed

+22
-16
lines changed

5 files changed

+22
-16
lines changed

export/src/data.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ export async function getModules(moduleCodes: string[]) {
4343
export const parseExportData: Middleware<State> = (ctx, next) => {
4444
if (ctx.query.data) {
4545
try {
46-
// @ts-expect-error: type string[] is not assignable to type string
46+
if (typeof ctx.query.data !== 'string') {
47+
throw new Error(`Expected query.data to be string, got ${typeof ctx.query.data}`);
48+
}
4749
const data = JSON.parse(ctx.query.data);
4850
validateExportData(data);
4951
ctx.state.data = data;

scrapers/nus-v2/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This folder contains the scraper which produces our [v2 API data][api-v2] from i
66

77
## Getting Started
88

9-
Node LTS is required. We use Node 16 in production.
9+
Node LTS is required. We use Node 18 in production.
1010

1111
Use `yarn` to install dependencies, then set up `env.json` with all the necessary keys and API base URL, then run the test script to check the setup is okay.
1212

website/README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ We recommend the following development tools to help speed up your work
4444

4545
### Writing styles
4646

47-
We uses [CSS Modules][css-modules] to structure styles. This means that with the exception of a few global styles, styles for each component lives beside their source files (see [colocation](#colocation)). This allows us to write short, semantic names for styles without worrying about collision.
47+
We use [CSS Modules][css-modules] to structure styles. This means that except for a few global styles, styles for each component lives beside their source files (see [colocation](#colocation)). This allows us to write short, semantic names for styles without worrying about collision.
4848

4949
```scss
5050
// MyComponent.scss
@@ -66,7 +66,7 @@ import "~styles/utils/modules-entry"; // Import variables, mixins
6666
}
6767
```
6868

69-
```ts
69+
```tsx
7070
// MyComponent.tsx
7171
import styles from './MyComponent.scss';
7272

@@ -86,23 +86,23 @@ Currently CSS variables are used only for colors that change under night mode.
8686

8787
Prefer SVG when possible. SVG images are usually smaller and more flexible. `.svg` files are loaded using [SVGR][svgr] as React components - this means you can add classnames, inline styles and other SVG attributes to the component loaded. SVGR also automatically optimizes the image.
8888

89-
```js
89+
```tsx
9090
import CloudyIcon from 'img/weather/cloudy.svg';
9191

9292
const cloud = <CloudyIcon className={styles.myIcon} />;
9393
```
9494

9595
PNG, JPEG and GIF files will be loaded using `url-loader` and can be imported as a string representing the URL of the asset after bundling. In production files smaller than 15kb will be converted into data URL
9696

97-
```js
97+
```tsx
9898
import partyParrot from 'img/gif/partyparrot.gif';
9999

100100
const danceParty = <img src={partyParrot} alt=":partyparrot:" />;
101101
```
102102

103103
To load SVG as files using `url-loader` instead, add the `?url` resource query to the end of the path.
104104

105-
```js
105+
```ts
106106
import { Icon } from 'leaflet';
107107
// eslint-disable-next-line import/extensions
108108
import marker from 'img/marker.svg?url';
@@ -127,7 +127,7 @@ To write an action that makes a request, simple call and return the result from
127127

128128
**Example**
129129

130-
```js
130+
```ts
131131
import { requestAction } from 'actions/requests';
132132

133133
export const FETCH_DATA = 'FETCH_DATA';
@@ -144,7 +144,7 @@ Components should dispatch the action to fetch data. The dispatch function retur
144144

145145
**Example**
146146

147-
```js
147+
```tsx
148148
import { fetchData } from 'actions/example';
149149

150150
type Props = {
@@ -164,7 +164,7 @@ class MyComponent extends React.Component<Props, State> {
164164
componentDidMount() {
165165
this.props.fetchData()
166166
.then(data => this.setState({ data }))
167-
.catch(error => this.setState({ error });
167+
.catch(error => this.setState({ error }));
168168
}
169169

170170
render() {
@@ -213,7 +213,7 @@ export function exampleBank(state: ExampleBank, action: FSA): ExampleBank {
213213

214214
**Component example**
215215

216-
```ts
216+
```tsx
217217
type Props = {
218218
myData: MyData | null,
219219
fetchData: () => Promise<MyData>,
@@ -226,7 +226,7 @@ type State = {
226226
class MyComponent extends React.Component<Props, State> {
227227
componentDidMount() {
228228
this.props.fetchData()
229-
.catch(error => this.setState({ error });
229+
.catch(error => this.setState({ error }));
230230
}
231231

232232
render() {

website/src/bootstrapping/configure-store.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createStore, applyMiddleware, compose } from 'redux';
1+
import { createStore, applyMiddleware, compose, PreloadedState } from 'redux';
22
import { persistStore } from 'redux-persist';
33
import thunk from 'redux-thunk';
44
import { setAutoFreeze } from 'immer';
@@ -44,8 +44,12 @@ export default function configureStore(defaultState?: State) {
4444

4545
const storeEnhancer = applyMiddleware(...middlewares);
4646

47-
// @ts-expect-error Argument of type 'State | undefined' is not assignable to parameter
48-
const store = createStore(rootReducer, defaultState, composeEnhancers(storeEnhancer));
47+
const store = createStore(
48+
rootReducer,
49+
// Redux typings does not seem to allow non-JSON serialized values in PreloadedState so this needs to be casted
50+
defaultState as PreloadedState<State> | undefined,
51+
composeEnhancers(storeEnhancer),
52+
);
4953

5054
if (module.hot) {
5155
// Enable webpack hot module replacement for reducers

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ type State = {};
2424
* queried items are distinct and mutually exclusive.
2525
*/
2626
export default class CheckboxItemFilter extends SearchkitComponent<CheckboxItemFilterProps, State> {
27-
declare accessor: CheckboxFilterAccessor; // This typing is bad - this should really be optional
27+
declare accessor: CheckboxFilterAccessor;
2828

2929
static defaultProps = {
3030
showCount: true,

0 commit comments

Comments
 (0)