Skip to content

Commit

Permalink
Merge pull request #1284 from christophercr/feature/tslint-rules-hard…
Browse files Browse the repository at this point in the history
…ening

Feature/tslint rules hardening
  • Loading branch information
SuperITMan committed May 20, 2019
2 parents d934e5f + 321722f commit 7e40365
Show file tree
Hide file tree
Showing 70 changed files with 247 additions and 210 deletions.
20 changes: 11 additions & 9 deletions packages/stark-build/config/tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"defaultSeverity": "error",
"rules": {
// Codelyzer recommended rules
"directive-selector": [true, "attribute", "", "kebab-case"],
"directive-selector": [true, "attribute", "", "camelCase"],
"component-selector": [true, "element", "", "kebab-case"],
"angular-whitespace": [true, "check-interpolation", "check-semicolon"],
"use-input-property-decorator": true,
Expand All @@ -18,9 +18,11 @@
"use-pipe-transform-interface": true,
"no-output-named-after-standard-event": true,
"max-inline-declarations": true,
// "no-life-cycle-call": true, // FIXME: throws an exception (Codelyzer v4.3.0). Enable this rule when solved
"no-life-cycle-call": true,
"prefer-output-readonly": true,
"no-conflicting-life-cycle-hooks": true,
"enforce-component-selector": true,
"no-queries-parameter": true,
"component-class-suffix": [true, "Component"],
"directive-class-suffix": [true, "Directive"],

Expand All @@ -31,7 +33,7 @@
"pipe-impure": true,
"templates-no-negated-async": true,
"use-pipe-decorator": true,
"use-view-encapsulation": false,
"use-view-encapsulation": true,
"trackBy-function": true,
"no-unused-css": true,
"template-cyclomatic-complexity": [true, 10],
Expand Down Expand Up @@ -123,10 +125,10 @@
"encoding": false,
"interface-name": [false, "never-prefix"],
"interface-over-type-literal": true,
"jsdoc-format": false,
"jsdoc-format": [true, "check-multiline-start"],
"no-angle-bracket-type-assertion": false,
"no-parameter-properties": false,
"no-redundant-jsdoc": false,
"no-redundant-jsdoc": true,
"no-reference-import": true,
"no-unnecessary-callback-wrapper": false,
"object-literal-shorthand": false,
Expand Down Expand Up @@ -199,16 +201,16 @@
"deprecation": false,
"use-default-type-parameter": true,
"await-promise": true,
"no-for-in-array": true
"no-for-in-array": true,
// "no-unused-variable": true,
// "strict-boolean-expressions": true,
// "promise-function-async": true,
// "completed-docs": true,
// "no-unbound-method": true,
"no-unbound-method": [true, { "ignore-static": true, "whitelist": ["expect"], "allow-typeof": true }],
// "no-unsafe-any": true,
// "no-unnecessary-type-assertion": true,
"no-unnecessary-type-assertion": true,
// "no-use-before-declare": true,
// "restrict-plus-operands": true,
"restrict-plus-operands": true
// "strict-type-predicates": true,
// "prefer-readonly": true,
}
Expand Down
1 change: 1 addition & 0 deletions packages/stark-build/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"removeComments": false,
"sourceMap": true,
"strict": true,
"strictBindCallApply": true,
"strictFunctionTypes": true,
"strictPropertyInitialization": true,
"strictNullChecks": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,14 @@ export abstract class StarkAbstractHttpFetchResourceRequestBuilder<T extends Sta
}

public addFilterByInclude(...fields: string[]): this {
const fieldNames = fields.join(",");
if (this.request.queryParameters && this.request.queryParameters.has(StarkHttpQueryParameters.FIELDS)) {
this.addQueryParameter(
StarkHttpQueryParameters.FIELDS,
this.request.queryParameters.get(StarkHttpQueryParameters.FIELDS) + "," + fields.join(",")
`${this.request.queryParameters.get(StarkHttpQueryParameters.FIELDS)},${fieldNames}`
);
} else {
this.addQueryParameter(StarkHttpQueryParameters.FIELDS, fields.join(","));
this.addQueryParameter(StarkHttpQueryParameters.FIELDS, fieldNames);
}
return this;
}
Expand All @@ -61,15 +62,14 @@ export abstract class StarkAbstractHttpFetchResourceRequestBuilder<T extends Sta
}

