8000 jshint —> semistandard by marshallswain · Pull Request #430 · feathersjs/feathers · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,15 @@
"release:prerelease": "npm version prerelease && npm publish --tag pegasus",
"compile": "rm -rf lib/ && babel -d lib/ src/",
"watch": "babel --watch -d lib/ src/",
"jshint": "jshint src/. test/. --config",
"lint": "eslint-if-supported semistandard --fix",
"mocha": "mocha --opts mocha.opts",
"coverage": "istanbul cover _mocha -- --opts mocha.opts",
"test": "npm run compile && npm run jshint && npm run coverage && nsp check"
"test": "npm run compile && npm run lint && npm run coverage && nsp check"
},
"semistandard": {
"env": [
"mocha"
]
},
"engines": {
"node": ">= 0.10.0",
Expand All @@ -59,6 +64,7 @@
"babel-plugin-add-module-exports": "^0.2.0",
"babel-preset-es2015": "^6.3.13",
"body-parser": "^1.13.2",
"eslint-if-supported": "^1.0.1",
"feathers-rest": "^1.1.0",
"feathers-socketio": "^1.1.0",
"istanbul": "^1.1.0-alpha.1",
Expand All @@ -67,6 +73,7 @@
"nsp": "^2.2.0",
"q": "^1.0.1",
"request": "^2.x",
"semistandard": "^9.1.0",
"socket.io-client": "^1.4.6"
},
"browser": {
Expand Down
23 changes: 12 additions & 11 deletions src/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const Proto = Uberproto.extend({
});

export default {
init() {
init () {
Object.assign(this, {
methods,
mixins: mixins(),
Expand All @@ -20,13 +20,13 @@ export default {
});
},

service(location, service, options = {}) {
service (location, service, options = {}) {
location = stripSlashes(location);

if(!service) {
if (!service) {
const current = this.services[location];

if(typeof current === 'undefined' && typeof this.defaultService === 'function') {
if (typeof current === 'undefined' && typeof this.defaultService === 'function') {
return this.service(location, this.defaultService(location), options);
}

Expand All @@ -40,7 +40,7 @@ export default {
// Add all the mixins
this.mixins.forEach(fn => fn.call(this, protoService));

if(typeof protoService._setup === 'function') {
if (typeof protoService._setup === 'function') {
protoService._setup(this, location);
}

Expand All @@ -58,8 +58,9 @@ export default {
return (this.services[location] = protoService);
},

use(location) {
let service, middleware = Array.from(arguments)
use (location) {
let service;
let middleware = Array.from(arguments)
.slice(1)
.reduce(function (middleware, arg) {
if (typeof arg === 'function') {
Expand All @@ -80,7 +81,7 @@ export default {
);

// Check for service (any object with at least one service method)
if(hasMethod(['handle', 'set']) || !hasMethod(this.methods.concat('setup'))) {
if (hasMethod(['handle', 'set']) || !hasMethod(this.methods.concat('setup'))) {
return this._super.apply(this, arguments);
}

Expand All @@ -90,7 +91,7 @@ export default {
return this;
},

setup() {
setup () {
// Setup each service (pass the app so that they can look up other services etc.)
Object.keys(this.services).forEach(path => {
const service = this.services[path];
Expand All @@ -110,13 +111,13 @@ export default {
// That just takes a function in order to keep Feathers plugin configuration easier.
// Environment specific configurations should be done as suggested in the 4.x migration guide:
// https://github.com/visionmedia/express/wiki/Migrating-from-3.x-to-4.x
configure(fn){
configure (fn) {
fn.call(this);

return this;
},

listen() {
listen () {
const server = this._super.apply(this, arguments);

this.setup(server);
Expand Down
18 changes: 9 additions & 9 deletions src/client/express.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
import { EventEmitter } from 'events';
import Proto from 'uberproto';

export default function() {
export default function () {
const app = {
settings: {},

get(name) {
get (name) {
return this.settings[name];
},

set(name, value) {
set (name, value) {
this.settings[name] = value;
return this;
},

disable(name) {
disable (name) {
this.settings[name] = false;
return this;
},

disabled(name) {
disabled (name) {
return !this.settings[name];
},

enable(name) {
enable (name) {
this.settings[name] = true;
return this;
},

enabled(name) {
enabled (name) {
return !!this.settings[name];
},

use() {
use () {
throw new Error('Middleware functions can not be used in the Feathers client');
},

listen() {
listen () {
return {};
}
};
Expand Down
4 changes: 2 additions & 2 deletions src/client/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import feathers from '../feathers';
import express from './express';

export default function createApplication(... args) {
return feathers(express(... args));
export default function createApplication (...args) {
return feathers(express(...args));
}

createApplication.version = '2.0.1';
2 changes: 1 addition & 1 deletion src/feathers.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Application from './application';
* @return {Function}
* @api public
*/
export default function createApplication(app) {
export default function createApplication (app) {
Proto.mixin(Application, app);
app.init();
return app;
Expand Down
6 changes: 3 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
if(!global._babelPolyfill) { require('babel-polyfill'); }
if (!global._babelPolyfill) { require('babel-polyfill'); }

import express from 'express';
import feathers from './feathers';

export default function createApplication(... args) {
return feathers(express(... args));
export default function createApplication (...args) {
return feathers(express(...args));
}

// Expose all express methods (like express.engine())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ const eventMappings = {
patch: 'patched'
};

function upperCase(name) {
function upperCase (name) {
return name.charAt(0).toUpperCase() + name.substring(1);
}

export default function(service) {
export default function (service) {
const app = this;
const isEmitter = typeof service.on === 'function' &&
typeof service.emit === 'function';
const emitter = service._rubberDuck = rubberduck.emitter(service);

if(typeof service.mixin === 'function' && !isEmitter) {
if (typeof service.mixin === 'function' && !isEmitter) {
service.mixin(EventEmitter.prototype);
}

Expand Down
6 changes: 3 additions & 3 deletions src/mixins/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
export default function() {
export default function () {
const mixins = [
require('./promise'),
require('./event'),
require('./normalizer')
];

// Override push to make sure that normalize is always the last
mixins.push = function() {
const args = [ this.length - 1, 0].concat(Array.from(arguments));
mixins.push = function () {
const args = [this.length - 1, 0].concat(Array.from(arguments));
this.splice.apply(this, args);
return this.length;
};
Expand Down
4 changes: 2 additions & 2 deletions src/mixins/normalizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ export default function (service) {
const mixin = {};

this.methods.forEach(method => {
if(typeof service[method] === 'function') {
mixin[method] = function() {
if (typeof service[method] === 'function') {
mixin[method] = function () {
return this._super.apply(this, getArguments(method, arguments));
};
}
Expand Down
8 changes: 4 additions & 4 deletions src/mixins/promise.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
function isPromise(result) {
function isPromise (result) {
return typeof result !== 'undefined' &&
typeof result.then === 'function';
}

function wrapper() {
function wrapper () {
const result = this._super.apply(this, arguments);
const callback = arguments[arguments.length - 1];

if(typeof callback === 'function' && isPromise(result)) {
if (typeof callback === 'function' && isPromise(result)) {
result.then(data => callback(null, data), error => callback(error));
}
return result;
Expand All @@ -18,7 +18,7 @@ export default function (service) {
const mixin = {};

this.methods.forEach(method => {
if(typeof service[method] === 'function') {
if (typeof service[method] === 'function') {
mixin[method] = wrapper;
}
});
Expand Down
Loading
0