diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 00000000..5b390797 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,14 @@ +module.exports = { + root: true, + parser: '@typescript-eslint/parser', + plugins: [ + '@typescript-eslint', + ], + rules: { + "@typescript-eslint/ban-ts-comment": "off" + }, + extends: [ + 'eslint:recommended', + 'plugin:@typescript-eslint/recommended', + ], +}; \ No newline at end of file diff --git a/optuna_dashboard/static/action.ts b/optuna_dashboard/static/action.ts index 191419d6..b62e8b03 100644 --- a/optuna_dashboard/static/action.ts +++ b/optuna_dashboard/static/action.ts @@ -37,7 +37,7 @@ export const actionCreator = () => { const updateStudyDetail = (studyId: number) => { getStudyDetailAPI(studyId) .then((study) => { - let newVal = Object.assign({}, studyDetails) + const newVal = Object.assign({}, studyDetails) newVal[studyId] = study setStudyDetails(newVal) }) diff --git a/optuna_dashboard/static/apiClient.ts b/optuna_dashboard/static/apiClient.ts index 213e9984..cd68c40a 100644 --- a/optuna_dashboard/static/apiClient.ts +++ b/optuna_dashboard/static/apiClient.ts @@ -161,8 +161,8 @@ export const createNewStudyAPI = ( }) } -export const deleteStudyAPI = (studyId: number): Promise<{}> => { - return axiosInstance.delete<{}>(`/api/studies/${studyId}`).then((res) => { +export const deleteStudyAPI = (studyId: number) => { + return axiosInstance.delete(`/api/studies/${studyId}`).then((res) => { return {} }) } diff --git a/optuna_dashboard/static/components/App.tsx b/optuna_dashboard/static/components/App.tsx index 6fa5add2..e0c3ae5d 100644 --- a/optuna_dashboard/static/components/App.tsx +++ b/optuna_dashboard/static/components/App.tsx @@ -6,7 +6,7 @@ import { SnackbarProvider } from "notistack" import { StudyDetail } from "./StudyDetail" import { StudyList } from "./StudyList" -export const App: FC<{}> = () => { +export const App: FC = () => { return ( diff --git a/optuna_dashboard/static/components/GraphHistory.tsx b/optuna_dashboard/static/components/GraphHistory.tsx index 4ae8d7aa..c740549c 100644 --- a/optuna_dashboard/static/components/GraphHistory.tsx +++ b/optuna_dashboard/static/components/GraphHistory.tsx @@ -199,7 +199,7 @@ const plotHistory = ( plotly.react(plotDomId, []) return } - let trialsForLinePlot: Trial[] = [] + const trialsForLinePlot: Trial[] = [] let currentBest: number | null = null filteredTrials.forEach((item) => { if (currentBest === null) { @@ -228,9 +228,9 @@ const plotHistory = ( : trial.datetime_complete! } - let xForLinePlot = trialsForLinePlot.map(getAxisX) + const xForLinePlot = trialsForLinePlot.map(getAxisX) xForLinePlot.push(getAxisX(filteredTrials[filteredTrials.length - 1])) - let yForLinePlot = trialsForLinePlot.map( + const yForLinePlot = trialsForLinePlot.map( (t: Trial): number => t.values![objectiveId] ) yForLinePlot.push(yForLinePlot[yForLinePlot.length - 1]) diff --git a/optuna_dashboard/static/components/GraphIntermediateValues.tsx b/optuna_dashboard/static/components/GraphIntermediateValues.tsx index 6a87bf00..227d7434 100644 --- a/optuna_dashboard/static/components/GraphIntermediateValues.tsx +++ b/optuna_dashboard/static/components/GraphIntermediateValues.tsx @@ -30,7 +30,7 @@ const plotIntermediateValue = (trials: Trial[]) => { return } - let filteredTrials = trials.filter( + const filteredTrials = trials.filter( (t) => t.state === "Complete" || t.state === "Pruned" ) const plotData: Partial[] = filteredTrials.map((trial) => { diff --git a/optuna_dashboard/static/components/GraphParallelCoordinate.tsx b/optuna_dashboard/static/components/GraphParallelCoordinate.tsx index d9e81466..ac227c47 100644 --- a/optuna_dashboard/static/components/GraphParallelCoordinate.tsx +++ b/optuna_dashboard/static/components/GraphParallelCoordinate.tsx @@ -30,7 +30,7 @@ const plotCoordinate = (trials: Trial[], objectiveId: number) => { plotly.react(plotDomId, []) return } - let filteredTrials = trials.filter( + const filteredTrials = trials.filter( (t) => t.state === "Complete" || t.state === "Pruned" ) @@ -50,7 +50,7 @@ const plotCoordinate = (trials: Trial[], objectiveId: number) => { const objectiveValues: number[] = filteredTrials.map( (t) => t.values![objectiveId] ) - let dimensions = [ + const dimensions = [ { label: "Objective value", values: objectiveValues, diff --git a/optuna_dashboard/static/components/StudyDetail.tsx b/optuna_dashboard/static/components/StudyDetail.tsx index 99d6bbfc..e32450e6 100644 --- a/optuna_dashboard/static/components/StudyDetail.tsx +++ b/optuna_dashboard/static/components/StudyDetail.tsx @@ -90,7 +90,7 @@ export const useStudyDetailValue = (studyId: number): StudyDetail | null => { return studyDetails[studyId] || null } -export const StudyDetail: FC<{}> = () => { +export const StudyDetail: FC = () => { const classes = useStyles() const action = actionCreator() const { studyId } = useParams() @@ -209,7 +209,7 @@ const TrialTable: FC<{ studyDetail: StudyDetail | null }> = ({ }) => { const trials: Trial[] = studyDetail !== null ? studyDetail.trials : [] - let columns: DataGridColumn[] = [ + const columns: DataGridColumn[] = [ { field: "number", label: "Number", sortable: true, padding: "none" }, { field: "state", diff --git a/optuna_dashboard/static/components/StudyList.tsx b/optuna_dashboard/static/components/StudyList.tsx index d88dd1f4..8e348ef1 100644 --- a/optuna_dashboard/static/components/StudyList.tsx +++ b/optuna_dashboard/static/components/StudyList.tsx @@ -46,7 +46,7 @@ const useStyles = makeStyles((theme: Theme) => }) ) -export const StudyList: FC<{}> = () => { +export const StudyList: FC = () => { const classes = useStyles() const [ @@ -384,7 +384,7 @@ export const StudyList: FC<{}> = () => {