Skip to content

Commit

Permalink
configure eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
burdiuz committed Mar 12, 2017
1 parent 2e2c213 commit 933bab3
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 25 deletions.
26 changes: 26 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"parser": "babel-eslint",
"extends": "airbnb",
"parserOptions": {
"ecmaVersion": 6,
"ecmaFeatures": {
"impliedStrict": true,
"experimentalObjectRestSpread": true
}
},
"env": {
"browser": true,
"mocha": true,
"node": true
},
"globals": {
"sinon": true
},
"rules": {
"linebreak-style": 0,
"no-underscore-dangle": 0,
"no-unused-expressions": 1,
"padded-blocks": 0,
"no-plusplus": 0
}
}
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "event-dispatcher",
"description": "EventDispatcher is a JavaScript class that adds events support to custom objects",
"version": "1.0.5",
"version": "1.0.6",
"main": "dist/event-dispatcher.js",
"keywords": [
"events",
Expand All @@ -22,16 +22,17 @@
"type": "git",
"url": "https://github.com/burdiuz/js-event-dispatcher.git"
},
"dependencies": {
},
"dependencies": {},
"devDependencies": {
"babel-core": "^6.22.1",
"babel-eslint": "^7.1.1",
"babel-loader": "^6.2.10",
"babel-plugin-istanbul": "^4.0.0",
"babel-plugin-transform-flow-strip-types": "^6.22.0",
"babel-preset-latest": "^6.22.0",
"chai": "^3.5.0",
"eslint": "^3.14.1",
"eslint-config-airbnb": "^14.1.0",
"flow-bin": "^0.41.0",
"karma": "^0.13.16",
"karma-coverage": "^1.1.1",
Expand All @@ -49,7 +50,7 @@
},
"scripts": {
"start": "webpack",
"lint": "./node_modules/.bin/eslint",
"lint": "./node_modules/.bin/eslint \"source/**/!(*.spec).js\"",
"flow": "./node_modules/.bin/flow",
"server": "./node_modules/.bin/webpack-dev-server --port 8081 --config webpack.config.main.js --open",
"test": "./node_modules/.bin/karma start --single-run --browsers Firefox karma.conf.js"
Expand Down
7 changes: 4 additions & 3 deletions source/Event.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@

'use strict';

import EventDispatcher, {Event} from './EventDispatcher';
import { expect } from 'chai';
import EventDispatcher, { Event } from './EventDispatcher';

describe('Event', () => {
var event = '';
var data = '';
var type = '';
beforeEach(() => {
data = {value: false};
data = { value: false };
type = 'someEventType';
event = new Event(type, data);
});
Expand Down Expand Up @@ -40,7 +41,7 @@ describe('Event', () => {
describe('toJSON()', () => {
it('should include only type and data', () => {
expect(event.toJSON()).to.be.eql({
data: {value: false},
data: { value: false },
type: 'someEventType'
});
});
Expand Down
18 changes: 7 additions & 11 deletions source/EventDispatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
* @flow
*/

'use strict';

import type { EventObject, EventType, EventListener, EventProcessor } from './TypeDefinition';

export class Event {
Expand All @@ -19,8 +17,6 @@ export class Event {
this.type = type;
this.data = data || null;
this.defaultPrevented = false;
this.stopPropagation;
this.stopImmediatePropagation;
}

toJSON(): EventObject {
Expand All @@ -36,14 +32,14 @@ export class Event {
}
}

type EventTypesCollection = {
[eventType:string]: EventPrioritiesCollection;
}

type EventPrioritiesCollection = {
[priority:string]: Array<EventListener>;
}

type EventTypesCollection = {
[eventType:string]: EventPrioritiesCollection;
}

class EventListeners {

_listeners: EventTypesCollection;
Expand All @@ -62,8 +58,8 @@ class EventListeners {

createList(eventType: string, priority: number): Array<EventListener> {
return this.getListenersListByKey(
parseInt(priority),
this.getPrioritiesByKey(eventType)
parseInt(priority, 10),
this.getPrioritiesByKey(eventType),
);
}

Expand Down Expand Up @@ -167,7 +163,7 @@ class EventListeners {
}
}

export class EventDispatcher {
class EventDispatcher {

_listeners: EventListeners;
_eventPreprocessor: EventProcessor;
Expand Down
5 changes: 3 additions & 2 deletions source/EventDispatcher.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

'use strict';


import { expect } from 'chai';
import EventDispatcher, { Event } from './EventDispatcher';

describe('EventDispatcher', () => {
Expand Down Expand Up @@ -258,7 +260,7 @@ describe('EventDispatcher', () => {
});
it('should create Event object', () => {
const arg = handlerA.getCall(0).args[0];
expect(arg).to.be.an.instanceof(EventDispatcher.Event);
expect(arg).to.be.an.instanceof(Event);
expect(arg.type).to.be.equal('eventA');
expect(arg.data).to.be.null;
});
Expand Down Expand Up @@ -397,7 +399,6 @@ describe('EventDispatcher', () => {
expect(handlerA_1).to.not.be.called;
});
});

});
});
});
2 changes: 0 additions & 2 deletions source/direct.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use strict';

import EventDispatcher from './EventDispatcher';

module.exports = EventDispatcher;
4 changes: 1 addition & 3 deletions source/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
'use strict';

import EventDispatcher, { Event } from './EventDispatcher';

export default EventDispatcher;
export { EventDispatcher, Event };
export { Event };

0 comments on commit 933bab3

Please sign in to comment.