Switch linting to ESLint and Prettier (#191)

* Switch linting to ESLint and Prettier
* Clean up config
* Prettier fixes
This commit was merged in pull request #191.
This commit is contained in:
BehindTheMath
2019-02-13 22:26:57 -05:00
committed by GitHub
parent 2c6506af65
commit 3c1a4b2e18
23 changed files with 4674 additions and 2222 deletions

View File

@@ -1,49 +1,50 @@
var tape = require("tape")
var tape = require("tape");
var parseOptions = require("../../lib/parse-options.js");
var parseOptions = require("../../lib/parse-options.js")
tape("test parse initalization options function", function(t) {
t.test("- default options", function(t) {
var pjax = {}
pjax.options = parseOptions({})
var pjax = {};
pjax.options = parseOptions({});
t.equal(pjax.options.elements, "a[href], form[action]")
t.equal(pjax.options.selectors.length, 2, "selectors length")
t.equal(pjax.options.selectors[0], "title")
t.equal(pjax.options.selectors[1], ".js-Pjax")
t.equal(pjax.options.elements, "a[href], form[action]");
t.equal(pjax.options.selectors.length, 2, "selectors length");
t.equal(pjax.options.selectors[0], "title");
t.equal(pjax.options.selectors[1], ".js-Pjax");
t.equal(typeof pjax.options.switches, "object")
t.equal(Object.keys(pjax.options.switches).length, 2)// head and body
t.equal(typeof pjax.options.switches, "object");
t.equal(Object.keys(pjax.options.switches).length, 2); // head and body
t.equal(typeof pjax.options.switchesOptions, "object")
t.equal(Object.keys(pjax.options.switchesOptions).length, 0)
t.equal(typeof pjax.options.switchesOptions, "object");
t.equal(Object.keys(pjax.options.switchesOptions).length, 0);
t.equal(pjax.options.history, true)
t.equal(typeof pjax.options.analytics, "function")
t.equal(pjax.options.scrollTo, 0)
t.equal(pjax.options.scrollRestoration, true)
t.equal(pjax.options.cacheBust, true)
t.equal(pjax.options.debug, false)
t.equal(pjax.options.currentUrlFullReload, false)
t.end()
})
t.equal(pjax.options.history, true);
t.equal(typeof pjax.options.analytics, "function");
t.equal(pjax.options.scrollTo, 0);
t.equal(pjax.options.scrollRestoration, true);
t.equal(pjax.options.cacheBust, true);
t.equal(pjax.options.debug, false);
t.equal(pjax.options.currentUrlFullReload, false);
t.end();
});
// verify analytics always ends up as a function even when passed not a function
t.test("- analytics is a function", function(t) {
var pjax = {}
pjax.options = parseOptions({analytics: "some string"})
var pjax = {};
pjax.options = parseOptions({ analytics: "some string" });
t.deepEqual(typeof pjax.options.analytics, "function")
t.end()
})
t.deepEqual(typeof pjax.options.analytics, "function");
t.end();
});
// verify that the value false for scrollTo is not squashed
t.test("- scrollTo remains false", function(t) {
var pjax = {}
pjax.options = parseOptions({scrollTo: false})
var pjax = {};
pjax.options = parseOptions({ scrollTo: false });
t.deepEqual(pjax.options.scrollTo, false)
t.end()
})
t.deepEqual(pjax.options.scrollTo, false);
t.end();
});
t.end()
})
t.end();
});

View File

@@ -1,6 +1,6 @@
var jsdomOptions = {
url: "https://example.org/",
runScripts: "dangerously"
}
};
require("jsdom-global")("", jsdomOptions)
require("jsdom-global")("", jsdomOptions);