From a287dc88d8f5d51bdb44a1281d64c7bee742d20f Mon Sep 17 00:00:00 2001 From: CarreraPHP Date: Fri, 13 Jan 2017 13:43:21 +0530 Subject: [PATCH] chore(lint): upgrade angular-cli to beta25.5 and lint project --- web/README.md | 6 +- web/package.json | 13 +- web/src/app/app.component.spec.ts | 12 +- web/src/app/app.component.ts | 1 - web/src/app/editor/editor.component.ts | 240 ++++++++++----------- web/src/app/header/header.component.ts | 6 +- web/src/app/shared/scaffolding-base.ts | 4 +- web/src/app/viewport/viewport.component.ts | 6 +- web/src/index.html | 7 +- web/src/polyfills.ts | 2 +- web/src/test.ts | 2 +- web/tslint.json | 9 + 12 files changed, 152 insertions(+), 156 deletions(-) diff --git a/web/README.md b/web/README.md index 49abb12..22e6126 100644 --- a/web/README.md +++ b/web/README.md @@ -1,6 +1,6 @@ # ScaffoldingAll -This project was generated with [angular-cli](https://github.com/angular/angular-cli) version 1.0.0-beta.24. +This project was generated with [angular-cli](https://github.com/angular/angular-cli) version 1.0.0-beta.25.5. ## Development server Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. @@ -22,9 +22,9 @@ Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github. Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/). Before running the tests make sure you are serving the app via `ng serve`. -## Deploying to Github Pages +## Deploying to GitHub Pages -Run `ng github-pages:deploy` to deploy to Github Pages. +Run `ng github-pages:deploy` to deploy to GitHub Pages. ## Further help diff --git a/web/package.json b/web/package.json index 296b50a..c6c7ed5 100644 --- a/web/package.json +++ b/web/package.json @@ -6,10 +6,15 @@ "scripts": { "ng": "ng", "start": "ng serve", - "lint": "tslint \"src/**/*.ts\"", + "lint": "tslint \"src/**/*.ts\" --project src/tsconfig.json --type-check && tslint \"e2e/**/*.ts\" --project e2e/tsconfig.json --type-check", "test": "ng test", "pree2e": "webdriver-manager update --standalone false --gecko false", - "e2e": "protractor" + "e2e": "protractor", + "prefirebase:init": "firebase init", + "firebase:init": "firebase init", + "postfirebase:init": "firebase init", + "prefirebase:deploy": "echo \"run firebase:init if deploy fails\" && ng build --prod", + "firebase:deploy": "firebase deploy" }, "private": true, "dependencies": { @@ -39,7 +44,7 @@ "@types/jasmine": "2.5.38", "@types/json5": "0.0.29", "@types/node": "^6.0.42", - "angular-cli": "1.0.0-beta.24", + "angular-cli": "1.0.0-beta.25.5", "codelyzer": "~2.0.0-beta.1", "jasmine-core": "2.5.2", "jasmine-spec-reporter": "2.5.0", @@ -50,7 +55,7 @@ "karma-remap-istanbul": "^0.2.1", "protractor": "~4.0.13", "ts-node": "1.2.1", - "tslint": "^4.0.2", + "tslint": "^4.3.0", "typescript": "~2.0.3" } } diff --git a/web/src/app/app.component.spec.ts b/web/src/app/app.component.spec.ts index 3ad633e..5be2cb3 100644 --- a/web/src/app/app.component.spec.ts +++ b/web/src/app/app.component.spec.ts @@ -14,21 +14,21 @@ describe('AppComponent', () => { }); it('should create the app', async(() => { - let fixture = TestBed.createComponent(AppComponent); - let app = fixture.debugElement.componentInstance; + const fixture = TestBed.createComponent(AppComponent); + const app = fixture.debugElement.componentInstance; expect(app).toBeTruthy(); })); it(`should have as title 'app works!'`, async(() => { - let fixture = TestBed.createComponent(AppComponent); - let app = fixture.debugElement.componentInstance; + const fixture = TestBed.createComponent(AppComponent); + const app = fixture.debugElement.componentInstance; expect(app.title).toEqual('app works!'); })); it('should render title in a h1 tag', async(() => { - let fixture = TestBed.createComponent(AppComponent); + const fixture = TestBed.createComponent(AppComponent); fixture.detectChanges(); - let compiled = fixture.debugElement.nativeElement; + const compiled = fixture.debugElement.nativeElement; expect(compiled.querySelector('h1').textContent).toContain('app works!'); })); }); diff --git a/web/src/app/app.component.ts b/web/src/app/app.component.ts index 2bcab87..ac9f15f 100644 --- a/web/src/app/app.component.ts +++ b/web/src/app/app.component.ts @@ -6,5 +6,4 @@ import {Component} from '@angular/core'; styleUrls: ['./app.component.scss'] }) export class AppComponent { - } diff --git a/web/src/app/editor/editor.component.ts b/web/src/app/editor/editor.component.ts index 1b3ea1c..35db0d3 100644 --- a/web/src/app/editor/editor.component.ts +++ b/web/src/app/editor/editor.component.ts @@ -10,7 +10,7 @@ import code from '../shared/scaffolding-base'; // import { } from '@angular/common'; import 'codemirror/mode/javascript/javascript'; -/// +/// import * as json5 from 'json5'; @Component({ @@ -23,8 +23,8 @@ import * as json5 from 'json5'; export class EditorComponent implements OnInit, DoCheck, AfterViewInit { @ViewChild('a#jsonDownload') - set downloadAnchor(v:HTMLAnchorElement) { - console.log("%c step 4: downloadAnchor", "color:red;font-size:medium;", arguments); + set downloadAnchor(v: HTMLAnchorElement) { + console.log('%c step 4: downloadAnchor', 'color:red;font-size:medium;', arguments); } public code: string = code; @@ -38,7 +38,7 @@ export class EditorComponent implements OnInit, DoCheck, AfterViewInit { private codeJSONKeyList: Array = []; private codeJSONUpdateTimeout: number = 0; - constructor(private renderer:Renderer) { + constructor(private renderer: Renderer) { this.cmOptions = { lineNumbers: true, // mode: { @@ -47,7 +47,7 @@ export class EditorComponent implements OnInit, DoCheck, AfterViewInit { // }, matchBrackets: true, autoCloseBrackets: true, - mode: "application/ld+json", + mode: 'application/ld+json', lineWrapping: true }; this.jsonViewerOptions = {}; @@ -65,14 +65,14 @@ export class EditorComponent implements OnInit, DoCheck, AfterViewInit { set codeObject(obj: Object) { this.codeJSON = obj; this.code = json5.stringify(obj); - this.codeKeys = this.getKeyListfromObject(this.codeJSON, 1, ""); + this.codeKeys = this.getKeyListfromObject(this.codeJSON, 1, ''); } get codeKeys(): Array { if (this.codeJSONKeyList.length > 0) { return this.codeJSONKeyList; } - return this.codeJSONKeyList = this.getKeyListfromObject(this.codeObject, 1, ""); + return this.codeJSONKeyList = this.getKeyListfromObject(this.codeObject, 1, ''); } set codeKeys(arr: Array) { @@ -80,22 +80,22 @@ export class EditorComponent implements OnInit, DoCheck, AfterViewInit { } getKeyListfromObject(obj: Object, span: number, path: string): Array { - let retArr = [], - spanArr = []; + let retArr = []; + const spanArr = []; - for (var k = 0; k < span; k++) { - spanArr.push(""); + for (let k = 0; k < span; k++) { + spanArr.push(''); } - for (let i in obj) { + for (const i in obj) { if (obj[i] instanceof Array) { - retArr.push(spanArr.concat([i, "[", this.getObjectPath(path, i)])); + retArr.push(spanArr.concat([i, '[', this.getObjectPath(path, i)])); retArr = retArr.concat(this.getObjectFromList(obj[i], span + 1, this.getObjectPath(path, i))); - retArr.push(spanArr.concat(["]"])); + retArr.push(spanArr.concat([']'])); } else if (obj[i] instanceof Object) { - retArr.push(spanArr.concat([i, "{", this.getObjectPath(path, i)])); + retArr.push(spanArr.concat([i, '{', this.getObjectPath(path, i)])); retArr = retArr.concat(this.getKeyListfromObject(obj[i], span + 1, this.getObjectPath(path, i))); - retArr.push(spanArr.concat(["}"])); + retArr.push(spanArr.concat(['}'])); } else { retArr.push(spanArr.concat([i, obj[i], this.getObjectPath(path, i)])); } @@ -104,42 +104,35 @@ export class EditorComponent implements OnInit, DoCheck, AfterViewInit { } getObjectPath(currPath: string, i: any): string { - let retStr = "", - keyStr = ""; + let keyStr = ''; - if (typeof i == "number") { - keyStr = [currPath, "[", i, "]"].join(""); + if (typeof i === 'number') { + keyStr = [currPath, '[', i, ']'].join(''); } else { - keyStr = [currPath, (currPath.length < 1 ? "" : "."), i].join(""); + keyStr = [currPath, (currPath.length < 1 ? '' : '.'), i].join(''); } - - // if(currPath.length < 1) { - // retStr = keyStr; - // } else { - // retStr = [currPath, keyStr].join(""); - // } return keyStr; } getObjectFromList(arr: Array, span: number, path: string): Array { - let retArr = [], - spanArr = []; + let retArr = []; + const spanArr = []; - for (var k = 0; k < span; k++) { - spanArr.push(""); + for (let k = 0; k < span; k++) { + spanArr.push(''); } arr.forEach((value, i) => { if (value instanceof Array) { - retArr.push(spanArr.concat([i, "[", this.getObjectPath(path, i)])); + retArr.push(spanArr.concat([i, '[', this.getObjectPath(path, i)])); retArr = retArr.concat(this.getObjectFromList(value, span + 1, this.getObjectPath(path, i))); - retArr.push(spanArr.concat(["]"])); + retArr.push(spanArr.concat([']'])); // retArr.push([i, [this.getObjectFromList(value)]]); } else if (value instanceof Object) { - retArr.push(spanArr.concat([i, "{", this.getObjectPath(path, i)])); - // console.log("key list from object", this.getKeyListfromObject(value)); + retArr.push(spanArr.concat([i, '{', this.getObjectPath(path, i)])); + // console.log('key list from object', this.getKeyListfromObject(value)); retArr = retArr.concat(this.getKeyListfromObject(value, span + 1, this.getObjectPath(path, i))); - retArr.push(spanArr.concat(["}"])); + retArr.push(spanArr.concat(['}'])); // retArr.push([i, this.getKeyListfromObject(value)]); } else { retArr.push(spanArr.concat([i, value, this.getObjectPath(path, i)])); @@ -155,8 +148,8 @@ export class EditorComponent implements OnInit, DoCheck, AfterViewInit { isPrimitive(item: Array): Boolean { if (item.length > 2) { - let value = item[item.length - 2]; - if (value == "{" || value == "[") { + const value = item[item.length - 2]; + if (value === '{' || value === '[') { return false; } } @@ -165,11 +158,10 @@ export class EditorComponent implements OnInit, DoCheck, AfterViewInit { isNotPrimitiveAndObjectEnd(item: Array, itemIndex: number, isLast: boolean): Boolean { if (!isLast) { - let i = itemIndex, + const i = itemIndex, nextItem: Array = this.codeKeys[i + 1]; - console.log("%c item & nextItem length", "color:red;font-size:20px;", item.length, nextItem.length, item, nextItem); - + console.log('%c item & nextItem length', 'color:red;font-size:20px;', item.length, nextItem.length, item, nextItem); if (item.length > nextItem.length) { return true; } @@ -179,62 +171,62 @@ export class EditorComponent implements OnInit, DoCheck, AfterViewInit { } isObjectKey(item: Array, subitem: any, subitemIndex: number) { - // this.log("is object key", [item, subitem, subitemIndex, item.length-3, item[subitemIndex+1]]); - let c1: boolean = subitemIndex == item.length - 3; - if (c1 && item[subitemIndex + 1] == "{") { + // this.log('is object key', [item, subitem, subitemIndex, item.length-3, item[subitemIndex+1]]); + const c1: boolean = subitemIndex === item.length - 3; + if (c1 && item[subitemIndex + 1] === '{') { return true; } return false; } isObjectBeginBrace(item: Array, subitem: any, subitemIndex: number) { - // this.log("is object key", [item, subitem, subitemIndex, item.length-2, item[subitemIndex]]); - let c1: boolean = subitemIndex == item.length - 2; - if (c1 && item[subitemIndex] == "{") { + // this.log('is object key', [item, subitem, subitemIndex, item.length-2, item[subitemIndex]]); + const c1: boolean = subitemIndex === item.length - 2; + if (c1 && item[subitemIndex] === '{') { return true; } return false; } isObjectEndBrace(item: Array, subitem: any, subitemIndex: number) { - // this.log("is object key", [item, subitem, subitemIndex, item.length-2, item[subitemIndex]]); - let c1: boolean = subitemIndex == item.length - 1; - if (c1 && subitem == "}") { + // this.log('is object key', [item, subitem, subitemIndex, item.length-2, item[subitemIndex]]); + const c1: boolean = subitemIndex === item.length - 1; + if (c1 && subitem === '}') { return true; } return false; } isArrayKey(item: Array, subitem: any, subitemIndex: number) { - // this.log("is array key", [item, subitem, subitemIndex, item.length-3, item[subitemIndex+1]]); - let c1: boolean = subitemIndex == item.length - 3; - if (c1 && item[subitemIndex + 1] == "[") { + // this.log('is array key', [item, subitem, subitemIndex, item.length-3, item[subitemIndex+1]]); + const c1: boolean = subitemIndex === item.length - 3; + if (c1 && item[subitemIndex + 1] === '[') { return true; } return false; } isArrayBeginBrace(item: Array, subitem: any, subitemIndex: number) { - // this.log("is array key", [item, subitem, subitemIndex, item.length-2, item[subitemIndex]]); - let c1: boolean = subitemIndex == item.length - 2; - if (c1 && item[subitemIndex] == "[") { + // this.log('is array key', [item, subitem, subitemIndex, item.length-2, item[subitemIndex]]); + const c1: boolean = subitemIndex === item.length - 2; + if (c1 && item[subitemIndex] === '[') { return true; } return false; } isArrayEndBrace(item: Array, subitem: any, subitemIndex: number) { - // this.log("is object key", [item, subitem, subitemIndex, item.length-2, item[subitemIndex]]); - let c1: boolean = subitemIndex == item.length - 1; - if (c1 && subitem == "]") { + // this.log('is object key', [item, subitem, subitemIndex, item.length-2, item[subitemIndex]]); + const c1: boolean = subitemIndex === item.length - 1; + if (c1 && subitem === ']') { return true; } return false; } isAttributeKey(item: Array, subitem: any, subitemIndex: number) { - // this.log("is attribute key", [item, subitem, subitemIndex, item.length-2, item[subitemIndex]]); - let c1: boolean = subitemIndex == item.length - 3, + // this.log('is attribute key', [item, subitem, subitemIndex, item.length-2, item[subitemIndex]]); + const c1: boolean = subitemIndex === item.length - 3, isKey = (subitem.length > 0); if (c1 && isKey && !this.isArrayKey(item, subitem, subitemIndex) && !this.isObjectKey(item, subitem, subitemIndex)) { return true; @@ -244,7 +236,7 @@ export class EditorComponent implements OnInit, DoCheck, AfterViewInit { isAttributeValue(item: Array, subitem: any, subitemIndex: number) { if (subitemIndex > 1) { - // this.log("is attribute value", [item, subitem, subitemIndex, item[subitemIndex-1], subitemIndex-1]); + // this.log('is attribute value', [item, subitem, subitemIndex, item[subitemIndex-1], subitemIndex-1]); return this.isAttributeKey(item, item[subitemIndex - 1], subitemIndex - 1); } return false; @@ -252,68 +244,60 @@ export class EditorComponent implements OnInit, DoCheck, AfterViewInit { isAttributeMetaValue(item: Array, subitem: any, subitemIndex: number) { if (subitemIndex > 2) { - // this.log("is attribute value", [item, subitem, subitemIndex, item[subitemIndex-1], subitemIndex-1]); + // this.log('is attribute value', [item, subitem, subitemIndex, item[subitemIndex-1], subitemIndex-1]); return this.isAttributeKey(item, item[subitemIndex - 2], subitemIndex - 2); } return false; } getBeginBraces(item: Array): Array { - let retArr = [], + const retArr = [], type = item[item.length - 2]; - for (var i = 0; i < item.length - 3; i++) { - retArr.push(""); + for (let i = 0; i < item.length - 3; i++) { + retArr.push(''); } - if (type == "{") { - retArr.push("{"); - } else if (type == "[") { - retArr.push("["); + if (type === '{') { + retArr.push('{'); + } else if (type === '[') { + retArr.push('['); } return retArr; } getEndBraces(item: Array): Array { - let retArr = [], + const retArr = [], type = item[item.length - 2]; - for (var i = 0; i < item.length - 3; i++) { - retArr.push(""); + for (let i = 0; i < item.length - 3; i++) { + retArr.push(''); } - if (type == "{") { - retArr.push("}"); - } else if (type == "[") { - retArr.push("]"); + if (type === '{') { + retArr.push('}'); + } else if (type === '[') { + retArr.push(']'); } return retArr; } getOptions(item: Array): Array { - var retArr = [], + const retArr = [], type = item[item.length - 1], name = item[item.length - 2]; - if (name == "application" && type == "{") { - + if (name === 'application' && type === '{') { } - return retArr; } updateCodeJSON(keyPath: string, result: any) { - Function("obj", "value", `obj.` + keyPath + ` = value`)(this.codeJSON, result); + Function('obj', 'value', `obj.` + keyPath + ` = value`)(this.codeJSON, result); this.codeObject = this.codeJSON; - this.codeKeys = this.getKeyListfromObject(this.codeJSON, 1, ""); - this.log("result from dialog", [result, keyPath, this.codeJSON]); + this.codeKeys = this.getKeyListfromObject(this.codeJSON, 1, ''); + this.log('result from dialog', [result, keyPath, this.codeJSON]); } handleAttributeValue(event: Event, keyPath: string) { - // if(this.codeJSONUpdateTimeout > 0) { - // window.clearTimeout(this.codeJSONUpdateTimeout); - // this.codeJSONUpdateTimeout = 0; - // } - // this.codeJSONUpdateTimeout = window.setTimeout(() => { - let value = (event.target as HTMLInputElement).value; + const value = (event.target as HTMLInputElement).value; this.updateCodeJSON(keyPath, value); - // }, 500); } /** @@ -325,34 +309,34 @@ export class EditorComponent implements OnInit, DoCheck, AfterViewInit { } isPropertiesArray(item: Array, subitem: any, subitemIndex: number): boolean { - return (subitem === "[" && item[subitemIndex - 1] === "properties") ? true : false; + return (subitem === '[' && item[subitemIndex - 1] === 'properties') ? true : false; } isInputArray(item: Array, subitem: any, subitemIndex: number): boolean { - return (subitem === "[" && item[subitemIndex - 1] === "input") ? true : false; + return (subitem === '[' && item[subitemIndex - 1] === 'input') ? true : false; } isOutputArray(item: Array, subitem: any, subitemIndex: number): boolean { - return (subitem === "[" && item[subitemIndex - 1] === "output") ? true : false; + return (subitem === '[' && item[subitemIndex - 1] === 'output') ? true : false; } isMethodArray(item: Array, subitem: any, subitemIndex: number): boolean { - return (subitem === "[" && item[subitemIndex - 1] === "methods") ? true : false; + return (subitem === '[' && item[subitemIndex - 1] === 'methods') ? true : false; } isMethodParamArray(item: Array, subitem: any, subitemIndex: number): boolean { - return (subitem === "[" && item[subitemIndex - 1] === "params") ? true : false; + return (subitem === '[' && item[subitemIndex - 1] === 'params') ? true : false; } isComponentArray(item: Array, subitem: any, subitemIndex: number): boolean { - return (subitem === "[" && item[subitemIndex - 1] === "components") ? true : false; + return (subitem === '[' && item[subitemIndex - 1] === 'components') ? true : false; } addProperty(item: Array, subitem: any, subitemIndex: number): void { const keyPath = item[subitemIndex + 1]; const result = { - name: "newProperty", - type: "boolean", + name: 'newProperty', + type: 'boolean', defaultValue: true }; this.pushToCodeJSONArray(keyPath, result); @@ -361,9 +345,9 @@ export class EditorComponent implements OnInit, DoCheck, AfterViewInit { addInput(item: Array, subitem: any, subitemIndex: number): void { const keyPath = item[subitemIndex + 1]; const result = { - name: "newInput", - // bindingType: "property", - parentBinding: "parentProperty" + name: 'newInput', + // bindingType: 'property', + parentBinding: 'parentProperty' }; this.pushToCodeJSONArray(keyPath, result); } @@ -371,9 +355,9 @@ export class EditorComponent implements OnInit, DoCheck, AfterViewInit { addOutput(item: Array, subitem: any, subitemIndex: number): void { const keyPath = item[subitemIndex + 1]; const result = { - name: "newOutput", - // bindingType: "property", - parentBinding: "parentMethod" + name: 'newOutput', + // bindingType: 'property', + parentBinding: 'parentMethod' }; this.pushToCodeJSONArray(keyPath, result); } @@ -381,10 +365,10 @@ export class EditorComponent implements OnInit, DoCheck, AfterViewInit { addMethod(item: Array, subitem: any, subitemIndex: number): void { const keyPath = item[subitemIndex + 1]; const result = { - name: "newMethod", + name: 'newMethod', params: [], return: { - type: "void" + type: 'void' }, getter: false, setter: false @@ -395,19 +379,19 @@ export class EditorComponent implements OnInit, DoCheck, AfterViewInit { addMethodParam(item: Array, subitem: any, subitemIndex: number): void { const keyPath = item[subitemIndex + 1]; const result = { - name: "newParam", - type: "string" + name: 'newParam', + type: 'string' }; this.pushToCodeJSONArray(keyPath, result); } addComponent(item: Array, subitem: any, subitemIndex: number): void { // Below code is not required as this condition check is done in the ngIf expression - // if (subitem === "[" && item[subitemIndex-1] === "components") {} - // this.log("Arguments for Add Component", [item, subitem, subitemIndex]); + // if (subitem === '[' && item[subitemIndex-1] === 'components') {} + // this.log('Arguments for Add Component', [item, subitem, subitemIndex]); const keyPath = item[subitemIndex + 1]; const result = { - name: "newComponent", + name: 'newComponent', bindings: { input: [], output: [] @@ -422,33 +406,33 @@ export class EditorComponent implements OnInit, DoCheck, AfterViewInit { isWithinArray(item: Array, subitem: any, subitemIndex: number): boolean { // will test is the value is an number or not. // This will confirm whether the value is within an Array or not. - const r:RegExp = /^\d+$/; - return (subitem === "{" && r.test(item[subitemIndex - 1])) ? true : false; + const r: RegExp = /^\d+$/ig; + return (subitem === '{' && r.test(item[subitemIndex - 1])) ? true : false; } prungeInstance(item: Array, subitem: any, subitemIndex: number): void { const keyPath = item[subitemIndex + 1]; - const result = parseInt(item[subitemIndex - 1]); + const result = parseInt(item[subitemIndex - 1], 10); this.spliceFromCodeJSONArray(keyPath, result); } pushToCodeJSONArray(keyPath: string, result: any) { - Function("obj", "value", `obj.` + keyPath + `.push(value)`)(this.codeJSON, result); + Function('obj', 'value', `obj.` + keyPath + `.push(value)`)(this.codeJSON, result); this.codeObject = this.codeJSON; - this.codeKeys = this.getKeyListfromObject(this.codeJSON, 1, ""); + this.codeKeys = this.getKeyListfromObject(this.codeJSON, 1, ''); } spliceFromCodeJSONArray(keyPath: string, result: number) { - Function("obj", "value", `obj.` + keyPath.replace("[" + result +"]", "") + `.splice(value, 1)`)(this.codeJSON, result); + Function('obj', 'value', `obj.` + keyPath.replace('[' + result + ']', '') + `.splice(value, 1)`)(this.codeJSON, result); this.codeObject = this.codeJSON; - this.codeKeys = this.getKeyListfromObject(this.codeJSON, 1, ""); + this.codeKeys = this.getKeyListfromObject(this.codeJSON, 1, ''); } - downloadLatestJSON() : void { - console.log("%c step 3: Before Anchor click event triggered", "color:red;font-size:medium;"); - const anchor:HTMLAnchorElement = this.renderer.selectRootElement("a#jsonDownload"); - const blob:Blob = new Blob([JSON.stringify(this.codeJSON)], { type: "application/json"}); - const url:string = URL.createObjectURL(blob); + downloadLatestJSON(): void { + console.log('%c step 3: Before Anchor click event triggered', 'color:red;font-size:medium;'); + const anchor: HTMLAnchorElement = this.renderer.selectRootElement('a#jsonDownload'); + const blob: Blob = new Blob([JSON.stringify(this.codeJSON)], { type: 'application/json' }); + const url: string = URL.createObjectURL(blob); anchor.href = url; anchor.click(); } @@ -458,12 +442,12 @@ export class EditorComponent implements OnInit, DoCheck, AfterViewInit { } log(text: string, values: Array) { - console.log.apply(this, ["%c " + text, "color:red;font-size:20px;"].concat(values)); + console.log.apply(this, ['%c ' + text, 'color:red;font-size:20px;'].concat(values)); } ngOnInit() { - console.log("code object", this.codeObject); - console.log("code object string", json5.stringify(this.codeObject)); + console.log('code object', this.codeObject); + console.log('code object string', json5.stringify(this.codeObject)); } ngDoCheck() { @@ -471,7 +455,7 @@ export class EditorComponent implements OnInit, DoCheck, AfterViewInit { } ngAfterViewInit() { - console.log("%c step 5: AfterViewInit", "color:red;font-size:medium;", arguments); + console.log('%c step 5: AfterViewInit', 'color:red;font-size:medium;', arguments); } } diff --git a/web/src/app/header/header.component.ts b/web/src/app/header/header.component.ts index 0deb98a..dff6666 100644 --- a/web/src/app/header/header.component.ts +++ b/web/src/app/header/header.component.ts @@ -12,9 +12,9 @@ export class HeaderComponent implements OnInit { constructor() { } - - generateJSONFile() : void { - console.log("%c step 1: button clicked", "color:red;font-size:medium;"); + + generateJSONFile(): void { + console.log('%c step 1: button clicked', 'color:red;font-size:medium;'); this.generateFile.emit(); } diff --git a/web/src/app/shared/scaffolding-base.ts b/web/src/app/shared/scaffolding-base.ts index aeaf695..fe8a8e3 100644 --- a/web/src/app/shared/scaffolding-base.ts +++ b/web/src/app/shared/scaffolding-base.ts @@ -1,4 +1,4 @@ -const code:string = `{ +const code: string = String`{ /* Application object is the root object that defines to the UI Application. All the components, its uni-directional bindings and hierachial structure forms the whole application. @@ -57,4 +57,4 @@ const code:string = `{ } } }`; -export default code; \ No newline at end of file +export default code; diff --git a/web/src/app/viewport/viewport.component.ts b/web/src/app/viewport/viewport.component.ts index 54d6069..dfba7d5 100644 --- a/web/src/app/viewport/viewport.component.ts +++ b/web/src/app/viewport/viewport.component.ts @@ -9,11 +9,11 @@ import { EditorComponent } from '../editor/editor.component'; }) export class ViewportComponent implements OnInit { - constructor() { + constructor() { } - downloadFile(editEl:EditorComponent) { - console.log("%c step 2: Viewport method triggered", "color:red;font-size:medium;", arguments); + downloadFile(editEl: EditorComponent) { + console.log('%c step 2: Viewport method triggered', 'color:red;font-size:medium;', arguments); editEl.downloadLatestJSON(); } diff --git a/web/src/index.html b/web/src/index.html index fd13523..19cdc48 100644 --- a/web/src/index.html +++ b/web/src/index.html @@ -1,13 +1,12 @@ - + ScaffoldingAll - - - + + Loading... diff --git a/web/src/polyfills.ts b/web/src/polyfills.ts index 3b4c55b..4749399 100644 --- a/web/src/polyfills.ts +++ b/web/src/polyfills.ts @@ -1,4 +1,4 @@ -// This file includes polyfills needed by Angular 2 and is loaded before +// This file includes polyfills needed by Angular and is loaded before // the app. You can add your own extra polyfills to this file. import 'core-js/es6/symbol'; import 'core-js/es6/object'; diff --git a/web/src/test.ts b/web/src/test.ts index be44dc5..f9d51ef 100644 --- a/web/src/test.ts +++ b/web/src/test.ts @@ -25,7 +25,7 @@ getTestBed().initTestEnvironment( platformBrowserDynamicTesting() ); // Then we find all the tests. -let context = require.context('./', true, /\.spec\.ts$/); +const context = require.context('./', true, /\.spec\.ts$/); // And load the modules. context.keys().map(context); // Finally, start Karma to run the tests. diff --git a/web/tslint.json b/web/tslint.json index 640d02c..86bc184 100644 --- a/web/tslint.json +++ b/web/tslint.json @@ -3,6 +3,7 @@ "node_modules/codelyzer" ], "rules": { + "callable-types": true, "class-name": true, "comment-format": [ true, @@ -11,10 +12,13 @@ "curly": true, "eofline": true, "forin": true, + "import-blacklist": [true, "rxjs"], + "import-spacing": true, "indent": [ true, "spaces" ], + "interface-over-type-literal": true, "label-position": true, "max-line-length": [ true, @@ -40,10 +44,12 @@ "no-debugger": true, "no-duplicate-variable": true, "no-empty": false, + "no-empty-interface": true, "no-eval": true, "no-inferrable-types": true, "no-shadowed-variable": true, "no-string-literal": false, + "no-string-throw": true, "no-switch-case-fall-through": true, "no-trailing-whitespace": true, "no-unused-expression": true, @@ -57,6 +63,7 @@ "check-else", "check-whitespace" ], + "prefer-const": true, "quotemark": [ true, "single" @@ -79,6 +86,8 @@ "variable-declaration": "nospace" } ], + "typeof-compare": true, + "unified-signatures": true, "variable-name": false, "whitespace": [ true,