Skip to content

Commit

Permalink
Fix linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
apendua committed Jun 4, 2018
1 parent 1f56f94 commit 412b4e3
Show file tree
Hide file tree
Showing 62 changed files with 427 additions and 596 deletions.
4 changes: 3 additions & 1 deletion ddp-redux/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"extends": "airbnb",
"rules": {
"import/prefer-default-export": "off"
"import/prefer-default-export": "off",
"import/extensions": "off",
"max-len": ["error", 140]
},
"parser": "babel-eslint",
"parserOptions": {
Expand Down
7 changes: 4 additions & 3 deletions ddp-redux/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"coverage": "jest --coverage",
"build": "babel src/ -d lib/",
"build-watch": "watch 'npm run build' ./src",
"lint": "eslint src/",
"prepublish": "npm run build"
},
"repository": {
Expand Down Expand Up @@ -38,11 +39,11 @@
"babel-preset-stage-3": "^6.24.1",
"chai": "^4.1.2",
"eslint": "^4.19.1",
"eslint-config-airbnb": "^15.1.0",
"eslint-config-airbnb": "^16.1.0",
"eslint-import-resolver-meteor": "^0.4.0",
"eslint-plugin-import": "^2.12.0",
"eslint-plugin-jsx-a11y": "^5.1.1",
"eslint-plugin-react": "^7.1.0",
"eslint-plugin-jsx-a11y": "^6.0.3",
"eslint-plugin-react": "^7.9.1",
"jest": "^23.1.0",
"redux": "^3.7.2",
"redux-mock-store": "^1.2.3",
Expand Down
14 changes: 5 additions & 9 deletions ddp-redux/src/DDPClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import DDPError from './DDPError';
import Storage from './utils/Storage';
import carefullyMapValues from './utils/carefullyMapValues';

import {
DEFAULT_SOCKET_ID,
} from './constants';
import { DEFAULT_SOCKET_ID } from './constants';

import * as collections from './modules/collections';
import * as connection from './modules/connection';
Expand Down Expand Up @@ -220,12 +218,10 @@ class DDPClient extends DDPEmitter {
} = properties;
return (dispatch) => {
dispatch(queryUpdate(queryId, null));
dispatch(
callMethod(name, params, {
queryId,
socketId,
}),
).then((result) => {
dispatch(callMethod(name, params, {
queryId,
socketId,
})).then((result) => {
dispatch(queryUpdate(queryId, { result }));
}).catch((error) => {
dispatch(queryUpdate(queryId, { error }));
Expand Down
42 changes: 21 additions & 21 deletions ddp-redux/src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,40 +124,40 @@ export const MSG_CONNECTED = 'connected';
export const MSG_FAILED = 'failed';

export const MESSAGE_TO_ACTION = {
[MSG_READY]: DDP_READY,
[MSG_NOSUB]: DDP_NOSUB,
[MSG_ADDED]: DDP_ADDED,
[MSG_REMOVED]: DDP_REMOVED,
[MSG_CHANGED]: DDP_CHANGED,
[MSG_READY]: DDP_READY,
[MSG_NOSUB]: DDP_NOSUB,
[MSG_ADDED]: DDP_ADDED,
[MSG_REMOVED]: DDP_REMOVED,
[MSG_CHANGED]: DDP_CHANGED,
// NOTE: These two are not supported at the moment;
// as a fallback, we interpret "added before"
// as "added", so ordering will be ignored
// but the element will still end up in the collection.
// [MSG_ADDED_BEFORE]: DDP_ADDED_BEFORE,
// [MSG_MOVED_BEFORE]: DDP_MOVED_BEFORE,
[MSG_ADDED_BEFORE]: DDP_ADDED,
[MSG_UPDATED]: DDP_UPDATED,
[MSG_RESULT]: DDP_RESULT,
[MSG_PING]: DDP_PING,
[MSG_ERROR]: DDP_ERROR,
[MSG_CONNECTED]: DDP_CONNECTED,
[MSG_FAILED]: DDP_FAILED,
[MSG_UPDATED]: DDP_UPDATED,
[MSG_RESULT]: DDP_RESULT,
[MSG_PING]: DDP_PING,
[MSG_ERROR]: DDP_ERROR,
[MSG_CONNECTED]: DDP_CONNECTED,
[MSG_FAILED]: DDP_FAILED,
};

export const ACTION_TO_MESSAGE = {
[DDP_SUB]: MSG_SUB,
[DDP_UNSUB]: MSG_UNSUB,
[DDP_METHOD]: MSG_METHOD,
[DDP_CONNECT]: MSG_CONNECT,
[DDP_PONG]: MSG_PONG,
[DDP_SUB]: MSG_SUB,
[DDP_UNSUB]: MSG_UNSUB,
[DDP_METHOD]: MSG_METHOD,
[DDP_CONNECT]: MSG_CONNECT,
[DDP_PONG]: MSG_PONG,
};

export const ACTION_TO_PRIORITY = {
[DDP_SUB]: 10,
[DDP_UNSUB]: 10,
[DDP_METHOD]: 0,
[DDP_CONNECT]: 100,
[DDP_PONG]: 10,
[DDP_SUB]: 10,
[DDP_UNSUB]: 10,
[DDP_METHOD]: 0,
[DDP_CONNECT]: 100,
[DDP_PONG]: 10,
};

// NOTE: It's important that the value is smaller than DDP_CONNECT priority,
Expand Down
4 changes: 2 additions & 2 deletions ddp-redux/src/ejson/newBinary.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

const newBinary = function (len) {
function newBinary(len) {
if (typeof Uint8Array === 'undefined' || typeof ArrayBuffer === 'undefined') {
const ret = [];
for (let i = 0; i < len; i += 1) {
Expand All @@ -35,6 +35,6 @@ const newBinary = function (len) {
return ret;
}
return new Uint8Array(new ArrayBuffer(len));
};
}

export default newBinary;
1 change: 1 addition & 0 deletions ddp-redux/src/ejson/tinytest.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint import/no-extraneous-dependencies: "off" */
import chai from 'chai';

const test = {
Expand Down
24 changes: 6 additions & 18 deletions ddp-redux/src/index.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,12 @@
import DDPClient from './DDPClient';
import DDPError from './DDPError';
import EJSON from './ejson';
import {
createCollectionSelectors,
} from './modules/collections/selectors';
import {
createCurrentUserSelectors,
} from './modules/currentUser/selectors';
import {
createSubscriptionsSelector,
} from './modules/subscriptions/selectors';
import {
createQueriesSelector,
} from './modules/queries/selectors';
import {
createConnectionSelector,
} from './modules/connection/selectors';
import {
createMethodsSelector,
} from './modules/methods/selectors';
import { createCollectionSelectors } from './modules/collections/selectors';
import { createCurrentUserSelectors } from './modules/currentUser/selectors';
import { createSubscriptionsSelector } from './modules/subscriptions/selectors';
import { createQueriesSelector } from './modules/queries/selectors';
import { createConnectionSelector } from './modules/connection/selectors';
import { createMethodsSelector } from './modules/methods/selectors';
import './shim';

export * from './actions';
Expand Down
8 changes: 2 additions & 6 deletions ddp-redux/src/modules/collections/middleware.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
/* eslint no-invalid-this: "off" */

import configureStore from 'redux-mock-store';
import {
createMiddleware,
} from './middleware';
import { createMiddleware } from './middleware';
import {
DDP_FLUSH,
DDP_READY,
Expand All @@ -14,9 +12,7 @@ import {
DDP_CHANGED,
DDP_REMOVED,
} from '../../constants';
import {
DDPClient,
} from './testCommon';
import { DDPClient } from './testCommon';

jest.useFakeTimers();

Expand Down
12 changes: 7 additions & 5 deletions ddp-redux/src/modules/collections/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,11 @@ export const createReducer = () => (state = {}, action) => {
});
case DDP_QUERY_UPDATE:
return (() => {
const queryId = action.meta.queryId;
const entities = action.payload.entities;
const oldEntities = action.payload.oldEntities;
const { queryId } = action.meta;
const {
entities,
oldEntities,
} = action.payload;
return insertQueries(
removeQueries(
state,
Expand All @@ -122,8 +124,8 @@ export const createReducer = () => (state = {}, action) => {
})();
case DDP_QUERY_DELETE:
return (() => {
const queryId = action.meta.queryId;
const entities = action.payload.entities;
const { queryId } = action.meta;
const { entities } = action.payload;
return removeQueries(
state,
queryId,
Expand Down
10 changes: 3 additions & 7 deletions ddp-redux/src/modules/collections/reducer.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
/* eslint-env jest */
/* eslint no-invalid-this: "off" */

import {
createReducer,
} from './reducer';
import { createReducer } from './reducer';
import {
DDP_FLUSH,
DDP_ADDED,
Expand All @@ -15,9 +13,7 @@ import {
DDP_METHOD,
DDP_UPDATED,
} from '../../constants';
import {
DDPClient,
} from './testCommon';
import { DDPClient } from './testCommon';

describe('Test module - collections - reducer', () => {
let testContext;
Expand Down Expand Up @@ -222,7 +218,7 @@ describe('Test module - collections - reducer', () => {
},
});
expect(state).toEqual(testContext.referenceState1);
}
},
);

test('should add another entity', () => {
Expand Down
4 changes: 1 addition & 3 deletions ddp-redux/src/modules/collections/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import mapValues from 'lodash/mapValues';
import values from 'lodash/values';
import forEach from 'lodash/forEach';
import map from 'lodash/map';
import {
createSelector,
} from 'reselect';
import { createSelector } from 'reselect';
import createValuesMappingSelector from '../../utils/createValuesMappingSelector';

const identity = x => x;
Expand Down
8 changes: 2 additions & 6 deletions ddp-redux/src/modules/collections/selectors.test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
/* eslint-env jest */

import {
createSelectors,
} from './selectors';
import {
DDPClient,
} from './testCommon';
import { createSelectors } from './selectors';
import { DDPClient } from './testCommon';

const constant = x => () => x;

Expand Down
10 changes: 3 additions & 7 deletions ddp-redux/src/modules/connection/middleware.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
/* eslint-env jest */

import configureStore from 'redux-mock-store';
import {
createMiddleware,
} from './middleware';
import { createMiddleware } from './middleware';
import {
DEFAULT_SOCKET_ID,

Expand All @@ -21,9 +19,7 @@ import {
DDP_CLOSE,
} from '../../constants';
// import DDPError from '../../DDPError';
import {
DDPClient,
} from './testCommon';
import { DDPClient } from './testCommon';

const createInitialState = (socketId, socketState) => ({
ddp: {
Expand Down Expand Up @@ -229,7 +225,7 @@ describe('Test module - connection - middleware', () => {
},
]);
expect(testContext.ddpClient.sockets).toEqual({});
}
},
);

test('should close connection if there is only one user', () => {
Expand Down
6 changes: 3 additions & 3 deletions ddp-redux/src/modules/connection/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ export const createReducer = (DDPClient) => {
...state.sockets,
[socketId]: {
...state.sockets[socketId],
id: socketId,
users: ((state.sockets[socketId] && state.sockets[socketId].users) || 0) + 1,
params: action.payload.params,
id: socketId,
users: ((state.sockets[socketId] && state.sockets[socketId].users) || 0) + 1,
params: action.payload.params,
endpoint: action.payload.endpoint,
},
},
Expand Down
8 changes: 2 additions & 6 deletions ddp-redux/src/modules/connection/reducer.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/* eslint-env jest */

import {
createReducer,
} from './reducer';
import { createReducer } from './reducer';
import {
DDP_CONNECTION_STATE__DISCONNECTED,
DDP_CONNECTION_STATE__CONNECTING,
Expand All @@ -14,9 +12,7 @@ import {
DDP_OPEN,
DDP_CLOSE,
} from '../../constants';
import {
DDPClient,
} from './testCommon';
import { DDPClient } from './testCommon';

describe('Test module - connection - reducer', () => {
let testContext;
Expand Down
8 changes: 2 additions & 6 deletions ddp-redux/src/modules/connection/selectors.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import find from 'lodash/find';
import {
createSelector,
} from 'reselect';
import { createSelector } from 'reselect';
import EJSON from '../../ejson';
import {
DEFAULT_SOCKET_ID,
} from '../../constants';
import { DEFAULT_SOCKET_ID } from '../../constants';

export const createConnectionSelector = ({
selectDeclaredConnection,
Expand Down
4 changes: 1 addition & 3 deletions ddp-redux/src/modules/connection/testCommon.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import DDPEmitter from '../../DDPEmitter';
import {
DEFAULT_SOCKET_ID,
} from '../../constants';
import { DEFAULT_SOCKET_ID } from '../../constants';

export class DDPClient extends DDPEmitter {
constructor() {
Expand Down
Loading

0 comments on commit 412b4e3

Please sign in to comment.