From 3724ae646cf4297fae2d077a3b8c83f54abfc86f Mon Sep 17 00:00:00 2001 From: Kalisa Date: Thu, 19 Oct 2023 11:36:39 +0200 Subject: [PATCH] lint fixes --- .../EditorPage/AudioEditor/AudioEditor.js | 2 +- .../EditorPage/AudioEditor/MainPlayer.js | 2 +- .../src/components/EditorPage/ObsEditor/core.js | 1 + renderer/src/components/Login/Signin.js | 2 -- renderer/src/components/Projects/NewWebProject.js | 1 - .../components/Projects/hooks/useEditProject.js | 1 - .../DownloadObsImages/checkandDownloadObsImages.js | 1 + .../ResourceUtils/DownloadCreateSBforHelps.js | 14 ++------------ renderer/src/components/Signup/WebSignup.js | 1 + .../src/components/Sync/Gitea/GiteaFileBrowser.js | 1 + renderer/src/components/hooks/useGetUserName.js | 1 + renderer/src/core/Login/handleJson.js | 4 ++++ renderer/src/core/editor/readFile.js | 1 + renderer/src/core/projects/fetchProjectsMeta.js | 2 ++ renderer/src/core/reference/readRefBurrito.js | 4 +--- renderer/src/core/reference/readRefMeta.js | 2 ++ renderer/src/layouts/editor/SubMenuBar.js | 6 +----- renderer/src/util/createObsContent.js | 7 ++----- 18 files changed, 22 insertions(+), 31 deletions(-) diff --git a/renderer/src/components/EditorPage/AudioEditor/AudioEditor.js b/renderer/src/components/EditorPage/AudioEditor/AudioEditor.js index 300e5cf97..3a1a6c27f 100644 --- a/renderer/src/components/EditorPage/AudioEditor/AudioEditor.js +++ b/renderer/src/components/EditorPage/AudioEditor/AudioEditor.js @@ -12,7 +12,7 @@ import { SnackBar } from '@/components/SnackBar'; import { useTranslation } from 'react-i18next'; import EmptyScreen from '@/components/Loading/EmptySrceen'; import LoadingScreen from '@/components/Loading/LoadingScreen'; -import { getDetails } from '../ObsEditor/ObsEditor'; +import { getDetails } from '../ObsEditor/utils/getDetails'; const grammar = require('usfm-grammar'); diff --git a/renderer/src/components/EditorPage/AudioEditor/MainPlayer.js b/renderer/src/components/EditorPage/AudioEditor/MainPlayer.js index 9b08f4e95..7a88d2fe3 100644 --- a/renderer/src/components/EditorPage/AudioEditor/MainPlayer.js +++ b/renderer/src/components/EditorPage/AudioEditor/MainPlayer.js @@ -6,7 +6,7 @@ import { } from 'react'; import { useReactMediaRecorder } from 'react-media-recorder'; import ConfirmationModal from '@/layouts/editor/ConfirmationModal'; -import { getDetails } from '../ObsEditor/ObsEditor'; +import { getDetails } from '../ObsEditor/utils/getDetails'; const MainPlayer = () => { const { diff --git a/renderer/src/components/EditorPage/ObsEditor/core.js b/renderer/src/components/EditorPage/ObsEditor/core.js index 4f7f79ce9..b132b4e80 100644 --- a/renderer/src/components/EditorPage/ObsEditor/core.js +++ b/renderer/src/components/EditorPage/ObsEditor/core.js @@ -54,6 +54,7 @@ export async function readBlobAsync(blob) { return content; // Do something with the content } catch (error) { + // eslint-disable-next-line no-console console.error('Error reading blob:', error); } } diff --git a/renderer/src/components/Login/Signin.js b/renderer/src/components/Login/Signin.js index b57623c75..78a665f2b 100644 --- a/renderer/src/components/Login/Signin.js +++ b/renderer/src/components/Login/Signin.js @@ -20,8 +20,6 @@ const SignIn = () => { }); if (data.session) { await localforage.setItem('userProfile', data); - const userData = await localforage.getItem('userProfile'); - console.log({ userData }); router.push('/projects'); setLoading(false); } else { diff --git a/renderer/src/components/Projects/NewWebProject.js b/renderer/src/components/Projects/NewWebProject.js index 1eaf2dc11..2a5d88649 100644 --- a/renderer/src/components/Projects/NewWebProject.js +++ b/renderer/src/components/Projects/NewWebProject.js @@ -226,7 +226,6 @@ export default function NewWebProject({ call, project, closeEdit }) { } if (create === true) { // Checking whether the burrito is of latest version - console.warn('NewProject.js', 'Checking whether the burrito is of latest version.'); if (call === 'edit' && burrito?.meta?.version !== metadata?.meta?.version) { setOpenModal(true); setLoading(false); diff --git a/renderer/src/components/Projects/hooks/useEditProject.js b/renderer/src/components/Projects/hooks/useEditProject.js index 4245698f9..c2bd4631e 100644 --- a/renderer/src/components/Projects/hooks/useEditProject.js +++ b/renderer/src/components/Projects/hooks/useEditProject.js @@ -51,7 +51,6 @@ const useEditProject = () => { }; const editProject = async (project, setCurrentProject, setCallEditProject) => { - console.log('editing this...', { project }); const metadata = await loadProjectData(project); setCurrentProject(metadata); setCallEditProject(true); diff --git a/renderer/src/components/Resources/DownloadObsImages/checkandDownloadObsImages.js b/renderer/src/components/Resources/DownloadObsImages/checkandDownloadObsImages.js index 39b9754af..d7e0b9123 100644 --- a/renderer/src/components/Resources/DownloadObsImages/checkandDownloadObsImages.js +++ b/renderer/src/components/Resources/DownloadObsImages/checkandDownloadObsImages.js @@ -39,6 +39,7 @@ async function downloadImageAndSaveSupabase(url) { throw error; } } catch (error) { + // eslint-disable-next-line no-console console.error('Error fetching image:', error); } } diff --git a/renderer/src/components/Resources/ResourceUtils/DownloadCreateSBforHelps.js b/renderer/src/components/Resources/ResourceUtils/DownloadCreateSBforHelps.js index 19a134490..1a91c426f 100644 --- a/renderer/src/components/Resources/ResourceUtils/DownloadCreateSBforHelps.js +++ b/renderer/src/components/Resources/ResourceUtils/DownloadCreateSBforHelps.js @@ -14,7 +14,6 @@ const JSZip = require('jszip'); const DownloadCreateSBforHelps = async (projectResource, setLoading, update = false, offlineResource = false) => { if (isElectron()) { try { - // console.log('download/update started --------', { projectResource, update, offlineResource }); logger.debug('DownloadCreateSBforHelps.js', 'Download Started'); setLoading(true); await localForage.getItem('userProfile').then(async (user) => { @@ -86,15 +85,12 @@ const DownloadCreateSBforHelps = async (projectResource, setLoading, update = fa await fetch(projectResource.metadata_json_url) .then((res) => res.json()) .then(async (data) => { - // console.log('json data : ', data); // adding offline true tag in meta for identification data.agOffline = true; data.meta = projectResource; data.lastUpdatedAg = moment().format(); - // console.log('json data after : ', data); await fs.writeFileSync(path.join(folder, projectResource?.name, 'metadata.json'), JSON.stringify(data)); }).catch((err) => { - // console.log('failed to save yml metadata.json : ', err); logger.debug('DownloadCreateSBforHelps.js', 'failed to save yml metadata.json : ', err); }); @@ -105,13 +101,11 @@ const DownloadCreateSBforHelps = async (projectResource, setLoading, update = fa fs.unlinkSync(path.join(folder, `${projectResource?.name}.zip`), (err) => { if (err) { logger.debug('DownloadCreateSBforHelps.js', 'error in deleting zip'); - // console.log(`Removing Resource Zip Failed : ${projectResource?.name}.zip`); throw new Error(`Removing Resource Zip Failed : ${projectResource?.name}.zip`); } }); if (update && update?.status) { // if updation delete old resource - // console.log({ projectOld: `${projectResource?.name}_${projectResource?.owner}_${update?.prevVersion}` }); try { fs.rmSync(path.join(folder, `${projectResource?.name}_${projectResource?.owner}_${update?.prevVersion}`), { recursive: true }); update && update?.setIsOpen(false); @@ -124,11 +118,8 @@ const DownloadCreateSBforHelps = async (projectResource, setLoading, update = fa } }); logger.debug('DownloadCreateSBforHelps.js', 'download completed'); - // console.log('download finished --------'); setLoading(false); - // resolve(json); }); - // }); } catch (err) { setLoading(false); throw err; @@ -158,7 +149,7 @@ const DownloadCreateSBforHelps = async (projectResource, setLoading, update = fa // extract zip const { data: filecontent, error: fileContentError } = await sbStorageDownload(`${folder}/${projectResource?.name}.zip}`); if (fileContentError) { - // eslint-disable-next-line no-console + // eslint-disable-next-line no-console console.log('Failed to download zip file', fileContentError); } @@ -181,7 +172,7 @@ const DownloadCreateSBforHelps = async (projectResource, setLoading, update = fa data.lastUpdatedAg = moment().format(); await createDirectory({ path: `${folder}/${projectResource?.name}/metadata.json`, payload: JSON.stringify(data) }); }).catch((err) => { - // eslint-disable-next-line no-console + // eslint-disable-next-line no-console console.log('DownloadCreateSBforHelps.js', 'failed to save yml metadata.json : ', err); }); @@ -189,7 +180,6 @@ const DownloadCreateSBforHelps = async (projectResource, setLoading, update = fa if (folderExist) { if (update && update?.status) { // if updation delete old resource - console.log({ projectOld: `${projectResource?.name}_${projectResource?.owner}_${update?.prevVersion}` }); try { sbStorageRemove(`folder/${projectResource?.name}_${projectResource?.owner}_${update?.prevVersion}`); update && update?.setIsOpen(false); diff --git a/renderer/src/components/Signup/WebSignup.js b/renderer/src/components/Signup/WebSignup.js index 40f7058ce..b28351ff7 100644 --- a/renderer/src/components/Signup/WebSignup.js +++ b/renderer/src/components/Signup/WebSignup.js @@ -25,6 +25,7 @@ function SignupPage() { createWebUser(data.user); router.push('/login'); } else { + // eslint-disable-next-line no-console console.error('error occured', error); setStatus(error); } diff --git a/renderer/src/components/Sync/Gitea/GiteaFileBrowser.js b/renderer/src/components/Sync/Gitea/GiteaFileBrowser.js index 00dbe7efd..5463b3d06 100644 --- a/renderer/src/components/Sync/Gitea/GiteaFileBrowser.js +++ b/renderer/src/components/Sync/Gitea/GiteaFileBrowser.js @@ -89,6 +89,7 @@ const GiteaFileBrowser = ({ changeRepo }) => { // regex is for old sync // const regex = /.+\/\d{4}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01]).1$/; let finalBranches = []; + // eslint-disable-next-line no-console console.log('chedk : ', fetchBranches.some((branch) => branch.name === 'scribe-main')); if (fetchBranches.some((branch) => branch.name === 'scribe-main')) { finalBranches.push({ name: 'scribe-main' }); diff --git a/renderer/src/components/hooks/useGetUserName.js b/renderer/src/components/hooks/useGetUserName.js index e29368600..76916d1b0 100644 --- a/renderer/src/components/hooks/useGetUserName.js +++ b/renderer/src/components/hooks/useGetUserName.js @@ -17,6 +17,7 @@ export const useGetUserName = () => { } else if (!IsElectron) { const { data: { session }, error } = await supabase.auth.getSession(); if (error) { + // eslint-disable-next-line no-console console.error(error); } if (session) { diff --git a/renderer/src/core/Login/handleJson.js b/renderer/src/core/Login/handleJson.js index 3398c443d..4eda99dd7 100644 --- a/renderer/src/core/Login/handleJson.js +++ b/renderer/src/core/Login/handleJson.js @@ -120,6 +120,7 @@ export const handleJsonWeb = async (values) => { error = { userExist: false, fetchFile: false }; if (await supabaseStorage().list().then((result) => result.error)) { + // eslint-disable-next-line no-console console.error('handleJson.js', 'Failed to access the storage'); error.fetchFile = true; return error; @@ -137,6 +138,7 @@ export const handleJsonWeb = async (values) => { // Add new user to localForage: localForage.setItem('users', array, (err) => { if (err) { + // eslint-disable-next-line no-console console.error('handleJson.js', 'Failed to Create a file and add user to LocalForage'); } }); @@ -170,11 +172,13 @@ export const handleJsonWeb = async (values) => { // Add new user to localForage: localForage.setItem('users', json, (errLoc) => { if (errLoc) { + // eslint-disable-next-line no-console console.error('handleJson.js', 'Failed to add new user to existing list'); } }); return error; } catch (errCatch) { + // eslint-disable-next-line no-console console.error('handleJson.js', 'Failed to add new user to the file'); return error; } diff --git a/renderer/src/core/editor/readFile.js b/renderer/src/core/editor/readFile.js index 9d5a7f9c8..1c5b8a6a3 100644 --- a/renderer/src/core/editor/readFile.js +++ b/renderer/src/core/editor/readFile.js @@ -31,6 +31,7 @@ export const readFile = async ({ return new Promise(async (resolve) => { const { data: fileContent, error } = await sbStorageDownload(projectsPath); if (error) { + // eslint-disable-next-line no-console console.error('readWebFile function error', error); } const parsedData = readBlobAsync(fileContent); diff --git a/renderer/src/core/projects/fetchProjectsMeta.js b/renderer/src/core/projects/fetchProjectsMeta.js index 02b120c73..956b800be 100644 --- a/renderer/src/core/projects/fetchProjectsMeta.js +++ b/renderer/src/core/projects/fetchProjectsMeta.js @@ -60,6 +60,7 @@ const fetchProjectsMeta = async ({ currentUser }) => { const { data, error } = await sbStorageDownload(`${path}/${projectName}/metadata.json`); if (error) { + // eslint-disable-next-line no-console console.error('fetchProjectsMeta.js', error); return null; } @@ -73,6 +74,7 @@ const fetchProjectsMeta = async ({ currentUser }) => { if (settingData) { setting = JSON.parse(await settingData.text()); } else { + // eslint-disable-next-line no-console console.error('ProjectList.js', 'Unable to find scribe-settings for the project'); } } diff --git a/renderer/src/core/reference/readRefBurrito.js b/renderer/src/core/reference/readRefBurrito.js index 3fa9c5fd4..410f6be09 100644 --- a/renderer/src/core/reference/readRefBurrito.js +++ b/renderer/src/core/reference/readRefBurrito.js @@ -2,9 +2,6 @@ import { isElectron } from '@/core/handleElectron'; import { sbStorageDownload } from '../../../../supabase'; import * as logger from '../../logger'; -// if (!process.env.NEXT_PUBLIC_IS_ELECTRON) { -// const supabaseStorage = require('../../../../supabase').supabaseStorage -// } export const readRefBurrito = async ({ metaPath, @@ -27,6 +24,7 @@ export const readRefBurrito = async ({ return new Promise(async (resolve) => { const { data: files, error } = await sbStorageDownload(metaPath); if (error) { + // eslint-disable-next-line no-console console.error('Error fetching files:', error); return; } diff --git a/renderer/src/core/reference/readRefMeta.js b/renderer/src/core/reference/readRefMeta.js index 73d246202..c7e44f61f 100644 --- a/renderer/src/core/reference/readRefMeta.js +++ b/renderer/src/core/reference/readRefMeta.js @@ -28,12 +28,14 @@ export const readRefMeta = async ({ try { const { data: files, error } = await sbStorageList(`${projectsDir}`); if (error) { + // eslint-disable-next-line no-console console.error('Error fetching files:', error); return []; } const directoryNames = files.map((file) => file.name); return directoryNames; } catch (error) { + // eslint-disable-next-line no-console console.error('Error reading reference metadata:', error); return []; } diff --git a/renderer/src/layouts/editor/SubMenuBar.js b/renderer/src/layouts/editor/SubMenuBar.js index 53f7181b3..a11d95a51 100644 --- a/renderer/src/layouts/editor/SubMenuBar.js +++ b/renderer/src/layouts/editor/SubMenuBar.js @@ -16,11 +16,6 @@ import MenuDropdown from '../../components/MenuDropdown/MenuDropdown'; import menuStyles from './MenuBar.module.css'; import packageInfo from '../../../../package.json'; import { newPath, sbStorageDownload } from '../../../../supabase'; -// if (!process.env.NEXT_PUBLIC_IS_ELECTRON) { -// const supabaseStorage = require('../../../../../supabase').supabaseStorage -// const newPath = require('../../../../supabase').newPath -// } -// import WifiIcon from '@/icons/wifi.svg'; const activate = () => { // console.log('rename'); @@ -107,6 +102,7 @@ export default function SubMenuBar() { const email = userProfile.user.email; const { data, error } = await sbStorageDownload(`${newPath}/${email}/projects/${projectName}/metadata.json`); if (error) { + // eslint-disable-next-line no-console console.log('SubMenuBar.js', error); } const metadata = JSON.parse(await data.text()); diff --git a/renderer/src/util/createObsContent.js b/renderer/src/util/createObsContent.js index 4f5492e64..909faf526 100644 --- a/renderer/src/util/createObsContent.js +++ b/renderer/src/util/createObsContent.js @@ -226,10 +226,7 @@ export const createObsContent = ( importedFiles, copyright, call, - ) => { - console.log('createObsContent.js', 'In OBS md content creation'); - - return new Promise(async (resolve) => { + ) => new Promise(async (resolve) => { const ingredients = {}; const supabasePath = `${newPath}/${username}/projects/${project.projectName}_${id}/ingredients`; @@ -239,6 +236,7 @@ export const createObsContent = ( }); if (error) { + // eslint-disable-next-line no-console console.error('Error uploading file to Supabase:', error); throw error; } else { @@ -384,4 +382,3 @@ export const createObsContent = ( }; resolve(ingredients); }); - };