Skip to content

Commit

Permalink
kept inferrable types
Browse files Browse the repository at this point in the history
  • Loading branch information
jina2k committed Mar 28, 2022
1 parent ae7ed77 commit e293a13
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 12 deletions.
31 changes: 31 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
{ "SwitchCase": 1 }
],
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-inferrable-types": "off",
"linebreak-style": [
"error",
"unix"
Expand Down Expand Up @@ -89,6 +90,36 @@
"{}": false
}
}
],
// same rules need to be added.
"indent": ["off"],
"@typescript-eslint/indent": [
"error",
"tab",
{ "SwitchCase": 1 }
],
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-inferrable-types": "off",
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"single",
{ "avoidEscape": true }
],
"max-len": [
"error",
{ "code": 150, "tabWidth": 0 }
],
"comma-dangle": [
"error",
"never"
],
"arrow-parens": [
"error",
"as-needed"
]
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/client/app/components/UIOptionsComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ class UIOptionsComponent extends React.Component<UIOptionsPropsWithIntl, UIOptio
);
}

private handleBarDurationChangeComplete(e: any) {
private handleBarDurationChangeComplete() {
this.props.changeDuration(moment.duration(this.state.barDurationDays, 'days'));
}

Expand Down
15 changes: 10 additions & 5 deletions src/client/app/reducers/maps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default function maps(state = defaultState, action: MapsAction) {
...state,
isLoading: true
};
case ActionType.ReceiveMapsDetails:
case ActionType.ReceiveMapsDetails: {
const data: MapMetadata[] = action.data.map(mapData => {
// parse JSON format to MapMetadata object
const parsedData = JSON.parse(JSON.stringify(mapData));
Expand All @@ -58,12 +58,14 @@ export default function maps(state = defaultState, action: MapsAction) {
isLoading: false,
byMapID: _.keyBy(data, map => map.id)
};
case ActionType.IncrementCounter:
}
case ActionType.IncrementCounter: {
const counter = state.newMapCounter;
return {
...state,
newMapCounter: counter + 1
};
}
case ActionType.SetCalibration:
byMapID = state.byMapID;
// if the map is freshly created, just add a new instance into editedMaps
Expand Down Expand Up @@ -113,7 +115,7 @@ export default function maps(state = defaultState, action: MapsAction) {
showGrid: !state.calibrationSettings.showGrid
}
};
case ActionType.ResetCalibration:
case ActionType.ResetCalibration: {
editedMaps = state.editedMaps;
const mapToReset = {...editedMaps[action.mapID]};
delete mapToReset.currentPoint;
Expand All @@ -126,6 +128,7 @@ export default function maps(state = defaultState, action: MapsAction) {
[calibrated]: mapToReset
}
};
}
case ActionType.UpdateMapSource:
return {
...state,
Expand Down Expand Up @@ -176,7 +179,7 @@ export default function maps(state = defaultState, action: MapsAction) {
editedMaps,
byMapID
};
case ActionType.UpdateCurrentCartesian:
case ActionType.UpdateCurrentCartesian: {
const newDataPoint: CalibratedPoint = {
cartesian: action.currentCartesian,
gps: {longitude: -1, latitude: -1}
Expand All @@ -191,6 +194,7 @@ export default function maps(state = defaultState, action: MapsAction) {
}
}
};
}
case ActionType.ResetCurrentPoint:
return {
...state,
Expand All @@ -202,7 +206,7 @@ export default function maps(state = defaultState, action: MapsAction) {
}
}
};
case ActionType.AppendCalibrationSet:
case ActionType.AppendCalibrationSet: {
const originalSet = state.editedMaps[calibrated].calibrationSet;
let copiedSet;
if (originalSet) {
Expand All @@ -221,6 +225,7 @@ export default function maps(state = defaultState, action: MapsAction) {
}
}
};
}
case ActionType.UpdateCalibrationResults:
return {
...state,
Expand Down
4 changes: 1 addition & 3 deletions src/client/app/utils/calculateCompare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ export function validateSortingOrder(sortingOrder: string): SortingOrder {
}

export function calculateCompareTimeInterval(comparePeriod: ComparePeriod, currentTime: moment.Moment): TimeInterval {
let compareTimeInterval;
// Moment changes the times by shifting to local (client/browser) timezone. To fix this up, we need
// to know the shift between UTC and local timezone. The value below is the time in minutes that
// must be added to go from UTC to local time. For example, for CST it is -360 (Central U.S.A.
Expand Down Expand Up @@ -82,8 +81,7 @@ export function calculateCompareTimeInterval(comparePeriod: ComparePeriod, curre
default:
throw new Error(`Unknown period value: ${comparePeriod}`);
}
compareTimeInterval = new TimeInterval(begin, end);
return compareTimeInterval;
return new TimeInterval(begin, end);
}

export function calculateCompareDuration(comparePeriod: ComparePeriod): moment.Duration {
Expand Down
4 changes: 1 addition & 3 deletions src/client/app/utils/calibration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,6 @@ function calculateScale(p1: CalibratedPoint, p2: CalibratedPoint) {
* @return Normalized size of map so no more than 500 on either side.
*/
export function normalizeImageDimensions(dimensions: Dimensions): Dimensions {
let res: Dimensions;
let width;
let height;
// Use the larger dimension to be 500 and this makes sure the other dimension
Expand All @@ -324,11 +323,10 @@ export function normalizeImageDimensions(dimensions: Dimensions): Dimensions {
height = 500;
width = 500 * dimensions.width / dimensions.height;
}
res = {
return {
width,
height
};
return res;
}

/**
Expand Down

0 comments on commit e293a13

Please sign in to comment.