diff --git a/.eslintrc.json b/.eslintrc.json index 21d35c47..29364c8f 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -16,7 +16,8 @@ ], "no-implicit-globals": "off", "es/no-object-fromentries": "off", - "es/no-object-entries": "off" + "es/no-object-entries": "off", + "mediawiki/class-doc": "off" }, "parserOptions": { "ecmaVersion": 11 diff --git a/resources/skins.citizen.preferences/skins.citizen.preferences.js b/resources/skins.citizen.preferences/skins.citizen.preferences.js index 89abcf11..c8504250 100644 --- a/resources/skins.citizen.preferences/skins.citizen.preferences.js +++ b/resources/skins.citizen.preferences/skins.citizen.preferences.js @@ -226,7 +226,7 @@ function togglePanel() { resetButton = document.getElementById( CLASS + '-resetbutton' ); if ( !panel.classList.contains( CLASS_PANEL_ACTIVE ) ) { - // eslint-disable-next-line mediawiki/class-doc + panel.classList.add( CLASS_PANEL_ACTIVE ); toggle.setAttribute( 'aria-expanded', true ); form.addEventListener( 'input', setPref ); @@ -234,7 +234,7 @@ function togglePanel() { window.addEventListener( 'click', dismissOnClickOutside ); window.addEventListener( 'keydown', dismissOnEscape ); } else { - // eslint-disable-next-line mediawiki/class-doc + panel.classList.remove( CLASS_PANEL_ACTIVE ); toggle.setAttribute( 'aria-expanded', false ); form.removeEventListener( 'input', setPref ); @@ -358,10 +358,10 @@ function initPref( window ) { // citizen-pref container.id = CLASS; - // eslint-disable-next-line mediawiki/class-doc + container.classList.add( CLASS, 'citizen-header__item' ); button.id = CLASS + '-toggle'; - // eslint-disable-next-line mediawiki/class-doc + button.classList.add( CLASS + '__button', 'citizen-header__button', 'citizen-header__button--icon' ); button.setAttribute( 'title', mw.message( 'preferences' ).text() ); button.setAttribute( 'aria-label', mw.message( 'preferences' ).text() ); diff --git a/resources/skins.citizen.scripts.sections/skins.citizen.scripts.sections.js b/resources/skins.citizen.scripts.sections/skins.citizen.scripts.sections.js index 0af4aeb9..5e4390cf 100644 --- a/resources/skins.citizen.scripts.sections/skins.citizen.scripts.sections.js +++ b/resources/skins.citizen.scripts.sections/skins.citizen.scripts.sections.js @@ -21,10 +21,10 @@ function initCollapsibleSections( document ) { // TODO: Need a keyboard handler headings[ i ].addEventListener( 'click', function () { // .section-heading--collapsed - // eslint-disable-next-line mediawiki/class-doc + this.classList.toggle( prefix + 'heading--collapsed' ); // .section-collapsible--collapsed - // eslint-disable-next-line mediawiki/class-doc + sections[ j ].classList.toggle( prefix + 'collapsible--collapsed' ); headline.setAttribute( 'aria-expanded', headline.getAttribute( 'aria-expanded' ) === 'true' ? 'false' : 'true' ); } ); diff --git a/resources/skins.citizen.scripts/inline.js b/resources/skins.citizen.scripts/inline.js index 6b435b06..bde1a313 100644 --- a/resources/skins.citizen.scripts/inline.js +++ b/resources/skins.citizen.scripts/inline.js @@ -47,7 +47,7 @@ window.applyPref = () => { // * skin-citizen-light // * skin-citizen-dark htmlElement.classList.remove( ...classNames( prefix ) ); - /* eslint-disable-next-line mediawiki/class-doc */ + htmlElement.classList.add( prefix + theme ); } diff --git a/resources/skins.citizen.scripts/search.js b/resources/skins.citizen.scripts/search.js index a5daddd3..99de993d 100644 --- a/resources/skins.citizen.scripts/search.js +++ b/resources/skins.citizen.scripts/search.js @@ -1,6 +1,6 @@ /* Some of the functions are based on Vector */ /* ESLint does not like having class names as const */ -/* eslint-disable mediawiki/class-doc */ + const SEARCH_INPUT_ID = 'searchInput', SEARCH_LOADING_CLASS = 'citizen-loading'; diff --git a/resources/skins.citizen.search/typeahead.js b/resources/skins.citizen.search/typeahead.js index c9a689d4..6fb1d882 100644 --- a/resources/skins.citizen.search/typeahead.js +++ b/resources/skins.citizen.search/typeahead.js @@ -38,7 +38,6 @@ function toggleActive( element ) { const typeaheadItems = typeahead.querySelectorAll( 'li > a' ), activeClass = 'citizen-typeahead-option--active'; - /* eslint-disable mediawiki/class-doc */ for ( let i = 0; i < typeaheadItems.length; i++ ) { if ( element !== typeaheadItems[ i ] ) { typeaheadItems[ i ].classList.remove( activeClass ); @@ -132,7 +131,7 @@ function clearSuggestions() { } // Remove loading animation - /* eslint-disable-next-line mediawiki/class-doc */ + searchInput.parentNode.classList.remove( SEARCH_LOADING_CLASS ); searchInput.setAttribute( 'aria-activedescendant', '' ); activeIndex.clear(); @@ -190,7 +189,7 @@ function getSuggestions( searchQuery ) { }; // Add loading animation - /* eslint-disable-next-line mediawiki/class-doc */ + searchInput.parentNode.classList.add( SEARCH_LOADING_CLASS ); /* eslint-disable-next-line compat/compat */ @@ -216,7 +215,7 @@ function getSuggestions( searchQuery ) { activeIndex.setMax( results.length ); } ).catch( ( error ) => { searchInput.removeEventListener( 'input', abortFetch ); - /* eslint-disable-next-line mediawiki/class-doc */ + searchInput.parentNode.classList.remove( SEARCH_LOADING_CLASS ); // User can trigger the abort when the fetch event is pending // There is no need for an error @@ -277,7 +276,7 @@ function initTypeahead( searchForm, input ) { if ( !clickInside ) { searchInput.setAttribute( 'aria-activedescendant', '' ); - /* eslint-disable-next-line mediawiki/class-doc */ + typeahead.classList.remove( expandedClass ); searchInput.removeEventListener( 'keydown', keyboardEvents ); searchInput.removeEventListener( 'blur', onBlur ); @@ -287,7 +286,7 @@ function initTypeahead( searchForm, input ) { const onFocus = function () { // Refresh the typeahead since the query will be emptied when blurred updateTypeahead( messages ); - /* eslint-disable-next-line mediawiki/class-doc */ + typeahead.classList.add( expandedClass ); searchInput.addEventListener( 'keydown', keyboardEvents ); searchInput.addEventListener( 'blur', onBlur );