diff --git a/codegen/common.ts b/codegen/common.ts index c2517ff..bd67143 100644 --- a/codegen/common.ts +++ b/codegen/common.ts @@ -1,12 +1,12 @@ -export interface CodeGenSpec extends CommonSpec { - operators: PartialOperatorSpec[]; -} - export interface CommonSpec { minExponent: number; maxExponent: number; } +export interface CodeGenSpec extends CommonSpec { + operators: PartialOperatorSpec[]; +} + export interface PartialOperatorSpec { fileNamePrefix: string; uncurriedTypeNamePrefix: string; @@ -53,7 +53,7 @@ function genImport({ symbols, source }: ImportSpec): string { return `import { ${symbols.join(", ")} } from "${source}";`; } -function order(first: string, second: string) { +function order(first: string, second: string): number { if (first < second) { return -1; } @@ -63,7 +63,7 @@ function order(first: string, second: string) { return 0; } -export function genUncurriedTypeName(spec: OperatorSpec, left?: string | number, right?: string | number) { +export function genUncurriedTypeName(spec: OperatorSpec, left?: string | number, right?: string | number): string { const args = left !== undefined && right !== undefined ? `<${left}, ${right}>` : ""; return `${spec.uncurriedTypeNamePrefix}Exponents${args}`; } @@ -76,6 +76,6 @@ export function genValueName(value: number): string { return `${sign}${Math.abs(value)}`; } -export function indent(line: string) { +export function indent(line: string): string { return " " + line; } diff --git a/codegen/emit.ts b/codegen/emit.ts index e369dca..b20e701 100644 --- a/codegen/emit.ts +++ b/codegen/emit.ts @@ -12,7 +12,7 @@ export interface EmitPlan { source: string; } -export function emit(callback?: () => void) { +export function emit(callback?: () => void): void { const emits: EmitPlan[] = getEmitPlans(); prepForEmit(() => { let index = -1; @@ -39,11 +39,11 @@ export function getEmitPlans(): EmitPlan[] { return emits; } -function prepForEmit(callback: () => void) { +function prepForEmit(callback: () => void): void { makeDirectory(PATH_PREFIX, () => makeDirectory(TEST_PREFIX, callback)); } -function makeDirectory(path: string, callback: () => void) { +function makeDirectory(path: string, callback: () => void): void { exists(path, doesExist => { if (doesExist) { return callback(); @@ -58,7 +58,7 @@ function makeDirectory(path: string, callback: () => void) { }); } -function emitFile({ path, source }: EmitPlan, callback?: () => void) { +function emitFile({ path, source }: EmitPlan, callback?: () => void): void { writeFile(path, source, error => { if (error) { console.error(`There was an error writing to ${path}`); diff --git a/codegen/genTests.ts b/codegen/genTests.ts index 1d52321..2313397 100644 --- a/codegen/genTests.ts +++ b/codegen/genTests.ts @@ -55,6 +55,6 @@ function genErrorTest(spec: OperatorSpec, left: number, right: number): string[] ]; } -function genTestBaseName(spec: OperatorSpec, left: number, right: number) { +function genTestBaseName(spec: OperatorSpec, left: number, right: number): string { return `${spec.testTypeNamePrefix}Of${genValueName(left)}And${genValueName(right)}`; } diff --git a/codegen/genTypes.ts b/codegen/genTypes.ts index 5677a90..c672d9e 100644 --- a/codegen/genTypes.ts +++ b/codegen/genTypes.ts @@ -62,6 +62,6 @@ function genCurriedTypeName({ curriedTypeNamePrefix }: OperatorSpec, value: numb return `${curriedTypeNamePrefix}${genValueName(value)}`; } -function genErrorCase() { +function genErrorCase(): string { return indent(": ArithmeticError;"); } diff --git a/package.json b/package.json index a8d24f6..d347e0b 100644 --- a/package.json +++ b/package.json @@ -22,10 +22,11 @@ "scripts": { "build": "npm-run-all -s codegen compile:src", "codegen": "npm-run-all -s compile:codegen node:codegen", - "compile:src": "tsc -p src", "compile:codegen": "tsc -p codegen", - "lint": "tslint -p src/tsconfig.json -c tslint.json '{src,codegen}/**/*.ts'", - "lint:fix": "yarn lint --fix", + "compile:src": "tsc -p src", + "lint:codegen": "tslint -p codegen/tsconfig.json -c tslint.json", + "lint:src": "tslint -p src/tsconfig.json -c tslint.json", + "lint": "npm-run-all -p lint:codegen lint:src", "node:codegen": "node codegen/dist/emit", "test": "jest --config jest.config.json", "prepack": "yarn build",