diff --git a/src/modules/hoc/with-form.js b/src/modules/hoc/with-form.js index 3da457ca6a..50ca31e814 100644 --- a/src/modules/hoc/with-form.js +++ b/src/modules/hoc/with-form.js @@ -23,6 +23,11 @@ export default ( getName = noop ) => ( WrappedComponent ) => { static propTypes = { registerForm: PropTypes.func, postType: PropTypes.string, + createDraft: PropTypes.func, + sendForm: PropTypes.func, + setSubmit: PropTypes.func, + editEntry: PropTypes.func, + maybeRemoveEntry: PropTypes.func, }; componentDidMount() { diff --git a/src/modules/utils/api.js b/src/modules/utils/api.js index ad751b770d..ce16075826 100644 --- a/src/modules/utils/api.js +++ b/src/modules/utils/api.js @@ -11,7 +11,7 @@ import { rest } from '@moderntribe/common/utils/globals'; /** * Send a request into a wp-json endpoint * - * @param {object} params An object with the following properties: + * @param {Object} params An object with the following properties: * - path: Path for the endpoint * - headers: Array of extra headers for the request * - initParams: Params send into the fetch along with headers and credentials diff --git a/src/modules/utils/dom.js b/src/modules/utils/dom.js index 9633bdacf1..e5395bc0cc 100644 --- a/src/modules/utils/dom.js +++ b/src/modules/utils/dom.js @@ -31,7 +31,7 @@ export const isRootNode = ( node ) => node === window.top.document; * Utility to search the parent of a node looking from the current node Up to the highest * node on the DOM Tree * - * @param {(HTMLElement|object)} node - The DOM node where the search starts + * @param {(HTMLElement | Object)} node - The DOM node where the search starts * @param {Function} callback - Is executed on every iteration, it should return a boolean * @returns {boolean} Returns tre if the callback returns true with any of the parents. */ diff --git a/src/modules/utils/proptypes.js b/src/modules/utils/proptypes.js index dcf7110d7f..038ba5b46e 100644 --- a/src/modules/utils/proptypes.js +++ b/src/modules/utils/proptypes.js @@ -39,7 +39,7 @@ export const timeRegex = /^([01]?[0-9]|2[0-3]):[0-5][0-9]$/; * PropTypes check for type string and time format using 24h clock in hh:mm format * e.g. 00:24, 03:57, 21:12 * - * @param {object} props Properties object. + * @param {Object} props Properties object. * @param {string} propName Property name. * @param {string} componentName Component name to validate property. */ diff --git a/src/modules/utils/recurrence.js b/src/modules/utils/recurrence.js index 229d631b90..927ebc02cd 100644 --- a/src/modules/utils/recurrence.js +++ b/src/modules/utils/recurrence.js @@ -7,7 +7,7 @@ import { plugins } from '@moderntribe/common/data'; * Returns whether the Event has at least one recurrence rule or not. * * @since 5.0.0 - * @param {object} state The current container state. + * @param {Object} state The current container state. * @returns {boolean} Whether the Event has at least one recurrence rule or not. */ export const hasRecurrenceRules = ( state ) => { @@ -25,7 +25,6 @@ export const hasRecurrenceRules = ( state ) => { * Returns whether tickets are allowed on Recurring events or not. * * @since 5.0.0 - * * @returns {boolean} Whether tickets are allowed on Recurring events or not. */ export const noTicketsOnRecurring = () => { @@ -36,9 +35,8 @@ export const noTicketsOnRecurring = () => { * Returns whether RSVPs are allowed on Recurring events or not. * * @since 5.8.0 - * * @returns {boolean} Whether RSVPs are allowed on Recurring events or not. */ export const noRsvpsOnRecurring = () => { - return document.body.classList.contains( 'tec-no-rsvp-on-recurring' ) + return document.body.classList.contains( 'tec-no-rsvp-on-recurring' ); }; diff --git a/src/modules/utils/time.js b/src/modules/utils/time.js index 7532335f43..c722e757c9 100644 --- a/src/modules/utils/time.js +++ b/src/modules/utils/time.js @@ -30,7 +30,7 @@ export const HOUR_IN_MS = HOUR_IN_SECONDS * SECOND_IN_MS; /** * Formats time object to time string in the format provided * - * @param {object} time Time object to format from + * @param {Object} time Time object to format from * @param {string} format Format of time to format to * @returns {string} Time string in format provided */ diff --git a/src/resources/js/.eslintrc b/src/resources/js/.eslintrc index 6bd019c3cc..afd59f17c1 100644 --- a/src/resources/js/.eslintrc +++ b/src/resources/js/.eslintrc @@ -5,10 +5,17 @@ "browser": true, "es6": true }, + "parserOptions": { + "ecmaVersion": 2018 + }, "rules": { "es5/no-block-scoping": 0, "es5/no-template-literals": 0, - "es5/no-arrow-functions": 0 + "es5/no-arrow-functions": 0, + "es5/no-shorthand-properties": 0, + "es5/no-destructuring": 0, + "es5/no-es6-methods": 0, + "es5/no-spread": 0 }, "globals": { "_": true, @@ -27,6 +34,7 @@ "TribeOnboardingHints": true, "TribeOnboardingTour": true, "tec_automator": true, - "tribe_dropdowns": true + "tribe_dropdowns": true, + "commonIan": true } } diff --git a/src/resources/js/admin/help-hub-iframe.js b/src/resources/js/admin/help-hub-iframe.js index 6acd2b2522..e32fbdb9c0 100644 --- a/src/resources/js/admin/help-hub-iframe.js +++ b/src/resources/js/admin/help-hub-iframe.js @@ -1,3 +1,5 @@ +/* eslint-disable max-len */ +// eslint-disable-next-line no-redeclare var tribe = tribe || {}; tribe.helpPage = tribe.helpPage || {}; window.DocsBotAI = window.DocsBotAI || {}; @@ -5,6 +7,8 @@ window.DocsBotAI = window.DocsBotAI || {}; ( ( $, obj ) => { 'use strict'; + /* global zE, helpHubSettings */ + obj.selectors = { body: 'body', helpHubPageID: 'help-hub-page', @@ -247,7 +251,7 @@ window.DocsBotAI = window.DocsBotAI || {}; if ( element ) { return resolve( element ); } - const observer = new MutationObserver( ( mutations ) => { + const observer = new MutationObserver( () => { const foundElement = document.querySelector( selector ); if ( foundElement ) { resolve( foundElement ); @@ -272,7 +276,7 @@ window.DocsBotAI = window.DocsBotAI || {}; obj.initializeDocsBot = () => { const bodyElement = document.getElementById( obj.selectors.helpHubPageID ); document.getElementById(obj.selectors.docsbotWidget).classList.remove( 'hide' ); - DocsBotAI.init = ( e ) => { + window.DocsBotAI.init = ( e ) => { return new Promise( ( resolve, reject ) => { const script = document.createElement( 'script' ); script.type = 'text/javascript'; @@ -289,9 +293,9 @@ window.DocsBotAI = window.DocsBotAI || {}; 'load', () => { Promise.all( [ - window.DocsBotAI.mount( { ...e } ), - obj.observeElement( '#docsbotai-root' ), - ] ) + window.DocsBotAI.mount( { ...e } ), + obj.observeElement( '#docsbotai-root' ), + ] ) .then( resolve ) .catch( reject ); } @@ -306,7 +310,7 @@ window.DocsBotAI = window.DocsBotAI || {}; } ); }; - DocsBotAI.init( { + window.DocsBotAI.init( { id: helpHubSettings.docsbot_key, options: { customCSS: obj.DocsBotAIcss, diff --git a/src/resources/js/admin/help-page.js b/src/resources/js/admin/help-page.js index fa14b7fabc..4e07c8ff6e 100644 --- a/src/resources/js/admin/help-page.js +++ b/src/resources/js/admin/help-page.js @@ -260,7 +260,9 @@ tribe.helpPage = tribe.helpPage || {}; // Find the currently active tab and corresponding container. let currentTab = document.querySelector( '.tec-nav__tab.tec-nav__tab--active' ); - let tabContainer = currentTab ? document.getElementById( currentTab.getAttribute( 'data-tab-target' ) ) : null; + let tabContainer = currentTab + ? document.getElementById( currentTab.getAttribute( 'data-tab-target' ) ) + : null; // Update modal button span text to the active tab’s text by default. if (currentTab) { diff --git a/src/resources/js/ian-client.js b/src/resources/js/ian-client.js index 02f3164b15..4ccc316a8a 100644 --- a/src/resources/js/ian-client.js +++ b/src/resources/js/ian-client.js @@ -29,7 +29,7 @@ window.addEventListener("resize", calculateSidebarPosition); window.addEventListener("scroll", onScroll); - if (Ian.consent == "true") getIan(true); + if (Ian.consent === "true") getIan(true); }; /** @@ -40,7 +40,9 @@ * @return {void} */ const wrapHeadings = () => { - const headings = document.querySelectorAll(".edit-php.post-type-tribe_events h1, .post-php.post-type-tribe_events h1"); + const headings = document.querySelectorAll( + ".edit-php.post-type-tribe_events h1, .post-php.post-type-tribe_events h1" + ); headings.forEach(heading => { const pageAction = heading.nextElementSibling; if (pageAction) { @@ -119,6 +121,7 @@ break; default: + // eslint-disable-next-line no-console console.log('e.composedPath', e.composedPath()); // Not an event we care about. break; @@ -188,7 +191,9 @@ let settingstabs = document.getElementById("tribe-settings-tabs"); if (settingstabs) { - settingstabs = window.innerWidth > 500 ? settingstabs : document.querySelector('.tec-settings-header-wrap'); + settingstabs = window.innerWidth > 500 + ? settingstabs + : document.querySelector('.tec-settings-header-wrap'); rect = settingstabs.getBoundingClientRect(); } @@ -232,7 +237,6 @@ */ const updatePosition = () => { const offset = window.innerWidth > 782 ? 32 : window.innerWidth > 600 ? 46 : 0; - const scrollY = window.scrollY; const initialTop = getParentPosition(); if (initialTop <= offset) { Ian.sidebar.style.top = offset + 'px'; @@ -311,6 +315,7 @@ let read = ""; let unread = ""; + // eslint-disable-next-line es5/no-destructuring, no-unused-vars Object.entries(response.data).forEach(([key, item]) => { if (item.read) { read += item.html; @@ -321,6 +326,7 @@ } }); + // eslint-disable-next-line max-len const separator = `
`; Ian.notifications.innerHTML = unread + separator + read; } @@ -456,12 +462,16 @@ Ian.loader.classList.add("is-hidden"); if (response.success) { + // eslint-disable-next-line es5/no-spread Ian.feed.read = [...Ian.feed.read, ...Ian.feed.unread]; Ian.feed.unread = []; const read = Ian.feed.read.map(item => item.html).join(""); + // eslint-disable-next-line max-len const separator = ``; Ian.notifications.innerHTML = separator + read; - document.querySelectorAll('.ian-sidebar__notification-link--right').forEach(el => el.remove()); + document + .querySelectorAll('.ian-sidebar__notification-link--right') + .forEach(el => el.remove()); updateIan(); } else { console.error("Failed to read all notifications:", response.message || "Unknown error");