Skip to content

Commit

Permalink
refactor: Upgrade to eslint@2
Browse files Browse the repository at this point in the history
  • Loading branch information
dignifiedquire committed Feb 18, 2016
1 parent d9d61a3 commit 64e301b
Show file tree
Hide file tree
Showing 33 changed files with 190 additions and 183 deletions.
3 changes: 1 addition & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
"extends": "standard",
"parser": "babel-eslint"
"extends": "standard"
}
3 changes: 2 additions & 1 deletion lib/constants.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var fs = require('graceful-fs')
var path = require('path')

var pkg = JSON.parse(fs.readFileSync(__dirname + '/../package.json').toString())
var pkg = JSON.parse(fs.readFileSync(path.join(__dirname, '/../package.json')).toString())

exports.VERSION = pkg.version

Expand Down
11 changes: 6 additions & 5 deletions lib/init/formatters.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
var fs = require('graceful-fs')
var util = require('util')
var path = require('path')

var JS_TEMPLATE_PATH = __dirname + '/../../config.tpl.js'
var COFFEE_TEMPLATE_PATH = __dirname + '/../../config.tpl.coffee'
var JS_REQUIREJS_TEMPLATE_PATH = __dirname + '/../../requirejs.config.tpl.js'
var COFFEE_REQUIREJS_TEMPLATE_PATH = __dirname + '/../../requirejs.config.tpl.coffee'
var JS_TEMPLATE_PATH = path.join(__dirname, '/../../config.tpl.js')
var COFFEE_TEMPLATE_PATH = path.join(__dirname, '/../../config.tpl.coffee')
var JS_REQUIREJS_TEMPLATE_PATH = path.join(__dirname, '/../../requirejs.config.tpl.js')
var COFFEE_REQUIREJS_TEMPLATE_PATH = path.join(__dirname, '/../../requirejs.config.tpl.coffee')
var COFFEE_REGEXP = /\.coffee$/
var LIVE_TEMPLATE_PATH = __dirname + '/../../config.tpl.ls'
var LIVE_TEMPLATE_PATH = path.join(__dirname, '/../../config.tpl.ls')
var LIVE_REGEXP = /\.ls$/

