Skip to content

Commit

Permalink
Fix linting not applying to codegen (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
jscheiny authored Aug 9, 2018
1 parent 7c968e2 commit 7db861d
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 16 deletions.
14 changes: 7 additions & 7 deletions codegen/common.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
}
Expand All @@ -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}`;
}
Expand All @@ -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;
}
8 changes: 4 additions & 4 deletions codegen/emit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand All @@ -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}`);
Expand Down
2 changes: 1 addition & 1 deletion codegen/genTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)}`;
}
2 changes: 1 addition & 1 deletion codegen/genTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@ function genCurriedTypeName({ curriedTypeNamePrefix }: OperatorSpec, value: numb
return `${curriedTypeNamePrefix}${genValueName(value)}`;
}

function genErrorCase() {
function genErrorCase(): string {
return indent(": ArithmeticError;");
}
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 7db861d

Please sign in to comment.