Skip to content

Commit

Permalink
Lint add --type-check (fixes #824) (#825)
Browse files Browse the repository at this point in the history
  • Loading branch information
lmmrssa authored and paulbert committed May 2, 2018
1 parent 0c16291 commit 34bcaa0
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 88 deletions.
4 changes: 2 additions & 2 deletions git-hooks/pre-push
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ vagrant_status=$(vagrant status --machine-readable | grep state,running)

echo "Running Linters:"
if [ "$vagrant_status" = "" ]; then
tslint=$(ng lint)
tslint=$(npm run lint)
else
tslint=$(vagrant ssh -- -t 'cd /vagrant;ng lint')
tslint=$(vagrant ssh -- -t 'cd /vagrant;npm run lint')
fi

ret_code_tslint=$?
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
"v-test": "vagrant ssh -- -t 'cd /vagrant;ng test'",
"htmlhint": "./node_modules/htmlhint-ng2/bin/htmlhint --config .htmlhintrc",
"sass-lint": "./node_modules/sass-lint/bin/sass-lint.js -c ./sass-lint.yml -v -q",
"lint": "npm run sass-lint && ng lint && npm run htmlhint",
"lint": "ng lint --type-check",
"lint-all": "npm run sass-lint && ng lint --type-check && npm run htmlhint",
"v-lint": "vagrant ssh -- -t 'cd /vagrant;npm run lint -s'",
"v-lint-fix": "vagrant ssh -- -t 'cd /vagrant;ng lint --fix'",
"v-lint-fix": "vagrant ssh -- -t 'cd /vagrant;ng lint --fix --type-check'",
"e2e": "ng e2e --environment test",
"v-e2e": "vagrant ssh -- -t 'cd /vagrant;ng e2e --environment test'",
"install-hooks": "cp -a git-hooks/. .git/hooks/"
Expand Down
12 changes: 6 additions & 6 deletions src/app/configuration/configuration.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ import { forkJoin } from 'rxjs/observable/forkJoin';
import { environment } from '../../environments/environment';
import { switchMap } from 'rxjs/operators';

const removeProtocol = (str: string) => {
// RegEx grabs the fragment of the string between '//' and '/'
// First match includes characters, second does not (so we use second)
return /\/\/(.*?)\//.exec(str)[1];
};

@Component({
selector: 'planet-configuration',
templateUrl: './configuration.component.html'
Expand Down Expand Up @@ -141,9 +147,3 @@ export class ConfigurationComponent implements OnInit {
}

}

const removeProtocol = (str: string) => {
// RegEx grabs the fragment of the string between '//' and '/'
// First match includes characters, second does not (so we use second)
return /\/\/(.*?)\//.exec(str)[1];
};
60 changes: 30 additions & 30 deletions src/app/feedback/feedback.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,36 @@ export class Feedback {
messages: Array<Message>;
}

const dialogFieldOptions = [
{
'label': 'Is your feedback Urgent?',
'type': 'radio',
'name': 'priority',
'options': [
'Yes',
'No',
],
'required': true
},
{
'label': 'Feedback Type:',
'type': 'radio',
'name': 'type',
'options': [
'Question',
'Bug',
'Suggestion',
],
'required': true
},
{
'type': 'textarea',
'name': 'message',
'placeholder': 'Your Feedback',
'required': true
}
];

@Directive({
selector: '[planetFeedback]'
})
Expand Down Expand Up @@ -83,33 +113,3 @@ export class FeedbackDirective {
}

}

const dialogFieldOptions = [
{
'label': 'Is your feedback Urgent?',
'type': 'radio',
'name': 'priority',
'options': [
'Yes',
'No',
],
'required': true
},
{
'label': 'Feedback Type:',
'type': 'radio',
'name': 'type',
'options': [
'Question',
'Bug',
'Suggestion',
],
'required': true
},
{
'type': 'textarea',
'name': 'message',
'placeholder': 'Your Feedback',
'required': true
}
];
32 changes: 16 additions & 16 deletions src/app/login/login-form.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,22 @@ import { CustomValidators } from '../validators/custom-validators';
import { PlanetMessageService } from '../shared/planet-message.service';
import { environment } from '../../environments/environment';

const repeatPassword = {
password: [ '', Validators.compose([
Validators.required,
CustomValidators.matchPassword('repeatPassword', false)
]) ],
repeatPassword: [ '', Validators.compose([
Validators.required,
CustomValidators.matchPassword('password', true)
]) ]
};

const loginForm = {
name: [ '', Validators.required ],
password: [ '', Validators.required ]
};

@Component({
templateUrl: './login-form.component.html',
styleUrls: [ './login.scss' ]
Expand Down Expand Up @@ -102,19 +118,3 @@ export class LoginFormComponent {
}, (error) => this.planetMessageService.showAlert('Username and/or password do not match'));
}
}

