Skip to content

Commit

Permalink
fix eslint rule no-jquery/variable-pattern (#397)
Browse files Browse the repository at this point in the history
  • Loading branch information
NovemLinguae authored Nov 27, 2024
1 parent bd4fd11 commit c0a11a2
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 32 deletions.
1 change: 0 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
26 changes: 13 additions & 13 deletions src/modules/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,7 @@
/**
* Represents the status container, created ub init()
*/
container: false,
$container: false,

/**
* Creates the status container
Expand All @@ -967,7 +967,7 @@
* status container should be prepended
*/
init: function ( location ) {
AFCH.status.container = $( '<div>' )
AFCH.status.$container = $( '<div>' )
.attr( 'id', 'afchStatus' )
.addClass( 'afchStatus' )
.prependTo( location || '#mw-content-text' );
Expand Down Expand Up @@ -1004,7 +1004,7 @@
html = html.replace( key, value );
} );
// Then update the element
this.element.html( html );
this.$element.html( html );
};

/**
Expand All @@ -1015,7 +1015,7 @@
};

// Sanity check, there better be a status container
if ( !AFCH.status.container ) {
if ( !AFCH.status.$container ) {
AFCH.status.init();
}

Expand All @@ -1027,8 +1027,8 @@

this.substitutions = substitutions;

this.element = $( '<li>' )
.appendTo( AFCH.status.container );
this.$element = $( '<li>' )
.appendTo( AFCH.status.$container );

this.update( initialText );
}
Expand Down Expand Up @@ -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;
};
},

Expand Down Expand Up @@ -1528,13 +1528,13 @@
titles: 'Category:' + pagename,
prop: 'categoryinfo'
},
linkSpan = $( '<span>' ).append( linkElement ),
$linkSpan = $( '<span>' ).append( linkElement ),
countSpanId = 'afch-cat-count-' + pagename
.toLowerCase()
.replace( / /g, '-' )
.replace( /\//g, '-' );

linkSpan.append( $( '<span>' ).attr( 'id', countSpanId ) );
$linkSpan.append( $( '<span>' ).attr( 'id', countSpanId ) );

AFCH.api.get( request )
.done( ( data ) => {
Expand All @@ -1548,7 +1548,7 @@
}
} );

return linkSpan;
return $linkSpan;
},

/**
Expand Down
36 changes: 18 additions & 18 deletions src/modules/submissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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!' );
Expand Down Expand Up @@ -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();
Expand All @@ -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' );
Expand All @@ -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' );
Expand Down

0 comments on commit c0a11a2

Please sign in to comment.