Skip to content

Commit

Permalink
Resolve lint warnings (#4808)
Browse files Browse the repository at this point in the history
This resolves around 200 lint warning (803 to 606) by disabling
camel-case check when unnecessary, adding a return type to functions, or
removing some unused code.
  • Loading branch information
gmechali authored Dec 21, 2024
1 parent 4a4e36c commit e5de2db
Show file tree
Hide file tree
Showing 32 changed files with 124 additions and 121 deletions.
4 changes: 2 additions & 2 deletions static/js/apps/explore/debug_info.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ const svToSentences = (
<li key={sentence.score + sentence.sentence}>
{sentence.sentence} (cosine:
{sentence.score.toFixed(4)}
{sentence.rerank_score
? " - rerank:" + sentence.rerank_score.toFixed(4)
{sentence.rerankScore
? " - rerank:" + sentence.rerankScore.toFixed(4)
: ""}
)
</li>
Expand Down
1 change: 0 additions & 1 deletion static/js/apps/visualization/selector_wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
* Wrapper for selectors used in the selector pane.
*/

import _ from "lodash";
import React from "react";

interface SelectorWrapperPropType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function getDisplayInputs(appContext: AppContextType): InputInfo[] {
return [
{
isChecked: appContext.displayOptions.scatterQuadrants,
onUpdated: (isChecked: boolean) => {
onUpdated: (isChecked: boolean): void => {
const newDisplayOptions = _.cloneDeep(appContext.displayOptions);
newDisplayOptions.scatterQuadrants = isChecked;
appContext.setDisplayOptions(newDisplayOptions);
Expand All @@ -86,7 +86,7 @@ function getDisplayInputs(appContext: AppContextType): InputInfo[] {
},
{
isChecked: appContext.displayOptions.scatterPlaceLabels,
onUpdated: (isChecked: boolean) => {
onUpdated: (isChecked: boolean): void => {
const newDisplayOptions = _.cloneDeep(appContext.displayOptions);
newDisplayOptions.scatterPlaceLabels = isChecked;
appContext.setDisplayOptions(newDisplayOptions);
Expand Down Expand Up @@ -122,7 +122,7 @@ function getFacetSelector(appContext: AppContextType): JSX.Element {
};
});
});
const onSvFacetIdUpdated = (svFacetId: Record<string, string>) => {
const onSvFacetIdUpdated = (svFacetId: Record<string, string>): void => {
const facetsChanged = statVars.filter(
(sv) => sv.facetId !== svFacetId[sv.dcid]
);
Expand Down
8 changes: 5 additions & 3 deletions static/js/biomedical/landing/card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const CardContainer = styled.a`
`;

const Text = styled.div`
color: ${(props) => props.theme.textColor || "#146C2E"};
color: ${(props: CardProps): string => props.theme.textColor || "#146C2E"};
font-size: 24px;
font-weight: 400;
line-height: 32px;
Expand All @@ -57,9 +57,11 @@ const Text = styled.div`

const Tag = styled.div`
align-items: center;
background-color: ${(props) => props.theme.tagBackgroundColor || "#C4EED0"};
background-color: ${(props: CardProps): string =>
props.theme.tagBackgroundColor || "#C4EED0"};
border-radius: 28px;
color: ${(props) => props.theme.tagLabelColor || "#072711"};
color: ${(props: CardProps): string =>
props.theme.tagLabelColor || "#072711"};
display: flex;
font-size: 12px;
font-weight: 500;
Expand Down
2 changes: 2 additions & 0 deletions static/js/shared/util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

/* eslint-disable camelcase */

import { MAX_DATE, MAX_YEAR } from "./constants";
import { getCappedStatVarDate, isDateTooFar } from "./util";

Expand Down
2 changes: 2 additions & 0 deletions static/js/tools/download/mock_functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

/* mocked axios calls for Page test for download tool. */

/* eslint-disable camelcase */

jest.mock("axios");
import axios from "axios";
import { when } from "jest-when";
Expand Down
2 changes: 2 additions & 0 deletions static/js/tools/scatter/app.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

/* eslint-disable camelcase */

jest.mock("axios");

import { act, waitFor } from "@testing-library/react";
Expand Down
4 changes: 2 additions & 2 deletions static/js/tools/scatter/place_and_type_options.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ function PlaceAndTypeOptions(props: PlaceAndTypeOptionsProps): JSX.Element {
? "selected-chart-option"
: "chart-type-option"
}`}
onClick={() => display.setChartType(ScatterChartType.SCATTER)}
onClick={(): void => display.setChartType(ScatterChartType.SCATTER)}
>
<i className="material-icons-outlined">scatter_plot</i>
</div>
Expand All @@ -117,7 +117,7 @@ function PlaceAndTypeOptions(props: PlaceAndTypeOptionsProps): JSX.Element {
? "selected-chart-option"
: "chart-type-option"
}`}
onClick={() => display.setChartType(ScatterChartType.MAP)}
onClick={(): void => display.setChartType(ScatterChartType.MAP)}
>
<i className="material-icons-outlined">public</i>
</div>
Expand Down
46 changes: 15 additions & 31 deletions static/js/tools/scatter/plot_options.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@
* lower and upper bounds for populations.
*/

import _ from "lodash";
import React, { useContext, useState } from "react";
import { Button, Card, FormGroup, Input, Label } from "reactstrap";
import { Container } from "reactstrap";

import { DENOM_INPUT_PLACEHOLDER } from "../../shared/constants";
import {
GA_EVENT_TOOL_CHART_OPTION_CLICK,
GA_PARAM_TOOL_CHART_OPTION,
Expand Down Expand Up @@ -65,18 +63,6 @@ function swapAxes(x: AxisWrapper, y: AxisWrapper): void {
y.set(xValue);
}

/**
* Toggles whether to plot per capita values for an axis.
* @param axis
* @param event
*/
function checkPerCapita(
axis: AxisWrapper,
event: React.ChangeEvent<HTMLInputElement>
): void {
axis.setPerCapita(event.target.checked);
}

/**
* Toggles whether to plot an axis on log scale.
* @param axis
Expand Down Expand Up @@ -178,8 +164,6 @@ function PlotOptions(): JSX.Element {
const [upperBound, setUpperBound] = useState(
place.value.upperBound.toString()
);
const [xDenomInput, setXDenomInput] = useState(x.value.denom);
const [yDenomInput, setYDenomInput] = useState(y.value.denom);
const yAxisLabel =
display.chartType === ScatterChartType.SCATTER
? "Y-axis"
Expand Down Expand Up @@ -217,7 +201,7 @@ function PlotOptions(): JSX.Element {
id="per-capita-y"
type="checkbox"
checked={y.value.perCapita}
onChange={(e) => {
onChange={(e): void => {
y.setPerCapita(e.target.checked);
if (!y.value.perCapita) {
triggerGAEvent(GA_EVENT_TOOL_CHART_OPTION_CLICK, {
Expand All @@ -237,7 +221,7 @@ function PlotOptions(): JSX.Element {
id="log-y"
type="checkbox"
checked={y.value.log}
onChange={(e) => {
onChange={(e): void => {
checkLog(y, e);
if (!y.value.log) {
triggerGAEvent(GA_EVENT_TOOL_CHART_OPTION_CLICK, {
Expand All @@ -264,7 +248,7 @@ function PlotOptions(): JSX.Element {
id="per-capita-x"
type="checkbox"
checked={x.value.perCapita}
onChange={(e) => {
onChange={(e): void => {
x.setPerCapita(e.target.checked);
if (!x.value.perCapita) {
triggerGAEvent(GA_EVENT_TOOL_CHART_OPTION_CLICK, {
Expand All @@ -284,7 +268,7 @@ function PlotOptions(): JSX.Element {
id="log-x"
type="checkbox"
checked={x.value.log}
onChange={(e) => {
onChange={(e): void => {
checkLog(x, e);
if (!x.value.log) {
triggerGAEvent(GA_EVENT_TOOL_CHART_OPTION_CLICK, {
Expand All @@ -309,7 +293,7 @@ function PlotOptions(): JSX.Element {
id="swap-axes"
size="sm"
color="light"
onClick={() => {
onClick={(): void => {
swapAxes(x, y);
triggerGAEvent(GA_EVENT_TOOL_CHART_OPTION_CLICK, {
[GA_PARAM_TOOL_CHART_OPTION]:
Expand All @@ -328,7 +312,7 @@ function PlotOptions(): JSX.Element {
id="quadrants"
type="checkbox"
checked={display.showQuadrants}
onChange={(e) => {
onChange={(e): void => {
checkQuadrants(display, e);
if (!display.showQuadrants) {
triggerGAEvent(GA_EVENT_TOOL_CHART_OPTION_CLICK, {
Expand All @@ -349,7 +333,7 @@ function PlotOptions(): JSX.Element {
id="quadrants"
type="checkbox"
checked={display.showLabels}
onChange={(e) => {
onChange={(e): void => {
checkLabels(display, e);
if (!display.showLabels) {
triggerGAEvent(GA_EVENT_TOOL_CHART_OPTION_CLICK, {
Expand All @@ -370,7 +354,7 @@ function PlotOptions(): JSX.Element {
id="density"
type="checkbox"
checked={display.showDensity}
onChange={(e) => {
onChange={(e): void => {
checkDensity(display, e);
if (!display.showDensity) {
triggerGAEvent(GA_EVENT_TOOL_CHART_OPTION_CLICK, {
Expand All @@ -396,7 +380,7 @@ function PlotOptions(): JSX.Element {
<Input
checked={display.showPopulation === SHOW_POPULATION_OFF}
id="show-population-off"
onChange={(e) => {
onChange={(e): void => {
selectShowPopulation(display, e);
if (display.showPopulation !== SHOW_POPULATION_OFF) {
triggerGAEvent(GA_EVENT_TOOL_CHART_OPTION_CLICK, {
Expand All @@ -416,7 +400,7 @@ function PlotOptions(): JSX.Element {
display.showPopulation === SHOW_POPULATION_LINEAR
}
id="show-population-linear"
onChange={(e) => {
onChange={(e): void => {
selectShowPopulation(display, e);
if (display.showPopulation !== SHOW_POPULATION_LINEAR) {
triggerGAEvent(GA_EVENT_TOOL_CHART_OPTION_CLICK, {
Expand All @@ -434,7 +418,7 @@ function PlotOptions(): JSX.Element {
<Input
checked={display.showPopulation === SHOW_POPULATION_LOG}
id="show-population-log"
onChange={(e) => {
onChange={(e): void => {
selectShowPopulation(display, e);
if (display.showPopulation !== SHOW_POPULATION_LOG) {
triggerGAEvent(GA_EVENT_TOOL_CHART_OPTION_CLICK, {
Expand All @@ -459,11 +443,11 @@ function PlotOptions(): JSX.Element {
<Input
className="pop-filter-input"
type="number"
onChange={(e) =>
onChange={(e): void =>
selectLowerBound(place, e, setLowerBound)
}
value={lowerBound}
onBlur={() => {
onBlur={(): void => {
setLowerBound(place.value.lowerBound.toString());
triggerGAEvent(GA_EVENT_TOOL_CHART_OPTION_CLICK, {
[GA_PARAM_TOOL_CHART_OPTION]:
Expand All @@ -479,11 +463,11 @@ function PlotOptions(): JSX.Element {
<Input
className="pop-filter-input"
type="number"
onChange={(e) =>
onChange={(e): void =>
selectUpperBound(place, e, setUpperBound)
}
value={upperBound}
onBlur={() => {
onBlur={(): void => {
setUpperBound(place.value.upperBound.toString());
triggerGAEvent(GA_EVENT_TOOL_CHART_OPTION_CLICK, {
[GA_PARAM_TOOL_CHART_OPTION]:
Expand Down
22 changes: 14 additions & 8 deletions static/js/tools/scatter/statvar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export function StatVarChooser(props: StatVarChooserProps): JSX.Element {
);
setSamplePlaces(samplePlaces);
}, [place.value.enclosedPlaces]);
const closeModal = () => {
const closeModal = (): void => {
setThirdStatVar(emptyStatVar);
setModalOpen(false);
};
Expand Down Expand Up @@ -155,13 +155,15 @@ export function StatVarChooser(props: StatVarChooserProps): JSX.Element {
collapsible={true}
svHierarchyType={StatVarHierarchyType.SCATTER}
sampleEntities={samplePlaces}
deselectSVs={(svList: string[]) =>
deselectSVs={(svList: string[]): void =>
svList.forEach((sv) => {
removeStatVar(x, y, sv);
})
}
selectedSVs={selectedSvs}
selectSV={(sv) => addStatVar(x, y, sv, setThirdStatVar, setModalOpen)}
selectSV={(sv): void =>
addStatVar(x, y, sv, setThirdStatVar, setModalOpen)
}
/>
{/* Modal for selecting 2 stat vars when a third is selected */}
<Modal isOpen={modalOpen} backdrop="static" id="statvar-modal">
Expand All @@ -181,7 +183,9 @@ export function StatVarChooser(props: StatVarChooserProps): JSX.Element {
type="radio"
name="statvar"
defaultChecked={modalSelected.x}
onClick={() => setModalSelected({ x: true, y: false })}
onClick={(): void =>
setModalSelected({ x: true, y: false })
}
/>
{xTitle}
</Label>
Expand All @@ -193,7 +197,9 @@ export function StatVarChooser(props: StatVarChooserProps): JSX.Element {
type="radio"
name="statvar"
defaultChecked={modalSelected.y}
onClick={() => setModalSelected({ x: false, y: true })}
onClick={(): void =>
setModalSelected({ x: false, y: true })
}
/>
{yTitle}
</Label>
Expand All @@ -204,7 +210,7 @@ export function StatVarChooser(props: StatVarChooserProps): JSX.Element {
<ModalFooter>
<Button
color="primary"
onClick={() =>
onClick={(): void =>
confirmStatVars(
x,
y,
Expand Down Expand Up @@ -241,7 +247,7 @@ function addStatVar(
svDcid: string,
setThirdStatVar: (statVar: StatVar) => void,
setModalOpen: (open: boolean) => void
) {
): void {
getStatVarInfo([svDcid])
.then((info) => {
const svInfo = info[svDcid] ? info[svDcid] : {};
Expand Down Expand Up @@ -298,7 +304,7 @@ function addStatVarHelper(
* @param statVar
* @param nodePath
*/
function removeStatVar(x: AxisWrapper, y: AxisWrapper, svDcid: string) {
function removeStatVar(x: AxisWrapper, y: AxisWrapper, svDcid: string): void {
const statVarX = x.value.statVarDcid;
const statVarY = y.value.statVarDcid;
if (statVarX === svDcid) {
Expand Down
Loading

0 comments on commit e5de2db

Please sign in to comment.