public addSortBy(...sortItems: StarkSortItem[]): this {
const sortValues = sortItems.map((sortBy: StarkSortItem) => sortBy.sortValue).join(",");
if (this.request.queryParameters && this.request.queryParameters.has(StarkHttpQueryParameters.SORT)) {
this.addQueryParameter(
StarkHttpQueryParameters.SORT,
this.request.queryParameters.get(StarkHttpQueryParameters.SORT) +
"," +
sortItems.map((sortBy: StarkSortItem) => sortBy.sortValue).join(",")
`${this.request.queryParameters.get(StarkHttpQueryParameters.SORT)},${sortValues}`
);
} else {
this.addQueryParameter(StarkHttpQueryParameters.SORT, sortItems.map((sortBy: StarkSortItem) => sortBy.sortValue).join(","));
this.addQueryParameter(StarkHttpQueryParameters.SORT, sortValues);
}
return this;
}
Expand Down
17 changes: 5 additions & 12 deletions packages/stark-core/src/modules/http/services/http.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,7 @@ export class StarkHttpServiceImpl<P extends StarkResource> implements StarkHttpS
return this.getSingleItemResponseWrapperObservable(httpResponse$, request);
} else {
return throwError(
"Unknown request type encountered " +
request.requestType +
". For collection requests, " +
"call the executeCollectionRequest method"
`Unknown request type encountered ${request.requestType}. For collection requests, call the executeCollectionRequest method`
);
}
}
Expand Down Expand Up @@ -118,10 +115,9 @@ export class StarkHttpServiceImpl<P extends StarkResource> implements StarkHttpS
} else {
// we return directly here because otherwise compilation fails (can't assign the ErrorObservable type to Subject)
return throwError(
"Unknown request type encountered " +
request.requestType +
". For single requests (no " +
"collection), call the executeSingleItemRequest method"
`Unknown request type encountered ${
request.requestType
}. For single requests (no collection), call the executeSingleItemRequest method`
);
}
}
Expand Down Expand Up @@ -360,10 +356,7 @@ export class StarkHttpServiceImpl<P extends StarkResource> implements StarkHttpS
}
} else {
this.logger.warn(
starkHttpServiceName +
": cannot set the etag property in the item '" +
item +
"' because it is not an object"
`${starkHttpServiceName}: cannot set the etag property in the item '${item}' because it is not an object`
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ describe("Service: StarkLoggingService", () => {
for (let i = 1; i <= loggingFlushPersistSize; i++) {
const message: StarkLogMessage = loggingService.constructLogMessageHelper(
StarkLogMessageType.INFO,
"Message " + i,
`Message ${i}`,
dummyObject
);
mockStarkLogging.messages = [...mockStarkLogging.messages, message];
Expand All @@ -286,7 +286,7 @@ describe("Service: StarkLoggingService", () => {
const data: string = JSON.stringify(Serialize(mockStarkLogging, StarkLoggingImpl));
loggingService.persistLogMessagesHelper();
expect(sendRequestSpy).toHaveBeenCalledTimes(1);
expect(sendRequestSpy.calls.mostRecent().args[0]).toBe(loggingBackend.url + "/" + loggingBackend.loginResource);
expect(sendRequestSpy.calls.mostRecent().args[0]).toBe(`${loggingBackend.url}/${loggingBackend.loginResource}`);
expect(sendRequestSpy.calls.mostRecent().args[1]).toBe(data);
expect(sendRequestSpy.calls.mostRecent().args[2]).toBe(true);

Expand All @@ -302,7 +302,7 @@ describe("Service: StarkLoggingService", () => {
const data: string = JSON.stringify(Serialize(mockStarkLogging, StarkLoggingImpl));
loggingService.persistLogMessagesHelper();
expect(sendRequestSpy).toHaveBeenCalledTimes(1);
expect(sendRequestSpy.calls.mostRecent().args[0]).toBe(loggingBackend.url + "/" + loggingBackend.loginResource);
expect(sendRequestSpy.calls.mostRecent().args[0]).toBe(`${loggingBackend.url}/${loggingBackend.loginResource}`);
expect(sendRequestSpy.calls.mostRecent().args[1]).toBe(data);
expect(sendRequestSpy.calls.mostRecent().args[2]).toBe(true);
expect(errorSpy).toHaveBeenCalledTimes(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,9 @@ export class StarkLoggingServiceImpl implements StarkLoggingService {
(error: Error) => {
this.isPersisting = false;
this.retryCounter++;
const errorMsg: string =
starkLoggingServiceName +
": an error occurred while persisting log messages." +
" (retry " +
this.retryCounter +
")";
const errorMsg = `${starkLoggingServiceName}: an error occurred while persisting log messages. (retry ${
this.retryCounter
})`;
this.error(errorMsg, error);
}
);
Expand Down
Loading

0 comments on commit 7e40365

Please sign in to comment.