Skip to content

Commit

Permalink
Apply eslint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mbergen committed Nov 22, 2024
1 parent ae4691b commit 0a0888a
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions resources/scripts/codemirror.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ if ( !String.prototype.includes ) {
// case 'setContents': // no params with defaults
// case 'getSelection': // no params
case 'encapsulateSelection':
options = $.extend( {
options = Object.assign( {
// Text to insert before the cursor/selection
pre: '',
// Text to insert between pre and post and select afterwards
Expand All @@ -232,15 +232,15 @@ if ( !String.prototype.includes ) {
}, options );
break;
case 'getCaretPosition':
options = $.extend( {
options = Object.assign( {
// Return [start, end] instead of just start
startAndEnd: false
}, options );
// FIXME: We may not need character position-based functions
// if we insert markers in the right places
break;
case 'setSelection':
options = $.extend( {
options = Object.assign( {
// Position to start selection at
start: undefined,
// Position to end selection at. Defaults to start
Expand All @@ -261,7 +261,7 @@ if ( !String.prototype.includes ) {
// functions if we insert markers in the right places
break;
case 'scrollToCaretPosition':
options = $.extend( {
options = Object.assign( {
force: false // Force a scroll even if the caret position is already visible
}, options );
break;
Expand Down Expand Up @@ -376,16 +376,16 @@ if ( !String.prototype.includes ) {
let pagename = element.text();

/** @type { HTMLElement | undefined } */
const parserfunction = element.parent().children().eq( element.index() - 2 )
const parserfunction = element.parent().children().eq( element.index() - 2 );

if ( pagename.startsWith( 'module=' ) ) {
pagename = pagename.slice( 7 );
} else if ( !parserfunction.hasClass( 'cm-mw-parserfunction-name' )
|| parserfunction.text() !== '#invoke' ) {
} else if ( !parserfunction.hasClass( 'cm-mw-parserfunction-name' ) ||
parserfunction.text() !== '#invoke' ) {
return;
}
pagename = 'Module:' + pagename

pagename = 'Module:' + pagename;
window.open( mw.config.get( 'wgScriptPath' ) + '/' + pagename );
}

Expand All @@ -400,7 +400,7 @@ if ( !String.prototype.includes ) {
openPageOnClick( 'cm-mw-link-pagename', $( this ) );
}
} );

$( '.CodeMirror' ).on( 'click', '.cm-mw-parserfunction', function( e ) {
if ( e.altKey ) {
openModuleOnClick( $( this ) );
Expand All @@ -423,12 +423,12 @@ if ( !String.prototype.includes ) {

attemptLineChangeOnHash();

window.addEventListener( 'hashchange', function() {
window.addEventListener( 'hashchange', () => {
attemptLineChangeOnHash();
} );

document.querySelectorAll( '.CodeMirror' ).forEach( function( el ) {
el.addEventListener( 'click', function( ev ) {
document.querySelectorAll( '.CodeMirror' ).forEach( ( el ) => {
el.addEventListener( 'click', ( ev ) => {
const targetElement = ev.target;
if ( targetElement.classList.contains( 'CodeMirror-linenumber' ) ) {
window.location.hash = magicHashPrefix + targetElement.innerHTML;
Expand All @@ -446,7 +446,7 @@ if ( !String.prototype.includes ) {
codeMirror = codeMirrorDesktop;
}
if ( codeMirror ) {
mw.hook( 'wikiEditor.toolbarReady' ).add( function() {
mw.hook( 'wikiEditor.toolbarReady' ).add( () => {
enableCodeMirror();

// define JQuery hook for searching and replacing text using
Expand Down

0 comments on commit 0a0888a

Please sign in to comment.