enable prefer-const rule for tslint, fix issues (#4409)

* enable prefer-const rule for tslint, fix issues

* Update content-node-selector.component.spec.ts

* Update content-node-selector.component.spec.ts

* fix const

* fix lint issues

* update tests

* update tests

* update tests

* fix code

* fix page class
This commit is contained in:
Denys Vuika
2019-03-25 12:19:33 +00:00
committed by Eugenio Romano
parent 26c5982a1a
commit a7a48e8b2b
581 changed files with 5435 additions and 5402 deletions

View File

@@ -134,7 +134,7 @@ describe('CheckAllowableOperationDirective', () => {
spyOn(contentService, 'hasAllowableOperations').and.returnValue(false);
spyOn(changeDetectorMock, 'detectChanges');
let testComponent = new TestComponent();
const testComponent = new TestComponent();
testComponent.disabled = false;
const directive = new CheckAllowableOperationDirective(null, null, contentService, changeDetectorMock, testComponent);
directive.nodes = <any> [{}, {}];
@@ -150,7 +150,7 @@ describe('CheckAllowableOperationDirective', () => {
spyOn(contentService, 'hasAllowableOperations').and.returnValue(true);
spyOn(changeDetectorMock, 'detectChanges');
let testComponent = new TestComponent();
const testComponent = new TestComponent();
testComponent.disabled = true;
const directive = new CheckAllowableOperationDirective(null, null, contentService, changeDetectorMock, testComponent);
directive.nodes = <any> [{}, {}];

View File

@@ -63,7 +63,7 @@ export class CheckAllowableOperationDirective implements OnChanges {
* @memberof CheckAllowableOperationDirective
*/
updateElement(): boolean {
let enable = this.hasAllowableOperations(this.nodes, this.permission);
const enable = this.hasAllowableOperations(this.nodes, this.permission);
if (enable) {
this.enable();

View File

@@ -72,7 +72,7 @@ describe('NodeFavoriteDirective', () => {
it('should reset favorites if selection is empty', fakeAsync(() => {
spyOn(alfrescoApiService.getInstance().core.favoritesApi, 'getFavorite').and.returnValue(Promise.resolve());
let selection = [
const selection = [
{ entry: { id: '1', name: 'name1' } }
];
@@ -104,7 +104,7 @@ describe('NodeFavoriteDirective', () => {
{ entry: { id: '2', name: 'name2' } }
];
let change = new SimpleChange(null, selection, true);
const change = new SimpleChange(null, selection, true);
directive.ngOnChanges({'selection': change});
tick();
@@ -185,7 +185,7 @@ describe('NodeFavoriteDirective', () => {
});
it('should not perform action if favorites collection is empty', fakeAsync(() => {
let change = new SimpleChange(null, [], true);
const change = new SimpleChange(null, [], true);
directive.ngOnChanges({'selection': change});
tick();
@@ -330,7 +330,7 @@ describe('NodeFavoriteDirective', () => {
{ entry: { id: '1', name: 'name1', isFavorite: true } }
];
let change = new SimpleChange(null, selection, true);
const change = new SimpleChange(null, selection, true);
directive.ngOnChanges({'selection': change});
tick();
@@ -345,7 +345,7 @@ describe('NodeFavoriteDirective', () => {
{ entry: { id: '1', name: 'name1' } }
];
let change = new SimpleChange(null, selection, true);
const change = new SimpleChange(null, selection, true);
directive.ngOnChanges({'selection': change});
tick();
@@ -359,7 +359,7 @@ describe('NodeFavoriteDirective', () => {
{ entry: { id: '1', name: 'name1' } }
];
let change = new SimpleChange(null, selection, true);
const change = new SimpleChange(null, selection, true);
directive.ngOnChanges({'selection': change});
tick();

View File

@@ -238,7 +238,7 @@ export class NodeRestoreDirective {
private notification(): void {
const status = Object.assign({}, this.restoreProcessStatus);
let message = this.getRestoreMessage();
const message = this.getRestoreMessage();
this.reset();
const action = (status.oneSucceeded && !status.someFailed) ? this.translation.instant('CORE.RESTORE_NODE.VIEW') : '';

View File

@@ -58,7 +58,7 @@ describe('UploadDirective', () => {
});
it('should prevent default event on dragover', () => {
let event = new Event('dom-event');
const event = new Event('dom-event');
spyOn(event, 'preventDefault').and.stub();
directive.enabled = true;
directive.onDragOver(event);
@@ -88,28 +88,28 @@ describe('UploadDirective', () => {
it('should prevent default event on drop', () => {
directive.enabled = true;
let event = jasmine.createSpyObj('event', ['preventDefault', 'stopPropagation']);
const event = jasmine.createSpyObj('event', ['preventDefault', 'stopPropagation']);
directive.onDrop(<DragEvent> event);
expect(event.preventDefault).toHaveBeenCalled();
});
it('should stop default event propagation on drop', () => {
directive.enabled = true;
let event = jasmine.createSpyObj('event', ['preventDefault', 'stopPropagation']);
const event = jasmine.createSpyObj('event', ['preventDefault', 'stopPropagation']);
directive.onDrop(<DragEvent> event);
expect(event.stopPropagation).toHaveBeenCalled();
});
it('should not prevent default event on drop when disabled', () => {
directive.enabled = false;
let event = jasmine.createSpyObj('event', ['preventDefault', 'stopPropagation']);
const event = jasmine.createSpyObj('event', ['preventDefault', 'stopPropagation']);
directive.onDrop(<DragEvent> event);
expect(event.preventDefault).not.toHaveBeenCalled();
});
it('should raise upload-files event on files drop', (done) => {
directive.enabled = true;
let event = jasmine.createSpyObj('event', ['preventDefault', 'stopPropagation']);
const event = jasmine.createSpyObj('event', ['preventDefault', 'stopPropagation']);
spyOn(directive, 'getDataTransfer').and.returnValue({});
spyOn(directive, 'getFilesDropped').and.returnValue(Promise.resolve([
<FileInfo> {},
@@ -123,10 +123,10 @@ describe('UploadDirective', () => {
it('should provide dropped files in upload-files event', (done) => {
directive.enabled = true;
let files = [
const files = [
<FileInfo> {}
];
let event = jasmine.createSpyObj('event', ['preventDefault', 'stopPropagation']);
const event = jasmine.createSpyObj('event', ['preventDefault', 'stopPropagation']);
spyOn(directive, 'getDataTransfer').and.returnValue({});
spyOn(directive, 'getFilesDropped').and.returnValue(Promise.resolve(files));

View File

@@ -63,7 +63,7 @@ export class UploadDirective implements OnInit, OnDestroy {
ngOnInit() {
if (this.isClickMode() && this.renderer) {
let inputUpload = this.renderer.createElement('input');
const inputUpload = this.renderer.createElement('input');
this.upload = this.el.nativeElement.parentElement.appendChild(inputUpload);
this.upload.type = 'file';
@@ -153,7 +153,7 @@ export class UploadDirective implements OnInit, OnDestroy {
onUploadFiles(files: FileInfo[]) {
if (this.enabled && files.length > 0) {
let customEvent = new CustomEvent('upload-files', {
const customEvent = new CustomEvent('upload-files', {
detail: {
sender: this,
data: this.data,
@@ -201,7 +201,7 @@ export class UploadDirective implements OnInit, OnDestroy {
if (items) {
for (let i = 0; i < items.length; i++) {
if (typeof items[i].webkitGetAsEntry !== 'undefined') {
let item = items[i].webkitGetAsEntry();
const item = items[i].webkitGetAsEntry();
if (item) {
if (item.isFile) {
iterations.push(Promise.resolve(<FileInfo> {
@@ -225,7 +225,7 @@ export class UploadDirective implements OnInit, OnDestroy {
}
} else {
// safari or FF
let files = FileUtils
const files = FileUtils
.toFileArray(dataTransfer.files)
.map((file) => <FileInfo> {
entry: null,