Skip to content

Commit

Permalink
fix linter errors, remove dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
NovemLinguae committed Apr 25, 2024
1 parent ead1538 commit 78cf7c1
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 37 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
39 changes: 14 additions & 25 deletions src/modules/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
},

/**
* @internal Functions called when AFCH.destroy() is run
* Functions called when AFCH.destroy() is run
*
* @internal
* @type {Array}
*/
_destroyFunctions: [],
Expand Down Expand Up @@ -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".' );
} );
Expand Down Expand Up @@ -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() ) {
Expand Down Expand Up @@ -244,7 +246,7 @@
/**
* Represents a page, mainly a wrapper for various actions
*
* @param name
* @param {string} name
*/
Page: function ( name ) {
var pg = this;
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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
Expand All @@ -534,7 +536,6 @@

return new AFCH.Page( title.getPrefixedText() );
};

},

/**
Expand Down Expand Up @@ -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
*
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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}
*/
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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...
Expand Down
19 changes: 9 additions & 10 deletions src/modules/submissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@
/**
* Represents text of an AfC submission
*
* @param text
* @param {string} text
*/
AFCH.Text = function ( text ) {
this.text = text;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -1021,8 +1020,7 @@
// <ref>1<ref> instead of <ref>1</ref> detection
if ( malformedRefs.length ) {
addWarning( 'The submission contains malformed <ref> tags.', 'View details', function () {
var $toggleLink = $( this ).addClass( 'malformed-refs-toggle' ),
$warningDiv = $( this ).parent();
var $warningDiv = $( this ).parent();
var $malformedRefWrapper = $( '<div>' )
.addClass( 'malformed-refs' )
.appendTo( $warningDiv );
Expand Down Expand Up @@ -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 = $( '<div>' )
.addClass( 'long-comments' )
.appendTo( $warningDiv );
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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' );

Expand Down Expand Up @@ -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( '<hr />' ) );
Expand Down

0 comments on commit 78cf7c1

Please sign in to comment.