Skip to content

Commit

Permalink
feat(stark-all): integrate SonarTS to current TSLint checks. Refactor…
Browse files Browse the repository at this point in the history
… code to fix TSLint violations.

ISSUES CLOSED: #331
  • Loading branch information
christophercr committed May 8, 2018
1 parent 5502026 commit 8627ab4
Show file tree
Hide file tree
Showing 26 changed files with 2,116 additions and 3,723 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@
"rxjs": "5.6.0-forward-compat.4",
"stylelint": "9.2.0",
"stylelint-config-prettier": "3.2.0",
"tslint": "5.9.1",
"tslint": "5.10.0",
"tslint-config-prettier": "1.12.0",
"tslint-sonarts": "1.6.0",
"typescript": "2.6.2",
"uglify-es": "3.3.9"
},
Expand Down
9 changes: 8 additions & 1 deletion packages/stark-build/config/tslint.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
{
"extends": ["tslint:latest", "tslint-config-prettier", "codelyzer"],
// FIXME: presets moved to packages/stark-core/tslint.json temporarily due to this issue: https://github.com/palantir/tslint/issues/3874
"defaultSeverity": "error",
"rules": {
// sonarts rules
"cognitive-complexity": false,
"no-duplicate-string": false,
"no-big-function": false,
"no-commented-code": false,

// Codelyzer recommended rules
"directive-selector": [true, "attribute", "", "kebab-case"],
"component-selector": [true, "element", "", "kebab-case"],
Expand Down Expand Up @@ -182,6 +188,7 @@
}
],
"prefer-function-over-method": false,
"prefer-while": true,
"no-import-side-effect": [
true,
{
Expand Down
3 changes: 2 additions & 1 deletion packages/stark-build/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@
"stylelint-webpack-plugin": "0.10.4",
"style-loader": "0.20.3",
"to-string-loader": "1.1.5",
"tslint": "5.9.1",
"tslint": "5.10.0",
"tslint-config-prettier": "1.12.0",
"tslint-loader": "3.6.0",
"tslint-sonarts": "1.6.0",
"uglifyjs-webpack-plugin": "1.2.5",
"url-loader": "1.0.1",
"webpack": "3.11.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/stark-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
},
"devDependencies": {
"@nationalbankbelgium/stark-testing": "../stark-testing",
"tslint": "5.9.1"
"tslint": "5.10.0"
},
"peerDependencies": {
"@angular/common": "5.x",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { StarkHttpRequest, StarkResource } from "../entities";
import { StarkHttpRequest, StarkQueryParam, StarkResource } from "../entities";

export interface StarkHttpBaseRequestBuilder<T extends StarkResource> {
/**
Expand All @@ -17,7 +17,7 @@ export interface StarkHttpBaseRequestBuilder<T extends StarkResource> {
* @param allowEmpty - (Optional) Whether to include the query parameter even if it is an empty string. Default: false.
* @returns The current builder
*/
addQueryParameter(name: string, value: string | string[] | undefined, allowUndefined?: boolean, allowEmpty?: boolean): this;
addQueryParameter(name: string, value: StarkQueryParam, allowUndefined?: boolean, allowEmpty?: boolean): this;

/**
* Adds query parameters to the request (adds them to the existing query parameters)
Expand All @@ -26,7 +26,7 @@ export interface StarkHttpBaseRequestBuilder<T extends StarkResource> {
* @param allowEmpty - (Optional) Whether to include the query parameter even if it is an empty string. Default: false.
* @returns The current builder
*/
addQueryParameters(params: { [param: string]: string | string[] | undefined }, allowUndefined?: boolean, allowEmpty?: boolean): this;
addQueryParameters(params: { [param: string]: StarkQueryParam }, allowUndefined?: boolean, allowEmpty?: boolean): this;

/**
* Sets query parameters to the request (all existing query parameters will be lost)
Expand All @@ -35,7 +35,7 @@ export interface StarkHttpBaseRequestBuilder<T extends StarkResource> {
* @param allowEmpty - (Optional) Whether to include the query parameter even if it is an empty string. Default: false.
* @returns The current builder
*/
setQueryParameters(params: { [param: string]: string | string[] | undefined }, allowUndefined?: boolean, allowEmpty?: boolean): this;
setQueryParameters(params: { [param: string]: StarkQueryParam }, allowUndefined?: boolean, allowEmpty?: boolean): this;

/**
* Interpolates the parameters in the resource path with actual values
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { StarkHttpRequest, StarkResource } from "../entities";
import { StarkHttpRequest, StarkQueryParam, StarkResource } from "../entities";
import { StarkHttpBaseRequestBuilder } from "./http-abstract-base-request-builder.intf";
import { StarkUrlUtil } from "../../util/url-util";

Expand All @@ -16,20 +16,15 @@ export abstract class StarkAbstractHttpBaseRequestBuilder<T extends StarkResourc
return this;
}

public addQueryParameter(
name: string,
value: string | string[] | undefined,
allowUndefined: boolean = false,
allowEmpty: boolean = false
): this {
public addQueryParameter(name: string, value: StarkQueryParam, allowUndefined: boolean = false, allowEmpty: boolean = false): this {
if ((typeof value !== "undefined" || allowUndefined) && (value !== "" || allowEmpty)) {
this.request.queryParameters.set(name, value);
}
return this;
}

public addQueryParameters(
params: { [param: string]: string | string[] | undefined },
params: { [param: string]: StarkQueryParam },
allowUndefined: boolean = false,
allowEmpty: boolean = false
): this {
Expand All @@ -42,7 +37,7 @@ export abstract class StarkAbstractHttpBaseRequestBuilder<T extends StarkResourc
}

public setQueryParameters(
params: { [param: string]: string | string[] | undefined },
params: { [param: string]: StarkQueryParam },
allowUndefined: boolean = false,
allowEmpty: boolean = false
): this {
Expand Down
Loading

0 comments on commit 8627ab4

Please sign in to comment.