From 78cf7c11cdd7b4c44bfcd30ca6b9034841d32644 Mon Sep 17 00:00:00 2001 From: NovemLinguae Date: Thu, 25 Apr 2024 04:38:10 -0700 Subject: [PATCH] fix linter errors, remove dead code --- .eslintrc.json | 4 ++-- src/modules/core.js | 39 ++++++++++++++------------------------ src/modules/submissions.js | 19 +++++++++---------- 3 files changed, 25 insertions(+), 37 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index a6edcde3..c44c19a1 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -19,11 +19,11 @@ "jsdoc/require-param-type": "warn", "jsdoc/require-returns": "warn", "max-len": "off", - "no-console": "warn", + "no-console": "off", "no-global-assign": "warn", "no-implicit-globals": "warn", "no-new": "warn", - "no-prototype-builtins": "warn", + "no-prototype-builtins": "off", "no-shadow": "off", "no-undef": "warn", "no-underscore-dangle": "off", diff --git a/src/modules/core.js b/src/modules/core.js index b3d198c0..05d27068 100644 --- a/src/modules/core.js +++ b/src/modules/core.js @@ -17,7 +17,9 @@ }, /** - * @internal Functions called when AFCH.destroy() is run + * Functions called when AFCH.destroy() is run + * + * @internal * @type {Array} */ _destroyFunctions: [], @@ -142,7 +144,7 @@ ( new mw.Api() ).postWithEditToken( { action: 'options', change: 'gadget-afchelper=0' - } ).done( function ( data ) { + } ).done( function () { mw.notify( 'AFCH has been disabled successfully. If you wish to re-enable it in the ' + 'future, you can do so via your Preferences by checking "Yet Another AFC Helper Script".' ); } ); @@ -185,8 +187,8 @@ /** * Loads the subscript and dependencies * - * @param {string} type Which type of script to load: - * 'redirects' or 'ffu' or 'submissions' + * @param {string} type Which type of script to load: 'redirects' or 'ffu' or 'submissions' + * @return {boolean} */ load: function ( type ) { if ( !AFCH.setup() ) { @@ -244,7 +246,7 @@ /** * Represents a page, mainly a wrapper for various actions * - * @param name + * @param {string} name */ Page: function ( name ) { var pg = this; @@ -354,7 +356,8 @@ * with recursion and all that mess, /g is our friend...which is pefectly * satisfactory for our purposes. * - * @param $v + * @param {jQuery} $v + * @return {string} */ function parseValue( $v ) { var text = AFCH.jQueryToHtml( $v ); @@ -519,10 +522,9 @@ /** * Gets the associated talk page * - * @param textOnly * @return {AFCH.Page} */ - this.getTalkPage = function ( textOnly ) { + this.getTalkPage = function () { var title, ns = this.title.getNamespaceId(); // Odd-numbered namespaces are already talk namespaces @@ -534,7 +536,6 @@ return new AFCH.Page( title.getPrefixedText() ); }; - }, /** @@ -722,18 +723,6 @@ return deferred; }, - /** - * Deletes a page - * - * @param {string} pagename Page to delete - * @param {string} reason Reason for deletion; shown in deletion log - * @return {jQuery.Deferred} Resolves with success/failure - */ - deletePage: function ( pagename, reason ) { - // FIXME: implement - return false; - }, - /** * Moves a page * @@ -835,8 +824,7 @@ * - title {string} * - reason {string} * - usersNotified {array} optional - * @return {jQuery.Deferred} resolves false if the page did not exist, otherwise - * resolves/rejects with data from the edit + * @return {jQuery.Deferred|void} resolves false if the page did not exist, otherwise resolves/rejects with data from the edit */ logCSD: function ( options ) { var deferred = $.Deferred(), @@ -934,6 +922,7 @@ * if that header doesn't already exist * * @param {string} logText Text of user's AfC log + * @return {string} headerText */ addLogHeaderIfNeeded: function ( logText ) { var date = new Date(), @@ -1449,7 +1438,7 @@ /** * Removes a key from a given object and returns the value of the key * - * @param object + * @param {Object} object * @param {string} key * @return {Mixed} */ @@ -1562,7 +1551,6 @@ */ makeLinkElementToCategory: function ( pagename, displayTitle ) { var linkElement = AFCH.makeLinkElementToPage( 'Special:RandomInCategory/' + pagename, displayTitle, false ), - linkText = displayTitle || pagename.replace( /_/g, ' ' ), request = { action: 'query', titles: 'Category:' + pagename, @@ -1623,6 +1611,7 @@ * works. The empty section may have categories after it - keep them there. * * @param {string} wikicode + * @return {string} wikicode */ removeEmptySectionAtEnd: function ( wikicode ) { // Hard to write a regex that doesn't catastrophic backtrack while still saving multiple categories and multiple blank lines. So we'll do this the old-fashioned way... diff --git a/src/modules/submissions.js b/src/modules/submissions.js index 8057b525..b0de513a 100644 --- a/src/modules/submissions.js +++ b/src/modules/submissions.js @@ -491,7 +491,7 @@ /** * Represents text of an AfC submission * - * @param text + * @param {string} text */ AFCH.Text = function ( text ) { this.text = text; @@ -884,8 +884,7 @@ // Set up the extra options slide-out panel, which appears // when the user click on the chevron $afch.find( '#afchExtra .open' ).click( function () { - var $extra = $afch.find( '#afchExtra' ), - $toggle = $( this ); + var $extra = $afch.find( '#afchExtra' ); if ( extrasRevealed ) { $extra.find( 'a' ).hide(); @@ -1021,8 +1020,7 @@ // 1 instead of 1 detection if ( malformedRefs.length ) { addWarning( 'The submission contains malformed tags.', 'View details', function () { - var $toggleLink = $( this ).addClass( 'malformed-refs-toggle' ), - $warningDiv = $( this ).parent(); + var $warningDiv = $( this ).parent(); var $malformedRefWrapper = $( '
' ) .addClass( 'malformed-refs' ) .appendTo( $warningDiv ); @@ -1157,8 +1155,7 @@ if ( numberOfComments ) { addWarning( 'The page contains ' + ( oneComment ? 'an' : '' ) + ' HTML comment' + ( oneComment ? '' : 's' ) + ' longer than 30 characters.', 'View comment' + ( oneComment ? '' : 's' ), function () { - var $toggleLink = $( this ).addClass( 'long-comment-toggle' ), - $warningDiv = $( this ).parent(), + var $warningDiv = $( this ).parent(), $commentsWrapper = $( '
' ) .addClass( 'long-comments' ) .appendTo( $warningDiv ); @@ -1450,6 +1447,8 @@ /** * If possible, use the session storage to get the WikiProject list. * If it hasn't been cached already, load it manually and then cache + * + * @return {jQuery.Deferred} */ function loadWikiProjectList() { var deferred = $.Deferred(), @@ -1649,7 +1648,7 @@ // Extend the chosen menu for new WikiProjects. We hackily show a // "Click to manually add {{PROJECT}}" link -- sadly, jquery.chosen // doesn't support this natively. - $afch.find( '#newWikiProjects_chzn input' ).keyup( function ( e ) { + $afch.find( '#newWikiProjects_chzn input' ).keyup( function () { var $chzn = $afch.find( '#newWikiProjects_chzn' ), $input = $( this ), newProject = $input.val(), @@ -1971,7 +1970,7 @@ candidateDupeName = ( afchSubmission.shortTitle !== 'sandbox' ) ? afchSubmission.shortTitle : '', prevDeclineComment = $afch.find( '#declineTextarea' ).val(), declineHandlers = { - cv: function ( pos ) { + cv: function () { $afch.find( '#cvUrlWrapper' ).removeClass( 'hidden' ); $afch.add( '#csdWrapper' ).removeClass( 'hidden' ); @@ -2097,7 +2096,7 @@ type: 'block' } ).css( 'padding', '20px' ) ); var reasonDeferreds = reason.map( AFCH.getReason ); - $.when.apply( $, reasonDeferreds ).then( function ( a, b ) { + $.when.apply( $, reasonDeferreds ).then( function () { $( '#previewContainer' ) .html( Array.prototype.slice.call( arguments ) .join( '
' ) );