Skip to content
This repository was archived by the owner on Aug 29, 2018. It is now read-only.

Commit 3fde9d9

Browse files
committed
jshint —> semistandard
1 parent 035269a commit 3fde9d9

10 files changed

Lines changed: 92 additions & 114 deletions

File tree

.jshintrc

Lines changed: 0 additions & 30 deletions
This file was deleted.

package.json

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,18 @@
3333
"release:major": "npm version major && npm publish",
3434
"compile": "rm -rf lib/ && babel -d lib/ src/",
3535
"watch": "babel --watch -d lib/ src/",
36-
"jshint": "jshint src/. test/. --config",
36+
"lint": "eslint-if-supported semistandard --fix",
3737
"mocha": "mocha --opts mocha.opts",
3838
"coverage": "istanbul cover _mocha -- --opts mocha.opts",
39-
"test": "npm run compile && npm run jshint && npm run coverage"
39+
"test": "npm run compile && npm run lint && npm run coverage"
40+
},
41+
"semistandard": {
42+
"env": [
43+
"mocha"
44+
],
45+
"ignore": [
46+
"/lib"
47+
]
4048
},
4149
"directories": {
4250
"lib": "lib"
@@ -57,14 +65,15 @@
5765
"babel-plugin-add-module-exports": "^0.2.0",
5866
"babel-plugin-transform-object-assign": "^6.3.13",
5967
"babel-preset-es2015": "^6.3.13",
68+
"eslint-if-supported": "^1.0.1",
6069
"feathers": "^2.0.0",
6170
"feathers-commons": "^0.7.2",
6271
"feathers-hooks": "^1.5.2",
6372
"feathers-memory": "^0.8.0",
6473
"istanbul": "^1.1.0-alpha.1",
65-
"jshint": "^2.8.0",
6674
"lodash": "^4.0.1",
6775
"mocha": "^3.0.0",
76+
"semistandard": "^9.1.0",
6877
"ws": "^1.0.0"
6978
}
7079
}

src/client.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
import Service from 'feathers-socket-commons/client';
22

