From 9f918a9f3dc56394886c04a46658ca4abc5ef96c Mon Sep 17 00:00:00 2001 From: NovemLinguae Date: Sun, 12 May 2024 03:54:40 -0700 Subject: [PATCH] fix linter errors --- .../modules/MOSOrderPositionFinder.js | 290 +++++++++--------- SpeciesHelper/modules/functions.js | 2 + 2 files changed, 147 insertions(+), 145 deletions(-) diff --git a/SpeciesHelper/modules/MOSOrderPositionFinder.js b/SpeciesHelper/modules/MOSOrderPositionFinder.js index 5bb09a3..2d30b00 100644 --- a/SpeciesHelper/modules/MOSOrderPositionFinder.js +++ b/SpeciesHelper/modules/MOSOrderPositionFinder.js @@ -32,7 +32,7 @@ export class MOSOrderPositionFinder { 'categories', 'improveCategories', 'stubTemplates', - 'bottom', + 'bottom' ]; this.sectionStartPositions = { @@ -65,25 +65,25 @@ export class MOSOrderPositionFinder { categories: -1, stubTemplates: -1, improveCategories: -1, - bottom: this.wikitext.length, + bottom: this.wikitext.length }; // https://en.wikipedia.org/w/index.php?title=Special:WhatLinksHere/Template:Short_description&hidelinks=1&hidetrans=1 - this.sectionStartPositions.shortDescription = this._lookForTemplates(this.wikitext, [ + this.sectionStartPositions.shortDescription = this._lookForTemplates( this.wikitext, [ 'Short description', 'Shortdesc', 'Shortdescription', 'Short desc' - ]); + ] ); - this.sectionStartPositions.displayTitle = this._lookForTemplates(this.wikitext, [ + this.sectionStartPositions.displayTitle = this._lookForTemplates( this.wikitext, [ 'DISPLAYTITLE', 'Lowercase title', 'Italic title' - ]); - + ] ); + // https://en.wikipedia.org/wiki/Wikipedia:Hatnote - this.sectionStartPositions.hatnotes = this._lookForTemplates(this.wikitext, [ + this.sectionStartPositions.hatnotes = this._lookForTemplates( this.wikitext, [ 'About-distinguish', 'About', 'About other people', @@ -107,18 +107,18 @@ export class MOSOrderPositionFinder { 'Self reference', 'Similar names', 'Technical reasons', - 'Malay name', // TODO: add more {{X name}} type templates. - ]); + 'Malay name' // TODO: add more {{X name}} type templates. + ] ); - this.sectionStartPositions.featured = this._lookForTemplates(this.wikitext, [ + this.sectionStartPositions.featured = this._lookForTemplates( this.wikitext, [ 'Featured list', 'Featured article', - 'Good article', - ]); + 'Good article' + ] ); // https://en.wikipedia.org/wiki/Wikipedia:Criteria_for_speedy_deletion // https://en.wikipedia.org/w/index.php?title=Special:WhatLinksHere/Template:Proposed_deletion&hidelinks=1&hidetrans=1 - this.sectionStartPositions.deletionAndProtection = this._lookForTemplates(this.wikitext, [ + this.sectionStartPositions.deletionAndProtection = this._lookForTemplates( this.wikitext, [ 'Db-a1', // CSD 'Db-a10', 'Db-a11', @@ -229,11 +229,11 @@ export class MOSOrderPositionFinder { 'Propose deletion', 'Draft-prod', 'Article for deletion', // AFD - 'Pp', // page protection padlocks, includes {{Pp}} and {{Pp-*}} - ]); + 'Pp' // page protection padlocks, includes {{Pp}} and {{Pp-*}} + ] ); // Source: Twinkle - this.sectionStartPositions.maintenanceTags = this._lookForTemplates(this.wikitext, [ + this.sectionStartPositions.maintenanceTags = this._lookForTemplates( this.wikitext, [ 'Multiple issues', // not from Twinkle 'Cleanup', 'Cleanup rewrite', @@ -320,11 +320,11 @@ export class MOSOrderPositionFinder { 'Merge to', 'GOCEinuse', 'In use', - 'Under construction', - ]); + 'Under construction' + ] ); // https://en.wikipedia.org/wiki/Template:Use_X_English - this.sectionStartPositions.engvar = this._lookForTemplates(this.wikitext, [ + this.sectionStartPositions.engvar = this._lookForTemplates( this.wikitext, [ 'Engvar', // engvar 'EngvarA', 'EngvarB', @@ -349,10 +349,10 @@ export class MOSOrderPositionFinder { 'Use South African English', 'Use Trinidad and Tobago English', 'Use dmy dates', // dates - 'Use mdy dates', - ]); + 'Use mdy dates' + ] ); - this.sectionStartPositions.infoboxes = this._lookForTemplates(this.wikitext, [ + this.sectionStartPositions.infoboxes = this._lookForTemplates( this.wikitext, [ 'Infobox', 'Speciesbox', 'Species box', @@ -361,11 +361,11 @@ export class MOSOrderPositionFinder { 'Subspeciesbox', 'Infraspeciesbox', 'Hybridbox', - 'Virusbox', - ]); + 'Virusbox' + ] ); // https://en.wikipedia.org/wiki/Category:Language_maintenance_templates - this.sectionStartPositions.languageScriptNeeded = this._lookForTemplates(this.wikitext, [ + this.sectionStartPositions.languageScriptNeeded = this._lookForTemplates( this.wikitext, [ 'Arabic script needed', 'Armenian script needed', 'Berber script needed', @@ -405,35 +405,35 @@ export class MOSOrderPositionFinder { 'User programming subcategory', 'Verify spelling', 'Vietnamese script needed', - 'Yiddish script needed', - ]); + 'Yiddish script needed' + ] ); // No reliable way to search for these. Some end in sidebar, many don't. Example of ones that don't: [[Rohingya genocide]] -> {{Rohingya conflict}}, {{Genocide}}. // TODO: Will need to return the position of any template between top and first sentence that isn't in one of the lists above. this.sectionStartPositions.sidebars = -1; // Return first text that isn't whitespace, a template, or inside a template. This is the article's first sentence. - this.sectionStartPositions.lead = this._getFirstNonTemplateNonWhitespace(this.wikitext); + this.sectionStartPositions.lead = this._getFirstNonTemplateNonWhitespace( this.wikitext ); // https://en.wikipedia.org/wiki/Help:Magic_words#Behavior_switches - this.sectionStartPositions.tableOfContents = this._lookForStrings(this.wikitext, [ - '__TOC__', - ]); + this.sectionStartPositions.tableOfContents = this._lookForStrings( this.wikitext, [ + '__TOC__' + ] ); - this.sectionStartPositions.body = this._lookForRegEx(this.wikitext, /(?<=\n)==/i); + this.sectionStartPositions.body = this._lookForRegEx( this.wikitext, /(?<=\n)==/i ); - this.sectionStartPositions.worksOrPublications = this._lookForHeadings(this.wikitext, [ + this.sectionStartPositions.worksOrPublications = this._lookForHeadings( this.wikitext, [ 'Works\\s*==', 'Publications', 'Discography', - 'Filmography', - ]); + 'Filmography' + ] ); - this.sectionStartPositions.seeAlso = this._lookForHeadings(this.wikitext, [ - 'See also', - ]); + this.sectionStartPositions.seeAlso = this._lookForHeadings( this.wikitext, [ + 'See also' + ] ); - this.sectionStartPositions.notesAndReferences = this._lookForHeadings(this.wikitext, [ + this.sectionStartPositions.notesAndReferences = this._lookForHeadings( this.wikitext, [ 'Bibliography', 'Citations', 'Endnotes', @@ -441,27 +441,27 @@ export class MOSOrderPositionFinder { 'Notes', 'References', 'Sources', - 'Works cited', - ]); + 'Works cited' + ] ); - this.sectionStartPositions.furtherReading = this._lookForHeadings(this.wikitext, [ - 'Further reading', - ]); + this.sectionStartPositions.furtherReading = this._lookForHeadings( this.wikitext, [ + 'Further reading' + ] ); - this.sectionStartPositions.externalLinks = this._lookForHeadings(this.wikitext, [ - 'External links', - ]); + this.sectionStartPositions.externalLinks = this._lookForHeadings( this.wikitext, [ + 'External links' + ] ); // https://en.wikipedia.org/wiki/Wikipedia:WikiProject_Succession_Box_Standardization/Templates // TODO: figure out what "geography boxes" are, add them - this.sectionStartPositions.successionAndGeographyBoxes = this._lookForTemplates(this.wikitext, [ - 'S-', // they all are of the format {{S-*}} - ]); + this.sectionStartPositions.successionAndGeographyBoxes = this._lookForTemplates( this.wikitext, [ + 'S-' // they all are of the format {{S-*}} + ] ); // Hard to figure these out, unless they are contained in the {{Navbox}} wrapper // TODO: assume any templates in this area that aren't on other lists are navboxes // https://en.wikipedia.org/w/index.php?title=Special%3AWhatLinksHere&hidetrans=1&hidelinks=1&target=Template%3ANavbox&namespace= - this.sectionStartPositions.navboxes = this._lookForTemplates(this.wikitext, [ + this.sectionStartPositions.navboxes = this._lookForTemplates( this.wikitext, [ 'Navbox', 'Dynamic navigation box', 'Navigation', @@ -470,27 +470,27 @@ export class MOSOrderPositionFinder { 'VG navigation', 'CVG navigation', 'TransNB', - 'Navtable', - ]); + 'Navtable' + ] ); // https://en.wikipedia.org/w/index.php?title=Special:WhatLinksHere/Template:Portal_bar&hidetrans=1&hidelinks=1 - this.sectionStartPositions.portalBar = this._lookForTemplates(this.wikitext, [ + this.sectionStartPositions.portalBar = this._lookForTemplates( this.wikitext, [ 'Portal bar', - 'Prb', - ]); + 'Prb' + ] ); // https://en.wikipedia.org/w/index.php?title=Special%3AWhatLinksHere&hidetrans=1&hidelinks=1&target=Template%3ATaxonbar&namespace= - this.sectionStartPositions.taxonBar = this._lookForTemplates(this.wikitext, [ + this.sectionStartPositions.taxonBar = this._lookForTemplates( this.wikitext, [ 'Taxonbar', 'Taxon-bar', 'Taxobar', 'TaxonIDs', 'Taxon identifiers', - 'Taxon bar', - ]); + 'Taxon bar' + ] ); // https://en.wikipedia.org/w/index.php?title=Special%3AWhatLinksHere&hidetrans=1&hidelinks=1&target=Template%3AAuthority+control&namespace= - this.sectionStartPositions.authorityControl = this._lookForTemplates(this.wikitext, [ + this.sectionStartPositions.authorityControl = this._lookForTemplates( this.wikitext, [ 'Authority control', 'Normdaten', 'Authoritycontrol', @@ -498,13 +498,13 @@ export class MOSOrderPositionFinder { 'Autorité', 'Control de autoridades', '전거 통제', - 'Normativna kontrola', - ]); + 'Normativna kontrola' + ] ); // https://en.wikipedia.org/w/index.php?title=Special:WhatLinksHere/Template:Coord&hidetrans=1&hidelinks=1 // https://en.wikipedia.org/w/index.php?title=Special:WhatLinksHere/Template:Coord_missing&hidetrans=1&hidelinks=1 // using _findStringNotInsideTemplate because {{Coord}} inside infobox doesn't count - this.sectionStartPositions.geographicalCoordinates = this._findTemplateNotInsideTemplate(this.wikitext, [ + this.sectionStartPositions.geographicalCoordinates = this._findTemplateNotInsideTemplate( this.wikitext, [ 'Coord', // coord 'Coor', 'Location', @@ -516,73 +516,73 @@ export class MOSOrderPositionFinder { 'Missing coord', 'Coords missing', 'Locate me', - 'Needs coordinates', - ]); + 'Needs coordinates' + ] ); // https://en.wikipedia.org/w/index.php?title=Special:WhatLinksHere/Template:DEFAULTSORT&hidetrans=1&hidelinks=1 - this.sectionStartPositions.defaultSort = this._lookForTemplates(this.wikitext, [ + this.sectionStartPositions.defaultSort = this._lookForTemplates( this.wikitext, [ 'DEFAULTSORT', 'Default sort', - 'SORTIERUNG', - ]); + 'SORTIERUNG' + ] ); - this.sectionStartPositions.categories = this._lookForRegEx(this.wikitext, /\[\[:?Category:/i); + this.sectionStartPositions.categories = this._lookForRegEx( this.wikitext, /\[\[:?Category:/i ); - this.sectionStartPositions.stubTemplates = this._lookForRegEx(this.wikitext, /\{\{[^\}]*-stub\}\}/i); + this.sectionStartPositions.stubTemplates = this._lookForRegEx( this.wikitext, /\{\{[^}]*-stub\}\}/i ); - this.sectionStartPositions.improveCategories = this._lookForTemplates(this.wikitext, ['Improve categories']); + this.sectionStartPositions.improveCategories = this._lookForTemplates( this.wikitext, [ 'Improve categories' ] ); // If the body is the same position as any of the appendices, set body to -1, since there isn't really a body, just appendices. - let appendices = [ + const appendices = [ this.sectionStartPositions.worksOrPublications, this.sectionStartPositions.seeAlso, this.sectionStartPositions.notesAndReferences, this.sectionStartPositions.furtherReading, - this.sectionStartPositions.externalLinks, + this.sectionStartPositions.externalLinks ]; - if ( this.sectionStartPositions.body !== -1 && appendices.includes(this.sectionStartPositions.body) ) { + if ( this.sectionStartPositions.body !== -1 && appendices.includes( this.sectionStartPositions.body ) ) { this.sectionStartPositions.body = -1; } if ( this.debug ) { - for ( let section of this.sectionOrder ) { - let position = this._getSectionStartPosition(section); - let chunkPreview = this.wikitext.slice(position, position + 50); - console.log(`${section}: ${position}: ${chunkPreview}`); + for ( const section of this.sectionOrder ) { + const position = this._getSectionStartPosition( section ); + const chunkPreview = this.wikitext.slice( position, position + 50 ); + console.log( `${ section }: ${ position }: ${ chunkPreview }` ); } } } /** To find the location of the lead of an article, determine the location of the first non-template, non-whitespace, and non-HTML comment. Non-HTML comment handles an edge case involving AFC drafts. */ - _getFirstNonTemplateNonWhitespace(wikicode) { - let length = wikicode.length; + _getFirstNonTemplateNonWhitespace( wikicode ) { + const length = wikicode.length; let nesting = 0; for ( let i = 0; i < length; i++ ) { - let chunk = wikicode.slice(i); - if ( chunk.startsWith('{{') || chunk.startsWith('