From e62e18521431d87d7bbf7c66327485173f3d06bb Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Tue, 21 May 2024 17:32:17 -0400 Subject: [PATCH] Lint a bunch of things --- .../notificationPopup/notificationPopup.jsx | 4 +- .../homebrew/editor/snippetbar/snippetbar.jsx | 4 +- client/homebrew/navbar/error-navitem.jsx | 10 +- client/homebrew/navbar/newbrew.navitem.jsx | 94 +++++++++---------- .../pages/basePages/listPage/listPage.jsx | 4 +- .../pages/errorPage/errors/errorIndex.js | 2 +- client/homebrew/pages/printPage/printPage.jsx | 10 +- client/homebrew/pages/sharePage/sharePage.jsx | 2 +- server.js | 2 +- server/admin.api.js | 2 +- server/app.js | 2 +- server/homebrew.api.js | 4 +- shared/helpers.js | 30 +++--- themes/V3/5ePHB/snippets/quote.gen.js | 68 +++++++------- .../V3/5ePHB/snippets/tableOfContents.gen.js | 2 +- themes/V3/Blank/snippets.js | 70 +++++++------- 16 files changed, 155 insertions(+), 155 deletions(-) diff --git a/client/homebrew/brewRenderer/notificationPopup/notificationPopup.jsx b/client/homebrew/brewRenderer/notificationPopup/notificationPopup.jsx index 1a38ef8ad..6872d6c3e 100644 --- a/client/homebrew/brewRenderer/notificationPopup/notificationPopup.jsx +++ b/client/homebrew/brewRenderer/notificationPopup/notificationPopup.jsx @@ -25,8 +25,8 @@ const NotificationPopup = createClass({ <>
  • Don't store IMAGES in Google Drive
    - Google Drive is not an image service, and will block images from being used - in brews if they get more views than expected. Google has confirmed they won't fix + Google Drive is not an image service, and will block images from being used + in brews if they get more views than expected. Google has confirmed they won't fix this, so we recommend you look for another image hosting service such as imgur, ImgBB or Google Photos.
  • diff --git a/client/homebrew/editor/snippetbar/snippetbar.jsx b/client/homebrew/editor/snippetbar/snippetbar.jsx index 75fe0d736..80a97f49e 100644 --- a/client/homebrew/editor/snippetbar/snippetbar.jsx +++ b/client/homebrew/editor/snippetbar/snippetbar.jsx @@ -161,7 +161,7 @@ const Snippetbar = createClass({ onClick={this.props.unfoldCode} > - + ; } @@ -181,7 +181,7 @@ const Snippetbar = createClass({ {this.state.themeSelector && this.renderThemeSelector()} - +
    this.props.onViewChange('text')}> diff --git a/client/homebrew/navbar/error-navitem.jsx b/client/homebrew/navbar/error-navitem.jsx index 8551408c5..59e05a253 100644 --- a/client/homebrew/navbar/error-navitem.jsx +++ b/client/homebrew/navbar/error-navitem.jsx @@ -42,7 +42,7 @@ const ErrorNavItem = createClass({
    ; } - + if(status === 412) { return Oops! @@ -51,7 +51,7 @@ const ErrorNavItem = createClass({ ; } - + if(HBErrorCode === '04') { return Oops! @@ -76,10 +76,10 @@ const ErrorNavItem = createClass({ if(response.body?.errors?.[0].reason == 'storageQuotaExceeded') { return Oops! -
    +
    Can't save because your Google Drive seems to be full! -
    - ; +
    +
    ; } if(response.req.url.match(/^\/api.*Google.*$/m)){ diff --git a/client/homebrew/navbar/newbrew.navitem.jsx b/client/homebrew/navbar/newbrew.navitem.jsx index 319ef3392..30d53c675 100644 --- a/client/homebrew/navbar/newbrew.navitem.jsx +++ b/client/homebrew/navbar/newbrew.navitem.jsx @@ -7,58 +7,58 @@ const BREWKEY = 'homebrewery-new'; const STYLEKEY = 'homebrewery-new-style'; const METAKEY = 'homebrewery-new-meta'; -const NewBrew = () => { - const handleFileChange = (e) => { - const file = e.target.files[0]; - if (file) { - const reader = new FileReader(); - reader.onload = (e) => { - const fileContent = e.target.result; - const newBrew = { - text: fileContent, - style: '' - }; - if(fileContent.startsWith('```metadata')) { - splitTextStyleAndMetadata(newBrew); // Modify newBrew directly - localStorage.setItem(BREWKEY, newBrew.text); - localStorage.setItem(STYLEKEY, newBrew.style); - localStorage.setItem(METAKEY, JSON.stringify(_.pick(newBrew, ['title', 'description', 'tags', 'systems', 'renderer', 'theme', 'lang']))); - window.location.href = '/new'; - } else { - alert('This file is invalid, please, enter a valid file'); - } - }; - reader.readAsText(file); - } - }; +const NewBrew = ()=>{ + const handleFileChange = (e)=>{ + const file = e.target.files[0]; + if(file) { + const reader = new FileReader(); + reader.onload = (e)=>{ + const fileContent = e.target.result; + const newBrew = { + text : fileContent, + style : '' + }; + if(fileContent.startsWith('```metadata')) { + splitTextStyleAndMetadata(newBrew); // Modify newBrew directly + localStorage.setItem(BREWKEY, newBrew.text); + localStorage.setItem(STYLEKEY, newBrew.style); + localStorage.setItem(METAKEY, JSON.stringify(_.pick(newBrew, ['title', 'description', 'tags', 'systems', 'renderer', 'theme', 'lang']))); + window.location.href = '/new'; + } else { + alert('This file is invalid, please, enter a valid file'); + } + }; + reader.readAsText(file); + } + }; - return ( - - + return ( + + new - - + + from blank - + - { document.getElementById('uploadTxt').click(); }}> - + { document.getElementById('uploadTxt').click(); }}> + from file - - - ); +
    + + ); }; module.exports = NewBrew; diff --git a/client/homebrew/pages/basePages/listPage/listPage.jsx b/client/homebrew/pages/basePages/listPage/listPage.jsx index 0b51609b5..ec557ffb1 100644 --- a/client/homebrew/pages/basePages/listPage/listPage.jsx +++ b/client/homebrew/pages/basePages/listPage/listPage.jsx @@ -262,8 +262,8 @@ const ListPage = createClass({ render : function(){ return
    {/**/} - - + + {this.props.navItems} {this.renderSortOptions()} {this.renderTagsOptions()} diff --git a/client/homebrew/pages/errorPage/errors/errorIndex.js b/client/homebrew/pages/errorPage/errors/errorIndex.js index f9d52c109..7fa24dddc 100644 --- a/client/homebrew/pages/errorPage/errors/errorIndex.js +++ b/client/homebrew/pages/errorPage/errors/errorIndex.js @@ -95,7 +95,7 @@ const errorIndex = (props)=>{ **Current Authors:** ${props.brew.authors?.map((author)=>{return `[${author}](/user/${author})`;}).join(', ') || 'Unable to list authors'} [Click here to be redirected to the brew's share page.](/share/${props.brew.shareId})`, - + // Brew load error '05' : dedent` diff --git a/client/homebrew/pages/printPage/printPage.jsx b/client/homebrew/pages/printPage/printPage.jsx index cde66ad7d..5f512660c 100644 --- a/client/homebrew/pages/printPage/printPage.jsx +++ b/client/homebrew/pages/printPage/printPage.jsx @@ -33,7 +33,7 @@ const PrintPage = createClass({ style : this.props.brew.style || undefined, renderer : this.props.brew.renderer || 'legacy', theme : this.props.brew.theme || '5ePHB', - lang : this.props.brew.lang || 'en' + lang : this.props.brew.lang || 'en' } }; }, @@ -51,7 +51,7 @@ const PrintPage = createClass({ style : styleStorage, renderer : metaStorage?.renderer || 'legacy', theme : metaStorage?.theme || '5ePHB', - lang : metaStorage?.lang || 'en' + lang : metaStorage?.lang || 'en' } }; }); @@ -95,11 +95,11 @@ const PrintPage = createClass({ return
    - + {baseThemePath && - + } - + {/* Apply CSS from Style tab */} {this.renderStyle()}
    diff --git a/client/homebrew/pages/sharePage/sharePage.jsx b/client/homebrew/pages/sharePage/sharePage.jsx index deb476c2e..2eab5f34a 100644 --- a/client/homebrew/pages/sharePage/sharePage.jsx +++ b/client/homebrew/pages/sharePage/sharePage.jsx @@ -57,7 +57,7 @@ const SharePage = createClass({ return edit - ; + ; }, render : function(){ diff --git a/server.js b/server.js index 39224bb88..6cbe07c4f 100644 --- a/server.js +++ b/server.js @@ -14,7 +14,7 @@ DB.connect(config).then(()=>{ console.log(`\n\tserver started at: ${new Date().toLocaleString()}`); console.log(`\tserver on port: ${PORT}`); - console.log(`\t${bright + cyan}Open in browser: ${reset}${underline + bright + cyan}http://localhost:${PORT}${reset}\n\n`) + console.log(`\t${bright + cyan}Open in browser: ${reset}${underline + bright + cyan}http://localhost:${PORT}${reset}\n\n`); }); }); diff --git a/server/admin.api.js b/server/admin.api.js index 5363ecc08..fe2def3ce 100644 --- a/server/admin.api.js +++ b/server/admin.api.js @@ -30,7 +30,7 @@ const junkBrewPipeline = [ { $match : { updatedAt : { $lt: Moment().subtract(30, 'days').toDate() }, lastViewed : { $lt: Moment().subtract(30, 'days').toDate() } - }}, + } }, { $project: { textBinSize: { $binarySize: '$textBin' } } }, { $match: { textBinSize: { $lt: 140 } } }, { $limit: 100 } diff --git a/server/app.js b/server/app.js index e04df77a6..a08ab4404 100644 --- a/server/app.js +++ b/server/app.js @@ -25,7 +25,7 @@ const sanitizeBrew = (brew, accessType)=>{ brew.__v = undefined; if(accessType !== 'edit' && accessType !== 'shareAuthor') { brew.editId = undefined; - } + } return brew; }; diff --git a/server/homebrew.api.js b/server/homebrew.api.js index e73a704a8..ae1abf787 100644 --- a/server/homebrew.api.js +++ b/server/homebrew.api.js @@ -83,9 +83,9 @@ const api = { if(accessType === 'edit' && (authorsExist && !(isAuthor || isInvited))) { const accessError = { name: 'Access Error', status: 401 }; if(req.account){ - throw { ...accessError, message: 'User is not an Author', HBErrorCode: '03', authors: stub.authors, brewTitle: stub.title, shareId: stub.shareId}; + throw { ...accessError, message: 'User is not an Author', HBErrorCode: '03', authors: stub.authors, brewTitle: stub.title, shareId: stub.shareId }; } - throw { ...accessError, message: 'User is not logged in', HBErrorCode: '04', authors: stub.authors, brewTitle: stub.title, shareId: stub.shareId}; + throw { ...accessError, message: 'User is not logged in', HBErrorCode: '04', authors: stub.authors, brewTitle: stub.title, shareId: stub.shareId }; } // If after all of that we still don't have a brew, throw an exception diff --git a/shared/helpers.js b/shared/helpers.js index 5abb93fea..42dd09e3f 100644 --- a/shared/helpers.js +++ b/shared/helpers.js @@ -1,22 +1,22 @@ const _ = require('lodash'); const yaml = require('js-yaml'); -const splitTextStyleAndMetadata = (brew) => { - brew.text = brew.text.replaceAll('\r\n', '\n'); - if (brew.text.startsWith('```metadata')) { - const index = brew.text.indexOf('```\n\n'); - const metadataSection = brew.text.slice(12, index - 1); - const metadata = yaml.load(metadataSection); - Object.assign(brew, _.pick(metadata, ['title', 'description', 'tags', 'systems', 'renderer', 'theme', 'lang'])); - brew.text = brew.text.slice(index + 5); - } - if (brew.text.startsWith('```css')) { - const index = brew.text.indexOf('```\n\n'); - brew.style = brew.text.slice(7, index - 1); - brew.text = brew.text.slice(index + 5); - } +const splitTextStyleAndMetadata = (brew)=>{ + brew.text = brew.text.replaceAll('\r\n', '\n'); + if(brew.text.startsWith('```metadata')) { + const index = brew.text.indexOf('```\n\n'); + const metadataSection = brew.text.slice(12, index - 1); + const metadata = yaml.load(metadataSection); + Object.assign(brew, _.pick(metadata, ['title', 'description', 'tags', 'systems', 'renderer', 'theme', 'lang'])); + brew.text = brew.text.slice(index + 5); + } + if(brew.text.startsWith('```css')) { + const index = brew.text.indexOf('```\n\n'); + brew.style = brew.text.slice(7, index - 1); + brew.text = brew.text.slice(index + 5); + } }; module.exports = { - splitTextStyleAndMetadata + splitTextStyleAndMetadata }; diff --git a/themes/V3/5ePHB/snippets/quote.gen.js b/themes/V3/5ePHB/snippets/quote.gen.js index c5e3d6293..c2a233255 100644 --- a/themes/V3/5ePHB/snippets/quote.gen.js +++ b/themes/V3/5ePHB/snippets/quote.gen.js @@ -1,47 +1,47 @@ -const _ = require("lodash"); +const _ = require('lodash'); const quotes = [ - "The sword glinted in the dim light, its edges keen and deadly. As the adventurer reached for it, he couldn't help but feel a surge of excitement mixed with fear. This was no ordinary blade.", - "The dragon's roar shook the ground beneath their feet, and the brave knight stood tall, his sword at the ready. He knew that this would be the battle of his life, but he was determined to emerge victorious.", - "The wizard's laboratory was a sight to behold, filled with bubbling cauldrons, ancient tomes, and strange artifacts from distant lands. As the apprentice gazed around in wonder, she knew that she was about to embark on a journey unlike any other.", - "The tavern was packed with rowdy patrons, their voices raised in song and laughter. The bard took center stage, strumming his lute and launching into a tale of adventure and heroism that had the crowd hanging on his every word.", - "The thief crept through the shadows, his eyes scanning the room for any sign of danger. He knew that one false move could mean the difference between success and failure, and he was determined to come out on top.", - "The elf queen stood atop her castle walls, surveying the kingdom below with a mix of pride and sadness. She knew that the coming war would be brutal, but she was determined to protect her people at all costs.", - "The necromancer's tower loomed in the distance, its dark spires piercing the sky. As the adventurers approached, they could feel the chill of death emanating from within", - "The ranger moved through the forest like a shadow, his senses attuned to every sound and movement around him. He knew that danger lurked behind every tree, but he was ready for whatever came his way.", - "The paladin knelt before the altar, his hands clasped in prayer. He knew that his faith would be tested in the days ahead, but he was ready to face whatever trials lay in store for him.", - "The druid communed with the spirits of nature, his mind merging with the trees, the animals, and the very earth itself. He knew that his power came with a great responsibility, and he was determined to use it for the greater good.", + 'The sword glinted in the dim light, its edges keen and deadly. As the adventurer reached for it, he couldn\'t help but feel a surge of excitement mixed with fear. This was no ordinary blade.', + 'The dragon\'s roar shook the ground beneath their feet, and the brave knight stood tall, his sword at the ready. He knew that this would be the battle of his life, but he was determined to emerge victorious.', + 'The wizard\'s laboratory was a sight to behold, filled with bubbling cauldrons, ancient tomes, and strange artifacts from distant lands. As the apprentice gazed around in wonder, she knew that she was about to embark on a journey unlike any other.', + 'The tavern was packed with rowdy patrons, their voices raised in song and laughter. The bard took center stage, strumming his lute and launching into a tale of adventure and heroism that had the crowd hanging on his every word.', + 'The thief crept through the shadows, his eyes scanning the room for any sign of danger. He knew that one false move could mean the difference between success and failure, and he was determined to come out on top.', + 'The elf queen stood atop her castle walls, surveying the kingdom below with a mix of pride and sadness. She knew that the coming war would be brutal, but she was determined to protect her people at all costs.', + 'The necromancer\'s tower loomed in the distance, its dark spires piercing the sky. As the adventurers approached, they could feel the chill of death emanating from within', + 'The ranger moved through the forest like a shadow, his senses attuned to every sound and movement around him. He knew that danger lurked behind every tree, but he was ready for whatever came his way.', + 'The paladin knelt before the altar, his hands clasped in prayer. He knew that his faith would be tested in the days ahead, but he was ready to face whatever trials lay in store for him.', + 'The druid communed with the spirits of nature, his mind merging with the trees, the animals, and the very earth itself. He knew that his power came with a great responsibility, and he was determined to use it for the greater good.', ]; const authors = [ - "Unknown", - "James Wyatt", - "Eolande Blackwood", - "Ragnar Ironheart", - "Lyra Nightshade", - "Valtorius Darkstar", - "Isadora Fireheart", - "Theron Shadowbane", - "Lirien Starweaver", - "Drogathar Bonecrusher", - "Kaelen Frostblade", + 'Unknown', + 'James Wyatt', + 'Eolande Blackwood', + 'Ragnar Ironheart', + 'Lyra Nightshade', + 'Valtorius Darkstar', + 'Isadora Fireheart', + 'Theron Shadowbane', + 'Lirien Starweaver', + 'Drogathar Bonecrusher', + 'Kaelen Frostblade', ]; const books = [ - "The Blade of Destiny", - "Dragonfire and Steel", - "The Bard's Tale", - "Darkness Rising", - "The Sacred Quest", - "Shadows in the Forest", - "The Starweaver Chronicles", - "Beneath the Bones", - "Moonlit Magic", - "Frost and Fury", + 'The Blade of Destiny', + 'Dragonfire and Steel', + 'The Bard\'s Tale', + 'Darkness Rising', + 'The Sacred Quest', + 'Shadows in the Forest', + 'The Starweaver Chronicles', + 'Beneath the Bones', + 'Moonlit Magic', + 'Frost and Fury', ]; -module.exports = () => { - return ` +module.exports = ()=>{ + return ` {{quote ${_.sample(quotes)} diff --git a/themes/V3/5ePHB/snippets/tableOfContents.gen.js b/themes/V3/5ePHB/snippets/tableOfContents.gen.js index 03f90d5fa..04ff77f3f 100644 --- a/themes/V3/5ePHB/snippets/tableOfContents.gen.js +++ b/themes/V3/5ePHB/snippets/tableOfContents.gen.js @@ -29,7 +29,7 @@ const getTOC = (pages)=>{ const res = []; _.each(pages, (page, pageNum)=>{ - if(!page.includes("{{frontCover}}") && !page.includes("{{insideCover}}") && !page.includes("{{partCover}}") && !page.includes("{{backCover}}")) { + if(!page.includes('{{frontCover}}') && !page.includes('{{insideCover}}') && !page.includes('{{partCover}}') && !page.includes('{{backCover}}')) { const lines = page.split('\n'); _.each(lines, (line)=>{ if(_.startsWith(line, '# ')){ diff --git a/themes/V3/Blank/snippets.js b/themes/V3/Blank/snippets.js index 272368665..8d45560c5 100644 --- a/themes/V3/Blank/snippets.js +++ b/themes/V3/Blank/snippets.js @@ -307,8 +307,8 @@ module.exports = [ /**************** FONTS *************/ { groupName : 'Fonts', - icon : 'fas fa-keyboard', - view : 'text', + icon : 'fas fa-keyboard', + view : 'text', snippets : [ { name : 'Open Sans', @@ -341,59 +341,59 @@ module.exports = [ gen : dedent`{{font-family:MrEavesRemake Dummy Text}}` }, { - name: 'Solbera Imitation', - icon: 'font SolberaImitationRemake', - gen: dedent`{{font-family:SolberaImitationRemake Dummy Text}}` + name : 'Solbera Imitation', + icon : 'font SolberaImitationRemake', + gen : dedent`{{font-family:SolberaImitationRemake Dummy Text}}` }, { - name: 'Scaly Sans Small Caps', - icon: 'font ScalySansSmallCapsRemake', - gen: dedent`{{font-family:ScalySansSmallCapsRemake Dummy Text}}` + name : 'Scaly Sans Small Caps', + icon : 'font ScalySansSmallCapsRemake', + gen : dedent`{{font-family:ScalySansSmallCapsRemake Dummy Text}}` }, { - name: 'Walter Turncoat', - icon: 'font WalterTurncoat', - gen: dedent`{{font-family:WalterTurncoat Dummy Text}}` + name : 'Walter Turncoat', + icon : 'font WalterTurncoat', + gen : dedent`{{font-family:WalterTurncoat Dummy Text}}` }, { - name: 'Lato', - icon: 'font Lato', - gen: dedent`{{font-family:Lato Dummy Text}}` + name : 'Lato', + icon : 'font Lato', + gen : dedent`{{font-family:Lato Dummy Text}}` }, { - name: 'Courier', - icon: 'font Courier', - gen: dedent`{{font-family:Courier Dummy Text}}` + name : 'Courier', + icon : 'font Courier', + gen : dedent`{{font-family:Courier Dummy Text}}` }, { - name: 'Nodesto Caps Condensed', - icon: 'font NodestoCapsCondensed', - gen: dedent`{{font-family:NodestoCapsCondensed Dummy Text}}` + name : 'Nodesto Caps Condensed', + icon : 'font NodestoCapsCondensed', + gen : dedent`{{font-family:NodestoCapsCondensed Dummy Text}}` }, { - name: 'Overpass', - icon: 'font Overpass', - gen: dedent`{{font-family:Overpass Dummy Text}}` + name : 'Overpass', + icon : 'font Overpass', + gen : dedent`{{font-family:Overpass Dummy Text}}` }, { - name: 'Davek', - icon: 'font Davek', - gen: dedent`{{font-family:Davek Dummy Text}}` + name : 'Davek', + icon : 'font Davek', + gen : dedent`{{font-family:Davek Dummy Text}}` }, { - name: 'Iokharic', - icon: 'font Iokharic', - gen: dedent`{{font-family:Iokharic Dummy Text}}` + name : 'Iokharic', + icon : 'font Iokharic', + gen : dedent`{{font-family:Iokharic Dummy Text}}` }, { - name: 'Rellanic', - icon: 'font Rellanic', - gen: dedent`{{font-family:Rellanic Dummy Text}}` + name : 'Rellanic', + icon : 'font Rellanic', + gen : dedent`{{font-family:Rellanic Dummy Text}}` }, { - name: 'Times New Roman', - icon: 'font TimesNewRoman', - gen: dedent`{{font-family:"Times New Roman" Dummy Text}}` + name : 'Times New Roman', + icon : 'font TimesNewRoman', + gen : dedent`{{font-family:"Times New Roman" Dummy Text}}` } ] },