Chore: Fix lint issues and add indent with tabs

This commit is contained in:
Gyandeep Singh 2017-03-11 14:43:30 -06:00
parent 123a413b68
commit daf5a64697
9 changed files with 99 additions and 88 deletions

View file

@ -60,7 +60,14 @@ module.exports = {
"id-blacklist": "error", "id-blacklist": "error",
"id-length": "off", "id-length": "off",
"id-match": "error", "id-match": "error",
"indent": "off", "indent": [
"warn",
"tab",
{
"outerIIFEBody": 0,
"SwitchCase": 1
}
],
"init-declarations": "off", "init-declarations": "off",
"jsx-quotes": "error", "jsx-quotes": "error",
"key-spacing": "off", "key-spacing": "off",
@ -217,5 +224,6 @@ module.exports = {
"wrap-regex": "error", "wrap-regex": "error",
"yield-star-spacing": "error", "yield-star-spacing": "error",
"yoda": "off" "yoda": "off"
} },
"root": true
}; };

View file

@ -38,10 +38,10 @@ module.exports = function($window) {
var index = callbacks.indexOf(key) var index = callbacks.indexOf(key)
if (index > -1) callbacks.splice(index, 2) if (index > -1) callbacks.splice(index, 2)
} }
function redraw() { function redraw() {
for (var i = 1; i < callbacks.length; i += 2) { for (var i = 1; i < callbacks.length; i += 2) {
callbacks[i]() callbacks[i]()
} }
} }
return {subscribe: subscribe, unsubscribe: unsubscribe, redraw: redraw, render: renderService.render} return {subscribe: subscribe, unsubscribe: unsubscribe, redraw: redraw, render: renderService.render}
} }

View file

