From 44b9b0fc9455f4d3e0290e85e74c27574a5ea24f Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Mon, 5 Oct 2020 09:56:21 +0100 Subject: [PATCH] Resolved "already declared in upper scope" linting warnings no issue - fixed all `no-shadow` linter warnings - changed `no-shadow` eslint rule from `warn` to `error` so we don't re-introduce shadowed variables in the future --- ghost/admin/.eslintrc.js | 2 ++ .../addon/components/koenig-card-embed.js | 4 ++-- .../koenig-editor/addon/components/koenig-card.js | 4 ++-- .../koenig-editor/addon/components/koenig-editor.js | 12 ++++++------ .../addon/components/koenig-slash-menu.js | 2 +- .../addon/lib/clean-text-replacement-html.js | 4 ++-- .../lib/koenig-editor/addon/options/key-commands.js | 4 ++-- .../addon/services/koenig-drag-drop-handler.js | 5 ++--- ghost/admin/mirage/config/pages.js | 4 ++-- 9 files changed, 21 insertions(+), 20 deletions(-) diff --git a/ghost/admin/.eslintrc.js b/ghost/admin/.eslintrc.js index 1fdba8e0a2..1dc4cfe352 100644 --- a/ghost/admin/.eslintrc.js +++ b/ghost/admin/.eslintrc.js @@ -16,6 +16,8 @@ module.exports = { 'plugin:ghost/ember' ], rules: { + 'no-shadow': ['error'], + // octane 🏎 'ghost/ember/classic-decorator-hooks': 'error', 'ghost/ember/classic-decorator-no-classic-methods': 'error', diff --git a/ghost/admin/lib/koenig-editor/addon/components/koenig-card-embed.js b/ghost/admin/lib/koenig-editor/addon/components/koenig-card-embed.js index 5f7187769b..244e4367b1 100644 --- a/ghost/admin/lib/koenig-editor/addon/components/koenig-card-embed.js +++ b/ghost/admin/lib/koenig-editor/addon/components/koenig-card-embed.js @@ -274,7 +274,7 @@ export default Component.extend({ mutations.forEach(addImageLoadListeners); } - function createMutationObserver(target) { + function createMutationObserver(mutationTarget) { let config = { attributes: true, attributeOldValue: false, @@ -285,7 +285,7 @@ export default Component.extend({ }; let observer = new MutationObserver(mutationObserved); - observer.observe(target, config); // eslint-disable-line ghost/ember/no-observers + observer.observe(mutationTarget, config); // eslint-disable-line ghost/ember/no-observers return observer; } diff --git a/ghost/admin/lib/koenig-editor/addon/components/koenig-card.js b/ghost/admin/lib/koenig-editor/addon/components/koenig-card.js index 065bbd684c..8fba120cb5 100644 --- a/ghost/admin/lib/koenig-editor/addon/components/koenig-card.js +++ b/ghost/admin/lib/koenig-editor/addon/components/koenig-card.js @@ -372,14 +372,14 @@ export default Component.extend({ mutations.forEach(addInputFocusListeners); } - function createMutationObserver(target) { + function createMutationObserver(mutationTarget) { let config = { childList: true, subtree: true }; let observer = new MutationObserver(mutationObserved); - observer.observe(target, config); // eslint-disable-line ghost/ember/no-observers + observer.observe(mutationTarget, config); // eslint-disable-line ghost/ember/no-observers return observer; } diff --git a/ghost/admin/lib/koenig-editor/addon/components/koenig-editor.js b/ghost/admin/lib/koenig-editor/addon/components/koenig-editor.js index e4a0906d32..cec7a61847 100644 --- a/ghost/admin/lib/koenig-editor/addon/components/koenig-editor.js +++ b/ghost/admin/lib/koenig-editor/addon/components/koenig-editor.js @@ -515,14 +515,14 @@ export default Component.extend({ return; } - let operation = function (postEditor) { + let operation = function (operationPostEditor) { // strip all formatting aside from links - postEditor.removeMarkupFromRange( + operationPostEditor.removeMarkupFromRange( editor.activeSection.toRange(), m => m.tagName !== 'a' ); - postEditor.toggleSection(headingTagName); + operationPostEditor.toggleSection(headingTagName); }; this._performEdit(operation, postEditor); @@ -670,7 +670,7 @@ export default Component.extend({ if (typeof shouldDelete === 'string') { let payloadKey = shouldDelete; - shouldDelete = card => isBlank(get(card, payloadKey)); + shouldDelete = cardToDelete => isBlank(get(cardToDelete, payloadKey)); } if (shouldDelete(card)) { @@ -1212,8 +1212,8 @@ export default Component.extend({ if (postEditor) { editOperation(postEditor); } else { - this.editor.run((postEditor) => { - editOperation(postEditor); + this.editor.run((operationPostEditor) => { + editOperation(operationPostEditor); }); } }, diff --git a/ghost/admin/lib/koenig-editor/addon/components/koenig-slash-menu.js b/ghost/admin/lib/koenig-editor/addon/components/koenig-slash-menu.js index c4645c94b3..f614973f4d 100644 --- a/ghost/admin/lib/koenig-editor/addon/components/koenig-slash-menu.js +++ b/ghost/admin/lib/koenig-editor/addon/components/koenig-slash-menu.js @@ -294,7 +294,7 @@ export default Component.extend({ } for (let section of sections) { - let item = section.items.find(item => item.selected); + let item = section.items.find(sectionItem => sectionItem.selected); if (item) { return item; } diff --git a/ghost/admin/lib/koenig-editor/addon/lib/clean-text-replacement-html.js b/ghost/admin/lib/koenig-editor/addon/lib/clean-text-replacement-html.js index 50663f1e6b..67dbc2a656 100644 --- a/ghost/admin/lib/koenig-editor/addon/lib/clean-text-replacement-html.js +++ b/ghost/admin/lib/koenig-editor/addon/lib/clean-text-replacement-html.js @@ -9,9 +9,9 @@ export default function cleanTextReplacementHtml(html = '', _options = {}) { throw new Error('cleanTextReplacementHtml() must be passed a `createDocument` function as an option when used in a non-browser environment'); } - options.createDocument = function (html) { + options.createDocument = function (documentHtml) { const parser = new Parser(); - return parser.parseFromString(html, 'text/html'); + return parser.parseFromString(documentHtml, 'text/html'); }; } diff --git a/ghost/admin/lib/koenig-editor/addon/options/key-commands.js b/ghost/admin/lib/koenig-editor/addon/options/key-commands.js index 9de565d683..d2af249282 100644 --- a/ghost/admin/lib/koenig-editor/addon/options/key-commands.js +++ b/ghost/admin/lib/koenig-editor/addon/options/key-commands.js @@ -182,7 +182,7 @@ export const DEFAULT_KEY_COMMANDS = [{ let hasReversed = false; specialMarkupTagNames.forEach((tagName) => { // only continue if we're about to delete a special markup - let markup = marker.markups.find(markup => markup.tagName.toUpperCase() === tagName); + let markup = marker.markups.find(markerMarkup => markerMarkup.tagName.toUpperCase() === tagName); if (markup) { let nextMarker = head.markerIn(1); // ensure we're at the end of the markup not inside it @@ -197,7 +197,7 @@ export const DEFAULT_KEY_COMMANDS = [{ markdown = markdown.char; } - let range = editor.range.expandByMarker(marker => !!marker.markups.includes(markup)); + let range = editor.range.expandByMarker(markerToExpand => !!markerToExpand.markups.includes(markup)); // replaced markdown (default) will have chars removed when formatted // and added back when the format is removed by backspace diff --git a/ghost/admin/lib/koenig-editor/addon/services/koenig-drag-drop-handler.js b/ghost/admin/lib/koenig-editor/addon/services/koenig-drag-drop-handler.js index 79c1a9debe..00ba068b73 100644 --- a/ghost/admin/lib/koenig-editor/addon/services/koenig-drag-drop-handler.js +++ b/ghost/admin/lib/koenig-editor/addon/services/koenig-drag-drop-handler.js @@ -230,8 +230,7 @@ export default Service.extend({ this.set('isDragging', true); utils.applyUserSelect(document.body, 'none'); - let container = this.sourceContainer; - let draggableInfo = container.getDraggableInfo(this.grabbedElement); + let draggableInfo = this.sourceContainer.getDraggableInfo(this.grabbedElement); if (!draggableInfo) { this._resetDrag(); @@ -261,7 +260,7 @@ export default Service.extend({ // create the ghost element and cache it's position so avoid costly // getBoundingClientRect calls in the mousemove handler - let ghostElement = container.createGhostElement(this.draggableInfo); + let ghostElement = this.sourceContainer.createGhostElement(this.draggableInfo); if (ghostElement && ghostElement instanceof HTMLElement) { this._ghostContainerElement.appendChild(ghostElement); let ghostElementRect = ghostElement.getBoundingClientRect(); diff --git a/ghost/admin/mirage/config/pages.js b/ghost/admin/mirage/config/pages.js index 96d99e7142..1eae8354aa 100644 --- a/ghost/admin/mirage/config/pages.js +++ b/ghost/admin/mirage/config/pages.js @@ -78,11 +78,11 @@ export default function mockPages(server) { let statusFilter = extractFilterParam('status', filter); - let collection = pages.all().filter((page) => { + let collection = pages.all().filter((pageModel) => { let matchesStatus = true; if (!isEmpty(statusFilter)) { - matchesStatus = statusFilter.includes(page.status); + matchesStatus = statusFilter.includes(pageModel.status); } return matchesStatus;