From 3a4ba4bdac2e774ee9e6f4e368c6e01d327be007 Mon Sep 17 00:00:00 2001 From: Dan Date: Fri, 14 Jun 2024 13:16:10 +0200 Subject: [PATCH] lint fix (#348) * - added a Juxta mode that creates a translation burrito - added a 'factoryCreateContent.js' file to help factorize some code for 'createObsContent', 'createVersificationUSFM' and 'createAudioVersification' in 'saveProjetcsMeta.js' - fixing some typos, fixing lint * Refactorization of 'saveProjectsMeta.js' * Scripture Burrito as a resource : added the poissibility for the user to search and download a SB as a resource in a module * removed checkbox from the UI and query sb resource everytime * Added a juxtalinear editor along with a new mode. - auto load a book on the opening of a project - auto save after a modification - fixed a bit of typos and code * created a juxtaBurrito creator and a function to add juxta content. Also edited the icon for Juxta mode (it's visible now) you can create a new juxta project * ADDED juxta support for SB creation and fixed some typos * ADDED support for usfm import for a juxta project. Now we have to change the way a juxta json is built. * juxtalineat mode functionnal * UPDATE : now the interface handle corectly a json juxta file and update it if needed. and layout color update * function to update a json juxta file if needed * checksums ok for each modifications of the juxta * bugfix : juxta was still using a translation settings * quick fix * added new kewboard shortcuts : 'Tab' to navigate through line chuncks, 'double click' to modify a chunck, 'enter' to end the modification of a chunck. And added seemless navigation between Juxtalinear editor and the BibleEditorX. Navigating through verses and chapters with the menu bar will load the corresponding sentence and vice versa. * removing a useless 'console.log' * FIXED font size when aditing a chunck, ADDED a bit of css and added a skip for the liter for .ts files * I put the sentences loading one layer outside the main editor, to avoid the editor to re-render everytime the juxtalinear editor module * Many bugfixes https://github.com/bible-technology/scribe-scripture-editor/pull/303#issuecomment-2034384825 * add a check if the folder exists * added a little bit of secure code for OBS loading * changed the behavior of the Snackbar. If error === 'failure' the snackbar will show up for a longer time * changed the behavior of the Snackbar. If error === 'failure' the snackbar will show up for a longer time * bold text 'CREATE PROJECT' for better visibility and start to check 'canonSpecification' for a juxta project * added the feature that download resources not imported by the user for juxtalinear project * Now the user is correctly notified when the imported books does not match the canon specification, and also, the canon specification automatically matches the file imported * minor bugfixes and code cleaning * changed place of the 'nprogress' by few px * added a better user-friendly messages to nugde the user to import at least one resource for a Juxtalinear project * FIXED : archive a Text Translation project OK. * star/unstar a juxtalinear project works now * FIX : bug that prevented some resources to show up. and FIX : bug that was throwing an error when a user where to search for a resource in the resource search field, and click on 'no match found' * deleted package-lock.json and updated yarn.lock * updated french translation * bugfix : you can now edit a juxta project properly * fixed bug where on book change, the sentences where wronly saved under another filename * make 'jsonFileContent.bookCode' to upper case for safety reasons * FIX : export/import now works properly for juxtalinear projects * fix obs auto zipping on export * spinner and 'create project' button css fix. * 'create project' button reverted * fixed most of the lint errors. It leaves the 'control label errors' and one nested ternary operation here : 'renderer/src/components/EditorPage/Reference/OBS/ObsTn.js' line 147 * lint fixes until 'labels missing' * removed useless file * removed a comment --------- Co-authored-by: danielc-n --- .eslintrc.json | 82 +++++++-- .../AudioRecorder/components/EditorPage.js | 1 + .../EditorPage/JuxtaTextEditor/Editor.jsx | 62 +++---- .../JuxtaTextEditor/EditorMenuBar.jsx | 2 +- .../EditorPage/Navigation/CustomNavigation.js | 2 + .../Navigation/reference/SelectBook.js | 6 +- .../EditorPage/Reference/MultiComboBox.js | 1 + .../EditorPage/Reference/OBS/ObsTn.js | 15 +- .../EditorPage/Reference/TranslationHelps.js | 1 - .../EditorPage/TextEditor/EditorMenuBar.jsx | 1 + .../src/components/ImageSlider/SliderItem.jsx | 3 +- renderer/src/components/Login/LeftLogin.js | 3 + .../src/components/Projects/ImportPopUp.js | 12 +- .../src/components/Projects/NewProject.js | 24 +-- .../Projects/utils/importGreekFromDoor43.js | 171 ------------------ .../CreateProject/AdvancedSettingsDropdown.js | 1 + .../src/components/Resources/ListResources.js | 4 + .../createDownloadedResourceSB.js | 4 +- .../src/core/projects/saveProjetcsMeta.js | 2 +- .../src/layouts/editor/ConfirmationModal.js | 20 +- .../modules/editorsidebar/EditorSideBar.js | 1 + 21 files changed, 150 insertions(+), 268 deletions(-) delete mode 100644 renderer/src/components/Projects/utils/importGreekFromDoor43.js diff --git a/.eslintrc.json b/.eslintrc.json index 673289bed..00816a9f4 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -18,9 +18,19 @@ "no-underscore-dangle": "off", "no-unused-expressions": "off", "max-len": "off", - "no-plusplus": ["error", { "allowForLoopAfterthoughts": true }], + "no-plusplus": [ + "error", + { + "allowForLoopAfterthoughts": true + } + ], "prefer-destructuring": "off", - "no-param-reassign": [2, { "props": false }], + "no-param-reassign": [ + 2, + { + "props": false + } + ], "camelcase": "off", "consistent-return": "off", "react/function-component-definition": [ @@ -31,13 +41,19 @@ "function-expression", "arrow-function" ], - "unnamedComponents": ["function-expression", "arrow-function"] + "unnamedComponents": [ + "function-expression", + "arrow-function" + ] } ], "react/jsx-filename-extension": [ 1, { - "extensions": [".js", ".jsx"] + "extensions": [ + ".js", + ".jsx" + ] } ], "react/jsx-no-bind": [ @@ -60,14 +76,23 @@ "react/forbid-prop-types": "off", "linebreak-style": 0, "global-require": 0, - "eslint linebreak-style": [0, "error", "windows"], + "eslint linebreak-style": [ + 0, + "error", + "windows" + ], "import/no-unresolved": [ "error", { - "ignore": [".svg"] + "ignore": [ + ".svg" + ] } ], - "curly": ["error", "all"], + "curly": [ + "error", + "all" + ], "template-curly-spacing": "off", "indent": "off" }, @@ -92,18 +117,43 @@ "import/resolver": { "alias": { "map": [ - ["@/components", "./renderer/src/components/"], - ["@/layouts", "./renderer/src/layouts/"], - ["@/modules", "./renderer/src/modules/"], - ["@/util", "./renderer/src/util/"], - ["@/core", "./renderer/src/core/"], - ["@/hooks", "./renderer/src/hooks/"] + [ + "@/components", + "./renderer/src/components/" + ], + [ + "@/layouts", + "./renderer/src/layouts/" + ], + [ + "@/modules", + "./renderer/src/modules/" + ], + [ + "@/util", + "./renderer/src/util/" + ], + [ + "@/core", + "./renderer/src/core/" + ], + [ + "@/hooks", + "./renderer/src/hooks/" + ] ], "node": { - "extensions": [".js", ".jsx", ".ts", ".tsx"] + "extensions": [ + ".js", + ".jsx", + ".ts", + ".tsx" + ] } } } }, - "plugins": ["react"] -} + "plugins": [ + "react" + ] +} \ No newline at end of file diff --git a/renderer/src/components/AudioRecorder/components/EditorPage.js b/renderer/src/components/AudioRecorder/components/EditorPage.js index 78990ef1b..e40e6f644 100644 --- a/renderer/src/components/AudioRecorder/components/EditorPage.js +++ b/renderer/src/components/AudioRecorder/components/EditorPage.js @@ -31,6 +31,7 @@ const EditorPage = ({ && (
{ const newSentences = [...sentences]; newSentences[index] = sentence; setGlobalTotalSentences(newSentences); - } + }; useEffect(() => { setBookChange(false); @@ -129,21 +128,21 @@ export default function Editor(props) { } return { ...src, index: counts[src.content] }; }); - currentCs = md5(normalizeString(JSON.stringify(source) + chunk.gloss)) + ''; + currentCs = `${md5(normalizeString(JSON.stringify(source) + chunk.gloss))}`; checksumChuncks += currentCs; return { source, gloss: chunk.gloss, - checksum: currentCs + checksum: currentCs, }; }); - currentCs = md5(checksumChuncks) + ''; + currentCs = `${md5(checksumChuncks)}`; checksumSentences += currentCs; return { originalSource: stc.originalSource, chunks, sourceString: stc.sourceString, - checksum: checksumSentences + checksum: checksumSentences, }; }); }; @@ -167,25 +166,24 @@ export default function Editor(props) { }; }) .filter(({ chunk }) => chunk.length); - } else { - return sentences[curIndex].chunks - .map(({ source, gloss, checksum }, index) => { - return { - chunk: source - .filter((s) => s) - .map((s, n) => { - return { - id: `item-${index * 1000 + n}`, - content: s.content, - index: s.index - }; - }), - gloss, - checksum, - }; - }) - .filter(({ chunk }) => chunk.length); } + return sentences[curIndex].chunks + .map(({ source, gloss, checksum }, index) => { + return { + chunk: source + .filter((s) => s) + .map((s, n) => { + return { + id: `item-${index * 1000 + n}`, + content: s.content, + index: s.index, + }; + }), + gloss, + checksum, + }; + }) + .filter(({ chunk }) => chunk.length); }; const tryLoadSentences = () => { @@ -201,7 +199,7 @@ export default function Editor(props) { } } setLoadingSentencesInProgress(false); - } + }; useEffect(() => { setLoadingSentencesInProgress(true); diff --git a/renderer/src/components/EditorPage/JuxtaTextEditor/EditorMenuBar.jsx b/renderer/src/components/EditorPage/JuxtaTextEditor/EditorMenuBar.jsx index 02af1c37d..ed0045880 100644 --- a/renderer/src/components/EditorPage/JuxtaTextEditor/EditorMenuBar.jsx +++ b/renderer/src/components/EditorPage/JuxtaTextEditor/EditorMenuBar.jsx @@ -2,7 +2,7 @@ import React, { useContext } from 'react'; import { ProjectContext } from '@/components/context/ProjectContext'; // import MenuDropdown from '@/components/MenuDropdown/MenuDropdown'; -import { LockClosedIcon, BookmarkIcon, LockOpenIcon } from '@heroicons/react/24/outline'; +import { LockClosedIcon, LockOpenIcon } from '@heroicons/react/24/outline'; // import BibleNavigationX from '@/components/EditorPage/JuxtaTextEditor/BibleNavigationX'; import BibleNavigationX from './BibleNavigationX'; // import Buttons from './Buttons'; diff --git a/renderer/src/components/EditorPage/Navigation/CustomNavigation.js b/renderer/src/components/EditorPage/Navigation/CustomNavigation.js index b79123d0d..b01c29517 100644 --- a/renderer/src/components/EditorPage/Navigation/CustomNavigation.js +++ b/renderer/src/components/EditorPage/Navigation/CustomNavigation.js @@ -112,6 +112,7 @@ export default function CustomNavigation({ onClick={openBooks} role="button" tabIndex="-2" + aria-label="open books" >