Skip to content

Commit

Permalink
Use xo es6 configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Toby committed Sep 15, 2015
1 parent f422eac commit d8f6e52
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 20 deletions.
6 changes: 2 additions & 4 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{
"extends": "xo-space",
"extends": "xo-space/esnext",
"rules": {
"strict": [2, "global"],
"no-var": 2,
"prefer-arrow-callback": 2
"strict": [2, "global"]
},
"ecmaFeatures": {
"arrowFunctions": true,
Expand Down
2 changes: 1 addition & 1 deletion lib/handlers/indexes/{name}.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {

index.insert(req.payload)
.then(o => {
reply(o).created(req.path + '/' + o.objectID);
reply(o).created(`${req.path}/${o.objectID}`);
}, reply.error.bind(reply));
}
};
4 changes: 2 additions & 2 deletions lib/search/query_builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const buildTermFilter = function (filterParams) {
// Can't currenlty be a 1 liner due to https://github.com/nodejs/node/issues/2507
const term = {[filterParams.field]: filterParams.term};
return {term: term};
return {term};
};

const buildRangeFilter = function (filterParams) {
Expand All @@ -15,7 +15,7 @@ const buildRangeFilter = function (filterParams) {
range[filterParams.field].lte = filterParams.range.to;
}

return {range: range};
return {range};
};

const buildFilter = function (filterParams) {
Expand Down
2 changes: 1 addition & 1 deletion lib/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ exports.register = function (server, options, next) {
path: '/version',
config: {
description: 'Returns the version of the server',
handler: function (request, reply) {
handler(request, reply) {
reply(versionResponse);
}
}
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@
"swaggerize-hapi": "^1.0.0"
},
"devDependencies": {
"babel-eslint": "^4.1.2",
"chai": "^3.2.0",
"cuid": "^1.3.8",
"enjoi": "^1.0.0",
"eslint": "^1.3.1",
"eslint-config-xo-space": "^0.4.0",
"eslint-plugin-babel": "^2.1.1",
"grunt": "^0.4.5",
"grunt-contrib-watch": "^0.6.1",
"grunt-eslint": "^17.1.0",
Expand Down
4 changes: 2 additions & 2 deletions spec/indexes_indexing.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ describe('Indexes', () => {
describe('indexing', () => {
let createResponse;
const testObject = {name: 'object', field: 'value'};
const testIndexName = 'test_index_' + cuid();
const testIndexName = `test_index_${cuid()}`;

before(() => {
return specRequest({url: '/1/indexes/' + testIndexName, method: 'post', payload: testObject})
return specRequest({url: `/1/indexes/${testIndexName}`, method: 'post', payload: testObject})
.then(response => {
createResponse = response;
});
Expand Down
18 changes: 9 additions & 9 deletions spec/indexes_{name}_query.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const specRequest = require('./spec_request');
const expect = require('chai').expect;

describe('Basic search', () => {
const testIndexName = 'test_index_' + cuid();
const testIndexName = `test_index_${cuid()}`;
const testIndexType = 'test_type';
const document1 = {sku: '12345', price: 1};
const document2 = {sku: '98765', price: 5};
Expand All @@ -31,7 +31,7 @@ describe('Basic search', () => {
it('queries by keyword', () => {
const payload = {query: '12345'};

return specRequest({url: `/1/indexes/${testIndexName}/query`, method: 'post', payload: payload})
return specRequest({url: `/1/indexes/${testIndexName}/query`, method: 'post', payload})
.then(response => {
expect(response.result).to.be.deep.equal([document1]);
expect(response.statusCode).to.equal(200);
Expand All @@ -41,7 +41,7 @@ describe('Basic search', () => {
it('filters results by terms', () => {
const payload = {filters: [{field: 'sku', term: '12345'}]};

return specRequest({url: `/1/indexes/${testIndexName}/query`, method: 'post', payload: payload})
return specRequest({url: `/1/indexes/${testIndexName}/query`, method: 'post', payload})
.then(response => {
expect(response.result).to.be.deep.equal([document1]);
expect(response.statusCode).to.equal(200);
Expand All @@ -51,7 +51,7 @@ describe('Basic search', () => {
it('filters results by ranges', () => {
const payload = {filters: [{field: 'sku', range: {from: 2}}]};

return specRequest({url: `/1/indexes/${testIndexName}/query`, method: 'post', payload: payload})
return specRequest({url: `/1/indexes/${testIndexName}/query`, method: 'post', payload})
.then(response => {
expect(response.result).to.be.deep.equal([document2]);
expect(response.statusCode).to.equal(200);
Expand All @@ -62,7 +62,7 @@ describe('Basic search', () => {
it('ensures query is a string', () => {
const payload = {query: {}};

return specRequest({url: `/1/indexes/test-index/query`, method: 'post', payload: payload})
return specRequest({url: '/1/indexes/test-index/query', method: 'post', payload})
.then(response => {
expect(response.result.message).to.match(/"query" must be a string]/);
expect(response.statusCode).to.equal(400);
Expand All @@ -72,7 +72,7 @@ describe('Basic search', () => {
it('ensures filters is an array', () => {
const payload = {filters: {}};

return specRequest({url: `/1/indexes/test-index/query`, method: 'post', payload: payload})
return specRequest({url: '/1/indexes/test-index/query', method: 'post', payload})
.then(response => {
expect(response.result.message).to.match(/"filters" must be an array]/);
expect(response.statusCode).to.equal(400);
Expand All @@ -82,7 +82,7 @@ describe('Basic search', () => {
it('ensures filter has field', () => {
const payload = {filters: [{term: '12345'}]};

return specRequest({url: `/1/indexes/test-index/query`, method: 'post', payload: payload})
return specRequest({url: '/1/indexes/test-index/query', method: 'post', payload})
.then(response => {
expect(response.result.message).to.match(/"field" is required]/);
expect(response.statusCode).to.equal(400);
Expand All @@ -92,7 +92,7 @@ describe('Basic search', () => {
it('ensures filter has term or range', () => {
const payload = {filters: [{field: 'sku'}]};

return specRequest({url: `/1/indexes/test-index/query`, method: 'post', payload: payload})
return specRequest({url: '/1/indexes/test-index/query', method: 'post', payload})
.then(response => {
expect(response.result.message).to.match(/"0" must have at least 2 children/);
expect(response.statusCode).to.equal(400);
Expand All @@ -102,7 +102,7 @@ describe('Basic search', () => {
it('ensures range filter has at least 1 bound', () => {
const payload = {filters: [{field: 'sku', range: {}}]};

return specRequest({url: `/1/indexes/test-index/query`, method: 'post', payload: payload})
return specRequest({url: `/1/indexes/test-index/query`, method: 'post', payload})
.then(response => {
expect(response.result.message).to.match(/"range" must have at least 1 children/);
expect(response.statusCode).to.equal(400);
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_request.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = function (options) {
}

const apiBasePath = swagger.basePath || '';
const route = response.request.route.path.replace(new RegExp('^' + apiBasePath), '');
const route = response.request.route.path.replace(new RegExp(`^${apiBasePath}`), '');
const method = response.request.method;

const swaggerPath = swagger.paths[route];
Expand Down

0 comments on commit d8f6e52

Please sign in to comment.