Skip to content

Commit

Permalink
linting & format
Browse files Browse the repository at this point in the history
  • Loading branch information
lmoertl committed Dec 1, 2023
1 parent 65ff7dd commit 39f5823
Show file tree
Hide file tree
Showing 16 changed files with 70 additions and 32 deletions.
1 change: 1 addition & 0 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export default defineNuxtConfig({
componentIslands: true,
},
pinia: {
// @ts-ignore
autoImports: ["defineStore", "acceptHMRUpdate"],
},
piniaPersistedstate: {
Expand Down
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"types:check": "vue-tsc --noEmit",
"validate": "run-p format:check lint:check types:check",
"full-validate": "run-p format:check lint:check types:check test test:e2e",
"validate-without-tests": "run-p format:check lint:check types:check"
"validate-without-tests": "run-p format:fix lint:check types:check"
},
"dependencies": {
"@acdh-oeaw/lib": "^0.1.4",
Expand Down Expand Up @@ -60,6 +60,7 @@
"@pinia-plugin-persistedstate/nuxt": "^1.2.0",
"@playwright/test": "^1.36.1",
"@tailwindcss/typography": "^0.5.9",
"@types/html-to-text": "^9.0.4",
"@types/node": "^20.7.0",
"autoprefixer": "^10.4.14",
"eslint": "^8.45.0",
Expand Down Expand Up @@ -102,7 +103,10 @@
"@acdh-oeaw/eslint-config-vue",
"@acdh-oeaw/eslint-config-nuxt",
"plugin:eslint-plugin-tailwindcss/recommended"
]
],
"rules": {
"@typescript-eslint/ban-ts-comment": "off"
}
},
"lint-staged": {
"*.@(vue)": [
Expand Down
7 changes: 7 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/components/DataDisplay/DataDisplayKeywordInContext.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const headers = ref([
{ title: "open", key: "open", type: "string" },
]);
function open(item) {
function open(item: KeywordInContext) {
console.log("open", { item });
selectedKWIC.value = item;
}
Expand Down
1 change: 1 addition & 0 deletions src/components/DataDisplay/DataDisplayMediaSource.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const series = computed(() => {
name: query.finalQuery,
data: categories.value
.map((category) => query.data.mediaSources.find(({ media }) => category === media))
// @ts-ignore
.map((a) => (a ? a[mode.value] : 0)),
};
});
Expand Down
3 changes: 2 additions & 1 deletion src/components/DataDisplay/KWICDetailDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const loading = ref(false);
const details: Ref<StructCtxDocumentResponse | null> = ref(null);
async function getDetails() {
if (!props.kwic) return;
loading.value = true;
details.value = null;
const { data: _details } = await authenticatedFetch(STRUCTCTX_URL, {
Expand All @@ -28,7 +29,7 @@ async function getDetails() {
});
loading.value = false;
details.value = _details.value;
details.value = _details.value as StructCtxDocumentResponse;
}
watch(active, async () => {
Expand Down
5 changes: 3 additions & 2 deletions src/composables/useKeywordInContextSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ export function useKeywordInContextSearch() {
});
const keywordInContext = data.value as KeywordInContextData;
// console.log('keywordInContext', { keywordInContext: keywordInContext.value });
// eslint-disable-next-line require-atomic-updates
// eslint-disable
// @ts-ignore
query.data.keywordInContext = keywordInContext.Lines.map(
({ Tbl_refs, Left, Kwic, toknum, Right }) => ({
// this mapping is directly taken from the ancient code
Expand All @@ -40,7 +41,7 @@ export function useKeywordInContextSearch() {
toknum,
}),
);

// eslint-enable
query.loading.keywordInContext = false; // eslint-disable-line require-atomic-updates
};

Expand Down
4 changes: 4 additions & 0 deletions src/composables/useMediaSourceSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export function useMediaSourceSearch() {
const { selectedCorpus } = storeToRefs(corpora);
const { data: mediaSources } = await authenticatedFetch(FREQUENCIES_MULTI_LEVEL_URL, {
params: {
// @ts-ignore
...corpora.corporaForSearchKeys.value,
format: "json",
fmaxitems: 5000,
Expand All @@ -46,12 +47,15 @@ export function useMediaSourceSearch() {
console.log({
mediaSourceData,
blocks: mediaSourceData.Blocks,
// @ts-ignore
items: mediaSourceData.Blocks[0].Items,
});

// @ts-ignore
const WordformData = mediaSourceData.Blocks[0].Items;
WordformData.forEach(({ frq, Word, fpm }) => {
query.data.mediaSources.push({
// @ts-ignore
media: Word[0].n,
// todo absolute is here actually also a frequency
absolute: frq,
Expand Down
15 changes: 8 additions & 7 deletions src/composables/useRegionsSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export function useRegionsSearch() {
/* eslint-disable */
const { data: regionsData } = await authenticatedFetch(FREQUENCIES_MULTI_LEVEL_URL, {
params: {
// @ts-ignore
...corpora.corporaForSearchKeys.value,
format: "json",
fmaxitems: 5000,
Expand All @@ -35,13 +36,13 @@ export function useRegionsSearch() {
return console.error("error on fetching freqml regions");
}
const freqmlRegionData = regionsData.value as unknown as FreqMLRegionResponse;
query.data.regionalFrequencies = freqmlRegionData.Blocks[0].Items.map(
(regionalData: FreqMLRegion) => ({
region: regionalData.Word[0].n,
absolute: escapeZeroSafe(regionalData.frq),
relative: escapeZeroSafe(regionalData.fpm),
}),
);
query.data.regionalFrequencies = (
freqmlRegionData.Blocks[0] ?? { Items: [] as Array<FreqMLRegion> }
).Items.map((regionalData: FreqMLRegion) => ({
region: regionalData.Word[0]?.n as unknown as Region,
absolute: escapeZeroSafe(regionalData.frq),
relative: escapeZeroSafe(regionalData.fpm),
}));

query.loading.regionalFrequencies = false;
};
Expand Down
1 change: 1 addition & 0 deletions src/composables/useWordFormsSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export function useWordFormsSearch() {
/* eslint-disable */
const { data: freqtWords } = await authenticatedFetch(FREQUENCIES_MULTI_LEVEL_URL, {
params: {
// @ts-ignore
...corpora.corporaForSearchKeys.value,

default_attr: "lemma",
Expand Down
15 changes: 8 additions & 7 deletions src/pages/corpsum.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import DataDisplayWordFormFrequencies from "../components/DataDisplay/DataDispla
import { useQuery } from "../stores/query";
import { useSearchSettingsStore } from "../stores/searchSettings";
const searchSettings = useSearchSettingsStore();
const { selectedSearches } = storeToRefs(searchSettings);
definePageMeta({
title: "Corpsum.meta.title",
});
const searchSettings = useSearchSettingsStore();
const { selectedSearches } = storeToRefs(searchSettings);
const t = useTranslations("Corpsum");
// const titles = [
Expand Down Expand Up @@ -47,23 +48,23 @@ const elementsPerRow = computed(() => {
<!-- <DisplayCard v-for="i in 2" :key="i" :title="titles[i]"></DisplayCard> -->

<DataDisplayYearlyFrequencies
v-if="selectedSearches.includes('yearlyFrequencies')"
v-if="selectedSearches.includes('yearlyFrequencies' as unknown as SearchFunctionKey)"
:queries="queries"
></DataDisplayYearlyFrequencies>
<DataDisplayWordFormFrequencies
v-if="selectedSearches.includes('wordFormFrequencies')"
v-if="selectedSearches.includes('wordFormFrequencies' as unknown as SearchFunctionKey)"
:queries="queries"
></DataDisplayWordFormFrequencies>
<DataDisplayRegionalFrequencies
v-if="selectedSearches.includes('regionalFrequencies')"
v-if="selectedSearches.includes('regionalFrequencies' as unknown as SearchFunctionKey)"
:queries="queries"
></DataDisplayRegionalFrequencies>
<DataDisplayMediaSource
v-if="selectedSearches.includes('mediaSources')"
v-if="selectedSearches.includes('mediaSources' as unknown as SearchFunctionKey)"
:queries="queries"
/>
<DataDisplayKeywordInContext
v-if="selectedSearches.includes('keywordInContext')"
v-if="selectedSearches.includes('keywordInContext' as unknown as SearchFunctionKey)"
:queries="queries"
></DataDisplayKeywordInContext>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/plugins/highcharts.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ import HighchartsVue from "highcharts-vue";

export default defineNuxtPlugin((nuxtApp) => {
MapsModule(Highcharts);
// @ts-ignore
nuxtApp.vueApp.use(HighchartsVue, { tagName: "HighCharts" });
});
2 changes: 2 additions & 0 deletions src/plugins/jsonViewer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import "vue-json-viewer/style.css";

// esilint-ignore-next-line
// @ts-ignore
import JsonViewer from "vue-json-viewer/ssr";

export default defineNuxtPlugin((nuxtApp) => {
Expand Down
27 changes: 16 additions & 11 deletions src/stores/searchSettings.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
import { acceptHMRUpdate, defineStore, storeToRefs } from "pinia";
import { type Ref, ref, watch } from "vue";

type SearchFunctionKey =
| "keywordInContext"
| "mediaSources"
| "regionalFrequencies"
| "wordFormFrequencies"
| "yearlyFrequencies";

export const useSearchSettingsStore = defineStore(
"searchSettings",
() => {
Expand All @@ -16,6 +9,7 @@ export const useSearchSettingsStore = defineStore(
const { getMediaSourceFrequencies } = useMediaSourceSearch();
const { getRegionsFrequencies } = useRegionsSearch();
const { getKeywordInContext } = useKeywordInContextSearch();

const possibleSearchKeys: Ref<Array<{ value: SearchFunctionKey; title: string }>> = ref([
{ value: "yearlyFrequencies", title: "Yearly Frequencies" },
{ value: "wordFormFrequencies", title: "Word Form Frequencies" },
Expand All @@ -36,7 +30,7 @@ export const useSearchSettingsStore = defineStore(
mediaSources: getMediaSourceFrequencies,
};

const selectedSearches = ref([
const selectedSearches: Ref<Array<SearchFunctionKey>> = ref([
// "keywordInContext",
// "regionalFrequencies",
// "wordFormFrequencies",
Expand All @@ -47,8 +41,14 @@ export const useSearchSettingsStore = defineStore(
async function doSearches(query: CorpusQuery) {
// console.log({ selsearchVal: selectedSearches.value });

// eslint-disable-next-line
return await Promise.all(selectedSearches.value.map((a) => searchFunctions[a](query)));
return await Promise.all(
selectedSearches.value.map(
(a: SearchFunctionKey) =>
(searchFunctions[a] as unknown as (query: CorpusQuery) => Promise<void>)(
query,
) as unknown as Promise<void>,
),
);
}

const queriesStore = useQuery();
Expand All @@ -74,7 +74,12 @@ export const useSearchSettingsStore = defineStore(
await Promise.all(functionsToRun);
});

return { possibleSearchKeys, searchFunctions, selectedSearches, doSearches };
return {
possibleSearchKeys,
searchFunctions,
selectedSearches,
doSearches,
};
},
{ persist: true },
);
Expand Down
3 changes: 2 additions & 1 deletion src/types/freqsResponse.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export interface FreqsResponseData {
interface FreqsResponseData {
Blocks: Array<Block>;
wllimit: number;
request: Request;
Expand Down Expand Up @@ -36,6 +36,7 @@ interface Item {
fbar: number;
pfilter_list: Array<string>;
frq: number;
fpm: number;
nfilter: string;
norel: number;
}
Expand Down
7 changes: 7 additions & 0 deletions src/types/query.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ type CorpusQueryType = "custom" | "lc" | "lc*" | "lemma" | "word";

type Region = "agesamt" | "amitte" | "aost" | "asuedost" | "awest" | "spezifisch";

type SearchFunctionKey =
| "keywordInContext"
| "mediaSources"
| "regionalFrequencies"
| "wordFormFrequencies"
| "yearlyFrequencies";

interface KeywordInContext {
date: string;
source: string;
Expand Down

0 comments on commit 39f5823

Please sign in to comment.