diff --git a/.eslintrc.js b/.eslintrc.js index 20a287b..5e07b07 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -25,6 +25,7 @@ module.exports = { "unused-vars": "off", "@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }], "no-redeclare": "off", - "@typescript-eslint/no-redeclare": ["error"] + "@typescript-eslint/no-redeclare": ["error"], + "quotes": ["error", "double"] }, }; diff --git a/src/App.tsx b/src/App.tsx index 82c9992..c39da0b 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,16 +1,16 @@ -import React, {useState} from 'react'; +import React, {useState} from "react"; -import './App.scss'; -import {SaiEntryProps, JutEntryProps, ElesuEntryProps, TukEntryProps} from './dbtypes'; -import {SaiEntry, JutEntry, ElesuEntry, TukEntry} from './Entries'; +import "./App.scss"; +import {SaiEntryProps, JutEntryProps, ElesuEntryProps, TukEntryProps} from "./dbtypes"; +import {SaiEntry, JutEntry, ElesuEntry, TukEntry} from "./Entries"; -const backendUrl = 'https://kucinakobackend.ichigo.everydayimshuflin.com'; +const backendUrl = "https://kucinakobackend.ichigo.everydayimshuflin.com"; enum Conlang { - Saimiar = 'saimiar', - Elesu = 'elesu', - Tukvaysi = 'tukvaysi', - Juteyuji = 'juteyuji', + Saimiar = "saimiar", + Elesu = "elesu", + Tukvaysi = "tukvaysi", + Juteyuji = "juteyuji", } enum SearchDirection { @@ -20,28 +20,28 @@ enum SearchDirection { const renderConlang = (conlang: Conlang): string => { if (conlang === Conlang.Saimiar) { - return 'Saimiar'; + return "Saimiar"; } if (conlang === Conlang.Elesu) { - return 'Elésu'; + return "Elésu"; } if (conlang === Conlang.Juteyuji) { - return 'Juteyuji'; + return "Juteyuji"; } if (conlang === Conlang.Tukvaysi) { - return 'Tukvaysi'; + return "Tukvaysi"; } }; function buildRequest(searchTerm: string, conlang: Conlang, direction: SearchDirection, jsonHandler: (json: Object) => void) { const specForConlang = { - [Conlang.Saimiar]: 'sai', - [Conlang.Juteyuji]: 'jut', - [Conlang.Tukvaysi]: 'tuk', - [Conlang.Elesu]: 'elesu', + [Conlang.Saimiar]: "sai", + [Conlang.Juteyuji]: "jut", + [Conlang.Tukvaysi]: "tuk", + [Conlang.Elesu]: "elesu", }; const offset = 0; @@ -49,13 +49,13 @@ function buildRequest(searchTerm: string, conlang: Conlang, direction: SearchDir const conlangDb = conlang.toString(); const conlangSpec = specForConlang[conlang]; - const field = direction === SearchDirection.ToConlang ? 'eng' : conlangSpec; + const field = direction === SearchDirection.ToConlang ? "eng" : conlangSpec; const params = new URLSearchParams([ [field, `like.*${searchTerm}*`], - ['order', conlangSpec], - ['limit', limit], - ['offset', offset], + ["order", conlangSpec], + ["limit", limit], + ["offset", offset], ]); const effectiveUri = `${backendUrl}/${conlangDb}?${params}`; @@ -106,7 +106,7 @@ const Results = (props: ResultsProps) => { const renderedName = renderConlang(conlang); const searchType = (props.direction === SearchDirection.ToConlang) ? `English -> ${renderedName}` : `${renderedName} -> English`; - const result = num === 1 ? 'result' : 'results'; + const result = num === 1 ? "result" : "results"; const header = (
Searched for { props.searchTerm }, { searchType }, found { num } { result } @@ -120,28 +120,28 @@ const Results = (props: ResultsProps) => { const results = props.searchResults; return (
- { results ? content() : 'No search' } + { results ? content() : "No search" }
); }; const App = (_props) => { - const defaultConlang = window.sessionStorage.getItem('conlang') as Conlang || Conlang.Saimiar; + const defaultConlang = window.sessionStorage.getItem("conlang") as Conlang || Conlang.Saimiar; const [searchResults, setSearchResults] = useState(null); const [conlang, setConlangState] = useState(defaultConlang); const [direction, setDirection] = useState(null); const [searchTerm, setSearchTerm] = useState(null); - const [searchBoxInput, setSearchBoxInput] = useState(''); + const [searchBoxInput, setSearchBoxInput] = useState(""); const setConlang = (conlang: Conlang) => { setConlangState(conlang); - window.sessionStorage.setItem('conlang', conlang); + window.sessionStorage.setItem("conlang", conlang); }; const searchConlang = (_evt) => { const searchTerm = searchBoxInput; - if (searchTerm === '') { + if (searchTerm === "") { setSearchResults(null); setSearchTerm(null); setDirection(null); @@ -157,7 +157,7 @@ const App = (_props) => { const searchEng = (_evt) => { const searchTerm = searchBoxInput; - if (searchTerm === '') { + if (searchTerm === "") { setSearchResults(null); setSearchTerm(null); setDirection(null); diff --git a/src/Entries.tsx b/src/Entries.tsx index 9238b8f..99467a0 100644 --- a/src/Entries.tsx +++ b/src/Entries.tsx @@ -1,11 +1,11 @@ -import React from 'react'; -import {declineSaimiar} from './saimiar_morphology'; -import {SaiEntryProps, JutEntryProps, ElesuEntryProps, TukEntryProps} from './dbtypes'; +import React from "react"; +import {declineSaimiar} from "./saimiar_morphology"; +import {SaiEntryProps, JutEntryProps, ElesuEntryProps, TukEntryProps} from "./dbtypes"; const SaiEntry = (props: {entry: SaiEntryProps}) => { const {entry} = props; const synCategory = entry.syn_category; - const isNominal = synCategory === 'nominal'; + const isNominal = synCategory === "nominal"; return (
{ entry.sai } - { entry.eng } @@ -23,10 +23,10 @@ const SaiEntry = (props: {entry: SaiEntryProps}) => { function formatMorphology(entry) { const decl = declineSaimiar(entry); if (!decl) { - return ''; + return ""; } - return ( + return ( Abs: {decl.abs}, Erg: {decl.erg}, Adp: {decl.adp}, All: {decl.all}, @@ -45,7 +45,7 @@ const JutEntry = (props: {entry: JutEntryProps}) => { { entry.jut } - { entry.eng }
- { entry.syn_category === 'noun' ? entry.gender : null } + { entry.syn_category === "noun" ? entry.gender : null }
); }; diff --git a/src/saimiar_morphology.ts b/src/saimiar_morphology.ts index 75de8cf..701e691 100644 --- a/src/saimiar_morphology.ts +++ b/src/saimiar_morphology.ts @@ -12,23 +12,23 @@ type SaimiarDeclension = { }; function declineSaimiar(entry): SaimiarDeclension { - const split = entry.sai.split(' '); + const split = entry.sai.split(" "); const sai = split.at(-1); const morph = entry.morph_type; - if (morph === '-V') { + if (morph === "-V") { return vowelDeclension(sai); } - if (morph === '-a/i') { + if (morph === "-a/i") { return aiDeclension(sai); } - if (morph === 'e-') { + if (morph === "e-") { return initalDeclension(sai); } - if (morph === '-C') { + if (morph === "-C") { return consonantDeclension(sai); } @@ -39,7 +39,7 @@ function declineSaimiar(entry): SaimiarDeclension { function vowelDeclension(sai: string): SaimiarDeclension { const {root, ending} = rootEndingPair(sai); - const adpEnding = ending === 'u' ? 'ys' : `${ending}s`; + const adpEnding = ending === "u" ? "ys" : `${ending}s`; return { abs: `${root}${ending}`, @@ -69,8 +69,8 @@ function aiDeclension(sai: string): SaimiarDeclension { function consonantDeclension(sai: string): SaimiarDeclension { const split = rootEndingPair(sai); - const root = split.ending === 'ø' ? split.root : sai; - const absFinal = split.ending === 'ø' ? 'ø' : ''; + const root = split.ending === "ø" ? split.root : sai; + const absFinal = split.ending === "ø" ? "ø" : ""; return { abs: `${root}${absFinal}`, @@ -84,7 +84,7 @@ function consonantDeclension(sai: string): SaimiarDeclension { }; } -const vowels = ['a', 'e', 'ê', 'i', 'o', 'ô', 'u', 'y']; +const vowels = ["a", "e", "ê", "i", "o", "ô", "u", "y"]; function initalDeclension(sai: string): SaimiarDeclension { const initial = sai.slice(0, 1); @@ -92,8 +92,8 @@ function initalDeclension(sai: string): SaimiarDeclension { const finalRootSound = root.slice(-1); const finalVowel = vowels.includes(finalRootSound); - const instEnding = finalVowel ? 'ŕø' : 'ar'; - const relEnding = finalVowel ? 'źi' : 'ai'; + const instEnding = finalVowel ? "ŕø" : "ar"; + const relEnding = finalVowel ? "źi" : "ai"; return { abs: `${initial}${root}`,