From 52c7c2ee75ec39d26acde228639ec90aa5f133ed Mon Sep 17 00:00:00 2001 From: bwang Date: Fri, 11 Feb 2022 10:19:59 -0600 Subject: [PATCH] [eslint] Disable mediawiki/class-doc Given our use of constants for tracking classes this eslint rule is more an annoyance than helpful. Change-Id: I37570e3e851997d058f2d93777990dddb3d04089 --- .eslintrc.json | 3 ++- .eslintrcEs6.json | 3 +++ resources/skins.vector.es6/searchToggle.js | 2 -- resources/skins.vector.es6/stickyHeader.js | 9 --------- resources/skins.vector.es6/tableOfContents.js | 4 ---- resources/skins.vector.js/dropdownMenus.js | 1 - resources/skins.vector.js/searchLoader.js | 1 - 7 files changed, 5 insertions(+), 18 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 1926b6e9..7d2bfaaa 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -11,6 +11,7 @@ "ResourceLoader's `packageFiles` do not require wrapping but the `module` option is only available in ES6+." ], "no-implicit-globals": "off", - "compat/compat": "warn" + "compat/compat": "warn", + "mediawiki/class-doc": "off" } } diff --git a/.eslintrcEs6.json b/.eslintrcEs6.json index 72bac248..8a562938 100644 --- a/.eslintrcEs6.json +++ b/.eslintrcEs6.json @@ -17,5 +17,8 @@ "VectorHeaderObserver": "VectorHeaderObserver" } } + }, + "rules": { + "mediawiki/class-doc": "off" } } diff --git a/resources/skins.vector.es6/searchToggle.js b/resources/skins.vector.es6/searchToggle.js index fa6374b3..17103f0d 100644 --- a/resources/skins.vector.es6/searchToggle.js +++ b/resources/skins.vector.es6/searchToggle.js @@ -26,7 +26,6 @@ function bindSearchBoxHandler( searchBox, header ) { !ev.target.closest( '.wvui-typeahead-suggestion' ) && !searchBox.contains( ev.target ) ) { - // eslint-disable-next-line mediawiki/class-doc header.classList.remove( SEARCH_VISIBLE_CLASS ); document.removeEventListener( 'click', clickHandler ); @@ -54,7 +53,6 @@ function bindToggleClickHandler( searchBox, header, searchToggle ) { // from the page when clicked. ev.preventDefault(); - // eslint-disable-next-line mediawiki/class-doc header.classList.add( SEARCH_VISIBLE_CLASS ); // Defer binding the search box handler until after the event bubbles to the diff --git a/resources/skins.vector.es6/stickyHeader.js b/resources/skins.vector.es6/stickyHeader.js index c1886b73..e2eb4f5a 100644 --- a/resources/skins.vector.es6/stickyHeader.js +++ b/resources/skins.vector.es6/stickyHeader.js @@ -35,10 +35,8 @@ function copyAttribute( from, to, attribute ) { */ function show() { if ( header ) { - // eslint-disable-next-line mediawiki/class-doc header.classList.add( STICKY_HEADER_VISIBLE_CLASS ); } - // eslint-disable-next-line mediawiki/class-doc document.body.classList.remove( ULS_HIDE_CLASS ); } @@ -47,9 +45,7 @@ function show() { */ function hide() { if ( header ) { - // eslint-disable-next-line mediawiki/class-doc header.classList.remove( STICKY_HEADER_VISIBLE_CLASS ); - // eslint-disable-next-line mediawiki/class-doc document.body.classList.add( ULS_HIDE_CLASS ); } } @@ -112,7 +108,6 @@ function removeNode( node ) { */ function removeClassFromNodes( nodes, className ) { Array.prototype.forEach.call( nodes, function ( node ) { - // eslint-disable-next-line mediawiki/class-doc node.classList.remove( className ); } ); } @@ -124,12 +119,9 @@ function removeClassFromNodes( nodes, className ) { * @param {string} status 'watched', 'unwatched', or 'temporary' */ function updateStickyWatchlink( watchSticky, status ) { - /* eslint-disable mediawiki/class-doc */ watchSticky.classList.toggle( 'mw-ui-icon-wikimedia-star', status === 'unwatched' ); watchSticky.classList.toggle( 'mw-ui-icon-wikimedia-unStar', status === 'watched' ); watchSticky.classList.toggle( 'mw-ui-icon-wikimedia-halfStar', status === 'temporary' ); - /* eslint-enable mediawiki/class-doc */ - watchSticky.setAttribute( 'data-event-name', status === 'unwatched' ? 'watch-sticky-header' : 'unwatch-sticky-header' ); } @@ -396,7 +388,6 @@ function makeStickyHeaderFunctional( const primaryEdit = protectedEdit || ( veEdit || ceEdit ); const secondaryEdit = veEdit ? ceEdit : null; const disableStickyHeader = () => { - // eslint-disable-next-line mediawiki/class-doc headerElement.classList.remove( STICKY_HEADER_VISIBLE_CLASS ); stickyObserver.unobserve( stickyIntersection ); }; diff --git a/resources/skins.vector.es6/tableOfContents.js b/resources/skins.vector.es6/tableOfContents.js index 5cc07d04..6bacf1be 100644 --- a/resources/skins.vector.es6/tableOfContents.js +++ b/resources/skins.vector.es6/tableOfContents.js @@ -54,19 +54,15 @@ module.exports = function tableOfContents( props ) { const parentSection = /** @type {HTMLElement} */ ( tocSection.closest( `.${PARENT_SECTION_CLASS}` ) ); if ( activeChildSection ) { - // eslint-disable-next-line mediawiki/class-doc activeChildSection.classList.remove( ACTIVE_SECTION_CLASS ); } if ( activeParentSection ) { - // eslint-disable-next-line mediawiki/class-doc activeParentSection.classList.remove( ACTIVE_SECTION_CLASS ); } - // eslint-disable-next-line mediawiki/class-doc tocSection.classList.add( ACTIVE_SECTION_CLASS ); if ( parentSection ) { - // eslint-disable-next-line mediawiki/class-doc parentSection.classList.add( ACTIVE_SECTION_CLASS ); } diff --git a/resources/skins.vector.js/dropdownMenus.js b/resources/skins.vector.js/dropdownMenus.js index 05bf3096..19575bd7 100644 --- a/resources/skins.vector.js/dropdownMenus.js +++ b/resources/skins.vector.js/dropdownMenus.js @@ -66,7 +66,6 @@ function addPortletLinkHandler( item, data ) { if ( isIconCapable && data.id && link ) { // If class was previously added this will be a no-op so it is safe to call even // if we've previously enhanced it. - // eslint-disable-next-line mediawiki/class-doc link.classList.add( 'mw-ui-icon', 'mw-ui-icon-before', diff --git a/resources/skins.vector.js/searchLoader.js b/resources/skins.vector.js/searchLoader.js index b93b7053..4ffe0023 100644 --- a/resources/skins.vector.js/searchLoader.js +++ b/resources/skins.vector.js/searchLoader.js @@ -4,7 +4,6 @@ * That doesn't happen in this file but the linter still throws an error. * https://github.com/wikimedia/eslint-plugin-mediawiki/blob/master/docs/rules/class-doc.md */ -/* eslint-disable mediawiki/class-doc */ /** @interface VectorResourceLoaderVirtualConfig */ /** @interface MediaWikiPageReadyModule */