diff --git a/.vimrc b/.vimrc new file mode 100644 index 0000000..68b68f0 --- /dev/null +++ b/.vimrc @@ -0,0 +1,3 @@ +let g:ale_linters = { +\ 'javascript': ['standard'], +\} diff --git a/bindModel.js b/bindModel.js index 76029da..a8029a8 100644 --- a/bindModel.js +++ b/bindModel.js @@ -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 }) @@ -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 = [] @@ -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 @@ -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) } }) @@ -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) diff --git a/domComponent.js b/domComponent.js index 8d0f57a..f62c3b5 100644 --- a/domComponent.js +++ b/domComponent.js @@ -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) { diff --git a/hyperx.js b/hyperx.js index e6f57cf..45e824f 100644 --- a/hyperx.js +++ b/hyperx.js @@ -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 diff --git a/isVdom.js b/isVdom.js index 239a8f7..49bb1ac 100644 --- a/isVdom.js +++ b/isVdom.js @@ -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' } } diff --git a/karma.conf.js b/karma.conf.js index acccf95..606b38f 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -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' ], @@ -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, diff --git a/mapBinding.js b/mapBinding.js index 075adaf..4c8e62e 100644 --- a/mapBinding.js +++ b/mapBinding.js @@ -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 diff --git a/mount.js b/mount.js index ef56136..c9e459c 100644 --- a/mount.js +++ b/mount.js @@ -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 @@ -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 } @@ -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) @@ -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) diff --git a/package.json b/package.json index d5e0424..cdb70f2 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/refreshEventResult.js b/refreshEventResult.js index d9052d5..5050c49 100644 --- a/refreshEventResult.js +++ b/refreshEventResult.js @@ -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') { diff --git a/rendering.js b/rendering.js index b12a585..a016b14 100644 --- a/rendering.js +++ b/rendering.js @@ -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) @@ -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} diff --git a/router.js b/router.js index afbbe1a..dc63bd2 100644 --- a/router.js +++ b/router.js @@ -43,7 +43,7 @@ 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) @@ -51,7 +51,7 @@ Router.prototype.render = function (model) { if (action) { if (action.url) { - if (self.lastUrl != action.url) { + if (self.lastUrl !== action.url) { if (action.push) { self.history.push(action.url) } else { @@ -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) } } @@ -333,7 +333,7 @@ Router.prototype.expandUrl = function (pattern, _params) { } function escapeRegex (pattern) { - return pattern.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&') + return pattern.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&') } function compilePattern (pattern) { @@ -344,7 +344,7 @@ function compilePattern (pattern) { return escapeRegex(pattern) .replace(splatVariableRegex, '(.+)') .replace(anyRegex, '.*') - .replace(variableRegex, '([^\/]+)') + .replace(variableRegex, '([^/]+)') } function preparePattern (pattern) { @@ -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 } } @@ -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) { @@ -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 } }) } diff --git a/set.js b/set.js index 7422713..65d8380 100644 --- a/set.js +++ b/set.js @@ -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) } } diff --git a/storeCache.js b/storeCache.js index 4bb444f..9cc2e39 100644 --- a/storeCache.js +++ b/storeCache.js @@ -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 => { diff --git a/test/browser/hyperdomSpec.js b/test/browser/hyperdomSpec.js index ddbc558..204c566 100644 --- a/test/browser/hyperdomSpec.js +++ b/test/browser/hyperdomSpec.js @@ -1,3 +1,7 @@ +/* eslint-env mocha */ + +require('lie/polyfill') + var $ = require('jquery') var hyperdom = require('../..') var mapBinding = require('../../mapBinding') @@ -129,7 +133,7 @@ describe('hyperdom', function () { expect(div.innerHTML).to.equal('
stuff
') return click('div.rendered').then(function () { - expect(renderRequested).to.be.true + expect(renderRequested).to.equal(true) }) }) @@ -146,8 +150,6 @@ describe('hyperdom', function () { } } - var renderRequested = false - hyperdom.append(targetDiv, model, { requestRender: function (render) { render() @@ -221,7 +223,7 @@ describe('hyperdom', function () { merge(mergeDiv, app) return retry(function () { - expect(find('button.update')[0].onclick).to.exist + expect(find('button.update')[0].onclick).to.exist // eslint-disable-line no-unused-expressions }).then(function () { return click('button.update').then(function () { }).then(function () { @@ -273,7 +275,7 @@ describe('hyperdom', function () { attach(render, {}) - expect(find('.haha').text()).to.eql(expectedValue != undefined ? expectedValue : String(value)) + expect(find('.haha').text()).to.eql(expectedValue !== undefined ? expectedValue : String(value)) }) } @@ -606,7 +608,7 @@ describe('hyperdom', function () { expect(address.namespaceURI).to.eql('urn:address') expect(address.prefix).to.eql(null) var addressAttribute = address.getAttributeNodeNS('urn:address', 'street') - expect(addressAttribute).to.exist + expect(addressAttribute).to.exist // eslint-disable-line no-unused-expressions expect(addressAttribute.namespaceURI).to.eql('urn:address') expect(addressAttribute.name).to.eql('addr:street') expect(addressAttribute.prefix).to.eql('addr') @@ -644,10 +646,10 @@ describe('hyperdom', function () { h('button', { onclick: function () { model.text = 'loading' - return new Promise(function (result) { + return new Promise(function (resolve) { setTimeout(function () { model.text = 'loaded' - result() + resolve() }, 100) }) } @@ -815,7 +817,7 @@ describe('hyperdom', function () { it('radio', function () { function render (model) { return h('div', - model.value == 1 ? h('h1', 'selected one') : undefined, + model.value === 1 ? h('h1', 'selected one') : undefined, h('label', h('input.one', {type: 'radio', name: 'thingy', binding: [model, 'value'], value: 1, id: 'one'}), 'one'), h('label', h('input.two', {type: 'radio', name: 'thingy', binding: [model, 'value'], value: 2, id: 'two'}), 'two') ) @@ -1301,7 +1303,7 @@ describe('hyperdom', function () { return h('div', h('h1', 'component'), - h('button.refresh', {onclick: function () {} }, 'refresh') + h('button.refresh', { onclick: function () {} }, 'refresh') ) } } @@ -1659,7 +1661,7 @@ describe('hyperdom', function () { var model = {} hyperdom.binding([model, 'field'], {component: component}).set('value') - expect(component.wasRefreshed).to.be.true + expect(component.wasRefreshed).to.equal(true) }) }) @@ -1674,7 +1676,7 @@ describe('hyperdom', function () { var model = {} hyperdom.binding([model, 'field'], {component: component}).set('value') - expect(component.wasRefreshed).to.be.true + expect(component.wasRefreshed).to.equal(true) }) }) @@ -2093,7 +2095,8 @@ describe('hyperdom', function () { it('updates the component when refreshed', function () { var monitor = renderMonitor() - var updated = 0, rendered = 0 + var updated = 0 + var rendered = 0 function render (model) { var refresh = h.refresh @@ -2741,9 +2744,9 @@ describe('hyperdom', function () { function load (model) { return waiting ? undefined - : waiting = wait(20).then(function () { + : (waiting = wait(20).then(function () { model.text = 'loaded' - }) + })) } function render (model) { @@ -2763,7 +2766,7 @@ describe('hyperdom', function () { }) function wait (n) { - return new Promise(function (result) { - setTimeout(result, n) + return new Promise(function (resolve) { + setTimeout(resolve, n) }) } diff --git a/test/browser/promisePolyfill.js b/test/browser/promisePolyfill.js deleted file mode 100644 index fdba81e..0000000 --- a/test/browser/promisePolyfill.js +++ /dev/null @@ -1,281 +0,0 @@ -(function (global) { -// -// Check for native Promise and it has correct interface -// - - var NativePromise = global['Promise'] - var nativePromiseSupported = - NativePromise && - // Some of these methods are missing from - // Firefox/Chrome experimental implementations - 'resolve' in NativePromise && - 'reject' in NativePromise && - 'all' in NativePromise && - 'race' in NativePromise && - // Older version of the spec had a resolver object - // as the arg rather than a function - (function () { - var resolve - new NativePromise(function (r) { resolve = r }) - return typeof resolve === 'function' - })() - -// -// export if necessary -// - - if (typeof exports !== 'undefined' && exports) { - // node.js - exports.Promise = Promise || NativePromise - } else { - // in browser add to global - if (!nativePromiseSupported) { global['Promise'] = Promise } - } - -// -// Polyfill -// - - var PENDING = 'pending' - var SEALED = 'sealed' - var FULFILLED = 'fulfilled' - var REJECTED = 'rejected' - var NOOP = function () {} - -// async calls - var asyncSetTimer = typeof setImmediate !== 'undefined' ? setImmediate : setTimeout - var asyncQueue = [] - var asyncTimer - - function asyncFlush () { - // run promise callbacks - for (var i = 0; i < asyncQueue.length; i++) { asyncQueue[i][0](asyncQueue[i][1]) } - - // reset async asyncQueue - asyncQueue = [] - asyncTimer = false - } - - function asyncCall (callback, arg) { - asyncQueue.push([callback, arg]) - - if (!asyncTimer) { - asyncTimer = true - asyncSetTimer(asyncFlush, 0) - } - } - - function invokeResolver (resolver, promise) { - function resolvePromise (value) { - resolve(promise, value) - } - - function rejectPromise (reason) { - reject(promise, reason) - } - - try { - resolver(resolvePromise, rejectPromise) - } catch (e) { - rejectPromise(e) - } - } - - function invokeCallback (subscriber) { - var owner = subscriber.owner - var settled = owner.state_ - var value = owner.data_ - var callback = subscriber[settled] - var promise = subscriber.then - - if (typeof callback === 'function') { - settled = FULFILLED - try { - value = callback(value) - } catch (e) { - reject(promise, e) - } - } - - if (!handleThenable(promise, value)) { - if (settled === FULFILLED) { resolve(promise, value) } - - if (settled === REJECTED) { reject(promise, value) } - } - } - - function handleThenable (promise, value) { - var resolved - - try { - if (promise === value) { throw new TypeError('A promises callback cannot return that same promise.') } - - if (value && (typeof value === 'function' || typeof value === 'object')) { - var then = value.then // then should be retrived only once - - if (typeof then === 'function') { - then.call(value, function (val) { - if (!resolved) { - resolved = true - - if (value !== val) { resolve(promise, val) } else { fulfill(promise, val) } - } - }, function (reason) { - if (!resolved) { - resolved = true - - reject(promise, reason) - } - }) - - return true - } - } - } catch (e) { - if (!resolved) { reject(promise, e) } - - return true - } - - return false - } - - function resolve (promise, value) { - if (promise === value || !handleThenable(promise, value)) { fulfill(promise, value) } - } - - function fulfill (promise, value) { - if (promise.state_ === PENDING) { - promise.state_ = SEALED - promise.data_ = value - - asyncCall(publishFulfillment, promise) - } - } - - function reject (promise, reason) { - if (promise.state_ === PENDING) { - promise.state_ = SEALED - promise.data_ = reason - - asyncCall(publishRejection, promise) - } - } - - function publish (promise) { - promise.then_ = promise.then_.forEach(invokeCallback) - } - - function publishFulfillment (promise) { - promise.state_ = FULFILLED - publish(promise) - } - - function publishRejection (promise) { - promise.state_ = REJECTED - publish(promise) - } - -/** -* @class -*/ - function Promise (resolver) { - if (typeof resolver !== 'function') { throw new TypeError('Promise constructor takes a function argument') } - - if (this instanceof Promise === false) { throw new TypeError('Failed to construct \'Promise\': Please use the \'new\' operator, this object constructor cannot be called as a function.') } - - this.then_ = [] - - invokeResolver(resolver, this) - } - - Promise.prototype = { - constructor: Promise, - - state_: PENDING, - then_: null, - data_: undefined, - - then: function (onFulfillment, onRejection) { - var subscriber = { - owner: this, - then: new this.constructor(NOOP), - fulfilled: onFulfillment, - rejected: onRejection - } - - if (this.state_ === FULFILLED || this.state_ === REJECTED) { - // already resolved, call callback async - asyncCall(invokeCallback, subscriber) - } else { - // subscribe - this.then_.push(subscriber) - } - - return subscriber.then - }, - - 'catch': function (onRejection) { - return this.then(null, onRejection) - } - } - - Promise.all = function (promises) { - var Class = this - - if (!Array.isArray(promises)) { throw new TypeError('You must pass an array to Promise.all().') } - - return new Class(function (resolve, reject) { - var results = [] - var remaining = 0 - - function resolver (index) { - remaining++ - return function (value) { - results[index] = value - if (!--remaining) { resolve(results) } - } - } - - for (var i = 0, promise; i < promises.length; i++) { - promise = promises[i] - - if (promise && typeof promise.then === 'function') { promise.then(resolver(i), reject) } else { results[i] = promise } - } - - if (!remaining) { resolve(results) } - }) - } - - Promise.race = function (promises) { - var Class = this - - if (!Array.isArray(promises)) { throw new TypeError('You must pass an array to Promise.race().') } - - return new Class(function (resolve, reject) { - for (var i = 0, promise; i < promises.length; i++) { - promise = promises[i] - - if (promise && typeof promise.then === 'function') { promise.then(resolve, reject) } else { resolve(promise) } - } - }) - } - - Promise.resolve = function (value) { - var Class = this - - if (value && typeof value === 'object' && value.constructor === Class) { return value } - - return new Class(function (resolve) { - resolve(value) - }) - } - - Promise.reject = function (reason) { - var Class = this - - return new Class(function (resolve, reject) { - reject(reason) - }) - } -})(new Function('return this')()) diff --git a/test/browser/routerSpec.js b/test/browser/routerSpec.js index b6bbd94..f5936c2 100644 --- a/test/browser/routerSpec.js +++ b/test/browser/routerSpec.js @@ -1,5 +1,7 @@ /* eslint-env mocha */ +require('lie/polyfill') + var mountHyperdom = require('./mountHyperdom') var hyperdomRouter = require('../../router') var h = require('../..').html @@ -18,7 +20,7 @@ function describeRouter (historyApi) { function mount (app, url) { var options = {router: router} - if (historyApi == 'hash') { + if (historyApi === 'hash') { options.hash = url } else { options.url = url @@ -31,29 +33,13 @@ function describeRouter (historyApi) { if (router) { router.reset() } - if (historyApi == 'hash') { + if (historyApi === 'hash') { router = hyperdomRouter.router({history: hyperdomRouter.hash()}) } else { router = hyperdomRouter.router({history: hyperdomRouter.pushState()}) } } - function push (route, params) { - if (history == 'hash') { - return new Promise(function (resolve) { - var oldURL = window.location.href - window.addEventListener('hashchange', function (event) { - if (event.oldURL === oldURL) { - resolve() - } - route.push(params) - }) - }) - } else { - route.push(params) - } - } - beforeEach(function () { resetRouter() }) @@ -212,7 +198,7 @@ function describeRouter (historyApi) { }) }) - if (history == 'pushState') { + if (historyApi === 'pushState') { describe('push replace', function () { context('app with bindings', function () { var app @@ -461,7 +447,7 @@ function describeRouter (historyApi) { app.refreshImmediately() }).to.throw(/too many redirects(\n|.)*\/a\?b=x(\n|.)*\/b\?b=x/m) - if (historyApi == 'hash') { + if (historyApi === 'hash') { // the recursive redirects test pushes a lot of URLs // in the hash form, this generates a lot of hashchange // events, which disrupts the next test @@ -568,7 +554,7 @@ function describeRouter (historyApi) { monkey.find('h1').shouldHave({text: 'b = b'}) ]).then(function () { expect(events).to.eql([]) - return push(routes.b, {a: 'a', b: 'c'}) + return routes.b.push({a: 'a', b: 'c'}) }).then(function () { app.refreshImmediately() diff --git a/test/server/detachedRenderingSpec.js b/test/server/detachedRenderingSpec.js index e3d66d7..0665996 100644 --- a/test/server/detachedRenderingSpec.js +++ b/test/server/detachedRenderingSpec.js @@ -1,3 +1,5 @@ +/* eslint-env mocha */ + var hyperdom = require('../..') var h = hyperdom.html diff --git a/test/server/hyperxSpec.js b/test/server/hyperxSpec.js index 7a8411f..d7c8fb4 100644 --- a/test/server/hyperxSpec.js +++ b/test/server/hyperxSpec.js @@ -1,3 +1,5 @@ +/* eslint-env mocha */ + var hx = require('../../hyperx') var toHtml = require('../../toHtml') var expect = require('chai').expect diff --git a/test/server/jsdomSpec.js b/test/server/jsdomSpec.js index 7cb820c..4316a06 100644 --- a/test/server/jsdomSpec.js +++ b/test/server/jsdomSpec.js @@ -1,3 +1,5 @@ +/* eslint-env mocha */ + var hyperdom = require('../..') var jsdom = require('jsdom') var expect = require('chai').expect diff --git a/test/server/storeCacheSpec.js b/test/server/storeCacheSpec.js index 3c89138..d7fb139 100644 --- a/test/server/storeCacheSpec.js +++ b/test/server/storeCacheSpec.js @@ -1,3 +1,5 @@ +/* eslint-env mocha */ + var serverRenderCache = require('../../serverRenderCache') var StoreCache = require('../../storeCache') var render = require('../../render') @@ -41,9 +43,9 @@ describe('store cache', function () { refreshify(function () { return serverRenderCache('key', () => load('some data')).then(data => { expect(data).to.equal('some data') - return setData1 = data + return (setData1 = data) }).then(data => { - return setData2 = data + return (setData2 = data) }) })() diff --git a/test/server/toHtmlSpec.js b/test/server/toHtmlSpec.js index 17ccb24..8d2c117 100644 --- a/test/server/toHtmlSpec.js +++ b/test/server/toHtmlSpec.js @@ -1,3 +1,5 @@ +/* eslint-env mocha */ + var toHtml = require('../../toHtml') var hyperdom = require('../..') var h = hyperdom.html diff --git a/toVdom.js b/toVdom.js index d41f468..307a103 100644 --- a/toVdom.js +++ b/toVdom.js @@ -1,22 +1,22 @@ -var vtext = require('virtual-dom/vnode/vtext.js') +var Vtext = require('virtual-dom/vnode/vtext.js') var isVdom = require('./isVdom') var Component = require('./component') function toVdom (object) { if (object === undefined || object === null) { - return new vtext('') + return new Vtext('') } else if (typeof (object) !== 'object') { - return new vtext(String(object)) + return new Vtext(String(object)) } else if (object instanceof Date) { - return new vtext(String(object)) + return new Vtext(String(object)) } else if (object instanceof Error) { - return new vtext(object.toString()) + return new Vtext(object.toString()) } else if (isVdom(object)) { return object } else if (typeof object.render === 'function') { return new Component(object) } else { - return new vtext(JSON.stringify(object)) + return new Vtext(JSON.stringify(object)) } } diff --git a/windowEvents.js b/windowEvents.js index b33c5a7..f594128 100644 --- a/windowEvents.js +++ b/windowEvents.js @@ -18,7 +18,7 @@ WindowWidget.prototype.type = 'Widget' WindowWidget.prototype.init = function () { applyPropertyDiffs(window, {}, this.attributes, {}, this.cache) - return this.element = document.createTextNode('') + return (this.element = document.createTextNode('')) } function uniq (array) { diff --git a/xml.js b/xml.js index a1afb70..92cbc9a 100644 --- a/xml.js +++ b/xml.js @@ -26,7 +26,7 @@ function transformProperties (vnode, namespaces) { var keys = Object.keys(properties) for (var k = 0, l = keys.length; k < l; k++) { var key = keys[k] - if (key != 'style' && key != 'attributes') { + if (key !== 'style' && key !== 'attributes') { var match = namespaceRegex.exec(key) if (match) { properties[match[1] + ':' + match[3]] = new AttributeHook(namespaces[match[1]], properties[key]) @@ -55,7 +55,7 @@ function declaredNamespaces (vnode) { var key = keys[k] var value = vnode.properties[key] - if (key == 'xmlns') { + if (key === 'xmlns') { namespaces[''] = value } else { var match = xmlnsRegex.exec(key)