Migrate to eslint

Summary
We'd like contributors to use the same linter and lint rules that we use
internally.  This diff swaps out eslint for jshint and fixes all lint failures
except for the max-len failures in the test suites.

Test Plan:
- ka-lint src
- make lint
- make test

Reviewers: emily
This commit is contained in:
Kevin Barabash
2015-11-30 20:52:22 -08:00
parent 1a082e81d9
commit 14a58adb90
34 changed files with 2271 additions and 2206 deletions

View File

@@ -1,3 +1,4 @@
/* eslint no-console:0, prefer-spread:0 */
"use strict";
var childProcess = require("child_process");
@@ -23,50 +24,50 @@ var opts = require("nomnom")
.option("browser", {
abbr: "b",
"default": "firefox",
help: "Name of the browser to use"
help: "Name of the browser to use",
})
.option("container", {
abbr: "c",
type: "string",
help: "Name or ID of a running docker container to contact"
help: "Name or ID of a running docker container to contact",
})
.option("seleniumURL", {
full: "selenium-url",
help: "Full URL of the Selenium web driver"
help: "Full URL of the Selenium web driver",
})
.option("seleniumIP", {
full: "selenium-ip",
help: "IP address of the Selenium web driver"
help: "IP address of the Selenium web driver",
})
.option("seleniumPort", {
full: "selenium-port",
"default": 4444,
help: "Port number of the Selenium web driver"
help: "Port number of the Selenium web driver",
})
.option("katexURL", {
full: "katex-url",
help: "Full URL of the KaTeX development server"
help: "Full URL of the KaTeX development server",
})
.option("katexIP", {
full: "katex-ip",
"default": "localhost",
help: "Full URL of the KaTeX development server"
help: "Full URL of the KaTeX development server",
})
.option("katexPort", {
full: "katex-port",
help: "Port number of the KaTeX development server"
help: "Port number of the KaTeX development server",
})
.option("include", {
abbr: "i",
help: "Comma-separated list of test cases to process"
help: "Comma-separated list of test cases to process",
})
.option("exclude", {
abbr: "x",
help: "Comma-separated list of test cases to exclude"
help: "Comma-separated list of test cases to exclude",
})
.option("verify", {
flag: true,
help: "Check whether screenshot matches current file content"
help: "Check whether screenshot matches current file content",
})
.parse();
@@ -121,7 +122,7 @@ if (!seleniumURL && opts.container) {
process.exit(2);
}
katexIP = config[1];
} catch(e) {
} catch (e) {
seleniumIP = katexIP = dockerCmd(
"inspect", "-f", "{{.NetworkSettings.Gateway}}", opts.container);
}
@@ -185,7 +186,7 @@ function tryConnect() {
}
var sock = net.connect({
host: seleniumIP,
port: +seleniumPort
port: +seleniumPort,
});
sock.on("connect", function() {
sock.end();
@@ -223,7 +224,8 @@ function buildDriver() {
//////////////////////////////////////////////////////////////////////
// Set the screen size
var targetW = 1024, targetH = 768;
var targetW = 1024;
var targetH = 768;
function setSize(reqW, reqH) {
return driver.manage().window().setSize(reqW, reqH).then(function() {
return driver.takeScreenshot();
@@ -247,7 +249,7 @@ function imageDimensions(img) {
return {
buf: buf,
width: buf.readUInt32BE(16),
height: buf.readUInt32BE(20)
height: buf.readUInt32BE(20),
};
}
@@ -310,7 +312,7 @@ function takeScreenshot(key) {
}
}
var opt = new jspngopt.Optimizer({
pako: pako
pako: pako,
});
var buf = opt.bufferSync(img.buf);
if (loadExpected) {