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
This commit is contained in:
Kevin Ansfield 2020-10-05 09:56:21 +01:00
parent 88f1291e16
commit 68efc5bff3
9 changed files with 21 additions and 20 deletions

View File

@ -16,6 +16,8 @@ module.exports = {
'plugin:ghost/ember' 'plugin:ghost/ember'
], ],
rules: { rules: {
'no-shadow': ['error'],
// octane 🏎 // octane 🏎
'ghost/ember/classic-decorator-hooks': 'error', 'ghost/ember/classic-decorator-hooks': 'error',
'ghost/ember/classic-decorator-no-classic-methods': 'error', 'ghost/ember/classic-decorator-no-classic-methods': 'error',

View File

@ -274,7 +274,7 @@ export default Component.extend({
mutations.forEach(addImageLoadListeners); mutations.forEach(addImageLoadListeners);
} }
function createMutationObserver(target) { function createMutationObserver(mutationTarget) {
let config = { let config = {
attributes: true, attributes: true,
attributeOldValue: false, attributeOldValue: false,
@ -285,7 +285,7 @@ export default Component.extend({
}; };
let observer = new MutationObserver(mutationObserved); 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; return observer;
} }

View File

@ -372,14 +372,14 @@ export default Component.extend({
mutations.forEach(addInputFocusListeners); mutations.forEach(addInputFocusListeners);
} }
function createMutationObserver(target) { function createMutationObserver(mutationTarget) {
let config = { let config = {
childList: true, childList: true,
subtree: true subtree: true
}; };
let observer = new MutationObserver(mutationObserved); 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; return observer;
} }

View File

@ -515,14 +515,14 @@ export default Component.extend({
return; return;
} }
let operation = function (postEditor) { let operation = function (operationPostEditor) {
// strip all formatting aside from links // strip all formatting aside from links
postEditor.removeMarkupFromRange( operationPostEditor.removeMarkupFromRange(
editor.activeSection.toRange(), editor.activeSection.toRange(),
m => m.tagName !== 'a' m => m.tagName !== 'a'
); );
postEditor.toggleSection(headingTagName); operationPostEditor.toggleSection(headingTagName);
}; };
this._performEdit(operation, postEditor); this._performEdit(operation, postEditor);
@ -670,7 +670,7 @@ export default Component.extend({
if (typeof shouldDelete === 'string') { if (typeof shouldDelete === 'string') {
let payloadKey = shouldDelete; let payloadKey = shouldDelete;
shouldDelete = card => isBlank(get(card, payloadKey)); shouldDelete = cardToDelete => isBlank(get(cardToDelete, payloadKey));
} }
if (shouldDelete(card)) { if (shouldDelete(card)) {
@ -1212,8 +1212,8 @@ export default Component.extend({
if (postEditor) { if (postEditor) {
editOperation(postEditor); editOperation(postEditor);
} else { } else {
this.editor.run((postEditor) => { this.editor.run((operationPostEditor) => {
editOperation(postEditor); editOperation(operationPostEditor);
}); });
} }
}, },

View File

@ -294,7 +294,7 @@ export default Component.extend({
} }
for (let section of sections) { for (let section of sections) {
let item = section.items.find(item => item.selected); let item = section.items.find(sectionItem => sectionItem.selected);
if (item) { if (item) {
return item; return item;
} }

View File

@ -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'); 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(); const parser = new Parser();
return parser.parseFromString(html, 'text/html'); return parser.parseFromString(documentHtml, 'text/html');
}; };
} }

View File

@ -182,7 +182,7 @@ export const DEFAULT_KEY_COMMANDS = [{
let hasReversed = false; let hasReversed = false;
specialMarkupTagNames.forEach((tagName) => { specialMarkupTagNames.forEach((tagName) => {
// only continue if we're about to delete a special markup // 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) { if (markup) {
let nextMarker = head.markerIn(1); let nextMarker = head.markerIn(1);
// ensure we're at the end of the markup not inside it // ensure we're at the end of the markup not inside it
@ -197,7 +197,7 @@ export const DEFAULT_KEY_COMMANDS = [{
markdown = markdown.char; 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 // replaced markdown (default) will have chars removed when formatted
// and added back when the format is removed by backspace // and added back when the format is removed by backspace

View File

@ -230,8 +230,7 @@ export default Service.extend({
this.set('isDragging', true); this.set('isDragging', true);
utils.applyUserSelect(document.body, 'none'); utils.applyUserSelect(document.body, 'none');
let container = this.sourceContainer; let draggableInfo = this.sourceContainer.getDraggableInfo(this.grabbedElement);
let draggableInfo = container.getDraggableInfo(this.grabbedElement);
if (!draggableInfo) { if (!draggableInfo) {
this._resetDrag(); this._resetDrag();
@ -261,7 +260,7 @@ export default Service.extend({
// create the ghost element and cache it's position so avoid costly // create the ghost element and cache it's position so avoid costly
// getBoundingClientRect calls in the mousemove handler // getBoundingClientRect calls in the mousemove handler
let ghostElement = container.createGhostElement(this.draggableInfo); let ghostElement = this.sourceContainer.createGhostElement(this.draggableInfo);
if (ghostElement && ghostElement instanceof HTMLElement) { if (ghostElement && ghostElement instanceof HTMLElement) {
this._ghostContainerElement.appendChild(ghostElement); this._ghostContainerElement.appendChild(ghostElement);
let ghostElementRect = ghostElement.getBoundingClientRect(); let ghostElementRect = ghostElement.getBoundingClientRect();

View File

@ -78,11 +78,11 @@ export default function mockPages(server) {
let statusFilter = extractFilterParam('status', filter); let statusFilter = extractFilterParam('status', filter);
let collection = pages.all().filter((page) => { let collection = pages.all().filter((pageModel) => {
let matchesStatus = true; let matchesStatus = true;
if (!isEmpty(statusFilter)) { if (!isEmpty(statusFilter)) {
matchesStatus = statusFilter.includes(page.status); matchesStatus = statusFilter.includes(pageModel.status);
} }
return matchesStatus; return matchesStatus;