Fixed lint issues in server

This commit is contained in:
Alex Mikhalev 2017-10-05 14:31:07 -06:00
parent e5cc6b86e7
commit 015614b1d6
9 changed files with 12 additions and 45 deletions

View File

@ -68,14 +68,6 @@ function write(value: any) {
fn.apply(null, args);
}
function withSpaces(value: string): string {
const lines = value.split("\n");
for (let i = 1; i < lines.length; i++) {
lines[i] = " " + lines[i];
}
return lines.join("\n");
}
function filter(value: any) {
const keys = Object.keys(value);
const result: any = {};
@ -93,19 +85,6 @@ function asISODate(time: string) {
return new Date(time).toISOString();
}
function formatTime(value: any, after?: string) {
after = after || "";
try {
if (!value || !value.time) {
return "";
} else {
return "[" + asISODate(value.time) + "]" + after;
}
} catch (_) {
return "";
}
}
function formatSource(value: any): { str: string, args: any[] } {
if (value.source) {
return { str: "%c(" + value.source + ") ", args: ["color: #FF00FF"] };

View File

@ -1,4 +1,4 @@
import { IObservableArray, observable } from "mobx";
import { observable } from "mobx";
import { Duration } from "./Duration";
import { SprinklersDevice } from "./SprinklersDevice";

View File

@ -1,4 +1,4 @@
import { IObservableArray, observable } from "mobx";
import { observable } from "mobx";
import { Duration } from "./Duration";
import { Program } from "./Program";
import { Section } from "./Section";

View File

@ -1,4 +1,3 @@
import { IObservableArray, observable } from "mobx";
export * from "./Duration";
export * from "./ISprinklersApi";
export * from "./Program";

View File

@ -1,8 +1,6 @@
/* tslint:disable:ordered-imports */
import { assign, pick } from "lodash";
import {
createSimpleSchema, createModelSchema, primitive, object, date, custom,
ModelSchema, PropSchema,
createSimpleSchema, primitive, object, ModelSchema, PropSchema,
} from "serializr";
import list from "./list";
import * as s from "..";

View File

@ -1,6 +1,5 @@
import { cloneDeep } from "lodash";
import * as mqtt from "mqtt";
import { deserialize, update } from "serializr";
import { update } from "serializr";
import logger from "@common/logger";
import * as s from "@common/sprinklers";
@ -260,11 +259,6 @@ interface IResponseData {
type ResponseCallback = (data: IResponseData) => void;
interface ISectionJSON {
name: string;
pin: number;
}
interface IRunSectionJSON {
duration: number;
}

6
env.js
View File

@ -8,7 +8,7 @@ delete require.cache[require.resolve("./paths")];
const NODE_ENV = process.env.NODE_ENV;
if (!NODE_ENV) {
throw new Error(
"The NODE_ENV environment variable is required but was not specified."
"The NODE_ENV environment variable is required but was not specified.",
);
}
@ -72,7 +72,7 @@ exports.getClientEnvironment = function getClientEnvironment(publicUrl) {
// This should only be used as an escape hatch. Normally you would put
// images into the `src` and `import` them in code to get their paths.
PUBLIC_URL: publicUrl,
}
},
);
// Stringify all values so we can feed into Webpack DefinePlugin
const stringified = {
@ -83,4 +83,4 @@ exports.getClientEnvironment = function getClientEnvironment(publicUrl) {
};
return { raw, stringified };
}
};

View File

@ -5,18 +5,17 @@ const url = require("url");
exports.rootDir = fs.realpathSync(process.cwd());
const resolveRoot = (p) => path.resolve(exports.rootDir, p);
function ensureSlash(path, needsSlash) {
const hasSlash = path.endsWith("/");
function ensureSlash(p, needsSlash) {
const hasSlash = p.endsWith("/");
if (hasSlash && !needsSlash) {
return path.substr(path, path.length - 1);
return p.substr(p, p.length - 1);
} else if (!hasSlash && needsSlash) {
return `${path}/`;
return `${p}/`;
} else {
return path;
return p;
}
}
exports.dotenv = resolveRoot(".env");
exports.nodeModulesDir = resolveRoot("node_modules");
exports.packageJson = resolveRoot("package.json");
@ -35,4 +34,3 @@ exports.publicDir = exports.appBuildDir;
exports.serverDir = resolveRoot("server");
exports.serverBuildDir = resolveRoot("dist");

View File

@ -1,7 +1,6 @@
import { Express } from "express";
import * as serveStatic from "serve-static";
import logger from "@common/logger";
import * as paths from "paths";
export default function serveApp(app: Express) {