@ -528,6 +528,7 @@ o.spec("route", function() {
}) })
o(root.firstChild.nodeName).equals("DIV") o(root.firstChild.nodeName).equals("DIV")
o(renderCount).equals(1)
}) })
o("RouteResolver `render` does not have component semantics", function(done) { o("RouteResolver `render` does not have component semantics", function(done) {

View file

@ -24,9 +24,9 @@ o.spec("bundler", function() {
write("b.js", "module.exports = 1") write("b.js", "module.exports = 1")
bundle(ns + "a.js", ns + "out.js") bundle(ns + "a.js", ns + "out.js")
o(read("out.js")).equals(";(function() {\nvar b = 1\n}());") o(read("out.js")).equals(";(function() {\nvar b = 1\n}());")
remove("a.js") remove("a.js")
remove("b.js") remove("b.js")
remove("out.js") remove("out.js")
}) })
@ -35,7 +35,7 @@ o.spec("bundler", function() {
write("b.js", "module.exports = 1;") write("b.js", "module.exports = 1;")
bundle(ns + "a.js", ns + "out.js") bundle(ns + "a.js", ns + "out.js")
o(read("out.js")).equals(";(function() {\nvar b = 1;\n}());") o(read("out.js")).equals(";(function() {\nvar b = 1;\n}());")
remove("a.js") remove("a.js")
remove("b.js") remove("b.js")
@ -46,7 +46,7 @@ o.spec("bundler", function() {
write("b.js", "module.exports = 1") write("b.js", "module.exports = 1")
bundle(ns + "a.js", ns + "out.js") bundle(ns + "a.js", ns + "out.js")
o(read("out.js")).equals(";(function() {\nlet b = 1\n}());") o(read("out.js")).equals(";(function() {\nlet b = 1\n}());")
remove("a.js") remove("a.js")
remove("b.js") remove("b.js")
@ -57,7 +57,7 @@ o.spec("bundler", function() {
write("b.js", "module.exports = 1") write("b.js", "module.exports = 1")
bundle(ns + "a.js", ns + "out.js") bundle(ns + "a.js", ns + "out.js")
o(read("out.js")).equals(";(function() {\nconst b = 1\n}());") o(read("out.js")).equals(";(function() {\nconst b = 1\n}());")
remove("a.js") remove("a.js")
remove("b.js") remove("b.js")
@ -156,9 +156,9 @@ o.spec("bundler", function() {
write("b.js", "module.exports = []") write("b.js", "module.exports = []")
bundle(ns + "a.js", ns + "out.js") bundle(ns + "a.js", ns + "out.js")
o(read("out.js")).equals(";(function() {\nvar _0 = []\nvar b = _0\n\t.toString()\n}());") o(read("out.js")).equals(";(function() {\nvar _0 = []\nvar b = _0\n\t.toString()\n}());")
remove("a.js") remove("a.js")
remove("b.js") remove("b.js")
remove("out.js") remove("out.js")
}) })
@ -169,7 +169,7 @@ o.spec("bundler", function() {
o(read("out.js")).equals(";(function() {\nvar _0 = function() {}\nvar b = _0()\n}());") o(read("out.js")).equals(";(function() {\nvar _0 = function() {}\nvar b = _0()\n}());")
remove("a.js") remove("a.js")
remove("b.js") remove("b.js")
remove("out.js") remove("out.js")
}) })

View file

@ -14,6 +14,7 @@
"lintdocs": "node docs/lint", "lintdocs": "node docs/lint",
"gendocs": "node docs/generate", "gendocs": "node docs/generate",
"lint": "eslint .", "lint": "eslint .",
"lint:fix": "eslint . --fix",
"test": "node ospec/bin/ospec", "test": "node ospec/bin/ospec",
"posttest": "npm run lint || true", "posttest": "npm run lint || true",
"cover": "istanbul cover --print both ospec/bin/ospec", "cover": "istanbul cover --print both ospec/bin/ospec",

View file

@ -584,15 +584,15 @@ o.spec("promise", function() {
var readCount = 0 var readCount = 0
var promise = Promise.resolve(1).then(function() { var promise = Promise.resolve(1).then(function() {
return Object.create(null, { return Object.create(null, {
then: { then: {
get: function () { get: function () {
++readCount ++readCount
return function(onFulfilled) { return function(onFulfilled) {
onFulfilled() onFulfilled()
} }
} }
} }
}) })
}) })
promise.then(function() { promise.then(function() {

View file

@ -162,6 +162,7 @@ o.spec("stream", function() {
}) })
o(b()).equals(undefined) o(b()).equals(undefined)
o(count).equals(0)
}) })
o("combine will throw with a helpful error if given non-stream values", function () { o("combine will throw with a helpful error if given non-stream values", function () {
var spy = o.spy() var spy = o.spy()

View file

@ -1,29 +1,29 @@
"use strict" "use strict"
module.exports = [ module.exports = [
{ {
kind: "POJO", kind: "POJO",
create: function(methods) { create: function(methods) {
var res = {view: function() {return {tag:"div"}}} var res = {view: function() {return {tag:"div"}}}
Object.keys(methods || {}).forEach(function(m){res[m] = methods[m]}) Object.keys(methods || {}).forEach(function(m){res[m] = methods[m]})
return res return res
} }
}, { }, {
kind: "constructible", kind: "constructible",
create: function(methods) { create: function(methods) {
function res(){} function res(){}
res.prototype.view = function() {return {tag:"div"}} res.prototype.view = function() {return {tag:"div"}}
Object.keys(methods || {}).forEach(function(m){res.prototype[m] = methods[m]}) Object.keys(methods || {}).forEach(function(m){res.prototype[m] = methods[m]})
return res return res
} }
}, { }, {
kind: "closure", kind: "closure",
create: function(methods) { create: function(methods) {
return function() { return function() {
var res = {view: function() {return {tag:"div"}}} var res = {view: function() {return {tag:"div"}}}
Object.keys(methods || {}).forEach(function(m){res[m] = methods[m]}) Object.keys(methods || {}).forEach(function(m){res[m] = methods[m]})
return res return res
} }
} }
} }
] ]

View file

@ -4,51 +4,51 @@ var o = require("../../ospec/ospec")
var components = require("../../test-utils/components") var components = require("../../test-utils/components")
o.spec("test-utils/components", function() { o.spec("test-utils/components", function() {
var test = o.spy(function(component) { var test = o.spy(function(component) {
return function() { return function() {
o("works", function() { o("works", function() {
o(typeof component.kind).equals("string") o(typeof component.kind).equals("string")
var methods = {oninit: function(){}, view: function(){}} var methods = {oninit: function(){}, view: function(){}}
var cmp1, cmp2 var cmp1, cmp2
if (component.kind === "POJO") { if (component.kind === "POJO") {
cmp1 = component.create() cmp1 = component.create()
cmp2 = component.create(methods) cmp2 = component.create(methods)
} else if (component.kind === "constructible") { } else if (component.kind === "constructible") {
cmp1 = new (component.create()) cmp1 = new (component.create())
cmp2 = new (component.create(methods)) cmp2 = new (component.create(methods))
} else if (component.kind === "closure") { } else if (component.kind === "closure") {
cmp1 = component.create()() cmp1 = component.create()()
cmp2 = component.create(methods)() cmp2 = component.create(methods)()
} else { } else {
throw new Error("unexpected component kind") throw new Error("unexpected component kind")
} }
o(cmp1 != null).equals(true) o(cmp1 != null).equals(true)
o(typeof cmp1.view).equals("function") o(typeof cmp1.view).equals("function")
var vnode = cmp1.view() var vnode = cmp1.view()
o(vnode != null).equals(true) o(vnode != null).equals(true)
o(vnode).deepEquals({tag: "div"}) o(vnode).deepEquals({tag: "div"})
if (component.kind !== "constructible") { if (component.kind !== "constructible") {
o(cmp2).deepEquals(methods) o(cmp2).deepEquals(methods)
} else { } else {
// deepEquals doesn't search the prototype, do it manually // deepEquals doesn't search the prototype, do it manually
o(cmp2 != null).equals(true) o(cmp2 != null).equals(true)
o(cmp2.view).equals(methods.view) o(cmp2.view).equals(methods.view)
o(cmp2.oninit).equals(methods.oninit) o(cmp2.oninit).equals(methods.oninit)
} }
}) })
} }
}) })
o.after(function(){ o.after(function(){
o(test.callCount).equals(3) o(test.callCount).equals(3)
}) })
components.forEach(function(component) { components.forEach(function(component) {
o.spec(component.kind, test(component)) o.spec(component.kind, test(component))
}) })
}) })