From 213fc308008353fbf09d564cdc4a36e1527c7f15 Mon Sep 17 00:00:00 2001 From: FinnStutzenstein Date: Wed, 12 Jun 2019 08:01:33 +0200 Subject: [PATCH] Update prettier --- client/package.json | 4 +- .../core/core-services/app-load.service.ts | 4 +- .../agenda/item-repository.service.ts | 4 +- .../list-of-speakers-repository.service.ts | 4 +- .../config/config-repository.service.ts | 8 +-- .../motions/motion-repository.service.ts | 14 ++-- .../src/app/core/ui-services/diff.service.ts | 66 ++++++++----------- .../core/ui-services/linenumbering.service.ts | 26 ++++---- .../agenda-sort/agenda-sort.component.ts | 8 +-- .../amendment-create-wizard.component.ts | 34 +++++----- .../motion-detail/motion-detail.component.ts | 53 ++++++--------- 11 files changed, 91 insertions(+), 134 deletions(-) diff --git a/client/package.json b/client/package.json index 4ba41e54c..66edbc7b8 100644 --- a/client/package.json +++ b/client/package.json @@ -49,9 +49,9 @@ "hammerjs": "^2.0.8", "material-icon-font": "git+https://github.com/petergng/materialIconFont.git", "ng-pick-datetime": "^7.0.0", + "ng2-pdf-viewer": "^5.2.3", "ngx-file-drop": "^6.0.0", "ngx-mat-select-search": "^1.7.2", - "ng2-pdf-viewer": "^5.2.3", "ngx-papaparse": "^3.0.2", "pdfmake": "^0.1.53", "po2json": "^1.0.0-alpha", @@ -83,7 +83,7 @@ "karma-jasmine-html-reporter": "^1.4.0", "npm-license-crawler": "^0.2.1", "npm-run-all": "^4.1.5", - "prettier": "^1.17.0", + "prettier": "^1.18.0", "protractor": "^5.4.2", "source-map-explorer": "^1.7.0", "ts-node": "~8.1.0", diff --git a/client/src/app/core/core-services/app-load.service.ts b/client/src/app/core/core-services/app-load.service.ts index 1a1660013..86febe4f2 100644 --- a/client/src/app/core/core-services/app-load.service.ts +++ b/client/src/app/core/core-services/app-load.service.ts @@ -111,9 +111,7 @@ export class AppLoadService { // to check if the result of the contructor (the model instance) is really a searchable. if (!isSearchable(new entry.viewModel())) { throw Error( - `Wrong configuration for ${ - entry.collectionString - }: you gave a searchOrder, but the model is not searchable.` + `Wrong configuration for ${entry.collectionString}: you gave a searchOrder, but the model is not searchable.` ); } return true; diff --git a/client/src/app/core/repositories/agenda/item-repository.service.ts b/client/src/app/core/repositories/agenda/item-repository.service.ts index 155557ed7..c0a6b0cff 100644 --- a/client/src/app/core/repositories/agenda/item-repository.service.ts +++ b/client/src/app/core/repositories/agenda/item-repository.service.ts @@ -112,9 +112,7 @@ export class ItemRepositoryService extends BaseHasContentObjectRepository< return contentObject; } else { throw new Error( - `The content object (${agendaItem.content_object.collection}, ${ - agendaItem.content_object.id - }) of item ${agendaItem.id} is not a BaseAgendaItemViewModel.` + `The content object (${agendaItem.content_object.collection}, ${agendaItem.content_object.id}) of item ${agendaItem.id} is not a BaseAgendaItemViewModel.` ); } } diff --git a/client/src/app/core/repositories/agenda/list-of-speakers-repository.service.ts b/client/src/app/core/repositories/agenda/list-of-speakers-repository.service.ts index 7de503a82..47301e3b2 100644 --- a/client/src/app/core/repositories/agenda/list-of-speakers-repository.service.ts +++ b/client/src/app/core/repositories/agenda/list-of-speakers-repository.service.ts @@ -130,9 +130,7 @@ export class ListOfSpeakersRepositoryService extends BaseHasContentObjectReposit return contentObject; } else { throw new Error( - `The content object (${listOfSpeakers.content_object.collection}, ${ - listOfSpeakers.content_object.id - }) of list of speakers ${listOfSpeakers.id} is not a BaseListOfSpeakersViewModel.` + `The content object (${listOfSpeakers.content_object.collection}, ${listOfSpeakers.content_object.id}) of list of speakers ${listOfSpeakers.id} is not a BaseListOfSpeakersViewModel.` ); } } diff --git a/client/src/app/core/repositories/config/config-repository.service.ts b/client/src/app/core/repositories/config/config-repository.service.ts index 8edce1d52..d2b719145 100644 --- a/client/src/app/core/repositories/config/config-repository.service.ts +++ b/client/src/app/core/repositories/config/config-repository.service.ts @@ -238,9 +238,7 @@ export class ConfigRepositoryService extends BaseRepository { return this.getViewModelListObservable().pipe( - map( - (motions: ViewMotion[]): ViewMotion[] => { - return motions.filter( - (motion: ViewMotion): boolean => { - return motion.parent_id === motionId; - } - ); - } - ) + map((motions: ViewMotion[]): ViewMotion[] => { + return motions.filter((motion: ViewMotion): boolean => { + return motion.parent_id === motionId; + }); + }) ); } diff --git a/client/src/app/core/ui-services/diff.service.ts b/client/src/app/core/ui-services/diff.service.ts index 1cc637550..ed7c174a4 100644 --- a/client/src/app/core/ui-services/diff.service.ts +++ b/client/src/app/core/ui-services/diff.service.ts @@ -967,21 +967,18 @@ export class DiffService { * @returns {string} */ public addCSSClassToFirstTag(html: string, className: string): string { - return html.replace( - /<[a-z][^>]*>/i, - (match: string): string => { - if (match.match(/class=["'][a-z0-9 _-]*["']/i)) { - return match.replace( - /class=["']([a-z0-9 _-]*)["']/i, - (match2: string, previousClasses: string): string => { - return 'class="' + previousClasses + ' ' + className + '"'; - } - ); - } else { - return match.substring(0, match.length - 1) + ' class="' + className + '">'; - } + return html.replace(/<[a-z][^>]*>/i, (match: string): string => { + if (match.match(/class=["'][a-z0-9 _-]*["']/i)) { + return match.replace( + /class=["']([a-z0-9 _-]*)["']/i, + (match2: string, previousClasses: string): string => { + return 'class="' + previousClasses + ' ' + className + '"'; + } + ); + } else { + return match.substring(0, match.length - 1) + ' class="' + className + '">'; } - ); + }); } /** @@ -1031,13 +1028,11 @@ export class DiffService { const styles = node.getAttribute('style'); if (styles && styles.indexOf('color') > -1) { const stylesNew = []; - styles.split(';').forEach( - (style: string): void => { - if (!style.match(/^\s*color\s*:/i)) { - stylesNew.push(style); - } + styles.split(';').forEach((style: string): void => { + if (!style.match(/^\s*color\s*:/i)) { + stylesNew.push(style); } - ); + }); if (stylesNew.join(';') === '') { node.removeAttribute('style'); } else { @@ -1060,24 +1055,21 @@ export class DiffService { * @returns {string} */ private addClassToHtmlTag(tagStr: string, className: string): string { - return tagStr.replace( - /<(\w+)( [^>]*)?>/gi, - (whole: string, tag: string, tagArguments: string): string => { - tagArguments = tagArguments ? tagArguments : ''; - if (tagArguments.match(/class="/gi)) { - // class="someclass" => class="someclass insert" - tagArguments = tagArguments.replace( - /(class\s*=\s*)(["'])([^\2]*)\2/gi, - (classWhole: string, attr: string, para: string, content: string): string => { - return attr + para + content + ' ' + className + para; - } - ); - } else { - tagArguments += ' class="' + className + '"'; - } - return '<' + tag + tagArguments + '>'; + return tagStr.replace(/<(\w+)( [^>]*)?>/gi, (whole: string, tag: string, tagArguments: string): string => { + tagArguments = tagArguments ? tagArguments : ''; + if (tagArguments.match(/class="/gi)) { + // class="someclass" => class="someclass insert" + tagArguments = tagArguments.replace( + /(class\s*=\s*)(["'])([^\2]*)\2/gi, + (classWhole: string, attr: string, para: string, content: string): string => { + return attr + para + content + ' ' + className + para; + } + ); + } else { + tagArguments += ' class="' + className + '"'; } - ); + return '<' + tag + tagArguments + '>'; + }); } /** diff --git a/client/src/app/core/ui-services/linenumbering.service.ts b/client/src/app/core/ui-services/linenumbering.service.ts index e11814e7e..ce29aa3f0 100644 --- a/client/src/app/core/ui-services/linenumbering.service.ts +++ b/client/src/app/core/ui-services/linenumbering.service.ts @@ -409,17 +409,15 @@ export class LinenumberingService { }); } } - return headings.sort( - (heading1: SectionHeading, heading2: SectionHeading): number => { - if (heading1.lineNumber < heading2.lineNumber) { - return 0; - } else if (heading1.lineNumber > heading2.lineNumber) { - return 1; - } else { - return 0; - } + return headings.sort((heading1: SectionHeading, heading2: SectionHeading): number => { + if (heading1.lineNumber < heading2.lineNumber) { + return 0; + } else if (heading1.lineNumber > heading2.lineNumber) { + return 1; + } else { + return 0; } - ); + }); } /** @@ -476,11 +474,9 @@ export class LinenumberingService { */ public splitToParagraphs(html: string): string[] { const fragment = this.htmlToFragment(html); - return this.splitNodeToParagraphs(fragment).map( - (node: Element): string => { - return node.outerHTML; - } - ); + return this.splitNodeToParagraphs(fragment).map((node: Element): string => { + return node.outerHTML; + }); } /** diff --git a/client/src/app/site/agenda/components/agenda-sort/agenda-sort.component.ts b/client/src/app/site/agenda/components/agenda-sort/agenda-sort.component.ts index 68688b3ca..834b668db 100644 --- a/client/src/app/site/agenda/components/agenda-sort/agenda-sort.component.ts +++ b/client/src/app/site/agenda/components/agenda-sort/agenda-sort.component.ts @@ -85,11 +85,9 @@ export class AgendaSortComponent extends SortTreeViewComponent impleme */ const filter = this.activeFilters.subscribe((value: number[]) => { this.hasActiveFilter = value.length === 0 ? false : true; - this.changeFilter.emit( - (item: ViewItem): boolean => { - return !(value.includes(item.type) || value.length === 0); - } - ); + this.changeFilter.emit((item: ViewItem): boolean => { + return !(value.includes(item.type) || value.length === 0); + }); }); this.subscriptions.push(filter); } diff --git a/client/src/app/site/motions/modules/motion-detail/components/amendment-create-wizard/amendment-create-wizard.component.ts b/client/src/app/site/motions/modules/motion-detail/components/amendment-create-wizard/amendment-create-wizard.component.ts index 2f0443cc7..1d0e8c4c7 100644 --- a/client/src/app/site/motions/modules/motion-detail/components/amendment-create-wizard/amendment-create-wizard.component.ts +++ b/client/src/app/site/motions/modules/motion-detail/components/amendment-create-wizard/amendment-create-wizard.component.ts @@ -164,17 +164,15 @@ export class AmendmentCreateWizardComponent extends BaseViewComponent { } else { newParagraphs = Object.assign([], oldSelected); newParagraphs.push(paragraph); - newParagraphs.sort( - (para1: ParagraphToChoose, para2: ParagraphToChoose): number => { - if (para1.paragraphNo < para2.paragraphNo) { - return -1; - } else if (para1.paragraphNo > para2.paragraphNo) { - return 1; - } else { - return 0; - } + newParagraphs.sort((para1: ParagraphToChoose, para2: ParagraphToChoose): number => { + if (para1.paragraphNo < para2.paragraphNo) { + return -1; + } else if (para1.paragraphNo > para2.paragraphNo) { + return 1; + } else { + return 0; } - ); + }); this.contentForm.addControl( 'text_' + paragraph.paragraphNo, @@ -206,16 +204,14 @@ export class AmendmentCreateWizardComponent extends BaseViewComponent { */ public async saveAmendment(): Promise { let text = ''; - const amendedParagraphs = this.paragraphs.map( - (paragraph: ParagraphToChoose, index: number): string => { - if (this.contentForm.value.selectedParagraphs.find(para => para.paragraphNo === index)) { - text = this.contentForm.value['text_' + index]; - return this.contentForm.value['text_' + index]; - } else { - return null; - } + const amendedParagraphs = this.paragraphs.map((paragraph: ParagraphToChoose, index: number): string => { + if (this.contentForm.value.selectedParagraphs.find(para => para.paragraphNo === index)) { + text = this.contentForm.value['text_' + index]; + return this.contentForm.value['text_' + index]; + } else { + return null; } - ); + }); const newMotionValues = { ...this.contentForm.value, title: this.translate.instant('Amendment to') + ' ' + this.motion.identifier, diff --git a/client/src/app/site/motions/modules/motion-detail/components/motion-detail/motion-detail.component.ts b/client/src/app/site/motions/modules/motion-detail/components/motion-detail/motion-detail.component.ts index a08668d75..930f57a0b 100644 --- a/client/src/app/site/motions/modules/motion-detail/components/motion-detail/motion-detail.component.ts +++ b/client/src/app/site/motions/modules/motion-detail/components/motion-detail/motion-detail.component.ts @@ -568,22 +568,18 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit, this.allChangingObjects = []; if (this.changeRecommendations) { - this.changeRecommendations.forEach( - (change: ViewUnifiedChange): void => { - this.allChangingObjects.push(change); - } - ); + this.changeRecommendations.forEach((change: ViewUnifiedChange): void => { + this.allChangingObjects.push(change); + }); } if (this.amendments) { - this.amendments.forEach( - (amendment: ViewMotion): void => { - this.repo.getAmendmentAmendedParagraphs(amendment, this.lineLength).forEach( - (change: ViewUnifiedChange): void => { - this.allChangingObjects.push(change); - } - ); - } - ); + this.amendments.forEach((amendment: ViewMotion): void => { + this.repo + .getAmendmentAmendedParagraphs(amendment, this.lineLength) + .forEach((change: ViewUnifiedChange): void => { + this.allChangingObjects.push(change); + }); + }); } this.allChangingObjects.sort((a: ViewUnifiedChange, b: ViewUnifiedChange) => { if (a.getLineFrom() < b.getLineFrom()) { @@ -618,12 +614,10 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit, } } }), - this.repo.amendmentsTo(motionId).subscribe( - (amendments: ViewMotion[]): void => { - this.amendments = amendments; - this.recalcUnifiedChanges(); - } - ), + this.repo.amendmentsTo(motionId).subscribe((amendments: ViewMotion[]): void => { + this.amendments = amendments; + this.recalcUnifiedChanges(); + }), this.changeRecoRepo .getChangeRecosOfMotionObservable(motionId) .subscribe((recos: ViewMotionChangeRecommendation[]) => { @@ -688,20 +682,15 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit, if (parentMotion && this.lineLength) { const paragraphsToChoose = this.repo.getParagraphsToChoose(parentMotion, this.lineLength); - paragraphsToChoose.forEach( - (paragraph: ParagraphToChoose, paragraphNo: number): void => { - if (formMotion.amendment_paragraphs[paragraphNo] !== null) { - this.contentForm.addControl( - 'text_' + paragraphNo, - new FormControl('', Validators.required) - ); + paragraphsToChoose.forEach((paragraph: ParagraphToChoose, paragraphNo: number): void => { + if (formMotion.amendment_paragraphs[paragraphNo] !== null) { + this.contentForm.addControl('text_' + paragraphNo, new FormControl('', Validators.required)); - contentPatch.selected_paragraphs.push(paragraph); - contentPatch.text = formMotion.amendment_paragraphs[paragraphNo]; // Workaround as 'text' is required from the backend - contentPatch['text_' + paragraphNo] = formMotion.amendment_paragraphs[paragraphNo]; - } + contentPatch.selected_paragraphs.push(paragraph); + contentPatch.text = formMotion.amendment_paragraphs[paragraphNo]; // Workaround as 'text' is required from the backend + contentPatch['text_' + paragraphNo] = formMotion.amendment_paragraphs[paragraphNo]; } - ); + }); } }