Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: fix linting errors and warnings #96

Merged
merged 3 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,8 @@ module.exports = {
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'semi': ['error', 'never'],
'object-curly-spacing': ['error', 'always']
},
"env": {
"node": true
}
}
6 changes: 3 additions & 3 deletions src/components/Workflows.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import WorkflowsIntroSection from "@/components/workflows/WorkflowsIntroSection.vue"
import filtersStore from "@/store/filters-store"
import workflowsStore from "@/store/workflows-store"
import type { ReleaseInfo } from "@/types";
import type { ReleaseInfo } from "@/types"

const { t } = useI18n()

Expand Down Expand Up @@ -70,7 +70,7 @@
return acc
}, {})

workflowsStore.releases = Object.keys(releasesObj).map(key => <ReleaseInfo>releasesObj[key])
workflowsStore.releases = Object.keys(releasesObj).map(key => releasesObj[key] as ReleaseInfo)

setEvalColors(workflowsStore.runs)

Expand All @@ -85,7 +85,7 @@
<div class="flex mb-6">
<p class="text-amber-600 flex-grow-0 px-4 py-2 bg-amber-100 rounded-md text-sm"><span class="font-semibold">Disclaimer:</span> This is an experimental view.</p>
</div>
<WorkflowsIntroSection :page="<'timeline'|'table'>selectedOption.value" class="mb-6"></WorkflowsIntroSection>
<WorkflowsIntroSection :page="selectedOption.value as ('timeline' | 'table')" class="mb-6"></WorkflowsIntroSection>
<div class="flex mb-6">
<SelectButton v-model="selectedOption" :options="options" optionLabel="name"></SelectButton>
<Filters class="ml-auto"/>
Expand Down
2 changes: 1 addition & 1 deletion src/components/workflows/TrendLegend.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
const props = withDefaults(defineProps<{
withDefaults(defineProps<{
showTextColors: boolean
}>(), {
showTextColors: true
Expand Down
2 changes: 1 addition & 1 deletion src/components/workflows/WorkflowsIntroSection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useI18n } from 'vue-i18n'

const { t } = useI18n()

const props = defineProps<{
defineProps<{
page: "timeline" | "table"
}>()
</script>
Expand Down
2 changes: 1 addition & 1 deletion src/components/workflows/WorkflowsTable.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { watch, ref, onMounted, computed } from "vue"
import { watch, ref, onMounted } from "vue"
import { useI18n } from "vue-i18n"
import { createReadableMetricValue, getEvalColor, mapGtId } from "@/helpers/utils"
import type { EvaluationRun } from "@/types"
Expand Down
8 changes: 4 additions & 4 deletions src/components/workflows/WorkflowsTimeline.vue
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
<script setup lang="ts">
import TimelineItem from "@/components/workflows/timeline/TimelineItem.vue"
import Dropdown from 'primevue/dropdown'
import { computed, onMounted, ref, watch} from "vue"
import { EvaluationMetrics, getMaxValueByMetric} from '@/helpers/metrics'
import { computed, onMounted, ref, watch } from "vue"
import { EvaluationMetrics, getMaxValueByMetric } from '@/helpers/metrics'
import { useI18n } from "vue-i18n"
import type { DropdownOption, EvaluationResultsDocumentWide, Workflow, GroundTruth } from "@/types"
import { DropdownPassThroughStyles } from '@/helpers/pt'
import workflowsStore from '@/store/workflows-store'
import filtersStore from '@/store/filters-store'
import timelineStore from "@/store/timeline-store"
import TrendLegend from "@/components/workflows/TrendLegend.vue";
import TrendLegend from "@/components/workflows/TrendLegend.vue"
import TimelineFilters from "./timeline/TimelineFilters.vue"

const { t } = useI18n()
const gtList = computed<GroundTruth[]>(() => workflowsStore.gt.filter(({ id }) => filtersStore.gtTimeline.findIndex(({ value }) => value === id) > -1))
const workflows = ref<Workflow[]>([])
const selectedMetric = ref<DropdownOption | null>(null)
const metrics = computed<DropdownOption[]>(() => Object.keys(EvaluationMetrics).map(key => ({ value: EvaluationMetrics[key], label: t(EvaluationMetrics[key]) })))
const selectedMetricValue = computed<keyof EvaluationResultsDocumentWide>(() => <keyof EvaluationResultsDocumentWide>selectedMetric.value?.value || EvaluationMetrics.CER_MEAN)
const selectedMetricValue = computed<keyof EvaluationResultsDocumentWide>(() => selectedMetric.value?.value as keyof EvaluationResultsDocumentWide || EvaluationMetrics.CER_MEAN)

onMounted(async () => {
selectedMetric.value = metrics.value[0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ function render([data, startDate, endDate, maxY]) {
.attr('fill', colors.gray['600'])
.style('cursor', 'pointer')

releaseGroup.on('mouseenter', function(e) {
releaseGroup.on('mouseenter', function() {
this.parentElement.appendChild(this)
})
})
Expand Down
8 changes: 4 additions & 4 deletions src/components/workflows/timeline/MetricAverageChart.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script setup lang="ts">
import {computed, onMounted, ref, watch} from "vue"
import { computed, onMounted, ref, watch } from "vue"
import { useI18n } from 'vue-i18n'
import OverlayPanel from "primevue/overlaypanel"
import type {EvaluationResultsDocumentWide, EvaluationRun, TimelineChartDataPoint} from "@/types"
import type { EvaluationResultsDocumentWide, EvaluationRun, TimelineChartDataPoint } from "@/types"
import { metricChartTooltipContent } from "@/helpers/metric-chart-tooltip-content"
import BaseTimelineChart from "@/components/workflows/timeline/BaseTimelineChart.vue"
import BaseTimelineDetailedChart from "@/components/workflows/timeline/BaseTimelineDetailedChart.vue"
Expand Down Expand Up @@ -38,14 +38,14 @@ function init() {
function getTimelineData(runs: EvaluationRun[], metric: string): TimelineChartDataPoint[] {
const datesValues = runs.reduce((acc, cur) => {
const date = new Date(new Date(cur.metadata.timestamp).setHours(0, 0, 0, 0)).toDateString()
const value = cur.evaluation_results.document_wide[<keyof EvaluationResultsDocumentWide>metric]
const value = cur.evaluation_results.document_wide[metric as keyof EvaluationResultsDocumentWide]
if (!value || Array.isArray(value)) return acc

if (!acc[date]) acc[date] = [value]
else acc[date] = [...acc[date], value]
return acc
},
<{ [key: string]: number[] }>{})
{} as { [key: string]: number[] })

return Object
.keys(datesValues)
Expand Down
2 changes: 1 addition & 1 deletion src/components/workflows/timeline/TimelineItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import TimelineItemMetadata from "@/components/workflows/timeline/TimelineItemMe
import filtersStore from "@/store/filters-store"


const props = defineProps<{
defineProps<{
gt: GroundTruth,
metric: keyof EvaluationResultsDocumentWide
}>()
Expand Down
Loading