Merge pull request #5323 from tsiegleauq/linter-prettier-updates

Update linting rules
This commit is contained in:
Finn Stutzenstein 2020-04-22 17:32:42 +02:00 committed by GitHub
commit 6a488eb78e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 130 additions and 69 deletions

View File

@ -99,8 +99,8 @@ export class AppLoadService {
private isSearchableModelEntry(entry: ModelEntry | SearchableModelEntry): entry is SearchableModelEntry {
if ((<SearchableModelEntry>entry).searchOrder !== undefined) {
// We need to double check, because Typescipt cannot check contructors. If typescript could differentiate
// between (ModelConstructor<BaseModel>) and (new (...args: any[]) => (BaseModel & Searchable)), we would not have
// to check if the result of the contructor (the model instance) is really a searchable.
// between (ModelConstructor<BaseModel>) and (new (...args: any[]) => (BaseModel & Searchable)),
// we would not have 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.model.COLLECTIONSTRING}: you gave a searchOrder, but the model is not searchable.`

View File

@ -160,7 +160,8 @@ interface JsonStorage {
}
/**
* TODO: Avoid circular dependencies between `DataStoreUpdateManagerService` and `DataStoreService` and split them into two files
* TODO: Avoid circular dependencies between `DataStoreUpdateManagerService` and
* `DataStoreService` and split them into two files
*/
@Injectable({
providedIn: 'root'

View File

@ -47,8 +47,8 @@ export class PdfError extends Error {
* Provides the general document structure for PDF documents, such as page margins, header, footer and styles.
* Also provides general purpose open and download functions.
*
* Use a local pdf service (i.e. MotionPdfService) to get the document definition for the content and use this service to
* open or download the pdf document
* Use a local pdf service (i.e. MotionPdfService) to get the document definition for the content and
* use this service to open or download the pdf document
*
* @example
* ```ts

View File

@ -80,7 +80,8 @@ export class ConfigRepositoryService extends BaseRepository<ViewConfig, Config,
}
/**
* Constructor for ConfigRepositoryService. Requests the constants from the server and creates the config group structure.
* Constructor for ConfigRepositoryService. Requests the constants from the server and creates the config
* group structure.
*
* @param DS The DataStore
* @param mapperService Maps collection strings to classes

View File

@ -275,7 +275,8 @@ export abstract class BaseFilterListService<V extends BaseViewModel> {
}
/**
* Helper function to get the `viewModelListObservable` of a given repository object and creates dynamic filters for them
* Helper function to get the `viewModelListObservable` of a given repository object and creates dynamic
* filters for them
*
* @param repo repository to create dynamic filters from
* @param filter the OSFilter for the filter property

View File

@ -754,7 +754,10 @@ describe('DiffService', () => {
}));
it('handles inserted paragraphs (2)', inject([DiffService], (service: DiffService) => {
// Specifically, Noch</p> should not be enclosed by <ins>...</ins>, as <ins>Noch </p></ins> would be seriously broken
/**
* Specifically, Noch</p> should not be enclosed by <ins>...</ins>, as <ins>Noch </p></ins>
* would be seriously broken
*/
const before =
"<P>rief sie alle sieben herbei und sprach 'liebe Kinder, ich will hinaus in den Wald, seid </P>",
after =

View File

@ -25,7 +25,8 @@ export enum ModificationType {
}
/**
* This data structure is used when determining the most specific common ancestor of two HTML nodes (`node1` and `node2`)
* This data structure is used when determining the most specific common ancestor of two HTML node
* (`node1` and `node2`)
* within the same Document Fragment.
*/
interface CommonAncestorData {
@ -34,11 +35,13 @@ interface CommonAncestorData {
*/
commonAncestor: Node;
/**
* The nodes inbetween `commonAncestor` and the `node1` in the DOM hierarchy. Empty, if node1 is a direct descendant.
* The nodes inbetween `commonAncestor` and the `node1` in the DOM hierarchy.
* Empty, if node1 is a direct descendant.
*/
trace1: Node[];
/**
* The nodes inbetween `commonAncestor` and the `node2` in the DOM hierarchy. Empty, if node2 is a direct descendant.
* The nodes inbetween `commonAncestor` and the `node2` in the DOM hierarchy.
* Empty, if node2 is a direct descendant.
*/
trace2: Node[];
/**
@ -109,7 +112,8 @@ export interface LineRange {
/**
* The end line number.
* HINT: As this object is usually referring to actual line numbers, not lines,
* the line starting by `to` is not included in the extracted content anymore, only the text between `from` and `to`.
* the line starting by `to` is not included in the extracted content anymore,
* only the text between `from` and `to`.
*/
to: number;
}
@ -167,7 +171,9 @@ export interface DiffLinesInParagraph {
*
* ```ts
* const lineLength = 80;
* const lineNumberedText = this.lineNumbering.insertLineNumbers('<p>A line</p><p>Another line</p><ul><li>A list item</li><li>Yet another item</li></ul>', lineLength);
* const lineNumberedText = this.lineNumbering.insertLineNumbers(
* '<p>A line</p><p>Another line</p><ul><li>A list item</li><li>Yet another item</li></ul>', lineLength
* );
* const extractFrom = 2;
* const extractUntil = 3;
* const extractedData = this.diffService.extractRangeByLineNumbers(lineNumberedText, extractFrom, extractUntil)
@ -197,7 +203,8 @@ export interface DiffLinesInParagraph {
* Given a diff'ed string, apply all changes to receive the new version of the text:
*
* ```ts
* const diffedHtml = '<p>Test <span class="delete">Test 2</span> Another test <del>Test 3</del></p><p class="delete">Test 4</p>';
* const diffedHtml =
* '<p>Test <span class="delete">Test 2</span> Another test <del>Test 3</del></p><p class="delete">Test 4</p>';
* const newVersion = this.diffService.diffHtmlToFinalText(diffedHtml);
* ```
*
@ -205,7 +212,11 @@ export interface DiffLinesInParagraph {
*
* ```ts
* const lineLength = 80;
* const lineNumberedText = this.lineNumbering.insertLineNumbers('<p>A line</p><p>Another line</p><ul><li>A list item</li><li>Yet another item</li></ul>', lineLength);
* const lineNumberedText =
* this.lineNumbering.insertLineNumbers(
* '<p>A line</p><p>Another line</p><ul><li>A list item</li><li>Yet another item</li></ul>',
* lineLength
* );
* const merged = this.diffService.replaceLines(lineNumberedText, '<p>Replaced paragraph</p>', 1, 2);
* ```
*/
@ -1063,7 +1074,8 @@ export class DiffService {
}
/**
* This fixes a very specific, really weird bug that is tested in the test case "does not a change in a very specific case".
* This fixes a very specific, really weird bug that is tested in the test case "does not a change in a very
* specific case.
*
* @param {string}diffStr
* @return {string}
@ -1178,7 +1190,8 @@ export class DiffService {
/**
* Given a DOM tree and a specific node within that tree, this method returns the HTML string from the beginning
* of this tree up to this node.
* The returned string in itself is not renderable, as it stops in the middle of the complete HTML, with opened tags.
* The returned string in itself is not renderable, as it stops in the middle of the complete HTML, with
* opened tags.
*
* Implementation hint: the first element of "toChildTrace" array needs to be a child element of "node"
* @param {Node} node
@ -1228,7 +1241,8 @@ export class DiffService {
/**
* Given a DOM tree and a specific node within that tree, this method returns the HTML string beginning after this
* node to the end of the tree.
* The returned string in itself is not renderable, as it starts in the middle of the complete HTML, with opened tags.
* The returned string in itself is not renderable, as it starts in the middle of the complete HTML
* with opened tags.
*
* Implementation hint: the first element of "fromChildTrace" array needs to be a child element of "node"
* @param {Node} node
@ -1283,7 +1297,8 @@ export class DiffService {
* Returns the HTML snippet between two given line numbers.
* extractRangeByLineNumbers
* Hint:
* - The last line (toLine) is not included anymore, as the number refers to the line breaking element at the end of the line
* - The last line (toLine) is not included anymore, as the number refers to the line breaking element at the end
* of the line
* - if toLine === null, then everything from fromLine to the end of the fragment is returned
*
* In addition to the HTML snippet, additional information is provided regarding the most specific DOM element
@ -1296,7 +1311,8 @@ export class DiffService {
* rendering it and for merging it again correctly.
* - os-split-*: These classes are set for all HTML Tags that have been split into two by this process,
* e.g. if the fromLine- or toLine-line-break was somewhere in the middle of this tag.
* If a tag is split, the first one receives "os-split-after", and the second one "os-split-before".
* If a tag is split, the first one receives "os-split-after", and the second
* one "os-split-before".
* For example, for the following string <p>Line 1<br>Line 2<br>Line 3</p>:
* - extracting line 1 to 2 results in <p class="os-split-after">Line 1</p>
* - extracting line 2 to 3 results in <p class="os-split-after os-split-before">Line 2</p>
@ -1588,7 +1604,8 @@ export class DiffService {
/**
* This returns the line number range in which changes (insertions, deletions) are encountered.
* As in extractRangeByLineNumbers(), "to" refers to the line breaking element at the end, i.e. the start of the following line.
* As in extractRangeByLineNumbers(), "to" refers to the line breaking element at the end, i.e. the start of the
* following line.
*
* @param {string} diffHtml
* @returns {LineRange}

View File

@ -29,7 +29,8 @@ export interface LineNumberRange {
/**
* The end line number.
* HINT: As this object is usually referring to actual line numbers, not lines,
* the line starting by `to` is not included in the extracted content anymore, only the text between `from` and `to`.
* the line starting by `to` is not included in the extracted content anymore, only the text between
* `from` and `to`.
*/
to: number;
}
@ -67,7 +68,9 @@ interface SectionHeading {
*
* Removing line numbers from a line-numbered string:
* ```ts
* const lineNumberedHtml = '<p><span class="os-line-number line-number-1" data-line-number="1" contenteditable="false">&nbsp;</span>Lorem ipsum dolorsit amet</p>';
* const lineNumberedHtml =
* '<p><span class="os-line-number line-number-1" data-line-number="1" contenteditable="false">&nbsp;</span>
* Lorem ipsum dolorsit amet</p>';
* const originalHtml = this.lineNumbering.stripLineNumbers(inHtml);
* ```
*
@ -118,7 +121,8 @@ export class LinenumberingService {
// The line number counter
private currentLineNumber: number = null;
// Indicates that we just entered a block element and we want to add a line number without line break at the beginning.
// Indicates that we just entered a block element and we want to add a line number without line break
// at the beginning.
private prependLineNumberToFirstText = false;
// A workaround to prevent double line numbers

View File

@ -354,7 +354,8 @@ export class TreeService {
*
* @param item The current item from which the flat node will be created.
* @param level The level the flat node will be.
* @param additionalTag Optional: A key of the items. If this parameter is set, the nodes will have a tag for filtering them.
* @param additionalTag Optional: A key of the items. If this parameter is set,
* the nodes will have a tag for filtering them.
*
* @returns An array containing the parent node with all its children.
*/

View File

@ -62,7 +62,8 @@ export class LogoComponent implements OnInit, OnDestroy {
/**
* Get the image based on custom images and footer.
* If a custom image is set and this component is displayed as footer or there is no custom image, then the OpenSlides logo is used.
* If a custom image is set and this component is displayed as footer or there is no custom image, then the
* OpenSlides logo is used.
*
* @returns path to image
*/

View File

@ -25,7 +25,8 @@ import { Selectable } from '../selectable';
/**
* Searchable Value Selector
*
* Use `multiple="true"`, `[inputListValues]=myValues`,`formControlName="myformcontrol"` and `placeholder={{listname}}` to pass the Values and Listname
* Use `multiple="true"`, `[inputListValues]=myValues`,`formControlName="myformcontrol"` and
* `placeholder={{listname}}` to pass the Values and Listname
*
* ## Examples:
*

View File

@ -62,7 +62,8 @@ export class SortFilterBarComponent<V extends BaseViewModel> {
public extraItemInfo: string;
/**
* Optional string to tell the verbose name of the filtered items. This string is displayed, if no filter service is given.
* Optional string to tell the verbose name of the filtered items. This string is displayed,
* if no filter service is given.
*/
@Input()
public itemsVerboseName: string;

View File

@ -865,7 +865,8 @@ export class SortingTreeComponent<T extends Identifiable & Displayable> implemen
/**
* Function to get the data from tree.
*
* @returns An array that contains all necessary information to see the connections between the nodes and their subnodes.
* @returns An array that contains all necessary information to see the connections between the nodes
* and their subnodes.
*/
public getTreeData(): TreeIdNode[] {
return this.treeService.makeTreeFromFlatTree(this.osTreeData);
@ -940,12 +941,13 @@ export class SortingTreeComponent<T extends Identifiable & Displayable> implemen
}
/**
* Function to check recursively the child nodes of a given node whether they will be filtered or if they should be seen.
* Function to check recursively the child nodes of a given node whether they will be filtered
* or if they should be seen.
* The result is necessary to decide whether the parent node is expandable or not.
*
* @param node is the inspected node.
* @param parent optional: If the node has a parent, it is necessary to see if this parent will be filtered or is seen.
*
* @param parent optional: If the node has a parent, it is necessary to see if this parent
* will be filtered or is seen.
* @returns A boolean which describes if the given node will be filtered.
*/
private checkChildrenToBeFiltered(node: FlatNode<T>, parent?: FlatNode<T>): boolean {

View File

@ -7,7 +7,8 @@ import { MatFormFieldControl } from '@angular/material/form-field';
import { Subject, Subscription } from 'rxjs';
/**
* Abstract class to implement some simple logic and provide the subclass as a controllable form-control in `MatFormField`.
* Abstract class to implement some simple logic and provide the subclass as a controllable
* form-control in `MatFormField`.
*
* Please remember to prepare the `providers` in the `@Component`-decorator. Something like:
*

View File

@ -91,7 +91,8 @@ export class AssignmentPollDialogComponent extends BasePollDialogComponent<ViewA
public ngOnInit(): void {
// TODO: not solid.
// on new poll creation, poll.options does not exist, so we have to build a substitute from the assignment candidates
// on new poll creation, poll.options does not exist, so we have to build a substitute
// from the assignment candidates
if (this.pollData) {
if (this.pollData.options) {
this.options = this.pollData.options;

View File

@ -146,7 +146,8 @@ export class ConfigFieldComponent extends BaseComponent implements OnInit, OnDes
* Sets up the form for this config field.
*/
public ngOnInit(): void {
// filter out empty results in group observable. We never have no groups and it messes up the settings change detection
// filter out empty results in group observable. We never have no groups and it messes up
// the settings change detection
this.groupObservable = this.groupRepo
.getViewModelListObservableWithoutDefaultGroup()
.pipe(filter(groups => !!groups.length));

View File

@ -29,7 +29,8 @@ import {
* This component displays the original motion text with the change blocks inside.
* If the user is an administrator, each change block can be rejected.
*
* The line numbers are provided within the pre-rendered HTML, so we have to work with raw HTML and native HTML elements.
* The line numbers are provided within the pre-rendered HTML, so we have to work with raw HTML
* and native HTML elements.
*
* It takes the styling from the parent component.
*

View File

@ -20,7 +20,8 @@ import { ViewMotionChangeRecommendation } from 'app/site/motions/models/view-mot
* It's called from motion-details for displaying the whole motion text as well as from the diff view to show the
* unchanged parts of the motion.
*
* The line numbers are provided within the pre-rendered HTML, so we have to work with raw HTML and native HTML elements.
* The line numbers are provided within the pre-rendered HTML, so we have to work with raw HTML
* and native HTML elements.
*
* It takes the styling from the parent component.
*

View File

@ -730,7 +730,9 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit,
this.contentForm.addControl('text_' + paragraphNo, new FormControl(''));
contentPatch.selected_paragraphs.push(paragraph);
contentPatch.text = formMotion.amendment_paragraphs[paragraphNo]; // Workaround as 'text' is required from the backend
// Workaround as 'text' is required from the backend
contentPatch.text = formMotion.amendment_paragraphs[paragraphNo];
contentPatch['text_' + paragraphNo] = formMotion.amendment_paragraphs[paragraphNo];
}
});
@ -1370,7 +1372,8 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit,
this.pdfExport.exportSingleMotion(this.motion, {
lnMode: this.lnMode === this.LineNumberingMode.Inside ? this.LineNumberingMode.Outside : this.lnMode,
crMode: this.crMode,
comments: this.motion.commentSectionIds.concat([PERSONAL_NOTE_ID]) // export all comment fields as well as personal note
// export all comment fields as well as personal note
comments: this.motion.commentSectionIds.concat([PERSONAL_NOTE_ID])
});
}

View File

@ -206,7 +206,8 @@ export class MotionMultiselectService {
if (selectedChoice.action === choices[0]) {
requestData = motions.map(motion => {
let submitterIds = [...motion.sorted_submitter_ids, ...(selectedChoice.items as number[])];
submitterIds = submitterIds.filter((id, index, self) => self.indexOf(id) === index); // remove duplicates
// remove duplicates
submitterIds = submitterIds.filter((id, index, self) => self.indexOf(id) === index);
return {
id: motion.id,
submitters: submitterIds

View File

@ -78,7 +78,8 @@ export class MotionPdfService {
* @param crMode determine the used change Recommendation mode
* @param contentToExport determine which content is to export. If left out, everything will be exported
* @param infoToExport determine which metaInfo to export. If left out, everything will be exported.
* @param commentsToExport comments to chose for export. If 'allcomments' is set in infoToExport, this selection will be ignored and all comments exported
* @param commentsToExport comments to chose for export. If 'allcomments' is set in infoToExport,
* this selection will be ignored and all comments exported
* @returns doc def for the motion
*/
public motionToDocDef(motion: ViewMotion, exportInfo?: MotionExportInfo): object {

View File

@ -114,7 +114,8 @@ export abstract class BasePollDetailComponent<V extends ViewBasePoll, S extends
this.votesRepo
.getViewModelListObservable()
.pipe(
filter(() => this.poll && this.canSeeVotes), // filter first for valid poll state to avoid unneccessary iteration of potentially thousands of votes
// filter first for valid poll state to avoid unneccessary iteration of potentially thousands of votes
filter(() => this.poll && this.canSeeVotes),
map(votes => votes.filter(vote => vote.option.poll_id === this.poll.id)),
filter(votes => !!votes.length)
)

View File

@ -59,7 +59,8 @@ export class CurrentListOfSpeakersService {
private getCurrentListOfSpeakersForProjector(projector: ViewProjector): ViewListOfSpeakers | null {
const nonStableElements = projector.elements.filter(element => !element.stable);
if (nonStableElements.length > 0) {
const nonStableElement = this.slideManager.getIdentifialbeProjectorElement(nonStableElements[0]); // The normal case is just one non stable slide
// The normal case is just one non stable slide
const nonStableElement = this.slideManager.getIdentifialbeProjectorElement(nonStableElements[0]);
try {
const viewModel = this.projectorService.getViewModelFromProjectorElement(nonStableElement);
if (isBaseViewModelWithListOfSpeakers(viewModel)) {

View File

@ -1,11 +1,7 @@
{
"rulesDirectory": ["node_modules/codelyzer"],
"linterOptions": {
"exclude": [
"src/polyfills.ts",
"src/test.ts",
"src/app/shared/shared.module.ts"
]
"exclude": ["src/polyfills.ts", "src/test.ts", "src/app/shared/shared.module.ts"]
},
"rules": {
"array-type": [true, "array"],
@ -21,6 +17,7 @@
"interface-name": false,
"interface-over-type-literal": true,
"label-position": true,
"max-line-length": [true, { "limit": 120, "ignore-pattern": "^import [^,]+ from" }],
"member-access": false,
"member-ordering": [
true,
@ -30,7 +27,19 @@
],
"no-arg": true,
"no-bitwise": true,
"no-console": [true, "table", "clear", "count", "countReset", "info", "time", "timeEnd", "timeline", "timelineEnd", "trace"],
"no-console": [
true,
"table",
"clear",
"count",
"countReset",
"info",
"time",
"timeEnd",
"timeline",
"timelineEnd",
"trace"
],
"no-consecutive-blank-lines": false,
"no-construct": true,
"no-debugger": true,
@ -51,26 +60,33 @@
"no-var-keyword": true,
"object-literal-key-quotes": [true, "as-needed"],
"object-literal-sort-keys": false,
"ordered-imports": [true, {
"import-source-order": "case-sensitive",
"grouped-imports": true,
"groups": [{
"name": "angular",
"match": "^@angular",
"order": 10
},{
"name": "internal dependencies",
"match": "^(app/|\\.?\\./).*",
"order": 30
},{
"name": "external dependencies",
"_match": "^(?!(app/|\\.?\\./)).*",
"match": ".*",
"order": 20
}],
"named-imports-order": "case-insensitive",
"module-source-path": "basename"
}],
"ordered-imports": [
true,
{
"import-source-order": "case-sensitive",
"grouped-imports": true,
"groups": [
{
"name": "angular",
"match": "^@angular",
"order": 10
},
{
"name": "internal dependencies",
"match": "^(app/|\\.?\\./).*",
"order": 30
},
{
"name": "external dependencies",
"_match": "^(?!(app/|\\.?\\./)).*",
"match": ".*",
"order": 20
}
],
"named-imports-order": "case-insensitive",
"module-source-path": "basename"
}
],
"prefer-const": true,
"radix": true,
"triple-equals": [true, "allow-null-check"],