build: Update eslint-config-wikimedia to 0.10.0
* Add inline exceptions for global selectors * Exception for $.animate in scrolling code * Fix $ prefixing in search.js * Fix repeated selectors in search.js & toc.js * Disable no-parse-html-literal in tests Change-Id: Id58fe11d1e09714501a378e4ca7ed9588f02f32d
This commit is contained in:
parent
6c53e320bf
commit
63ead8075d
|
@ -11,12 +11,7 @@
|
|||
"require": false
|
||||
},
|
||||
"rules": {
|
||||
"no-restricted-properties": [2,
|
||||
{
|
||||
"object": "$",
|
||||
"property": "noop",
|
||||
"message": "Use function() {}"
|
||||
},
|
||||
"no-restricted-properties": [ "error",
|
||||
{
|
||||
"property": "done",
|
||||
"message": "The method `done` if used with Deferred objects is incompatible with ES6 Promises. Please use `then`."
|
||||
|
@ -42,7 +37,7 @@
|
|||
}
|
||||
}],
|
||||
"object-property-newline": "error",
|
||||
"no-use-before-define": 0,
|
||||
"no-underscore-dangle": 0
|
||||
"no-use-before-define": "off",
|
||||
"no-underscore-dangle": "off"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"eslint-config-wikimedia": "0.9.0",
|
||||
"eslint-config-wikimedia": "0.10.0",
|
||||
"grunt": "1.0.3",
|
||||
"grunt-banana-checker": "0.6.0",
|
||||
"grunt-contrib-watch": "1.1.0",
|
||||
|
|
|
@ -93,7 +93,7 @@
|
|||
*/
|
||||
isOpen: function () {
|
||||
// FIXME: We should be moving away from applying classes to the body
|
||||
return $( 'body' ).hasClass( 'navigation-enabled' );
|
||||
return $( document.body ).hasClass( 'navigation-enabled' );
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -103,7 +103,7 @@
|
|||
*/
|
||||
closeNavigationDrawers: function () {
|
||||
// FIXME: We should be moving away from applying classes to the body
|
||||
$( 'body' ).removeClass( 'navigation-enabled' )
|
||||
$( document.body ).removeClass( 'navigation-enabled' )
|
||||
.removeClass( 'secondary-navigation-enabled' )
|
||||
.removeClass( 'primary-navigation-enabled' );
|
||||
},
|
||||
|
@ -121,7 +121,7 @@
|
|||
this.closeNavigationDrawers();
|
||||
drawerType = drawerType || 'primary';
|
||||
// FIXME: We should be moving away from applying classes to the body
|
||||
$( 'body' ).toggleClass( 'navigation-enabled' )
|
||||
$( document.body ).toggleClass( 'navigation-enabled' )
|
||||
.toggleClass( drawerType + '-navigation-enabled' );
|
||||
|
||||
this.emit( 'open' );
|
||||
|
|
|
@ -110,13 +110,16 @@
|
|||
this.$el.on( 'click', this.onClickBadge.bind( this ) );
|
||||
this.options.overlayManager.add( /^\/notifications$/, function () {
|
||||
return self._loadNotificationOverlay().then( function ( overlay ) {
|
||||
// eslint-disable-next-line jquery/no-global-selector
|
||||
var $pageCenter = $( '#mw-mf-page-center' );
|
||||
|
||||
mainMenu.openNavigationDrawer( 'secondary' );
|
||||
overlay.on( 'hide', function () {
|
||||
mainMenu.closeNavigationDrawers();
|
||||
$( '#mw-mf-page-center' ).off( '.secondary' );
|
||||
$pageCenter.off( '.secondary' );
|
||||
} );
|
||||
|
||||
$( '#mw-mf-page-center' ).one( 'click.secondary', function () {
|
||||
$pageCenter.one( 'click.secondary', function () {
|
||||
self.options.router.back();
|
||||
} );
|
||||
return overlay;
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
overlayManager: overlayManager,
|
||||
router: router,
|
||||
mainMenu: mainMenu,
|
||||
// eslint-disable-next-line jquery/no-global-selector
|
||||
el: $( '#secondary-button.user-button' ).parent()
|
||||
} );
|
||||
|
||||
|
@ -35,6 +36,7 @@
|
|||
label: mw.msg( 'mobile-frontend-notifications-filter' )
|
||||
} );
|
||||
|
||||
// eslint-disable-next-line jquery/no-global-selector
|
||||
$( '.mw-echo-ui-notificationsInboxWidget-cell-placeholder' ).append(
|
||||
$( '<div>' )
|
||||
.addClass( 'mw-echo-ui-notificationsInboxWidget-main-toolbar-nav-filter' )
|
||||
|
@ -57,7 +59,9 @@
|
|||
|
||||
// Load the notification filter overlay
|
||||
mw.loader.using( 'mobile.notifications.overlay' ).then( function () {
|
||||
// eslint-disable-next-line jquery/no-global-selector
|
||||
var $crossWikiUnreadFilter = $( '.mw-echo-ui-crossWikiUnreadFilterWidget' ),
|
||||
// eslint-disable-next-line jquery/no-global-selector
|
||||
$notifReadState = $( '.mw-echo-ui-notificationsInboxWidget-main-toolbar-readState' ),
|
||||
NotificationsFilterOverlay = M.require( 'mobile.notifications.overlay/NotificationsFilterOverlay' );
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
* @instance
|
||||
*/
|
||||
onBackToTopClick: function () {
|
||||
// eslint-disable-next-line jquery/no-global-selector, jquery/no-animate
|
||||
$( 'html, body' ).animate( { scrollTop: 0 }, 400 );
|
||||
}
|
||||
} );
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
* @ignore
|
||||
*/
|
||||
function initButton() {
|
||||
// eslint-disable-next-line jquery/no-global-selector
|
||||
$( '.category-button' ).removeClass( 'hidden' );
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
}
|
||||
|
||||
$( function () {
|
||||
// eslint-disable-next-line jquery/no-global-selector
|
||||
if ( !$( '#mw-mf-page-left' ).find( '.menu' ).length ) {
|
||||
// Now we have a main menu button register it.
|
||||
mainMenu.registerClickEvents();
|
||||
|
|
|
@ -61,6 +61,7 @@
|
|||
*/
|
||||
function initButton() {
|
||||
// This catches language selectors in page actions and in secondary actions (e.g. Main Page)
|
||||
// eslint-disable-next-line jquery/no-global-selector
|
||||
var $primaryBtn = $( '.language-selector' );
|
||||
|
||||
if ( $primaryBtn.length ) {
|
||||
|
@ -214,6 +215,7 @@
|
|||
* @ignore
|
||||
*/
|
||||
function initModifiedInfo() {
|
||||
// eslint-disable-next-line jquery/no-global-selector
|
||||
$( '.modified-enhancement' ).each( function () {
|
||||
initHistoryLink( $( this ) );
|
||||
} );
|
||||
|
@ -248,6 +250,7 @@
|
|||
* @ignore
|
||||
*/
|
||||
function initRegistrationInfo() {
|
||||
// eslint-disable-next-line jquery/no-global-selector
|
||||
$( '#tagline-userpage' ).each( function () {
|
||||
initRegistrationDate( $( this ) );
|
||||
} );
|
||||
|
@ -344,6 +347,7 @@
|
|||
disabledClass = disabledEditIcon.getGlyphClassName();
|
||||
|
||||
if ( mw.config.get( 'wgMinervaReadOnly' ) ) {
|
||||
// eslint-disable-next-line jquery/no-global-selector
|
||||
$( '#ca-edit' )
|
||||
.removeClass( enabledClass )
|
||||
.addClass( disabledClass );
|
||||
|
@ -354,6 +358,7 @@
|
|||
// Update anything else that needs enhancing (e.g. watchlist)
|
||||
initModifiedInfo();
|
||||
initRegistrationInfo();
|
||||
// eslint-disable-next-line jquery/no-global-selector
|
||||
initHistoryLink( $( '.last-modifier-tagline a' ) );
|
||||
appendDownloadButton();
|
||||
initRedlinksCta();
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line jquery/no-global-selector
|
||||
$( '#mw-mf-display-toggle' ).on( 'click', desktopViewClick );
|
||||
|
||||
}( mw.mobileFrontend ) );
|
||||
|
|
|
@ -24,8 +24,7 @@
|
|||
* @return {JQuery}
|
||||
*/
|
||||
function createLinkElement( labelText ) {
|
||||
return $( '<a class="cleanup mw-mf-cleanup"></a>' )
|
||||
.text( labelText );
|
||||
return $( '<a>' ).addClass( 'cleanup mw-mf-cleanup' ).text( labelText );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -78,7 +77,7 @@
|
|||
$parentContentContainer.prepend( issue.iconString );
|
||||
$parentContentContainer.prepend( $learnMoreEl );
|
||||
|
||||
$parentContainer.click( function () {
|
||||
$parentContainer.on( 'click', function () {
|
||||
overlayManager.router.navigate( overlayUrl );
|
||||
return false;
|
||||
} );
|
||||
|
@ -95,6 +94,7 @@
|
|||
function createPageIssueNotice( labelText, section ) {
|
||||
var $link = createLinkElement( labelText );
|
||||
$link.attr( 'href', '#/issues/' + section );
|
||||
// eslint-disable-next-line jquery/no-global-selector
|
||||
$link.insertAfter( $( 'h1#section_0' ) );
|
||||
}
|
||||
|
||||
|
@ -230,6 +230,7 @@
|
|||
// set A-B test class.
|
||||
// When wgMinervaPageIssuesNewTreatment is the default this can be removed.
|
||||
if ( newTreatmentEnabled ) {
|
||||
// eslint-disable-next-line jquery/no-global-selector
|
||||
$( 'html' ).addClass( 'issues-group-B' );
|
||||
}
|
||||
|
||||
|
|
|
@ -5,8 +5,11 @@
|
|||
SearchGateway = client.search.SearchGateway,
|
||||
overlayManager = M.require( 'skins.minerva.scripts/overlayManager' ),
|
||||
searchLogger = client.search.MobileWebSearchLogger,
|
||||
searchInput = $( '#searchInput' ),
|
||||
placeholder = searchInput.attr( 'placeholder' ),
|
||||
// eslint-disable-next-line jquery/no-global-selector
|
||||
$searchInput = $( '#searchInput' ),
|
||||
placeholder = $searchInput.attr( 'placeholder' ),
|
||||
// eslint-disable-next-line jquery/no-global-selector
|
||||
$searchBar = $( '#searchInput, #searchIcon, .skin-minerva-search-trigger' ),
|
||||
searchRoute = new RegExp( /\/search/ ),
|
||||
searchOverlayInstance;
|
||||
|
||||
|
@ -35,7 +38,7 @@
|
|||
router: overlayManager.router,
|
||||
gatewayClass: SearchGateway,
|
||||
api: new mw.Api(),
|
||||
searchTerm: searchInput.val(),
|
||||
searchTerm: $searchInput.val(),
|
||||
placeholderMsg: placeholder
|
||||
} );
|
||||
searchLogger.register( searchOverlayInstance );
|
||||
|
@ -47,7 +50,7 @@
|
|||
overlayManager.add( searchRoute, getSearchOverlay );
|
||||
|
||||
// Apparently needed for main menu to work correctly.
|
||||
$( '#searchInput, #searchIcon, .skin-minerva-search-trigger' ).prop( 'readonly', true );
|
||||
$searchBar.prop( 'readonly', true );
|
||||
|
||||
/**
|
||||
* Trigger overlay on touchstart so that the on-screen keyboard on iOS
|
||||
|
@ -55,12 +58,12 @@
|
|||
* triggered unless the element is already visible.
|
||||
* Touchstart makes the overlay visible, touchend brings up the keyboard afterwards.
|
||||
*/
|
||||
$( '#searchInput, #searchIcon, .skin-minerva-search-trigger' ).on( 'touchstart click', function ( ev ) {
|
||||
$searchBar.on( 'touchstart click', function ( ev ) {
|
||||
ev.preventDefault();
|
||||
overlayManager.router.navigate( '/search' );
|
||||
} );
|
||||
|
||||
$( '#searchInput, #searchIcon, .skin-minerva-search-trigger' ).on( 'touchend', function ( ev ) {
|
||||
$searchBar.on( 'touchend', function ( ev ) {
|
||||
ev.preventDefault();
|
||||
/**
|
||||
* Manually triggering focus event because on-screen keyboard only
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
var mobile = M.require( 'mobile.startup' ),
|
||||
Toggler = mobile.Toggler,
|
||||
TableOfContents = mobile.toc.TableOfContents,
|
||||
eventBus = mobile.eventBusSingleton;
|
||||
eventBus = mobile.eventBusSingleton,
|
||||
// eslint-disable-next-line jquery/no-global-selector
|
||||
$toc = $( '#toc' );
|
||||
|
||||
/**
|
||||
* Create TableOfContents if the given Page has sections and is not the main page
|
||||
|
@ -12,13 +14,10 @@
|
|||
* @ignore
|
||||
*/
|
||||
function init( page ) {
|
||||
var toc,
|
||||
sections = page.getSections(),
|
||||
$toc = $( '#toc' );
|
||||
|
||||
toc = new TableOfContents( {
|
||||
sections: sections
|
||||
} );
|
||||
var sections = page.getSections(),
|
||||
toc = new TableOfContents( {
|
||||
sections: sections
|
||||
} );
|
||||
|
||||
// eslint-disable-next-line no-new
|
||||
new Toggler( {
|
||||
|
@ -40,7 +39,7 @@
|
|||
|
||||
// add a ToC only for "view" action (user is reading a page)
|
||||
// provided a table of contents placeholder has been rendered
|
||||
if ( mw.config.get( 'wgAction' ) === 'view' && $( '#toc' ).length > 0 ) {
|
||||
if ( mw.config.get( 'wgAction' ) === 'view' && $toc.length > 0 ) {
|
||||
init( M.getCurrentPage() );
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
var loader = M.require( 'mobile.startup/rlModuleLoader' ),
|
||||
LoadingOverlay = M.require( 'mobile.startup/LoadingOverlay' ),
|
||||
eventBus = new EventEmitter(),
|
||||
// eslint-disable-next-line jquery/no-global-selector
|
||||
$talk = $( '.talk' ),
|
||||
// use the plain return value here - T128273
|
||||
title = $talk.attr( 'data-title' ),
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
( function ( M ) {
|
||||
var page = M.getCurrentPage(),
|
||||
// eslint-disable-next-line jquery/no-global-selector
|
||||
$contentContainer = $( '#mw-content-text > .mw-parser-output' ),
|
||||
Toggler = M.require( 'mobile.startup' ).Toggler,
|
||||
eventBus = M.require( 'mobile.startup/eventBusSingleton' );
|
||||
|
@ -10,6 +11,7 @@
|
|||
}
|
||||
// If there was no mw-parser-output wrapper, just use the parent
|
||||
if ( $contentContainer.length === 0 ) {
|
||||
// eslint-disable-next-line jquery/no-global-selector
|
||||
$contentContainer = $( '#mw-content-text' );
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
* @ignore
|
||||
*/
|
||||
function init( page ) {
|
||||
// eslint-disable-next-line jquery/no-global-selector
|
||||
var $container = $( '#ca-watch' );
|
||||
if ( !page.inNamespace( 'special' ) ) {
|
||||
// eslint-disable-next-line no-new
|
||||
|
|
|
@ -2,5 +2,8 @@
|
|||
"extends": [
|
||||
"wikimedia/qunit",
|
||||
"../../.eslintrc.json"
|
||||
]
|
||||
],
|
||||
"rules": {
|
||||
"jquery/no-parse-html-literal": "off"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue