Use double-quotes

This commit is contained in:
Greg Shuflin 2021-09-13 01:05:41 -07:00
parent 48d8cef2fd
commit 5b3355a651
4 changed files with 48 additions and 47 deletions

View File

@ -25,6 +25,7 @@ module.exports = {
"unused-vars": "off", "unused-vars": "off",
"@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }], "@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
"no-redeclare": "off", "no-redeclare": "off",
"@typescript-eslint/no-redeclare": ["error"] "@typescript-eslint/no-redeclare": ["error"],
"quotes": ["error", "double"]
}, },
}; };

View File

@ -1,16 +1,16 @@
import React, {useState} from 'react'; import React, {useState} from "react";
import './App.scss'; import "./App.scss";
import {SaiEntryProps, JutEntryProps, ElesuEntryProps, TukEntryProps} from './dbtypes'; import {SaiEntryProps, JutEntryProps, ElesuEntryProps, TukEntryProps} from "./dbtypes";
import {SaiEntry, JutEntry, ElesuEntry, TukEntry} from './Entries'; import {SaiEntry, JutEntry, ElesuEntry, TukEntry} from "./Entries";
const backendUrl = 'https://kucinakobackend.ichigo.everydayimshuflin.com'; const backendUrl = "https://kucinakobackend.ichigo.everydayimshuflin.com";
enum Conlang { enum Conlang {
Saimiar = 'saimiar', Saimiar = "saimiar",
Elesu = 'elesu', Elesu = "elesu",
Tukvaysi = 'tukvaysi', Tukvaysi = "tukvaysi",
Juteyuji = 'juteyuji', Juteyuji = "juteyuji",
} }
enum SearchDirection { enum SearchDirection {
@ -20,28 +20,28 @@ enum SearchDirection {
const renderConlang = (conlang: Conlang): string => { const renderConlang = (conlang: Conlang): string => {
if (conlang === Conlang.Saimiar) { if (conlang === Conlang.Saimiar) {
return 'Saimiar'; return "Saimiar";
} }
if (conlang === Conlang.Elesu) { if (conlang === Conlang.Elesu) {
return 'Elésu'; return "Elésu";
} }
if (conlang === Conlang.Juteyuji) { if (conlang === Conlang.Juteyuji) {
return 'Juteyuji'; return "Juteyuji";
} }
if (conlang === Conlang.Tukvaysi) { if (conlang === Conlang.Tukvaysi) {
return 'Tukvaysi'; return "Tukvaysi";
} }
}; };
function buildRequest(searchTerm: string, conlang: Conlang, direction: SearchDirection, jsonHandler: (json: Object) => void) { function buildRequest(searchTerm: string, conlang: Conlang, direction: SearchDirection, jsonHandler: (json: Object) => void) {
const specForConlang = { const specForConlang = {
[Conlang.Saimiar]: 'sai', [Conlang.Saimiar]: "sai",
[Conlang.Juteyuji]: 'jut', [Conlang.Juteyuji]: "jut",
[Conlang.Tukvaysi]: 'tuk', [Conlang.Tukvaysi]: "tuk",
[Conlang.Elesu]: 'elesu', [Conlang.Elesu]: "elesu",
}; };
const offset = 0; const offset = 0;
@ -49,13 +49,13 @@ function buildRequest(searchTerm: string, conlang: Conlang, direction: SearchDir
const conlangDb = conlang.toString(); const conlangDb = conlang.toString();
const conlangSpec = specForConlang[conlang]; const conlangSpec = specForConlang[conlang];
const field = direction === SearchDirection.ToConlang ? 'eng' : conlangSpec; const field = direction === SearchDirection.ToConlang ? "eng" : conlangSpec;
const params = new URLSearchParams([ const params = new URLSearchParams([
[field, `like.*${searchTerm}*`], [field, `like.*${searchTerm}*`],
['order', conlangSpec], ["order", conlangSpec],
['limit', limit], ["limit", limit],
['offset', offset], ["offset", offset],
]); ]);
const effectiveUri = `${backendUrl}/${conlangDb}?${params}`; const effectiveUri = `${backendUrl}/${conlangDb}?${params}`;
@ -106,7 +106,7 @@ const Results = (props: ResultsProps) => {
const renderedName = renderConlang(conlang); const renderedName = renderConlang(conlang);
const searchType = (props.direction === SearchDirection.ToConlang) ? `English -> ${renderedName}` : `${renderedName} -> English`; const searchType = (props.direction === SearchDirection.ToConlang) ? `English -> ${renderedName}` : `${renderedName} -> English`;
const result = num === 1 ? 'result' : 'results'; const result = num === 1 ? "result" : "results";
const header = ( const header = (
<div className="searchResultHeader" key="header"> <div className="searchResultHeader" key="header">
Searched for <b>{ props.searchTerm }</b>, { searchType }, found { num } { result } Searched for <b>{ props.searchTerm }</b>, { searchType }, found { num } { result }
@ -120,28 +120,28 @@ const Results = (props: ResultsProps) => {
const results = props.searchResults; const results = props.searchResults;
return ( return (
<div className="results"> <div className="results">
{ results ? content() : 'No search' } { results ? content() : "No search" }
</div> </div>
); );
}; };
const App = (_props) => { 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 [searchResults, setSearchResults] = useState(null);
const [conlang, setConlangState] = useState(defaultConlang); const [conlang, setConlangState] = useState(defaultConlang);
const [direction, setDirection] = useState(null); const [direction, setDirection] = useState(null);
const [searchTerm, setSearchTerm] = useState(null); const [searchTerm, setSearchTerm] = useState(null);
const [searchBoxInput, setSearchBoxInput] = useState(''); const [searchBoxInput, setSearchBoxInput] = useState("");
const setConlang = (conlang: Conlang) => { const setConlang = (conlang: Conlang) => {
setConlangState(conlang); setConlangState(conlang);
window.sessionStorage.setItem('conlang', conlang); window.sessionStorage.setItem("conlang", conlang);
}; };
const searchConlang = (_evt) => { const searchConlang = (_evt) => {
const searchTerm = searchBoxInput; const searchTerm = searchBoxInput;
if (searchTerm === '') { if (searchTerm === "") {
setSearchResults(null); setSearchResults(null);
setSearchTerm(null); setSearchTerm(null);
setDirection(null); setDirection(null);
@ -157,7 +157,7 @@ const App = (_props) => {
const searchEng = (_evt) => { const searchEng = (_evt) => {
const searchTerm = searchBoxInput; const searchTerm = searchBoxInput;
if (searchTerm === '') { if (searchTerm === "") {
setSearchResults(null); setSearchResults(null);
setSearchTerm(null); setSearchTerm(null);
setDirection(null); setDirection(null);

View File

@ -1,11 +1,11 @@
import React from 'react'; import React from "react";
import {declineSaimiar} from './saimiar_morphology'; import {declineSaimiar} from "./saimiar_morphology";
import {SaiEntryProps, JutEntryProps, ElesuEntryProps, TukEntryProps} from './dbtypes'; import {SaiEntryProps, JutEntryProps, ElesuEntryProps, TukEntryProps} from "./dbtypes";
const SaiEntry = (props: {entry: SaiEntryProps}) => { const SaiEntry = (props: {entry: SaiEntryProps}) => {
const {entry} = props; const {entry} = props;
const synCategory = entry.syn_category; const synCategory = entry.syn_category;
const isNominal = synCategory === 'nominal'; const isNominal = synCategory === "nominal";
return ( return (
<div className="searchResult" key={ entry.id }> <div className="searchResult" key={ entry.id }>
<b>{ entry.sai }</b> - { entry.eng } <b>{ entry.sai }</b> - { entry.eng }
@ -23,10 +23,10 @@ const SaiEntry = (props: {entry: SaiEntryProps}) => {
function formatMorphology(entry) { function formatMorphology(entry) {
const decl = declineSaimiar(entry); const decl = declineSaimiar(entry);
if (!decl) { if (!decl) {
return ''; return "";
} }
return (<span style={ {fontSize: 'medium', color: '#6a3131'} } > return (<span style={ {fontSize: "medium", color: "#6a3131"} } >
Abs: <i>{decl.abs}</i>, Erg: <i>{decl.erg}</i>, Abs: <i>{decl.abs}</i>, Erg: <i>{decl.erg}</i>,
Adp: <i>{decl.adp}</i>, Adp: <i>{decl.adp}</i>,
All: <i>{decl.all}</i>, All: <i>{decl.all}</i>,
@ -45,7 +45,7 @@ const JutEntry = (props: {entry: JutEntryProps}) => {
<b>{ entry.jut }</b> - { entry.eng } <b>{ entry.jut }</b> - { entry.eng }
<br/> <br/>
<span className="synclass"> <span className="synclass">
{ entry.syn_category === 'noun' ? entry.gender : null } { entry.syn_category === "noun" ? entry.gender : null }
</span> </span>
</div>); </div>);
}; };

View File

@ -12,23 +12,23 @@ type SaimiarDeclension = {
}; };
function declineSaimiar(entry): SaimiarDeclension { function declineSaimiar(entry): SaimiarDeclension {
const split = entry.sai.split(' '); const split = entry.sai.split(" ");
const sai = split.at(-1); const sai = split.at(-1);
const morph = entry.morph_type; const morph = entry.morph_type;
if (morph === '-V') { if (morph === "-V") {
return vowelDeclension(sai); return vowelDeclension(sai);
} }
if (morph === '-a/i') { if (morph === "-a/i") {
return aiDeclension(sai); return aiDeclension(sai);
} }
if (morph === 'e-') { if (morph === "e-") {
return initalDeclension(sai); return initalDeclension(sai);
} }
if (morph === '-C') { if (morph === "-C") {
return consonantDeclension(sai); return consonantDeclension(sai);
} }
@ -39,7 +39,7 @@ function declineSaimiar(entry): SaimiarDeclension {
function vowelDeclension(sai: string): SaimiarDeclension { function vowelDeclension(sai: string): SaimiarDeclension {
const {root, ending} = rootEndingPair(sai); const {root, ending} = rootEndingPair(sai);
const adpEnding = ending === 'u' ? 'ys' : `${ending}s`; const adpEnding = ending === "u" ? "ys" : `${ending}s`;
return { return {
abs: `${root}${ending}`, abs: `${root}${ending}`,
@ -69,8 +69,8 @@ function aiDeclension(sai: string): SaimiarDeclension {
function consonantDeclension(sai: string): SaimiarDeclension { function consonantDeclension(sai: string): SaimiarDeclension {
const split = rootEndingPair(sai); const split = rootEndingPair(sai);
const root = split.ending === 'ø' ? split.root : sai; const root = split.ending === "ø" ? split.root : sai;
const absFinal = split.ending === 'ø' ? 'ø' : ''; const absFinal = split.ending === "ø" ? "ø" : "";
return { return {
abs: `${root}${absFinal}`, 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 { function initalDeclension(sai: string): SaimiarDeclension {
const initial = sai.slice(0, 1); const initial = sai.slice(0, 1);
@ -92,8 +92,8 @@ function initalDeclension(sai: string): SaimiarDeclension {
const finalRootSound = root.slice(-1); const finalRootSound = root.slice(-1);
const finalVowel = vowels.includes(finalRootSound); const finalVowel = vowels.includes(finalRootSound);
const instEnding = finalVowel ? 'ŕø' : 'ar'; const instEnding = finalVowel ? "ŕø" : "ar";
const relEnding = finalVowel ? 'źi' : 'ai'; const relEnding = finalVowel ? "źi" : "ai";
return { return {
abs: `${initial}${root}`, abs: `${initial}${root}`,