diff --git a/includes/CommentModifier.php b/includes/CommentModifier.php index e07c17b0c..edc6827e9 100644 --- a/includes/CommentModifier.php +++ b/includes/CommentModifier.php @@ -368,10 +368,6 @@ class CommentModifier { * @param DocumentFragment|null $fragment Containing document fragment if list has no parent */ public static function unwrapList( Node $list, ?DocumentFragment $fragment = null ): void { - $doc = $list->ownerDocument; - $container = $fragment ?: $list->parentNode; - $referenceNode = $list; - if ( !( $list instanceof Element && ( strtolower( $list->tagName ) === 'dl' || @@ -388,6 +384,9 @@ class CommentModifier { return; } + $doc = $list->ownerDocument; + $container = $fragment ?: $list->parentNode; + $referenceNode = $list; while ( $list->firstChild ) { if ( $list->firstChild instanceof Element ) { // Move
diff --git a/modules/.eslintrc.json b/modules/.eslintrc.json index 7c9627ad0..2a6c69aec 100644 --- a/modules/.eslintrc.json +++ b/modules/.eslintrc.json @@ -11,7 +11,6 @@ }, "rules": { "no-implicit-globals": "off", - "prefer-const": "off", "max-len": "off", "prefer-arrow-callback": "error", "implicit-arrow-linebreak": "error", diff --git a/modules/CommentController.js b/modules/CommentController.js index 6babc2cb1..10f225ee0 100644 --- a/modules/CommentController.js +++ b/modules/CommentController.js @@ -671,10 +671,10 @@ CommentController.prototype.getUnsupportedNodeSelectors = function () { * @return {jQuery.Promise} Promise which resolves when switch is complete */ CommentController.prototype.switchToVisual = function () { - let oldWidget = this.replyWidget, + const oldWidget = this.replyWidget, oldShowAdvanced = oldWidget.showAdvanced, - oldEditSummary = oldWidget.getEditSummary(), - wikitext = oldWidget.getValue(); + oldEditSummary = oldWidget.getEditSummary(); + let wikitext = oldWidget.getValue(); // Replace wikitext signatures with a special marker recognized by DtDmMWSignatureNode // to render them as signature nodes in visual mode. diff --git a/modules/Parser.js b/modules/Parser.js index f044aaee0..7f12ddde1 100644 --- a/modules/Parser.js +++ b/modules/Parser.js @@ -516,11 +516,10 @@ function acceptOnlyNodesAllowingComments( node ) { * - {Object} range Range-like object covering the timestamp */ Parser.prototype.findTimestamp = function ( node, timestampRegexps ) { - let matchData, i, - nodeText = '', - offset = 0, - // Searched nodes (reverse order) - nodes = []; + let nodeText = ''; + let offset = 0; + // Searched nodes (reverse order) + const nodes = []; while ( node ) { nodeText = node.nodeValue + nodeText; @@ -554,12 +553,12 @@ Parser.prototype.findTimestamp = function ( node, timestampRegexps ) { } } - for ( i = 0; i < timestampRegexps.length; i++ ) { + for ( let i = 0; i < timestampRegexps.length; i++ ) { // Technically, there could be multiple matches in a single text node. However, the ultimate // point of this is to find the signatures which precede the timestamps, and any later // timestamps in the text node can't be directly preceded by a signature (as we require them to // have links), so we only concern ourselves with the first match. - matchData = nodeText.match( timestampRegexps[ i ] ); + const matchData = nodeText.match( timestampRegexps[ i ] ); if ( matchData ) { const timestampLength = matchData[ 0 ].length; // Bytes at the end of the last node which aren't part of the match diff --git a/modules/controller.js b/modules/controller.js index 49d3e72f9..896727d8e 100644 --- a/modules/controller.js +++ b/modules/controller.js @@ -251,9 +251,9 @@ function getCheckboxesPromise( pageName, oldId ) { * @return {string[]} */ function getReplyWidgetModules() { - let veConf = mw.config.get( 'wgVisualEditorConfig' ), - modules = [ 'ext.discussionTools.ReplyWidget' ] - .concat( veConf.pluginModules.filter( mw.loader.getState ) ); + const veConf = mw.config.get( 'wgVisualEditorConfig' ); + let modules = [ 'ext.discussionTools.ReplyWidget' ] + .concat( veConf.pluginModules.filter( mw.loader.getState ) ); if ( OO.ui.isMobile() ) { modules = [ @@ -281,9 +281,9 @@ function getReplyWidgetModules() { function init( $container, state ) { let activeCommentId = null, - activeController = null, - // Loads later to avoid circular dependency - CommentController = require( './CommentController.js' ), + activeController = null; + // Loads later to avoid circular dependency + const CommentController = require( './CommentController.js' ), NewTopicController = require( './NewTopicController.js' ); // We may be re-initializing after posting a new comment, so clear the cache, because diff --git a/modules/dt-ve/dt.ui.UsernameCompletionAction.js b/modules/dt-ve/dt.ui.UsernameCompletionAction.js index 952b94e61..a3ceea0f2 100644 --- a/modules/dt-ve/dt.ui.UsernameCompletionAction.js +++ b/modules/dt-ve/dt.ui.UsernameCompletionAction.js @@ -1,5 +1,5 @@ const controller = require( 'ext.discussionTools.init' ).controller; -let sequence; +let sequence = null; function sortAuthors( a, b ) { return a.username < b.username ? -1 : ( a.username === b.username ? 0 : 1 ); @@ -67,8 +67,8 @@ MWUsernameCompletionAction.static.methods.push( 'insertAndOpen' ); /* Methods */ MWUsernameCompletionAction.prototype.insertAndOpen = function () { - let inserted = false, - surfaceModel = this.surface.getModel(), + let inserted = false; + const surfaceModel = this.surface.getModel(), fragment = surfaceModel.getFragment(); // This is opening a window in a slightly weird way, so the normal logging diff --git a/modules/modifier.js b/modules/modifier.js index 9c8fc441e..3996059c0 100644 --- a/modules/modifier.js +++ b/modules/modifier.js @@ -310,10 +310,6 @@ function removeAddedListItem( node ) { * @param {DocumentFragment|null} fragment Containing document fragment if list has no parent */ function unwrapList( list, fragment ) { - let doc = list.ownerDocument, - container = fragment || list.parentNode, - referenceNode = list; - if ( !( list.nodeType === Node.ELEMENT_NODE && ( list.tagName.toLowerCase() === 'dl' || @@ -330,7 +326,9 @@ function unwrapList( list, fragment ) { return; } - let insertBefore; + const doc = list.ownerDocument; + const container = fragment || list.parentNode; + let referenceNode = list; while ( list.firstChild ) { if ( list.firstChild.nodeType === Node.ELEMENT_NODE ) { // Move
@@ -340,11 +338,11 @@ function unwrapList( list, fragment ) { // and start a new paragraph after if ( utils.isBlockElement( list.firstChild.firstChild ) ) { if ( p.firstChild ) { - insertBefore = referenceNode.nextSibling; + const insertBefore2 = referenceNode.nextSibling; referenceNode = p; - container.insertBefore( p, insertBefore ); + container.insertBefore( p, insertBefore2 ); } - insertBefore = referenceNode.nextSibling; + const insertBefore = referenceNode.nextSibling; referenceNode = list.firstChild.firstChild; container.insertBefore( list.firstChild.firstChild, insertBefore ); p = doc.createElement( 'p' ); @@ -353,14 +351,14 @@ function unwrapList( list, fragment ) { } } if ( p.firstChild ) { - insertBefore = referenceNode.nextSibling; + const insertBefore = referenceNode.nextSibling; referenceNode = p; container.insertBefore( p, insertBefore ); } list.removeChild( list.firstChild ); } else { // Text node / comment node, probably empty - insertBefore = referenceNode.nextSibling; + const insertBefore = referenceNode.nextSibling; referenceNode = list.firstChild; container.insertBefore( list.firstChild, insertBefore ); } diff --git a/modules/topicsubscriptions.js b/modules/topicsubscriptions.js index 334b51e55..1e4310344 100644 --- a/modules/topicsubscriptions.js +++ b/modules/topicsubscriptions.js @@ -321,7 +321,7 @@ function maybeShowFirstTimeAutoTopicSubPopup() { mw.user.options.set( 'discussiontools-seenautotopicsubpopup', '1' ); api.saveOption( 'discussiontools-seenautotopicsubpopup', '1' ); - let $popupContent, popup; + let popup = null; function close() { popup.$element.removeClass( 'ext-discussiontools-autotopicsubpopup-fadein' ); @@ -330,7 +330,7 @@ function maybeShowFirstTimeAutoTopicSubPopup() { }, 1000 ); } - $popupContent = $( '