From bcd04a349cd8fdb6f1a03a725914d54144ee726d Mon Sep 17 00:00:00 2001 From: glacambre Date: Tue, 26 Mar 2019 06:34:40 +0100 Subject: [PATCH 1/2] Make compiler tslint/tslint-sonarts ready --- compiler/metadata/ClassMetadata.ts | 8 ++++---- compiler/metadata/FileMetadata.ts | 18 +++++++++--------- compiler/metadata/ProgramMetadata.ts | 6 +++--- compiler/metadata/SymbolMetadata.ts | 2 +- compiler/types/AnyType.ts | 12 +++++------- compiler/types/ArrayType.ts | 8 ++++---- compiler/types/BooleanType.ts | 19 ++++++++++--------- compiler/types/FunctionType.ts | 8 ++++---- compiler/types/LiteralTypeType.ts | 12 +++++++----- compiler/types/NumberType.ts | 20 +++++++++++--------- compiler/types/ObjectType.ts | 12 ++++++------ compiler/types/StringType.ts | 14 ++++++++------ compiler/types/TupleType.ts | 10 +++++----- compiler/types/Type.ts | 2 +- compiler/types/TypeReferenceType.ts | 8 ++++---- compiler/types/UnionType.ts | 10 +++++----- compiler/types/VoidType.ts | 10 +++++----- 17 files changed, 92 insertions(+), 87 deletions(-) diff --git a/compiler/metadata/ClassMetadata.ts b/compiler/metadata/ClassMetadata.ts index 7eb0248d..d91915c3 100644 --- a/compiler/metadata/ClassMetadata.ts +++ b/compiler/metadata/ClassMetadata.ts @@ -9,19 +9,19 @@ export class ClassMetadata { >(), ) {} - setMember(name: string, s: SymbolMetadata) { + public setMember(name: string, s: SymbolMetadata) { this.members.set(name, s) } - getMember(name: string) { + public getMember(name: string) { return this.members.get(name) } - getMembers() { + public getMembers() { return this.members.keys() } - toConstructor() { + public toConstructor() { return ( `new ClassMetadata(new Map([` + Array.from(this.members.entries()) diff --git a/compiler/metadata/FileMetadata.ts b/compiler/metadata/FileMetadata.ts index a28e779d..a1c61185 100644 --- a/compiler/metadata/FileMetadata.ts +++ b/compiler/metadata/FileMetadata.ts @@ -1,5 +1,5 @@ -import { SymbolMetadata } from "./SymbolMetadata" import { ClassMetadata } from "./ClassMetadata" +import { SymbolMetadata } from "./SymbolMetadata" export class FileMetadata { constructor( @@ -13,35 +13,35 @@ export class FileMetadata { >(), ) {} - setClass(name: string, c: ClassMetadata) { + public setClass(name: string, c: ClassMetadata) { this.classes.set(name, c) } - getClass(name: string) { + public getClass(name: string) { return this.classes.get(name) } - getClasses() { + public getClasses() { return Array.from(this.classes.keys()) } - setFunction(name: string, f: SymbolMetadata) { + public setFunction(name: string, f: SymbolMetadata) { this.functions.set(name, f) } - getFunction(name: string) { + public getFunction(name: string) { return this.functions.get(name) } - getFunctions() { + public getFunctions() { return Array.from(this.functions.entries()) } - getFunctionNames() { + public getFunctionNames() { return Array.from(this.functions.keys()) } - toConstructor() { + public toConstructor() { return ( `new FileMetadata(new Map([` + Array.from(this.classes.entries()) diff --git a/compiler/metadata/ProgramMetadata.ts b/compiler/metadata/ProgramMetadata.ts index 8d082616..2b8dfbdc 100644 --- a/compiler/metadata/ProgramMetadata.ts +++ b/compiler/metadata/ProgramMetadata.ts @@ -8,15 +8,15 @@ export class ProgramMetadata { >(), ) {} - setFile(name: string, file: FileMetadata) { + public setFile(name: string, file: FileMetadata) { this.files.set(name, file) } - getFile(name: string) { + public getFile(name: string) { return this.files.get(name) } - toConstructor() { + public toConstructor() { return ( `new ProgramMetadata(new Map([` + Array.from(this.files.entries()) diff --git a/compiler/metadata/SymbolMetadata.ts b/compiler/metadata/SymbolMetadata.ts index 513d0f65..9a93e42d 100644 --- a/compiler/metadata/SymbolMetadata.ts +++ b/compiler/metadata/SymbolMetadata.ts @@ -3,7 +3,7 @@ import { Type } from "../types/AllTypes" export class SymbolMetadata { constructor(public doc: string, public type: Type, public hidden = false) {} - toConstructor() { + public toConstructor() { return `new SymbolMetadata(${JSON.stringify( this.doc, )}, ${this.type.toConstructor()}, ${this.hidden})` diff --git a/compiler/types/AnyType.ts b/compiler/types/AnyType.ts index 521d6d0f..f1ac7581 100644 --- a/compiler/types/AnyType.ts +++ b/compiler/types/AnyType.ts @@ -1,20 +1,18 @@ import { Type } from "./Type" export class AnyType implements Type { - static instance = new AnyType() - kind = "any" + public static instance = new AnyType() + public kind = "any" - constructor() {} - - toConstructor() { + public toConstructor() { return "AnyType.instance" } - toString() { + public toString() { return this.kind } - convert(argument) { + public convert(argument) { return argument } } diff --git a/compiler/types/ArrayType.ts b/compiler/types/ArrayType.ts index a155cb1b..c894538d 100644 --- a/compiler/types/ArrayType.ts +++ b/compiler/types/ArrayType.ts @@ -1,19 +1,19 @@ import { Type } from "./Type" export class ArrayType implements Type { - kind = "array" + public kind = "array" constructor(public elemType: Type) {} - toConstructor() { + public toConstructor() { return `new ArrayType(${this.elemType.toConstructor()})` } - toString() { + public toString() { return `${this.elemType.toString()}[]` } - convert(argument) { + public convert(argument) { if (!Array.isArray(argument)) { try { argument = JSON.parse(argument) diff --git a/compiler/types/BooleanType.ts b/compiler/types/BooleanType.ts index 759a3358..26f126c7 100644 --- a/compiler/types/BooleanType.ts +++ b/compiler/types/BooleanType.ts @@ -1,22 +1,23 @@ import { Type } from "./Type" export class BooleanType implements Type { - static instance = new BooleanType() - kind = "boolean" + public static instance = new BooleanType() + public kind = "boolean" - constructor() {} - - toConstructor() { + public toConstructor() { return "BooleanType.instance" } - toString() { + public toString() { return this.kind } - convert(argument) { - if (argument === "true") return true - else if (argument === "false") return false + public convert(argument) { + if (argument === "true") { + return true + } else if (argument === "false") { + return false + } throw new Error("Can't convert ${argument} to boolean") } } diff --git a/compiler/types/FunctionType.ts b/compiler/types/FunctionType.ts index 12fcb872..4a84e2c9 100644 --- a/compiler/types/FunctionType.ts +++ b/compiler/types/FunctionType.ts @@ -1,11 +1,11 @@ import { Type } from "./Type" export class FunctionType implements Type { - kind = "function" + public kind = "function" constructor(public args: Type[], public ret: Type) {} - toConstructor() { + public toConstructor() { return ( `new FunctionType([` + // Convert every argument type to its string constructor representation @@ -14,11 +14,11 @@ export class FunctionType implements Type { ) } - toString() { + public toString() { return `(${this.args.map(a => a.toString()).join(", ")}) => ${this.ret.toString()}` } - convert(argument) { + public convert(argument) { // Possible strategies: // - eval() // - window[argument] diff --git a/compiler/types/LiteralTypeType.ts b/compiler/types/LiteralTypeType.ts index 6f0e9656..76b13a84 100644 --- a/compiler/types/LiteralTypeType.ts +++ b/compiler/types/LiteralTypeType.ts @@ -1,20 +1,22 @@ import { Type } from "./Type" export class LiteralTypeType implements Type { - kind = "LiteralType" + public kind = "LiteralType" constructor(public value: string) {} - toConstructor() { + public toConstructor() { return `new LiteralTypeType(${JSON.stringify(this.value)})` } - toString() { + public toString() { return JSON.stringify(this.value) } - convert(argument) { - if (argument === this.value) return argument + public convert(argument) { + if (argument === this.value) { + return argument + } throw new Error( `Argument does not match expected value (${ this.value diff --git a/compiler/types/NumberType.ts b/compiler/types/NumberType.ts index db2b5200..61f4eb98 100644 --- a/compiler/types/NumberType.ts +++ b/compiler/types/NumberType.ts @@ -1,24 +1,26 @@ import { Type } from "./Type" export class NumberType implements Type { - static instance = new NumberType() - kind = "number" + public static instance = new NumberType() + public kind = "number" - constructor() {} - - toConstructor() { + public toConstructor() { return "NumberType.instance" } - toString() { + public toString() { return this.kind } - convert(argument) { + public convert(argument) { let n = parseInt(argument) - if (!Number.isNaN(n)) return n + if (!Number.isNaN(n)) { + return n + } n = parseFloat(argument) - if (!Number.isNaN(n)) return n + if (!Number.isNaN(n)) { + return n + } throw new Error(`Can't convert to number: ${argument}`) } } diff --git a/compiler/types/ObjectType.ts b/compiler/types/ObjectType.ts index e32d5430..fb19ede5 100644 --- a/compiler/types/ObjectType.ts +++ b/compiler/types/ObjectType.ts @@ -1,23 +1,23 @@ import { Type } from "./Type" export class ObjectType implements Type { - kind = "object" + public kind = "object" // Note: a map that has an empty key ("") uses the corresponding type as default type constructor(public members: Map = new Map()) {} - toConstructor() { + public toConstructor() { return `new ObjectType(new Map([` + Array.from(this.members.entries()).map(([n, m]) => `[${JSON.stringify(n)}, ${m.toConstructor()}]`) .join(", ") + `]))` } - toString() { + public toString() { return this.kind } - convertMember(memberName: string[], memberValue: string) { + public convertMember(memberName: string[], memberValue: string) { let type = this.members.get(memberName[0]) if (!type) { // No type, try to get the default type @@ -27,13 +27,13 @@ export class ObjectType implements Type { return memberValue } } - if (type.kind == "object") { + if (type.kind === "object") { return (type as ObjectType).convertMember(memberName.slice(1), memberValue) } return type.convert(memberValue) } - convert(argument) { + public convert(argument) { try { return JSON.parse(argument) } catch (e) { diff --git a/compiler/types/StringType.ts b/compiler/types/StringType.ts index 57fe8c83..eb049c89 100644 --- a/compiler/types/StringType.ts +++ b/compiler/types/StringType.ts @@ -1,21 +1,23 @@ import { Type } from "./Type" export class StringType implements Type { - static instance = new StringType() - kind = "string" + public static instance = new StringType() + public kind = "string" constructor() {} - toConstructor() { + public toConstructor() { return "StringType.instance" } - toString() { + public toString() { return this.kind } - convert(argument) { - if (typeof argument === "string") return argument + public convert(argument) { + if (typeof argument === "string") { + return argument + } throw new Error(`Can't convert to string: ${argument}`) } } diff --git a/compiler/types/TupleType.ts b/compiler/types/TupleType.ts index 6fd08e2a..e1389a43 100644 --- a/compiler/types/TupleType.ts +++ b/compiler/types/TupleType.ts @@ -1,11 +1,11 @@ import { Type } from "./Type" export class TupleType implements Type { - kind = "tuple" + public kind = "tuple" constructor(public elemTypes: Type[]) {} - toConstructor() { + public toConstructor() { return ( `new TupleType([` + // Convert every element type to its constructor representation @@ -14,11 +14,11 @@ export class TupleType implements Type { ) } - toString() { + public toString() { return `[${this.elemTypes.map(e => e.toString()).join(", ")}]` } - convert(argument) { + public convert(argument) { if (!Array.isArray(argument)) { try { argument = JSON.parse(argument) @@ -29,7 +29,7 @@ export class TupleType implements Type { throw new Error(`Can't convert to tuple: ${argument}`) } } - if (argument.length != this.elemTypes.length) { + if (argument.length !== this.elemTypes.length) { throw new Error( `Error converting tuple: number of elements and type mismatch ${argument}`, ) diff --git a/compiler/types/Type.ts b/compiler/types/Type.ts index 008b998e..09557f66 100644 --- a/compiler/types/Type.ts +++ b/compiler/types/Type.ts @@ -5,5 +5,5 @@ export interface Type { name?: string toConstructor(): string toString(): string - convert: (argument: string) => any + convert(argument: string): any } diff --git a/compiler/types/TypeReferenceType.ts b/compiler/types/TypeReferenceType.ts index 8f135737..65b99985 100644 --- a/compiler/types/TypeReferenceType.ts +++ b/compiler/types/TypeReferenceType.ts @@ -1,9 +1,9 @@ import { Type } from "./Type" export class TypeReferenceType implements Type { - constructor(public kind: string, public args: Type[]) {} + public constructor(public kind: string, public args: Type[]) {} - toConstructor() { + public toConstructor() { return ( `new TypeReferenceType(${JSON.stringify(this.kind)}, [` + // Turn every type argument into its constructor representation @@ -12,11 +12,11 @@ export class TypeReferenceType implements Type { ) } - toString() { + public toString() { return `${this.kind}<${this.args.map(a => a.toString()).join(", ")}>` } - convert(argument) { + public convert(argument) { throw new Error("Conversion of simple type references not implemented.") } } diff --git a/compiler/types/UnionType.ts b/compiler/types/UnionType.ts index 5caf84bc..e261b259 100644 --- a/compiler/types/UnionType.ts +++ b/compiler/types/UnionType.ts @@ -1,11 +1,11 @@ import { Type } from "./Type" export class UnionType implements Type { - kind = "union" + public kind = "union" constructor(public types: Type[]) {} - toConstructor() { + public toConstructor() { return ( `new UnionType([` + // Convert every type to its string constructor representation @@ -14,12 +14,12 @@ export class UnionType implements Type { ) } - toString() { + public toString() { return this.types.map(t => t.toString()).join(" | ") } - convert(argument) { - for (let t of this.types) { + public convert(argument) { + for (const t of this.types) { try { return t.convert(argument) } catch (e) {} diff --git a/compiler/types/VoidType.ts b/compiler/types/VoidType.ts index 4d110a4f..3fecd1c6 100644 --- a/compiler/types/VoidType.ts +++ b/compiler/types/VoidType.ts @@ -1,20 +1,20 @@ import { Type } from "./Type" export class VoidType implements Type { - static instance = new VoidType() - kind = "void" + public static instance = new VoidType() + public kind = "void" constructor() {} - toConstructor() { + public toConstructor() { return "VoidType.instance" } - toString() { + public toString() { return this.kind } - convert(argument) { + public convert(argument) { return null } } From d36eedf05b29c36a3bf6e9949b758bfc250d1ca3 Mon Sep 17 00:00:00 2001 From: glacambre Date: Sun, 31 Mar 2019 15:26:45 +0200 Subject: [PATCH 2/2] Add tslint and sonarts to Travis Tslint and sonarts are pretty cool linters/static analyzers. Currently, we ask them to ignore any of the rules that Tridactyl might not respect. This enables progressively re-enabling rules and submitting small, reviewable PRs that fix things. --- .travis.yml | 1 + package-lock.json | 131 +++++++++++++++++++++++++++++++++----------- package.json | 2 + src/content/toys.ts | 8 +-- tslint.json | 84 ++++++++++++++++++++++++++++ 5 files changed, 191 insertions(+), 35 deletions(-) create mode 100644 tslint.json diff --git a/.travis.yml b/.travis.yml index 935ce42f..de236dfb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,7 @@ script: - npm install - npm run test - npm run lint + - bash -c '"$(npm bin)/tslint" --project .' notifications: webhooks: diff --git a/package-lock.json b/package-lock.json index a41a011c..b2887842 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2148,6 +2148,12 @@ "integrity": "sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk=", "dev": true }, + "builtin-modules": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", + "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=", + "dev": true + }, "builtin-status-codes": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz", @@ -2855,7 +2861,7 @@ "dev": true }, "csp-serdes": { - "version": "github:cmcaine/csp-serdes#6c6fe34dbd138855e5c26f331b094e9a75358a64", + "version": "github:cmcaine/csp-serdes#91876274b0bfa5cd10ceebabe9f8cb29b0ccd7aa", "from": "github:cmcaine/csp-serdes" }, "css": { @@ -4520,8 +4526,7 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "aproba": { "version": "1.2.0", @@ -4542,14 +4547,12 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -4564,20 +4567,17 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "core-util-is": { "version": "1.0.2", @@ -4694,8 +4694,7 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "ini": { "version": "1.3.5", @@ -4707,7 +4706,6 @@ "version": "1.0.0", "bundled": true, "dev": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -4722,7 +4720,6 @@ "version": "3.0.4", "bundled": true, "dev": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -4730,14 +4727,12 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "minipass": { "version": "2.3.5", "bundled": true, "dev": true, - "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -4756,7 +4751,6 @@ "version": "0.5.1", "bundled": true, "dev": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -4837,8 +4831,7 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "object-assign": { "version": "4.1.1", @@ -4850,7 +4843,6 @@ "version": "1.4.0", "bundled": true, "dev": true, - "optional": true, "requires": { "wrappy": "1" } @@ -4936,8 +4928,7 @@ "safe-buffer": { "version": "5.1.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "safer-buffer": { "version": "2.1.2", @@ -4973,7 +4964,6 @@ "version": "1.0.2", "bundled": true, "dev": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -4993,7 +4983,6 @@ "version": "3.0.1", "bundled": true, "dev": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -5037,14 +5026,12 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "yallist": { "version": "3.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true } } }, @@ -5626,6 +5613,12 @@ "integrity": "sha512-Pgs951kaMm5GXP7MOvxERINe3gsaVjUWFm+UZPSq9xYriQAksyhg0csnS0KXSNRD5NmNdapXEpjxG49+AKh/ug==", "dev": true }, + "immutable": { + "version": "3.8.2", + "resolved": "https://registry.npmjs.org/immutable/-/immutable-3.8.2.tgz", + "integrity": "sha1-wkOZUUVbs5kT2vKBN28VMOEErfM=", + "dev": true + }, "import-fresh": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.0.0.tgz", @@ -10583,6 +10576,82 @@ "integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==", "dev": true }, + "tslint": { + "version": "5.14.0", + "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.14.0.tgz", + "integrity": "sha512-IUla/ieHVnB8Le7LdQFRGlVJid2T/gaJe5VkjzRVSRR6pA2ODYrnfR1hmxi+5+au9l50jBwpbBL34txgv4NnTQ==", + "dev": true, + "requires": { + "babel-code-frame": "^6.22.0", + "builtin-modules": "^1.1.1", + "chalk": "^2.3.0", + "commander": "^2.12.1", + "diff": "^3.2.0", + "glob": "^7.1.1", + "js-yaml": "^3.7.0", + "minimatch": "^3.0.4", + "mkdirp": "^0.5.1", + "resolve": "^1.3.2", + "semver": "^5.3.0", + "tslib": "^1.8.0", + "tsutils": "^2.29.0" + }, + "dependencies": { + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, + "tslint-sonarts": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/tslint-sonarts/-/tslint-sonarts-1.9.0.tgz", + "integrity": "sha512-CJWt+IiYI8qggb2O/JPkS6CkC5DY1IcqRsm9EHJ+AxoWK70lvtP7jguochyNDMP2vIz/giGdWCfEM39x/I/Vnw==", + "dev": true, + "requires": { + "immutable": "^3.8.2" + } + }, + "tsutils": { + "version": "2.29.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz", + "integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==", + "dev": true, + "requires": { + "tslib": "^1.8.1" + } + }, "tty-browserify": { "version": "0.0.0", "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz", diff --git a/package.json b/package.json index a5498d3c..7a9a6bad 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,8 @@ "source-map-loader": "^0.2.4", "ts-jest": "^24.0.0", "ts-node": "^8.0.2", + "tslint": "^5.14.0", + "tslint-sonarts": "^1.9.0", "typedoc": "^0.14.2", "typedoc-default-themes": "git://github.com/tridactyl/typedoc-default-themes.git#fix_weird_member_names_bin", "typescript": "^3.3.3333", diff --git a/src/content/toys.ts b/src/content/toys.ts index 76263f0e..72e62561 100644 --- a/src/content/toys.ts +++ b/src/content/toys.ts @@ -13,12 +13,12 @@ export function jack_in() { "", ) const colour = "#0F0" //green text - rain(chinese,colour) + rain(chinese, colour) } -export let snow = () => rain(["❄"],"#FFF",0.15) +export let snow = () => rain(["❄"], "#FFF", 0.15) -export function rain(characters: string[], colour, darkening=0.05){ +export function rain(characters: string[], colour, darkening = 0.05) { let d = document.createElement("div") d.style.position = "fixed" d.style.display = "block" @@ -53,7 +53,7 @@ export function rain(characters: string[], colour, darkening=0.05){ function draw() { //Black BG for the canvas //translucent BG to show trail - ctx.fillStyle = "rgba(0, 0, 0, "+darkening+")" + ctx.fillStyle = "rgba(0, 0, 0, " + darkening + ")" ctx.fillRect(0, 0, c.width, c.height) ctx.fillStyle = colour diff --git a/tslint.json b/tslint.json new file mode 100644 index 00000000..e15eec26 --- /dev/null +++ b/tslint.json @@ -0,0 +1,84 @@ +{ + "extends": ["tslint:recommended", "tslint-sonarts"], + "rules": { + "align": false, + "array-type": false, + "arrow-parens": false, + "ban-types": false, + "bool-param-default": false, + "callable-types": false, + "class-name": false, + "cognitive-complexity": false, + "comment-format": false, + "curly": false, + "forin": false, + "if-filter": false, + "import-spacing": false, + "interface-name": false, + "interface-over-type-literal": false, + "jsdoc-format": false, + "max-classes-per-file": false, + "max-line-length": false, + "max-union-size": false, + "member-access": false, + "member-ordering": false, + "missing-whitespace": false, + "no-angle-bracket-type-assertion": false, + "no-array-delete": false, + "no-big-function": false, + "no-bitwise": false, + "no-collapsible-if": false, + "no-commented-code": false, + "no-conditional-assignment": false, + "no-consecutive-blank-lines": false, + "no-console": false, + "no-construct": false, + "no-dead-store": false, + "no-duplicate-string": false, + "no-empty": false, + "no-eval": false, + "no-extra-semicolon": false, + "no-identical-functions": false, + "no-ignored-return": false, + "no-map-without-using": false, + "no-misleading-array-reverse": false, + "no-nested-template-literals": false, + "no-nexted-template-literals": false, + "no-redundant-boolean": false, + "no-redundant-jump": false, + "no-self-assignment": false, + "no-shadowed-variable": false, + "no-small-switch": false, + "no-string-literal": false, + "no-string-throw": false, + "no-trailing-whitespace": false, + "no-try-promise": false, + "no-unenclosed-multiline-block": false, + "no-unnecessary-initializer": false, + "no-unnecessary-type-assertion": false, + "no-unsafe-finally": false, + "no-unused-expression": false, + "no-useless-cast": false, + "no-useless-catch": false, + "no-useless-catch": false, + "no-var-keyword": false, + "no-variable-usage-before-declaration": false, + "object-literal-key-quotes": false, + "object-literal-shorthand": false, + "object-literal-sort-keys": false, + "one-variable-per-declaration": false, + "only-arrow-functions": false, + "ordered-imports": false, + "prefer-const": false, + "prefer-immediate-return": false, + "prefer-promise-shorthand": false, + "quotemark": false, + "radix": false, + "semicolon": false, + "trailing-comma": false, + "triple-equals": false, + "use-primitive-type": false, + "variable-name": false, + "whitespace": false + } +}