Chore: Fix lint issues and add indent with tabs
This commit is contained in:
parent
123a413b68
commit
daf5a64697
9 changed files with 99 additions and 88 deletions
12
.eslintrc.js
12
.eslintrc.js
|
|
@ -60,7 +60,14 @@ module.exports = {
|
|||
"id-blacklist": "error",
|
||||
"id-length": "off",
|
||||
"id-match": "error",
|
||||
"indent": "off",
|
||||
"indent": [
|
||||
"warn",
|
||||
"tab",
|
||||
{
|
||||
"outerIIFEBody": 0,
|
||||
"SwitchCase": 1
|
||||
}
|
||||
],
|
||||
"init-declarations": "off",
|
||||
"jsx-quotes": "error",
|
||||
"key-spacing": "off",
|
||||
|
|
@ -217,5 +224,6 @@ module.exports = {
|
|||
"wrap-regex": "error",
|
||||
"yield-star-spacing": "error",
|
||||
"yoda": "off"
|
||||
}
|
||||
},
|
||||
"root": true
|
||||
};
|
||||
|
|
|
|||
|
|
@ -38,10 +38,10 @@ module.exports = function($window) {
|
|||
var index = callbacks.indexOf(key)
|
||||
if (index > -1) callbacks.splice(index, 2)
|
||||
}
|
||||
function redraw() {
|
||||
for (var i = 1; i < callbacks.length; i += 2) {
|
||||
callbacks[i]()
|
||||
}
|
||||
}
|
||||
function redraw() {
|
||||
for (var i = 1; i < callbacks.length; i += 2) {
|
||||
callbacks[i]()
|
||||
}
|
||||
}
|
||||
return {subscribe: subscribe, unsubscribe: unsubscribe, redraw: redraw, render: renderService.render}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -528,6 +528,7 @@ o.spec("route", function() {
|
|||
})
|
||||
|
||||
o(root.firstChild.nodeName).equals("DIV")
|
||||
o(renderCount).equals(1)
|
||||
})
|
||||
|
||||
o("RouteResolver `render` does not have component semantics", function(done) {
|
||||
|
|
|
|||
|
|
@ -24,9 +24,9 @@ o.spec("bundler", function() {
|
|||
write("b.js", "module.exports = 1")
|
||||
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("out.js")
|
||||
})
|
||||
|
|
@ -35,7 +35,7 @@ o.spec("bundler", function() {
|
|||
write("b.js", "module.exports = 1;")
|
||||
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("b.js")
|
||||
|
|
@ -46,7 +46,7 @@ o.spec("bundler", function() {
|
|||
write("b.js", "module.exports = 1")
|
||||
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("b.js")
|
||||
|
|
@ -57,7 +57,7 @@ o.spec("bundler", function() {
|
|||
write("b.js", "module.exports = 1")
|
||||
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("b.js")
|
||||
|
|
@ -156,9 +156,9 @@ o.spec("bundler", function() {
|
|||
write("b.js", "module.exports = []")
|
||||
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("out.js")
|
||||
})
|
||||
|
|
@ -169,7 +169,7 @@ o.spec("bundler", function() {
|
|||
|
||||
o(read("out.js")).equals(";(function() {\nvar _0 = function() {}\nvar b = _0()\n}());")
|
||||
|
||||
remove("a.js")
|
||||
remove("a.js")
|
||||
remove("b.js")
|
||||
remove("out.js")
|
||||
})
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
"lintdocs": "node docs/lint",
|
||||
"gendocs": "node docs/generate",
|
||||
"lint": "eslint .",
|
||||
"lint:fix": "eslint . --fix",
|
||||
"test": "node ospec/bin/ospec",
|
||||
"posttest": "npm run lint || true",
|
||||
"cover": "istanbul cover --print both ospec/bin/ospec",
|
||||
|
|
|
|||
|
|
@ -584,15 +584,15 @@ o.spec("promise", function() {
|
|||
var readCount = 0
|
||||
var promise = Promise.resolve(1).then(function() {
|
||||
return Object.create(null, {
|
||||
then: {
|
||||
get: function () {
|
||||
++readCount
|
||||
return function(onFulfilled) {
|
||||
onFulfilled()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
then: {
|
||||
get: function () {
|
||||
++readCount
|
||||
return function(onFulfilled) {
|
||||
onFulfilled()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
promise.then(function() {
|
||||
|
|
|
|||
|
|
@ -162,6 +162,7 @@ o.spec("stream", function() {
|
|||
})
|
||||
|
||||
o(b()).equals(undefined)
|
||||
o(count).equals(0)
|
||||
})
|
||||
o("combine will throw with a helpful error if given non-stream values", function () {
|
||||
var spy = o.spy()
|
||||
|
|
|
|||
|
|
@ -1,29 +1,29 @@
|
|||
"use strict"
|
||||
|
||||
module.exports = [
|
||||
{
|
||||
kind: "POJO",
|
||||
create: function(methods) {
|
||||
var res = {view: function() {return {tag:"div"}}}
|
||||
Object.keys(methods || {}).forEach(function(m){res[m] = methods[m]})
|
||||
return res
|
||||
}
|
||||
}, {
|
||||
kind: "constructible",
|
||||
create: function(methods) {
|
||||
function res(){}
|
||||
res.prototype.view = function() {return {tag:"div"}}
|
||||
Object.keys(methods || {}).forEach(function(m){res.prototype[m] = methods[m]})
|
||||
return res
|
||||
}
|
||||
}, {
|
||||
kind: "closure",
|
||||
create: function(methods) {
|
||||
return function() {
|
||||
var res = {view: function() {return {tag:"div"}}}
|
||||
Object.keys(methods || {}).forEach(function(m){res[m] = methods[m]})
|
||||
return res
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
kind: "POJO",
|
||||
create: function(methods) {
|
||||
var res = {view: function() {return {tag:"div"}}}
|
||||
Object.keys(methods || {}).forEach(function(m){res[m] = methods[m]})
|
||||
return res
|
||||
}
|
||||
}, {
|
||||
kind: "constructible",
|
||||
create: function(methods) {
|
||||
function res(){}
|
||||
res.prototype.view = function() {return {tag:"div"}}
|
||||
Object.keys(methods || {}).forEach(function(m){res.prototype[m] = methods[m]})
|
||||
return res
|
||||
}
|
||||
}, {
|
||||
kind: "closure",
|
||||
create: function(methods) {
|
||||
return function() {
|
||||
var res = {view: function() {return {tag:"div"}}}
|
||||
Object.keys(methods || {}).forEach(function(m){res[m] = methods[m]})
|
||||
return res
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -4,51 +4,51 @@ var o = require("../../ospec/ospec")
|
|||
var components = require("../../test-utils/components")
|
||||
|
||||
o.spec("test-utils/components", function() {
|
||||
var test = o.spy(function(component) {
|
||||
return function() {
|
||||
o("works", function() {
|
||||
o(typeof component.kind).equals("string")
|
||||
var test = o.spy(function(component) {
|
||||
return function() {
|
||||
o("works", function() {
|
||||
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") {
|
||||
cmp1 = component.create()
|
||||
cmp2 = component.create(methods)
|
||||
} else if (component.kind === "constructible") {
|
||||
cmp1 = new (component.create())
|
||||
cmp2 = new (component.create(methods))
|
||||
} else if (component.kind === "closure") {
|
||||
cmp1 = component.create()()
|
||||
cmp2 = component.create(methods)()
|
||||
} else {
|
||||
throw new Error("unexpected component kind")
|
||||
}
|
||||
if (component.kind === "POJO") {
|
||||
cmp1 = component.create()
|
||||
cmp2 = component.create(methods)
|
||||
} else if (component.kind === "constructible") {
|
||||
cmp1 = new (component.create())
|
||||
cmp2 = new (component.create(methods))
|
||||
} else if (component.kind === "closure") {
|
||||
cmp1 = component.create()()
|
||||
cmp2 = component.create(methods)()
|
||||
} else {
|
||||
throw new Error("unexpected component kind")
|
||||
}
|
||||
|
||||
o(cmp1 != null).equals(true)
|
||||
o(typeof cmp1.view).equals("function")
|
||||
o(cmp1 != null).equals(true)
|
||||
o(typeof cmp1.view).equals("function")
|
||||
|
||||
var vnode = cmp1.view()
|
||||
var vnode = cmp1.view()
|
||||
|
||||
o(vnode != null).equals(true)
|
||||
o(vnode).deepEquals({tag: "div"})
|
||||
o(vnode != null).equals(true)
|
||||
o(vnode).deepEquals({tag: "div"})
|
||||
|
||||
if (component.kind !== "constructible") {
|
||||
o(cmp2).deepEquals(methods)
|
||||
} else {
|
||||
if (component.kind !== "constructible") {
|
||||
o(cmp2).deepEquals(methods)
|
||||
} else {
|
||||
// deepEquals doesn't search the prototype, do it manually
|
||||
o(cmp2 != null).equals(true)
|
||||
o(cmp2.view).equals(methods.view)
|
||||
o(cmp2.oninit).equals(methods.oninit)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
o.after(function(){
|
||||
o(test.callCount).equals(3)
|
||||
})
|
||||
components.forEach(function(component) {
|
||||
o.spec(component.kind, test(component))
|
||||
})
|
||||
o(cmp2 != null).equals(true)
|
||||
o(cmp2.view).equals(methods.view)
|
||||
o(cmp2.oninit).equals(methods.oninit)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
o.after(function(){
|
||||
o(test.callCount).equals(3)
|
||||
})
|
||||
components.forEach(function(component) {
|
||||
o.spec(component.kind, test(component))
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue