mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-23 16:06:53 +00:00
ESLint: Manually fix remaining no-var violations
Change-Id: I4474bd0205e7a1ed8e60147e52675e3e0b93ccd9
This commit is contained in:
parent
ca5157156a
commit
dda9227947
|
@ -11,7 +11,6 @@
|
|||
},
|
||||
"rules": {
|
||||
"no-implicit-globals": "off",
|
||||
"no-var": "off",
|
||||
"prefer-const": "off",
|
||||
"max-len": "off",
|
||||
"prefer-arrow-callback": "error",
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
var
|
||||
const
|
||||
controller = require( './controller.js' ),
|
||||
modifier = require( './modifier.js' ),
|
||||
dtConf = require( './config.json' ),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
var ThreadItem = require( './ThreadItem.js' ),
|
||||
const ThreadItem = require( './ThreadItem.js' ),
|
||||
moment = require( './lib/moment-timezone/moment-timezone-with-data-1970-2030.js' );
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
var ThreadItem = require( './ThreadItem.js' );
|
||||
const ThreadItem = require( './ThreadItem.js' );
|
||||
// Placeholder headings must have a level higher than real headings (1-6)
|
||||
var PLACEHOLDER_HEADING_LEVEL = 99;
|
||||
const PLACEHOLDER_HEADING_LEVEL = 99;
|
||||
|
||||
/**
|
||||
* A heading item
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
var
|
||||
const
|
||||
CommentController = require( './CommentController.js' ),
|
||||
HeadingItem = require( './HeadingItem.js' );
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
/* global $:off */
|
||||
|
||||
var
|
||||
const
|
||||
utils = require( './utils.js' ),
|
||||
charAt = require( 'mediawiki.String' ).charAt,
|
||||
codePointLength = require( 'mediawiki.String' ).codePointLength,
|
||||
|
@ -30,7 +30,7 @@ function Parser( data ) {
|
|||
*
|
||||
* @constant {number}
|
||||
*/
|
||||
var SIGNATURE_SCAN_LIMIT = 100;
|
||||
const SIGNATURE_SCAN_LIMIT = 100;
|
||||
|
||||
/**
|
||||
* Parse a discussion page.
|
||||
|
@ -195,11 +195,12 @@ Parser.prototype.getTimestampRegexp = function ( contLangVariant, format, digits
|
|||
s += '"';
|
||||
}
|
||||
break;
|
||||
default:
|
||||
default: {
|
||||
// Copy whole characters together, instead of single UTF-16 surrogates
|
||||
var char = charAt( format, p );
|
||||
const char = charAt( format, p );
|
||||
s += mw.util.escapeRegExp( char );
|
||||
p += char.length - 1;
|
||||
}
|
||||
}
|
||||
if ( num !== false ) {
|
||||
if ( raw ) {
|
||||
|
@ -560,17 +561,16 @@ Parser.prototype.findTimestamp = function ( node, timestampRegexps ) {
|
|||
// have links), so we only concern ourselves with the first match.
|
||||
matchData = nodeText.match( timestampRegexps[ i ] );
|
||||
if ( matchData ) {
|
||||
var timestampLength = matchData[ 0 ].length;
|
||||
const timestampLength = matchData[ 0 ].length;
|
||||
// Bytes at the end of the last node which aren't part of the match
|
||||
const tailLength = nodeText.length - timestampLength - matchData.index;
|
||||
// We are moving right to left, but we start to the right of the end of
|
||||
// the timestamp if there is trailing garbage, so that is a negative offset.
|
||||
var count = -tailLength;
|
||||
let count = -tailLength;
|
||||
const endContainer = nodes[ 0 ];
|
||||
const endOffset = endContainer.nodeValue.length - tailLength;
|
||||
|
||||
var startContainer, startOffset;
|
||||
// eslint-disable-next-line no-loop-func
|
||||
let startContainer, startOffset;
|
||||
nodes.some( ( n ) => {
|
||||
count += n.nodeValue.length;
|
||||
// If we have counted to beyond the start of the timestamp, we are in the
|
||||
|
@ -866,7 +866,7 @@ Parser.prototype.buildThreadItems = function () {
|
|||
|
||||
let node;
|
||||
while ( ( node = treeWalker.nextNode() ) ) {
|
||||
var match;
|
||||
let match;
|
||||
if ( node.tagName && ( match = node.tagName.match( /^h([1-6])$/i ) ) ) {
|
||||
const headingNode = utils.getHeadlineNode( node );
|
||||
range = {
|
||||
|
@ -890,15 +890,15 @@ Parser.prototype.buildThreadItems = function () {
|
|||
continue;
|
||||
}
|
||||
|
||||
var sigRanges = [];
|
||||
var timestampRanges = [];
|
||||
const sigRanges = [];
|
||||
const timestampRanges = [];
|
||||
|
||||
sigRanges.push( adjustSigRange( foundSignature.nodes, match, node ) );
|
||||
timestampRanges.push( match.range );
|
||||
|
||||
// Everything from the last comment up to here is the next comment
|
||||
const startNode = this.nextInterestingLeafNode( curCommentEnd );
|
||||
var endNode = foundSignature.nodes[ 0 ];
|
||||
let endNode = foundSignature.nodes[ 0 ];
|
||||
|
||||
// Skip to the end of the "paragraph". This only looks at tag names and can be fooled by CSS, but
|
||||
// avoiding that would be more difficult and slower.
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
var
|
||||
const
|
||||
// LanguageData::getLocalData()
|
||||
parserData = require( './parser/data.json' ),
|
||||
utils = require( './utils.js' );
|
||||
|
||||
var featuresEnabled = mw.config.get( 'wgDiscussionToolsFeaturesEnabled' ) || {};
|
||||
const featuresEnabled = mw.config.get( 'wgDiscussionToolsFeaturesEnabled' ) || {};
|
||||
|
||||
function tryInfuse( $element ) {
|
||||
if ( $element.length ) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* global moment */
|
||||
|
||||
var utils = require( './utils.js' );
|
||||
const utils = require( './utils.js' );
|
||||
|
||||
/**
|
||||
* A thread item, either a heading or a comment
|
||||
|
@ -65,9 +65,9 @@ ThreadItem.static.newFromJSON = function ( json, rootNode ) {
|
|||
|
||||
let item;
|
||||
switch ( hash.type ) {
|
||||
case 'comment':
|
||||
case 'comment': {
|
||||
// Late require to avoid circular dependency
|
||||
var CommentItem = require( './CommentItem.js' );
|
||||
const CommentItem = require( './CommentItem.js' );
|
||||
item = new CommentItem(
|
||||
hash.level,
|
||||
hash.range,
|
||||
|
@ -82,8 +82,9 @@ ThreadItem.static.newFromJSON = function ( json, rootNode ) {
|
|||
hash.displayName
|
||||
);
|
||||
break;
|
||||
case 'heading':
|
||||
var HeadingItem = require( './HeadingItem.js' );
|
||||
}
|
||||
case 'heading': {
|
||||
const HeadingItem = require( './HeadingItem.js' );
|
||||
// Cached HTML may still have the placeholder heading constant in it.
|
||||
// This code can be removed a few weeks after being deployed.
|
||||
if ( hash.headingLevel === 99 ) {
|
||||
|
@ -94,6 +95,7 @@ ThreadItem.static.newFromJSON = function ( json, rootNode ) {
|
|||
hash.headingLevel
|
||||
);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw new Error( 'Unknown ThreadItem type ' + hash.name );
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
var CommentItem = require( './CommentItem.js' );
|
||||
var HeadingItem = require( './HeadingItem.js' );
|
||||
var ThreadItem = require( './ThreadItem.js' );
|
||||
const CommentItem = require( './CommentItem.js' );
|
||||
const HeadingItem = require( './HeadingItem.js' );
|
||||
const ThreadItem = require( './ThreadItem.js' );
|
||||
|
||||
/**
|
||||
* Groups thread items (headings and comments) generated by parsing a discussion page.
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
var
|
||||
$pageContainer, linksController,
|
||||
pageThreads,
|
||||
lastControllerScrollOffset,
|
||||
featuresEnabled = mw.config.get( 'wgDiscussionToolsFeaturesEnabled' ) || {},
|
||||
const featuresEnabled = mw.config.get( 'wgDiscussionToolsFeaturesEnabled' ) || {},
|
||||
MemoryStorage = require( './MemoryStorage.js' ),
|
||||
STORAGE_EXPIRY = 60 * 60 * 24 * 30,
|
||||
Parser = require( './Parser.js' ),
|
||||
|
@ -16,14 +12,18 @@ var
|
|||
highlighter = require( './highlighter.js' ),
|
||||
topicSubscriptions = require( './topicsubscriptions.js' ),
|
||||
permalinks = require( './permalinks.js' ),
|
||||
pageHandlersSetup = false,
|
||||
pageDataCache = {},
|
||||
defaultEditMode = mw.user.options.get( 'discussiontools-editmode' ) || mw.config.get( 'wgDiscussionToolsFallbackEditMode' ),
|
||||
defaultVisual = defaultEditMode === 'visual',
|
||||
enable2017Wikitext = featuresEnabled.sourcemodetoolbar,
|
||||
overflowMenu = require( './overflowMenu.js' );
|
||||
let
|
||||
$pageContainer, linksController,
|
||||
pageThreads,
|
||||
lastControllerScrollOffset,
|
||||
pageDataCache = {},
|
||||
pageHandlersSetup = false;
|
||||
|
||||
var mobile = null;
|
||||
let mobile = null;
|
||||
if ( OO.ui.isMobile() && mw.config.get( 'skin' ) === 'minerva' ) {
|
||||
mobile = require( './mobile.js' );
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
'use strict';
|
||||
|
||||
var initialOffset, indentWidth, firstMarker;
|
||||
var updaters = [];
|
||||
let initialOffset, indentWidth, firstMarker;
|
||||
const updaters = [];
|
||||
// eslint-disable-next-line no-jquery/no-global-selector
|
||||
var isRtl = $( 'html' ).attr( 'dir' ) === 'rtl';
|
||||
const isRtl = $( 'html' ).attr( 'dir' ) === 'rtl';
|
||||
|
||||
function markTimestamp( parser, node, match ) {
|
||||
const dfParsers = parser.getLocalTimestampParsers();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
var registries = require( './dt.ui.registries.js' );
|
||||
const registries = require( './dt.ui.registries.js' );
|
||||
|
||||
/**
|
||||
* DiscussionTools-specific target, inheriting from the stand-alone target
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
var sequence,
|
||||
controller = require( 'ext.discussionTools.init' ).controller;
|
||||
const controller = require( 'ext.discussionTools.init' ).controller;
|
||||
let sequence;
|
||||
|
||||
function sortAuthors( a, b ) {
|
||||
return a.username < b.username ? -1 : ( a.username === b.username ? 0 : 1 );
|
||||
|
@ -238,11 +238,11 @@ MWUsernameCompletionAction.prototype.shouldAbandon = function ( input ) {
|
|||
|
||||
ve.ui.actionFactory.register( MWUsernameCompletionAction );
|
||||
|
||||
var openCommand = new ve.ui.Command(
|
||||
const openCommand = new ve.ui.Command(
|
||||
'openMWUsernameCompletions', MWUsernameCompletionAction.static.name, 'open',
|
||||
{ supportedSelections: [ 'linear' ] }
|
||||
);
|
||||
var insertAndOpenCommand = new ve.ui.Command(
|
||||
const insertAndOpenCommand = new ve.ui.Command(
|
||||
'insertAndOpenMWUsernameCompletions', MWUsernameCompletionAction.static.name, 'insertAndOpen',
|
||||
{ supportedSelections: [ 'linear' ] }
|
||||
);
|
||||
|
|
|
@ -13,14 +13,14 @@ function importRegistry( parent, child ) {
|
|||
|
||||
// Create new registries so that we can override the behavior for signatures
|
||||
// without affecting normal VisualEditor.
|
||||
var commandRegistry = new ve.ui.CommandRegistry();
|
||||
const commandRegistry = new ve.ui.CommandRegistry();
|
||||
importRegistry( ve.ui.commandRegistry, commandRegistry );
|
||||
var sequenceRegistry = new ve.ui.SequenceRegistry();
|
||||
const sequenceRegistry = new ve.ui.SequenceRegistry();
|
||||
importRegistry( ve.ui.sequenceRegistry, sequenceRegistry );
|
||||
|
||||
var wikitextCommandRegistry = new ve.ui.MWWikitextCommandRegistry( commandRegistry );
|
||||
const wikitextCommandRegistry = new ve.ui.MWWikitextCommandRegistry( commandRegistry );
|
||||
importRegistry( ve.ui.wikitextCommandRegistry, wikitextCommandRegistry );
|
||||
var wikitextSequenceRegistry = new ve.ui.SequenceRegistry();
|
||||
const wikitextSequenceRegistry = new ve.ui.SequenceRegistry();
|
||||
importRegistry( ve.ui.wikitextSequenceRegistry, wikitextSequenceRegistry );
|
||||
|
||||
// Disable find-and-replace (T263570)
|
||||
|
@ -58,7 +58,7 @@ sequenceRegistry.register(
|
|||
// TODO: Show a warning when typing ~~~~ in wikitext mode?
|
||||
|
||||
// Show wikitext warnings for disabled sequences (disabled via excludeCommands):
|
||||
var sequenceRegistryForReplyTool = new ve.ui.SequenceRegistry();
|
||||
const sequenceRegistryForReplyTool = new ve.ui.SequenceRegistry();
|
||||
importRegistry( sequenceRegistry, sequenceRegistryForReplyTool );
|
||||
|
||||
// insertTable
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
var
|
||||
const
|
||||
Parser = require( 'ext.discussionTools.init' ).Parser,
|
||||
modifier = require( 'ext.discussionTools.init' ).modifier,
|
||||
utils = require( 'ext.discussionTools.init' ).utils,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
var controller = require( './controller.js' ),
|
||||
const controller = require( './controller.js' ),
|
||||
url = new URL( location.href );
|
||||
|
||||
/**
|
||||
|
@ -13,7 +13,7 @@ mw.dt.initState = {
|
|||
|
||||
// A/B test for logged out users:
|
||||
if ( mw.user.isAnon() && mw.config.get( 'wgDiscussionToolsABTest' ) && mw.config.get( 'wgDiscussionToolsABTestBucket' ) ) {
|
||||
var token = mw.cookie.get( 'DTABid', '', mw.user.generateRandomSessionId() );
|
||||
const token = mw.cookie.get( 'DTABid', '', mw.user.generateRandomSessionId() );
|
||||
mw.cookie.set( 'DTAB', mw.config.get( 'wgDiscussionToolsABTestBucket' ), { path: '/', expires: 90 * 86400, prefix: '' } );
|
||||
mw.cookie.set( 'DTABid', token, { path: '/', expires: 90 * 86400, prefix: '' } );
|
||||
}
|
||||
|
@ -77,15 +77,13 @@ if ( url.searchParams.get( 'dtdebug' ) ) {
|
|||
mw.hook( 'wikipage.content' ).add( mw.dt.init );
|
||||
}
|
||||
|
||||
var topicSubscriptions;
|
||||
|
||||
if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'TopicSubscriptions' ) {
|
||||
topicSubscriptions = require( './topicsubscriptions.js' );
|
||||
const topicSubscriptions = require( './topicsubscriptions.js' );
|
||||
topicSubscriptions.initSpecialTopicSubscriptions();
|
||||
}
|
||||
|
||||
if ( mw.config.get( 'wgAction' ) === 'history' ) {
|
||||
topicSubscriptions = require( './topicsubscriptions.js' );
|
||||
const topicSubscriptions = require( './topicsubscriptions.js' );
|
||||
topicSubscriptions.initNewTopicsSubscription();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
var controller = require( 'ext.discussionTools.init' ).controller,
|
||||
const controller = require( 'ext.discussionTools.init' ).controller,
|
||||
utils = require( 'ext.discussionTools.init' ).utils,
|
||||
ModeTabSelectWidget = require( './ModeTabSelectWidget.js' ),
|
||||
ModeTabOptionWidget = require( './ModeTabOptionWidget.js' ),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
var utils = require( 'ext.discussionTools.init' ).utils;
|
||||
const utils = require( 'ext.discussionTools.init' ).utils;
|
||||
|
||||
/**
|
||||
* DiscussionTools ReplyWidgetPlain class
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
var CommentTargetWidget = require( './dt-ve/CommentTargetWidget.js' );
|
||||
const CommentTargetWidget = require( './dt-ve/CommentTargetWidget.js' );
|
||||
|
||||
require( './dt-ve/dt.ui.MWSignatureContextItem.js' );
|
||||
require( './dt-ve/dt.dm.MWSignatureNode.js' );
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
var
|
||||
lastHighlightedPublishedComment = null,
|
||||
const
|
||||
featuresEnabled = mw.config.get( 'wgDiscussionToolsFeaturesEnabled' ) || {},
|
||||
CommentItem = require( './CommentItem.js' ),
|
||||
HeadingItem = require( './HeadingItem.js' ),
|
||||
utils = require( './utils.js' );
|
||||
let lastHighlightedPublishedComment = null;
|
||||
|
||||
/**
|
||||
* Draw a semi-transparent rectangle on the page to highlight the given thread item.
|
||||
|
@ -165,7 +165,7 @@ Highlight.prototype.destroy = function () {
|
|||
window.removeEventListener( 'resize', this.updateDebounced );
|
||||
};
|
||||
|
||||
var highlightedTarget = null;
|
||||
let highlightedTarget = null;
|
||||
/**
|
||||
* Highlight the thread item(s) on the page associated with the URL hash or query string
|
||||
*
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
var newTopicButton, ledeSectionDialog;
|
||||
var viewportScrollContainer = null;
|
||||
var wasKeyboardOpen = null;
|
||||
var initialClientHeight = null;
|
||||
let newTopicButton, ledeSectionDialog;
|
||||
let viewportScrollContainer = null;
|
||||
let wasKeyboardOpen = null;
|
||||
let initialClientHeight = null;
|
||||
// Copied from ve.init.Platform.static.isIos
|
||||
var isIos = /ipad|iphone|ipod/i.test( navigator.userAgent );
|
||||
const isIos = /ipad|iphone|ipod/i.test( navigator.userAgent );
|
||||
|
||||
$( document.body ).toggleClass( 'ext-discussiontools-init-ios', isIos );
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
/* global $:off */
|
||||
|
||||
var
|
||||
const
|
||||
utils = require( './utils.js' );
|
||||
|
||||
/**
|
||||
|
@ -270,7 +270,7 @@ function addListItem( comment, replyIndentation ) {
|
|||
*/
|
||||
function removeAddedListItem( node ) {
|
||||
while ( node && node.discussionToolsModified ) {
|
||||
var nextNode;
|
||||
let nextNode;
|
||||
if ( node.discussionToolsModified === 'new' ) {
|
||||
nextNode = node.previousSibling || node.parentNode;
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
/* global moment */
|
||||
var
|
||||
api,
|
||||
seenAutoTopicSubPopup = !!+mw.user.options.get( 'discussiontools-seenautotopicsubpopup' ),
|
||||
const
|
||||
STATE_UNSUBSCRIBED = 0,
|
||||
STATE_SUBSCRIBED = 1,
|
||||
STATE_AUTOSUBSCRIBED = 2,
|
||||
utils = require( './utils.js' ),
|
||||
CommentItem = require( './CommentItem.js' ),
|
||||
HeadingItem = require( './HeadingItem.js' ),
|
||||
HeadingItem = require( './HeadingItem.js' );
|
||||
let api,
|
||||
seenAutoTopicSubPopup = !!+mw.user.options.get( 'discussiontools-seenautotopicsubpopup' ),
|
||||
linksByName = {},
|
||||
buttonsByName = {};
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
/**
|
||||
* @constant
|
||||
*/
|
||||
var NEW_TOPIC_COMMENT_ID = 'new|' + mw.config.get( 'wgRelevantPageName' );
|
||||
const NEW_TOPIC_COMMENT_ID = 'new|' + mw.config.get( 'wgRelevantPageName' );
|
||||
|
||||
/**
|
||||
* @param {Node} node
|
||||
|
@ -14,7 +14,7 @@ function isBlockElement( node ) {
|
|||
return node instanceof HTMLElement && ve.isBlockElement( node );
|
||||
}
|
||||
|
||||
var solTransparentLinkRegexp = /(?:^|\s)mw:PageProp\/(?:Category|redirect|Language)(?=$|\s)/;
|
||||
const solTransparentLinkRegexp = /(?:^|\s)mw:PageProp\/(?:Category|redirect|Language)(?=$|\s)/;
|
||||
|
||||
/**
|
||||
* @param {Node} node
|
||||
|
@ -59,7 +59,7 @@ function isOurGeneratedNode( node ) {
|
|||
}
|
||||
|
||||
// Elements which can't have element children (but some may have text content).
|
||||
var noElementChildrenElementTypes = [
|
||||
const noElementChildrenElementTypes = [
|
||||
// https://html.spec.whatwg.org/multipage/syntax.html#elements-2
|
||||
// Void elements
|
||||
'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input',
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
var
|
||||
const
|
||||
CommentItem = require( 'ext.discussionTools.init' ).CommentItem,
|
||||
HeadingItem = require( 'ext.discussionTools.init' ).HeadingItem;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
var
|
||||
const
|
||||
testUtils = require( './testUtils.js' ),
|
||||
Parser = require( 'ext.discussionTools.init' ).Parser,
|
||||
modifier = require( 'ext.discussionTools.init' ).modifier;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* global moment */
|
||||
var
|
||||
const
|
||||
testUtils = require( './testUtils.js' ),
|
||||
Parser = require( 'ext.discussionTools.init' ).Parser;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
var utils = require( 'ext.discussionTools.init' ).utils;
|
||||
const utils = require( 'ext.discussionTools.init' ).utils;
|
||||
|
||||
module.exports = {};
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
var utils = require( 'ext.discussionTools.init' ).utils;
|
||||
const utils = require( 'ext.discussionTools.init' ).utils;
|
||||
|
||||
QUnit.module( 'mw.dt.utils', QUnit.newMwEnvironment() );
|
||||
|
||||
|
|
Loading…
Reference in a new issue