const repeatPassword = {
password: [ '', Validators.compose([
Validators.required,
CustomValidators.matchPassword('repeatPassword', false)
]) ],
repeatPassword: [ '', Validators.compose([
Validators.required,
CustomValidators.matchPassword('password', true)
]) ]
};

const loginForm = {
name: [ '', Validators.required ],
password: [ '', Validators.required ]
};
34 changes: 17 additions & 17 deletions src/app/resources/rating-resources/resources-rating.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,23 @@ import { map } from 'rxjs/operators';
import { DialogsFormService } from '../../shared/dialogs/dialogs-form.service';
import { ResourcesService } from '../resources.service';

const popupFormFields = [
{
'label': 'Rate',
'type': 'rating',
'name': 'rate',
'placeholder': 'Your Rating',
'required': false
},
{
'label': 'Comment',
'type': 'textarea',
'name': 'comment',
'placeholder': 'Leave your comment',
'required': false
}
];

@Component({
templateUrl: './resources-rating.component.html',
selector: 'planet-resources-rating'
Expand Down Expand Up @@ -119,20 +136,3 @@ export class ResourcesRatingComponent implements OnChanges {
}
}
}

const popupFormFields = [
{
'label': 'Rate',
'type': 'rating',
'name': 'rate',
'placeholder': 'Your Rating',
'required': false
},
{
'label': 'Comment',
'type': 'textarea',
'name': 'comment',
'placeholder': 'Leave your comment',
'required': false
}
];
4 changes: 2 additions & 2 deletions src/app/resources/resources.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { of } from 'rxjs/observable/of';
import { forkJoin } from 'rxjs/observable/forkJoin';
import { catchError } from 'rxjs/operators';

const startingRating = { rateSum: 0, totalRating: 0, maleRating: 0, femaleRating: 0, userRating: {} };

@Injectable()
export class ResourcesService {
private resourcesDb = 'resources';
Expand Down Expand Up @@ -91,5 +93,3 @@ export class ResourcesService {
}

}

const startingRating = { rateSum: 0, totalRating: 0, maleRating: 0, femaleRating: 0, userRating: {} };
8 changes: 4 additions & 4 deletions src/app/shared/dialogs/dialogs-list.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import { Injectable } from '@angular/core';
import { CouchService } from '../couchdb.service';
import { map } from 'rxjs/operators';

const listColumns = {
'resources': [ 'title' ]
};

@Injectable()
export class DialogsListService {

Expand All @@ -16,7 +20,3 @@ export class DialogsListService {
}

}

const listColumns = {
'resources': [ 'title' ]
};
18 changes: 9 additions & 9 deletions src/app/shared/table-helpers.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
const checkFilterItems = (data: any) => ((includeItem: boolean, [ field, val ]) => {
// If field is an array field, check if one value matches. If not check if values match exactly.
const noMatch = data[field] instanceof Array ? data[field].indexOf(val) === -1 : val.toLowerCase() !== data[field].toLowerCase();
if (val && noMatch) {
return false;
}
return includeItem;
});

export const filterSpecificFields = (filterFields: string[]): any => {
return (data: any, filter: string) => {
for (let i = 0; i < filterFields.length; i++) {
Expand All @@ -23,12 +32,3 @@ export const composeFilterFunctions = (filterFunctions: any[]) => {
}, true);
};
};

const checkFilterItems = (data: any) => ((includeItem: boolean, [ field, val ]) => {
// If field is an array field, check if one value matches. If not check if values match exactly.
const noMatch = data[field] instanceof Array ? data[field].indexOf(val) === -1 : val.toLowerCase() !== data[field].toLowerCase();
if (val && noMatch) {
return false;
}
return includeItem;
});

0 comments on commit 34bcaa0

Please sign in to comment.