diff --git a/.eslintrc.json b/.eslintrc.json index 4b80200d..f055af9b 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -54,7 +54,6 @@ "no-jquery/no-sizzle": "warn", "no-jquery/no-slide": "warn", "no-jquery/no-trim": "warn", - "no-jquery/variable-pattern": "warn", "no-undef": "warn", "prefer-const": "warn" } diff --git a/src/modules/core.js b/src/modules/core.js index d37f29bf..f0676eb7 100644 --- a/src/modules/core.js +++ b/src/modules/core.js @@ -958,7 +958,7 @@ /** * Represents the status container, created ub init() */ - container: false, + $container: false, /** * Creates the status container @@ -967,7 +967,7 @@ * status container should be prepended */ init: function ( location ) { - AFCH.status.container = $( '
' ) + AFCH.status.$container = $( '
' ) .attr( 'id', 'afchStatus' ) .addClass( 'afchStatus' ) .prependTo( location || '#mw-content-text' ); @@ -1004,7 +1004,7 @@ html = html.replace( key, value ); } ); // Then update the element - this.element.html( html ); + this.$element.html( html ); }; /** @@ -1015,7 +1015,7 @@ }; // Sanity check, there better be a status container - if ( !AFCH.status.container ) { + if ( !AFCH.status.$container ) { AFCH.status.init(); } @@ -1027,8 +1027,8 @@ this.substitutions = substitutions; - this.element = $( '
  • ' ) - .appendTo( AFCH.status.container ); + this.$element = $( '
  • ' ) + .appendTo( AFCH.status.$container ); this.update( initialText ); } @@ -1390,20 +1390,20 @@ this.views = views; this.$element = $element; - this.previousState = false; + this.$previousState = false; this.loadView = function ( view, data ) { const code = this.views.renderView( view, data ); // Update the view cache - this.previousState = this.$element.clone( true ); + this.$previousState = this.$element.clone( true ); this.$element.html( code ); }; this.loadPrevious = function () { - this.$element.replaceWith( this.previousState ); - this.$element = this.previousState; + this.$element.replaceWith( this.$previousState ); + this.$element = this.$previousState; }; }, @@ -1528,13 +1528,13 @@ titles: 'Category:' + pagename, prop: 'categoryinfo' }, - linkSpan = $( '' ).append( linkElement ), + $linkSpan = $( '' ).append( linkElement ), countSpanId = 'afch-cat-count-' + pagename .toLowerCase() .replace( / /g, '-' ) .replace( /\//g, '-' ); - linkSpan.append( $( '' ).attr( 'id', countSpanId ) ); + $linkSpan.append( $( '' ).attr( 'id', countSpanId ) ); AFCH.api.get( request ) .done( ( data ) => { @@ -1548,7 +1548,7 @@ } } ); - return linkSpan; + return $linkSpan; }, /** diff --git a/src/modules/submissions.js b/src/modules/submissions.js index f564d9a6..b22190c7 100644 --- a/src/modules/submissions.js +++ b/src/modules/submissions.js @@ -1896,19 +1896,19 @@ // is triggering this update is first or second in the multi-select // control function updateTextfield( newPrompt, newPlaceholder, newValue, pos ) { - const wrapper = $afch.find( '#textfieldWrapper' + ( pos === 2 ? '2' : '' ) ); + const $wrapper = $afch.find( '#textfieldWrapper' + ( pos === 2 ? '2' : '' ) ); // Update label and placeholder - wrapper.find( 'label' ).text( newPrompt ); - wrapper.find( 'input' ).attr( 'placeholder', newPlaceholder ); + $wrapper.find( 'label' ).text( newPrompt ); + $wrapper.find( 'input' ).attr( 'placeholder', newPlaceholder ); // Update default textfield value (perhaps) if ( typeof newValue !== 'undefined' ) { - wrapper.find( 'input' ).val( newValue ); + $wrapper.find( 'input' ).val( newValue ); } // And finally show the textfield - wrapper.removeClass( 'hidden' ); + $wrapper.removeClass( 'hidden' ); } // Copy most-used options to top of decline dropdown @@ -1967,16 +1967,16 @@ $afch.find( '#cvUrlTextarea' ).on( 'keyup', function () { let text = $( this ).val(), numUrls = text ? text.split( '\n' ).length : 0, - submitButton = $afch.find( '#afchSubmitForm' ); + $submitButton = $afch.find( '#afchSubmitForm' ); if ( numUrls >= 1 && numUrls <= 3 ) { $( this ).removeClass( 'bad-input' ); - submitButton + $submitButton .removeClass( 'disabled' ) .css( 'pointer-events', 'auto' ) .text( 'Decline submission' ); } else { $( this ).addClass( 'bad-input' ); - submitButton + $submitButton .addClass( 'disabled' ) .css( 'pointer-events', 'none' ) .text( 'Please enter between one and three URLs!' ); @@ -2220,10 +2220,10 @@ // Show an error if there's no such user $afch.find( '#submitterName' ).on( 'keyup', function () { - const field = $( this ), - status = $( '#submitterNameStatus' ), - submitButton = $afch.find( '#afchSubmitForm' ), - submitter = field.val(); + const $field = $( this ), + $status = $( '#submitterNameStatus' ), + $submitButton = $afch.find( '#afchSubmitForm' ), + submitter = $field.val(); // Reset form resetStatus(); @@ -2235,9 +2235,9 @@ // Check if the user string starts with "User:", because Template:AFC submission dies horribly if it does if ( submitter.lastIndexOf( 'User:', 0 ) === 0 ) { - field.addClass( 'bad-input' ); - status.text( 'Remove "User:" from the beginning.' ); - submitButton + $field.addClass( 'bad-input' ); + $status.text( 'Remove "User:" from the beginning.' ); + $submitButton .addClass( 'disabled' ) .css( 'pointer-events', 'none' ) .text( 'Invalid user name' ); @@ -2251,9 +2251,9 @@ ususers: submitter } ).done( ( data ) => { if ( data.query.users[ 0 ].missing !== undefined ) { - field.addClass( 'bad-input' ); - status.text( 'No user named "' + submitter + '".' ); - submitButton + $field.addClass( 'bad-input' ); + $status.text( 'No user named "' + submitter + '".' ); + $submitButton .addClass( 'disabled' ) .css( 'pointer-events', 'none' ) .text( 'No such user' );