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",
"@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
"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 {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 = (
<div className="searchResultHeader" key="header">
Searched for <b>{ props.searchTerm }</b>, { searchType }, found { num } { result }
@ -120,28 +120,28 @@ const Results = (props: ResultsProps) => {
const results = props.searchResults;
return (
<div className="results">
{ results ? content() : 'No search' }
{ results ? content() : "No search" }
</div>
);
};
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);

View File

@ -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 (
<div className="searchResult" key={ entry.id }>
<b>{ entry.sai }</b> - { entry.eng }
@ -23,10 +23,10 @@ const SaiEntry = (props: {entry: SaiEntryProps}) => {
function formatMorphology(entry) {
const decl = declineSaimiar(entry);
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>,
Adp: <i>{decl.adp}</i>,
All: <i>{decl.all}</i>,
@ -45,7 +45,7 @@ const JutEntry = (props: {entry: JutEntryProps}) => {
<b>{ entry.jut }</b> - { entry.eng }
<br/>
<span className="synclass">
{ entry.syn_category === 'noun' ? entry.gender : null }
{ entry.syn_category === "noun" ? entry.gender : null }
</span>
</div>);
};

View File

@ -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}`,