Skip to content

Commit

Permalink
fixed standard issues
Browse files Browse the repository at this point in the history
  • Loading branch information
refractalize committed Apr 9, 2017
1 parent c135a78 commit 99ab051
Show file tree
Hide file tree
Showing 25 changed files with 89 additions and 366 deletions.
3 changes: 3 additions & 0 deletions .vimrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
let g:ale_linters = {
\ 'javascript': ['standard'],
\}
12 changes: 6 additions & 6 deletions bindModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var inputTypeBindings = {

radio: function (attributes, children, get, set) {
var value = attributes.value
attributes.checked = get() == attributes.value
attributes.checked = get() === attributes.value
attributes.on_hyperdomsyncchecked = listener(function (event) {
attributes.checked = event.target.checked
})
Expand All @@ -47,7 +47,7 @@ var inputTypeBindings = {
var currentValue = get()

var options = children.filter(function (child) {
return child.tagName.toLowerCase() == 'option'
return child.tagName.toLowerCase() === 'option'
})

var values = []
Expand All @@ -61,7 +61,7 @@ var inputTypeBindings = {

values.push(hasValue ? value : text)

var selected = value == currentValue || text == currentValue
var selected = value === currentValue || text === currentValue

if (selected) {
selectedIndex = n
Expand Down Expand Up @@ -109,11 +109,11 @@ function bindTextInput (attributes, children, get, set) {

var bindingValue = get()
if (!(bindingValue instanceof Error)) {
attributes.value = bindingValue != undefined ? bindingValue : ''
attributes.value = bindingValue !== undefined ? bindingValue : ''
}

attachEventHandler(attributes, textEventNames, function (ev) {
if (get() != ev.target.value) {
if (get() !== ev.target.value) {
set(ev.target.value)
}
})
Expand Down Expand Up @@ -151,7 +151,7 @@ function sequenceFunctions (handler1, handler2) {

function customEvent (name) {
if (typeof Event === 'function') {
return new Event(name)
return new window.Event(name)
} else {
var event = document.createEvent('Event')
event.initEvent(name, false, false)
Expand Down
6 changes: 3 additions & 3 deletions domComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ function prepareVdom (object) {

DomComponent.prototype.create = function (vdom) {
this.vdom = prepareVdom(vdom)
return this.element = createElement(this.vdom, {document: this.document})
return (this.element = createElement(this.vdom, {document: this.document}))
}

DomComponent.prototype.merge = function (vdom, element) {
this.vdom = prepareVdom(vdom)
return this.element = element
return (this.element = element)
}

DomComponent.prototype.update = function (vdom) {
var oldVdom = this.vdom
this.vdom = prepareVdom(vdom)
var patches = diff(oldVdom, this.vdom)
return this.element = patch(this.element, patches)
return (this.element = patch(this.element, patches))
}

DomComponent.prototype.destroy = function (options) {
Expand Down
2 changes: 1 addition & 1 deletion hyperx.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
try {
var hyperx = require('hyperx')
} catch (e) {
if (e.code == 'MODULE_NOT_FOUND') {
if (e.code === 'MODULE_NOT_FOUND') {
throw new Error('to use hyperx with hyperdom you need to install the hyperx package')
}
throw e
Expand Down
6 changes: 3 additions & 3 deletions isVdom.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ var virtualDomVersion = require('virtual-dom/vnode/version')

module.exports = function (x) {
var type = x.type
if (type == 'VirtualNode' || type == 'VirtualText') {
return x.version == virtualDomVersion
if (type === 'VirtualNode' || type === 'VirtualText') {
return x.version === virtualDomVersion
} else {
return type == 'Widget' || type == 'Thunk'
return type === 'Widget' || type === 'Thunk'
}
}
5 changes: 2 additions & 3 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ module.exports = function (config) {

// list of files / patterns to load in the browser
files: [
'test/browser/promisePolyfill.js',
'test/browser/**/*Spec.js'
],

Expand Down Expand Up @@ -60,14 +59,14 @@ module.exports = function (config) {
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_WARN,
concurrency: process.env.BROWSERS == 'all' ? 2 : Infinity,
concurrency: process.env.BROWSERS === 'all' ? 2 : Infinity,

// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,

// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: process.env.BROWSERS == 'all' ? Object.keys(browsers) : ['Chrome'],
browsers: process.env.BROWSERS === 'all' ? Object.keys(browsers) : ['Chrome'],

browserStack: {
username: process.env.BROWSERSTACK_USER,
Expand Down
2 changes: 1 addition & 1 deletion mapBinding.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function chainConverters (startIndex, converters) {
}
}

if ((converters.length - startIndex) == 1) {
if ((converters.length - startIndex) === 1) {
return makeConverter(converters[startIndex])
} else {
var _converters
Expand Down
8 changes: 4 additions & 4 deletions mount.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var runRender = require('./render')
var domComponent = require('./domComponent')
var Set = require('./set')
var refreshEventResult = require('./refreshEventResult')
var vtext = require('virtual-dom/vnode/vtext.js')
var Vtext = require('virtual-dom/vnode/vtext.js')
var PropertyHook = require('./propertyHook')

var lastId = 0
Expand All @@ -29,7 +29,7 @@ Mount.prototype.refreshify = function (fn, options) {
return fn
}

if (options && (options.norefresh == true || options.refresh == false)) {
if (options && (options.norefresh === true || options.refresh === false)) {
return fn
}

Expand Down Expand Up @@ -142,7 +142,7 @@ Mount.prototype.setupModelComponent = function (model) {

Mount.prototype._renderComponent = function (model) {
this.setupModelComponent(model)
var vdom = typeof model.render === 'function' ? model.render() : new vtext(JSON.stringify(model))
var vdom = typeof model.render === 'function' ? model.render() : new Vtext(JSON.stringify(model))

if (vdom instanceof Array) {
console.error('vdom returned from component cannot be an array, component: ', model)
Expand Down Expand Up @@ -171,7 +171,7 @@ Mount.prototype.renderComponent = function (model) {
return meta.cachedVdom
} else {
meta.cacheKey = key
return meta.cachedVdom = this._renderComponent(model)
return (meta.cachedVdom = this._renderComponent(model))
}
} else {
return this._renderComponent(model)
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,17 @@
"karma-mocha": "1.3.0",
"karma-mocha-reporter": "2.2.2",
"karma-safari-launcher": "1.0.0",
"lie": "3.1.1",
"lowscore": "1.12.1",
"mocha": "3.2.0",
"standard": "10.0.1",
"trytryagain": "1.2.0",
"uglify-js": "2.4.16",
"vdom-to-html": "2.0.0"
"vdom-to-html": "2.3.1",
"watchify": "3.9.0"
},
"scripts": {
"test": "npm run karma && npm run mocha",
"test": "npm run karma && npm run mocha && standard",
"test-all": "BROWSERS=all npm test",
"karma": "karma start --single-run",
"mocha": "mocha test/server/*Spec.js",
Expand Down
2 changes: 1 addition & 1 deletion refreshEventResult.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function norefreshFunction () {
module.exports.norefresh = norefreshFunction

function refreshAfterEvent (result, mount, options) {
var onlyRefreshAfterPromise = options && options.refresh == 'promise'
var onlyRefreshAfterPromise = options && options.refresh === 'promise'
var componentToRefresh = options && options.component

if (result && typeof (result.then) === 'function') {
Expand Down
4 changes: 2 additions & 2 deletions rendering.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ exports.html = function (hierarchySelector) {
var tag
var attributes = arguments[1]

if (attributes && attributes.constructor == Object && typeof attributes.render !== 'function') {
if (attributes && attributes.constructor === Object && typeof attributes.render !== 'function') {
childElements = toVdom.recursive(Array.prototype.slice.call(arguments, 2))
prepareAttributes(selector, attributes, childElements)
tag = parseTag(selector, attributes)
Expand Down Expand Up @@ -160,7 +160,7 @@ function rawHtml () {
var html
var options

if (arguments.length == 2) {
if (arguments.length === 2) {
selector = arguments[0]
html = arguments[1]
options = {innerHTML: html}
Expand Down
16 changes: 8 additions & 8 deletions router.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ Router.prototype.render = function (model) {
var routes = modelRoutes(model, true)

var action
if (self.lastUrl != url) {
if (self.lastUrl !== url) {
action = setUrl(url, routes)
} else {
action = getUrl(url, routes)
}

if (action) {
if (action.url) {
if (self.lastUrl != action.url) {
if (self.lastUrl !== action.url) {
if (action.push) {
self.history.push(action.url)
} else {
Expand Down Expand Up @@ -114,7 +114,7 @@ Router.prototype.route = function (pattern) {

route.push = function (params, options) {
self.history.push(self.expandUrl(patternVariables.pattern, params))
if (!(options && options.resetScroll == false)) {
if (!(options && options.resetScroll === false)) {
window.scrollTo(0, 0)
}
}
Expand Down Expand Up @@ -333,7 +333,7 @@ Router.prototype.expandUrl = function (pattern, _params) {
}

function escapeRegex (pattern) {
return pattern.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&')
return pattern.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&')
}

function compilePattern (pattern) {
Expand All @@ -344,7 +344,7 @@ function compilePattern (pattern) {
return escapeRegex(pattern)
.replace(splatVariableRegex, '(.+)')
.replace(anyRegex, '.*')
.replace(variableRegex, '([^\/]+)')
.replace(variableRegex, '([^/]+)')
}

function preparePattern (pattern) {
Expand All @@ -361,7 +361,7 @@ function preparePattern (pattern) {
return {
pattern: pattern,
regex: new RegExp('^' + compiledPattern + '($)'),
mountRegex: new RegExp('^' + compiledPattern + (pattern[pattern.length - 1] == '/' ? '' : '(/|$)')),
mountRegex: new RegExp('^' + compiledPattern + (pattern[pattern.length - 1] === '/' ? '' : '(/|$)')),
variables: variables
}
}
Expand Down Expand Up @@ -423,7 +423,7 @@ QueryString.prototype.stringify = function (paramsObject) {
var query = Object.keys(paramsObject).map(function (key) {
var param = paramToString(paramsObject[key])

if (param != '') {
if (param !== '') {
return encodeURIComponent(key) + '=' + encodeURIComponent(param)
}
}).filter(function (param) {
Expand Down Expand Up @@ -456,7 +456,7 @@ PushState.prototype.start = function (model) {
// before that scroll takes place, which is what we do with model.refreshImmediately()
// also, it seems that its necessary to call document.body.clientHeight to force it
// to layout the page before attempting set the scroll position
document.body.clientHeight
document.body.clientHeight // eslint-disable-line no-unused-expressions
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion set.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ if (typeof Set === 'function') {
}

module.exports.prototype.add = function (widget) {
if (this.items.indexOf(widget) == -1) {
if (this.items.indexOf(widget) === -1) {
this.items.push(widget)
}
}
Expand Down
2 changes: 1 addition & 1 deletion storeCache.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ StoreCache.prototype.cache = function (key, loadFn) {
var self = this

var loadPromise = loadFn().then(function (data) {
return self.data[key] = data
return (self.data[key] = data)
})

return modifyPromiseChain(loadPromise, p => {
Expand Down
Loading

0 comments on commit 99ab051

Please sign in to comment.