3-
export default function(connection, options) {
4-
if(!connection) {
3+
export default function (connection, options) {
4+
if (!connection) {
55
throw new Error('Primus connection needs to be provided');
66
}
77

8-
const defaultService = function(name) {
8+
const defaultService = function (name) {
99
return new Service(Object.assign({}, options, {
1010
name,
1111
connection,
1212
method: 'send'
1313
}));
1414
};
1515

16-
const initialize = function() {
17-
if(typeof this.defaultService === 'function') {
16+
const initialize = function () {
17+
if (typeof this.defaultService === 'function') {
1818
throw new Error('Only one default client provider can be configured');
1919
}
2020

src/index.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,25 @@ import Emitter from 'primus-emitter';
66

77
const debug = makeDebug('feathers-primus');
88

9-
export default function(config, configurer) {
10-
return function() {
9+
export default function (config, configurer) {
10+
return function () {
1111
const app = this;
1212

1313
app.configure(socket('primus'));
1414

1515
// Monkey patch app.setup(server)
1616
Proto.mixin({
17-
setup(server) {
17+
setup (server) {
1818
debug('Setting up Primus');
1919

2020
let primus = this.primus;
2121

22-
if(!primus) {
22+
if (!primus) {
2323
primus = this.primus = new Primus(server, config);
2424

2525
primus.use('emitter', Emitter);
2626

27-
primus.before('feathers', function(req, res, next) {
27+
primus.before('feathers', function (req, res, next) {
2828
req.feathers = { provider: 'primus' };
2929
next();
3030
}, 0);
@@ -37,13 +37,13 @@ export default function(config, configurer) {
3737

3838
this._socketInfo = {
3939
method: 'send',
40-
connection() {
40+
connection () {
4141
return primus;
4242
},
43-
clients() {
43+
clients () {
4444
return primus;
4545
},
46-
params(spark) {
46+
params (spark) {
4747
return spark.request.feathers;
4848
}
4949
};

test/client/client.test.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,36 @@ import baseTests from 'feathers-commons/lib/test/client';
55
import server from './server';
66
import primus from '../../src/client';
77

8-
describe('feathers-primus/client', function() {
8+
describe('feathers-primus/client', function () {
99
const app = feathers().configure(primus({}, { timeout: 500 }));
1010
const service = app.service('todos');
1111

12-
before(function(done) {
12+
before(function (done) {
1313
this.server = server(primus => {
1414
service.connection = this.socket = new primus.Socket('http://localhost:12012');
1515
}).listen(12012);
1616
this.server.on('listening', () => done());
1717
});
1818

19-
after(function(done) {
19+
after(function (done) {
2020
this.socket.socket.close();
2121
this.server.close(done);
2222
});
2323

24-
it('throws an error with no connection', function() {
24+
it('throws an error with no connection', function () {
2525
try {
2626
feathers().configure(primus());
2727
assert.ok(false);
28-
} catch(e) {
28+
} catch (e) {
2929
assert.equal(e.message, 'Primus connection needs to be provided');
3030
}
3131
});
3232

33-
it('app has the primus attribute', function() {
33+
it('app has the primus attribute', function () {
3434
assert.ok(app.primus);
3535
});
3636

37-
it('throws an error when configured twice', function() {
37+
it('throws an error when configured twice', function () {
3838
try {
3939
app.configure(primus({}));
4040
assert.ok(false, 'Should never get here');
@@ -43,7 +43,7 @@ describe('feathers-primus/client', function() {
4343
}
4444
});
4545

46-
it('can initialize a client instance', function(done) {
46+
it('can initialize a client instance', function (done) {
4747
const init = primus(service.connection);
4848
const todos = init.service('todos');
4949

@@ -57,7 +57,7 @@ describe('feathers-primus/client', function() {
5757
])).then(() => done()).catch(done);
5858
});
5959

60-
it('times out with error when using non-existent service', function(done) {
60+
it('times out with error when using non-existent service', function (done) {
6161
const notMe = app.service('not-me');
6262
// Hack because we didn't set the connection at the beginning
6363
notMe.connection = this.socket;

test/client/server.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import feathers from 'feathers';
22
import primus from '../../src';
33
import memory from 'feathers-memory';
44

5+
// eslint-disable-next-line no-extend-native
56
Object.defineProperty(Error.prototype, 'toJSON', {
67
value: function () {
78
var alt = {};
@@ -15,11 +16,11 @@ Object.defineProperty(Error.prototype, 'toJSON', {
1516
configurable: true
1617
});
1718

18-
export default function(cb) {
19+
export default function (cb) {
1920
// Create an in-memory CRUD service for our Todos
2021
var todoService = memory().extend({
21-
get: function(id, params, callback) {
22-
if(params.query.error) {
22+
get: function (id, params, callback) {
23+
if (params.query.error) {
2324
return callback(new Error('Something went wrong'));
2425
}
2526

@@ -33,7 +34,7 @@ export default function(cb) {
3334
}, cb))
3435
.use('/todos', todoService);
3536

36-
app.service('todos').create({ text: 'some todo', complete: false }, {}, function() {});
37+
app.service('todos').create({ text: 'some todo', complete: false }, {}, function () {});
3738

3839
return app;
3940
}

test/index.test.js

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ describe('feathers-primus', () => {
1616
};
1717

1818
before(done => {
19-
const errorHook = function(hook) {
20-
if(hook.params.query.hookError) {
19+
const errorHook = function (hook) {
20+
if (hook.params.query.hookError) {
2121
throw new Error(`Error from ${hook.method}, ${hook.type} hook`);
2222
}
2323
};
2424
const app = options.app = feathers()
2525
.configure(hooks())
2626
.configure(primus({
2727
transformer: 'websockets'
28-
}, function(primus) {
28+
}, function (primus) {
2929
options.socket = new primus.Socket('http://localhost:7888');
3030

3131
primus.authorize(function (req, done) {
@@ -39,7 +39,7 @@ describe('feathers-primus', () => {
3939
get: errorHook
4040
});
4141

42-
options.server = app.listen(7888, function(){
42+
options.server = app.listen(7888, function () {
4343
app.use('tasks', todoService);
4444
app.service('tasks').before({
4545
get: errorHook
@@ -57,32 +57,32 @@ describe('feathers-primus', () => {
5757
assert.equal(typeof require('../lib'), 'function');
5858
});
5959

60-
it('runs primus before setup (#131)', function(done) {
60+
it('runs primus before setup (#131)', function (done) {
6161
var counter = 0;
6262
var app = feathers()
6363
.configure(primus({
6464
transformer: 'websockets'
65-
}, function() {
65+
}, function () {
6666
assert.equal(counter, 0);
6767
counter++;
6868
}))
6969
.use('/todos', {
70-
find: function(params, callback) {
70+
find: function (params, callback) {
7171
callback(null, []);
7272
},
73-
setup: function(app) {
73+
setup: function (app) {
7474
assert.ok(app.primus);
7575
assert.equal(counter, 1, 'SocketIO configuration ran first');
7676
}
7777
});
7878

7979
var srv = app.listen(9119);
80-
srv.on('listening', function() {
80+
srv.on('listening', function () {
8181
srv.close(done);
8282
});
8383
});
8484

85-
it('Passes handshake as service parameters.', function(done) {
85+
it('Passes handshake as service parameters.', function (done) {
8686
var service = options.app.service('todo');
8787
var old = {
8888
find: service.find,
@@ -91,19 +91,19 @@ describe('feathers-primus', () => {
9191
remove: service.remove
9292
};
9393

94-
service.find = function(params) {
94+
service.find = function (params) {
9595
assert.deepEqual(_.omit(params, 'query'), options.socketParams,
9696
'Handshake parameters passed on proper position');
9797
old.find.apply(this, arguments);
9898
};
9999

100-
service.create = function(data, params) {
100+
service.create = function (data, params) {
101101
assert.deepEqual(_.omit(params, 'query'), options.socketParams,
102102
'Passed handshake parameters');
103103
old.create.apply(this, arguments);
104104
};
105105

106-
service.update = function(id, data, params) {
106+
service.update = function (id, data, params) {
107107
assert.deepEqual(params, _.extend({
108108
query: {
109109
test: 'param'
@@ -113,20 +113,20 @@ describe('feathers-primus', () => {
113113
};
114114

115115
options.socket.send('todo::create', {}, {}, function () {
116-
options.socket.send('todo::update', 1, {}, { test: 'param' }, function() {
116+
options.socket.send('todo::update', 1, {}, { test: 'param' }, function () {
117117
_.extend(service, old);
118118
done();
119119
});
120120
});
121121
});
122122

123-
it('Missing parameters in socket call works. (#88)', function(done) {
123+
it('Missing parameters in socket call works. (#88)', function (done) {
124124
var service = options.app.service('todo');
125125
var old = {
126126
find: service.find
127127
};
128128

129-
service.find = function(params) {
129+
service.find = function (params) {
130130
assert.deepEqual(_.omit(params, 'query'), options.socketParams,
131131
'Handshake parameters passed on proper position');
132132
old.find.apply(this, arguments);
@@ -143,7 +143,7 @@ describe('feathers-primus', () => {
143143
const sub = feathers()
144144
.configure(primus({
145145
transformer: 'websockets'
146-
}, function(primus) {
146+
}, function (primus) {
147147
const socket = new primus.Socket('http://localhost:9876');
148148

149149
const original = {
@@ -160,17 +160,17 @@ describe('feathers-primus', () => {
160160
}))
161161
.use('/todo', todoService);
162162

163-
const main = feathers()
163+
const main = feathers()
164164
.use('/v1', sub);
165165

166-
server = main.listen(9876);
166+
server = main.listen(9876);
167167
});
168168

169-
describe('Services', function() {
169+
describe('Services', function () {
170170
services('todo', options);
171171
});
172172

173-
describe('Dynamic services', function() {
173+
describe('Dynamic services', function () {
174174
services('tasks', options);
175175
});
176176
});

0 commit comments

Comments
 (0)