var isCoffeeFile = function (filename) {
Expand Down
2 changes: 1 addition & 1 deletion lib/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ exports.resolve = function (plugins) {
plugins.forEach(function (plugin) {
if (helper.isString(plugin)) {
if (plugin.indexOf('*') !== -1) {
var pluginDirectory = path.normalize(__dirname + '/../..')
var pluginDirectory = path.normalize(path.join(__dirname, '/../..'))
var regexp = new RegExp('^' + plugin.replace('*', '.*'))

log.debug('Loading %s from %s', plugin, pluginDirectory)
Expand Down
2 changes: 1 addition & 1 deletion lib/web-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ createCustomHandler.$inject = ['customFileHandlers', 'config.basePath']
var createWebServer = function (injector, emitter, fileList) {
var config = injector.get('config')
common.initializeMimeTypes(config)
var serveStaticFile = common.createServeFile(fs, path.normalize(__dirname + '/../static'), config)
var serveStaticFile = common.createServeFile(fs, path.normalize(path.join(__dirname, '/../static')), config)
var serveFile = common.createServeFile(fs, null, config)
var filesPromise = new common.PromiseContainer()

Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -288,14 +288,14 @@
"devDependencies": {
"LiveScript": "^1.3.0",
"babel": "^5.6.23",
"babel-eslint": "^4.1.8",
"chai": "^3.3.0",
"chai-as-promised": "^5.0.0",
"chai-subset": "^1.0.1",
"coffee-script": "^1.9.2",
"cucumber": "^0.9.1",
"eslint": "^1.0.0",
"eslint-config-standard": "^4.0.0",
"eslint": "^2.1.0",
"eslint-config-standard": "^5.1.0",
"eslint-plugin-promise": "^1.0.8",
"eslint-plugin-react": "^3.15.0",
"eslint-plugin-standard": "^1.3.1",
"ghooks": "^1.0.3",
Expand All @@ -308,7 +308,7 @@
"grunt-conventional-changelog": "^6.0.1",
"grunt-conventional-github-releaser": "^0.5.0",
"grunt-cucumberjs": "^0.8.7",
"grunt-eslint": "^17.0.0",
"grunt-eslint": "^18.0.0",
"grunt-mocha-test": "^0.12.7",
"grunt-npm": "0.0.2",
"jasmine-core": "^2.3.4",
Expand Down
14 changes: 7 additions & 7 deletions requirejs.config.tpl.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
var allTestFiles = [];
var TEST_REGEXP = /(spec|test)\.js$/i;
var allTestFiles = []
var TEST_REGEXP = /(spec|test)\.js$/i

// Get a list of all the test files to include
Object.keys(window.__karma__.files).forEach(function(file) {
Object.keys(window.__karma__.files).forEach(function (file) {
if (TEST_REGEXP.test(file)) {
// Normalize paths to RequireJS module names.
// If you require sub-dependencies of test files to be loaded as-is (requiring file extension)
// then do not normalize the paths
var normalizedTestModule = file.replace(/^\/base\/|\.js$/g, '');
allTestFiles.push(normalizedTestModule);
var normalizedTestModule = file.replace(/^\/base\/|\.js$/g, '')
allTestFiles.push(normalizedTestModule)
}
});
})

require.config({
// Karma serves files under /base, which is the basePath from your config file
Expand All @@ -21,4 +21,4 @@ require.config({

// we have to kickoff jasmine, as it is asynchronous
callback: window.__karma__.start
});
})
2 changes: 1 addition & 1 deletion test/e2e/steps/core_steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = function coreSteps () {
this.World = require('../support/world').World
require('../support/after_hooks').call(this)

var baseDir = fs.realpathSync(__dirname + '/../../..')
var baseDir = fs.realpathSync(path.join(__dirname, '/../../..'))
var tmpDir = path.join(baseDir, 'tmp', 'sandbox')
var tmpConfigFile = 'karma.conf.js'
var cleansingNeeded = true
Expand Down
2 changes: 1 addition & 1 deletion test/unit/browser.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('Browser', () => {
browser.init()

expect(collection.length).to.equal(1)
collection.forEach(browserInCollection => {
collection.forEach((browserInCollection) => {
expect(browserInCollection).to.equal(browser)
})
})
Expand Down
10 changes: 5 additions & 5 deletions test/unit/browser_collection.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ describe('BrowserCollection', () => {

beforeEach(() => {
browsers = [new Browser(), new Browser(), new Browser()]
browsers.forEach(browser => {
browsers.forEach((browser) => {
collection.add(browser)
})
})

it('should set all browsers state to executing', () => {
collection.setAllToExecuting()
browsers.forEach(browser => {
browsers.forEach((browser) => {
expect(browser.isReady()).to.equal(false)
expect(browser.state).to.equal(Browser.STATE_EXECUTING)
})
Expand All @@ -100,7 +100,7 @@ describe('BrowserCollection', () => {

beforeEach(() => {
browsers = [new Browser(), new Browser(), new Browser()]
browsers.forEach(browser => {
browsers.forEach((browser) => {
browser.state = Browser.STATE_READY
collection.add(browser)
})
Expand Down Expand Up @@ -237,7 +237,7 @@ describe('BrowserCollection', () => {
browsers[1].lastResult.disconnected = true

collection.clearResults()
browsers.forEach(browser => {
browsers.forEach((browser) => {
expect(browser.lastResult.success).to.equal(0)
expect(browser.lastResult.failed).to.equal(0)
expect(browser.lastResult.skipped).to.equal(0)
Expand Down Expand Up @@ -266,7 +266,7 @@ describe('BrowserCollection', () => {
var browsers = [new Browser(1), new Browser(2), new Browser(3)]
browsers.forEach(collection.add)

var mappedIds = collection.map(browser => browser.id)
var mappedIds = collection.map((browser) => browser.id)

expect(mappedIds).to.deep.equal([1, 2, 3])
})
Expand Down
4 changes: 2 additions & 2 deletions test/unit/cli.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('cli', () => {
}
}

var setCWD = cwd => {
var setCWD = (cwd) => {
currentCwd = cwd
fsMock._setCWD(cwd)
}
Expand All @@ -40,7 +40,7 @@ describe('cli', () => {
mockery.console = {error: sinon.spy()}

// load file under test
m = loadFile(__dirname + '/../../lib/cli.js', mockery, {
m = loadFile(path.join(__dirname, '/../../lib/cli.js'), mockery, {
global: {},
console: mockery.console,
process: mockery.process,
Expand Down
2 changes: 1 addition & 1 deletion test/unit/completion.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('completion', () => {
}

beforeEach(() => {
sinon.stub(console, 'log', msg => completion.push(msg))
sinon.stub(console, 'log', (msg) => completion.push(msg))
completion = []
})

Expand Down
14 changes: 7 additions & 7 deletions test/unit/config.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ describe('config', () => {
var e
var mocks

var resolveWinPath = p => helper.normalizeWinPath(path.resolve(p))
var resolveWinPath = (p) => helper.normalizeWinPath(path.resolve(p))

var normalizeConfigWithDefaults = cfg => {
var normalizeConfigWithDefaults = (cfg) => {
if (!cfg.urlRoot) cfg.urlRoot = ''
if (!cfg.files) cfg.files = []
if (!cfg.exclude) cfg.exclude = []
Expand All @@ -22,10 +22,10 @@ describe('config', () => {
}

// extract only pattern properties from list of pattern objects
var patternsFrom = list => list.map(pattern => pattern.pattern)
var patternsFrom = (list) => list.map((pattern) => pattern.pattern)

var wrapCfg = function (cfg) {
return config => config.set(cfg)
return (config) => config.set(cfg)
}

beforeEach(() => {
Expand All @@ -38,7 +38,7 @@ describe('config', () => {
'/home/config4.js': wrapCfg({port: 123, autoWatch: true, basePath: '/abs/base'}),
'/home/config6.js': wrapCfg({reporters: 'junit'}),
'/home/config7.js': wrapCfg({browsers: ['Chrome', 'Firefox']}),
'/home/config8.js': config => config.set({ files: config.suite === 'e2e' ? ['tests/e2e.spec.js'] : ['tests/unit.spec.js'] }),
'/home/config8.js': (config) => config.set({ files: config.suite === 'e2e' ? ['tests/e2e.spec.js'] : ['tests/unit.spec.js'] }),
'/conf/invalid.js': () => { throw new SyntaxError('Unexpected token =') },
'/conf/exclude.js': wrapCfg({exclude: ['one.js', 'sub/two.js']}),
'/conf/absolute.js': wrapCfg({files: ['http://some.com', 'https://more.org/file.js']}),
Expand All @@ -47,7 +47,7 @@ describe('config', () => {
}

// load file under test
m = loadFile(__dirname + '/../../lib/config.js', mocks, {
m = loadFile(path.join(__dirname, '/../../lib/config.js'), mocks, {
global: {},
process: mocks.process,
require (path) {
Expand Down Expand Up @@ -360,7 +360,7 @@ describe('config', () => {
describe('custom', () => {
var di = require('di')

var forwardArgsFactory = args => args
var forwardArgsFactory = (args) => args

var baseModule = {
'preprocessor:base': ['type', forwardArgsFactory],
Expand Down
8 changes: 4 additions & 4 deletions test/unit/emitter_wrapper.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ describe('emitter_wrapper', () => {

beforeEach(() => {
emitter = new EventEmitter()
emitter.aMethod = e => true
emitter.aMethod = (e) => true
emitter.on('anEvent', emitter.aMethod)
wrapped = new EmitterWrapper(emitter)
})

describe('addListener', () => {
var aListener = e => true
var aListener = (e) => true

it('should add a listener to the wrapped emitter', () => {
wrapped.addListener('anEvent', aListener)
Expand All @@ -26,7 +26,7 @@ describe('emitter_wrapper', () => {
})

describe('removeAllListeners', () => {
var aListener = e => true
var aListener = (e) => true

beforeEach(() => {
wrapped.addListener('anEvent', aListener)
Expand All @@ -43,7 +43,7 @@ describe('emitter_wrapper', () => {
})

it('should remove only matching listeners when called with an event name', () => {
var anotherListener = e => true
var anotherListener = (e) => true
wrapped.addListener('anotherEvent', anotherListener)
wrapped.removeAllListeners('anEvent')
expect(emitter.listeners('anEvent')).not.to.contain(aListener)
Expand Down
10 changes: 5 additions & 5 deletions test/unit/events.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ describe('events', () => {
emitter.bind(object)
})

it('should resolve the promise once all listeners are done', done => {
it('should resolve the promise once all listeners are done', (done) => {
var callbacks = []
var eventDone = sinon.spy()

emitter.on('a', d => d())
emitter.on('a', d => callbacks.push(d))
emitter.on('a', d => callbacks.push(d))
emitter.on('a', (d) => d())
emitter.on('a', (d) => callbacks.push(d))
emitter.on('a', (d) => callbacks.push(d))

var promise = emitter.emitAsync('a')

Expand All @@ -86,7 +86,7 @@ describe('events', () => {
})
})

it('should resolve asynchronously when no listener', done => {
it('should resolve asynchronously when no listener', (done) => {
var spyDone = sinon.spy(done)
emitter.emitAsync('whatever').then(spyDone)
expect(spyDone).to.not.have.been.called
Expand Down
Loading

0 comments on commit 64e301b

Please sign in to comment.