Skip to content

Commit

Permalink
use airbnb eslint and add lint npm script
Browse files Browse the repository at this point in the history
  • Loading branch information
chentsulin committed Aug 14, 2015
1 parent 2c233fc commit 982c676
Show file tree
Hide file tree
Showing 26 changed files with 235 additions and 271 deletions.
57 changes: 20 additions & 37 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,43 +1,26 @@
{
"parser": "babel-eslint",
"plugins": [
"react"
],
"ecmaFeatures": {
"jsx": true,
"modules": true
},
"env": {
"node": true,
"extends": "eslint-config-airbnb",
"env": {
"browser": true,
"mocha": true,
"es6": true,
"browser": true
"node": true
},
"globals": {
"rules": {
"react/jsx-uses-react": 2,
"react/jsx-uses-vars": 2,
"react/react-in-jsx-scope": 2,

},
"rules": {
"quotes": [2, "single"],
"semi": [2, "never"],
"curly": [2, "multi-line"],
"no-underscore-dangle": 0,
"no-var": 0,
"vars-on-top": 0,
"comma-dangle": 0,
"no-use-before-define": 0,

"react/display-name": 0,
"react/jsx-boolean-value": 1,
"react/jsx-quotes": 1,
"react/jsx-no-undef": 1,
"react/jsx-sort-props": 1,
"react/jsx-sort-prop-types": 1,
"react/jsx-uses-react": 1,
"react/jsx-uses-vars": 1,
"react/no-did-mount-set-state": 1,
"react/no-did-update-set-state": 1,
"react/no-multi-comp": 1,
"react/no-unknown-property": 1,
"react/prop-types": 1,
"react/react-in-jsx-scope": 1,
"react/self-closing-comp": 1,
"react/sort-comp": 0,
"react/wrap-multilines": 1
}
//Temporarirly disabled due to a possible bug in babel-eslint (todomvc example)
"block-scoped-var": 0,
// Temporarily disabled for test/* until babel/babel-eslint#33 is resolved
"padded-blocks": 0
},
"plugins": [
"react"
]
}
4 changes: 2 additions & 2 deletions app/actions/AppActions.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import createActions from '../utils/createActions'
import createActions from '../utils/createActions';


export default createActions({

})
});
4 changes: 2 additions & 2 deletions app/constants/ActionTypes.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import keyMirror from 'keymirror'
import keyMirror from 'keymirror';


export default keyMirror({

// Routes
ROUTE_CHANGE: null

})
});
4 changes: 2 additions & 2 deletions app/constants/PayloadSources.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import keyMirror from 'keymirror'
import keyMirror from 'keymirror';


export default keyMirror({
SERVER_ACTION: null,
VIEW_ACTION: null
})
});
6 changes: 3 additions & 3 deletions app/containers/AboutPageContainer.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import { Link } from 'react-router'
import React from 'react';
import { Link } from 'react-router';


export default class AboutPageContainer extends React.Component {
Expand All @@ -15,7 +15,7 @@ export default class AboutPageContainer extends React.Component {
<p>About us.</p>
<Link to="home">back Home</Link>
</div>
)
);
}

}
6 changes: 3 additions & 3 deletions app/containers/AppContainer.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import { RouteHandler } from 'react-router'
import React from 'react';
import { RouteHandler } from 'react-router';


export default class AppContainer extends React.Component {
Expand All @@ -9,7 +9,7 @@ export default class AppContainer extends React.Component {
<div>
<RouteHandler />
</div>
)
);
}

}
Expand Down
6 changes: 3 additions & 3 deletions app/containers/HomePageContainer.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import { Link } from 'react-router'
import React from 'react';
import { Link } from 'react-router';


export default class HomePageContainer extends React.Component {
Expand All @@ -15,7 +15,7 @@ export default class HomePageContainer extends React.Component {
<p>This is the homepage.</p>
<Link to="about">to About</Link>
</div>
)
);
}

}
28 changes: 14 additions & 14 deletions app/dispatcher/AppDispatcher.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
import Dispatcher from 'flux'
import assign from 'object-assign'
import PayloadSources from '../constants/PayloadSources'
import debug from './utils/debug'
import Dispatcher from 'flux';
import assign from 'object-assign';
import PayloadSources from '../constants/PayloadSources';
import debug from './utils/debug';

var dd = debug('AppDispatcher')
var dd = debug('AppDispatcher');


export default assign(new Dispatcher(), {

handleServerAction(action) {
dd('server action', action)
dd('server action', action);

if (!action.type) {
throw new Error('Empty action.type: you likely mistyped the action.')
throw new Error('Empty action.type: you likely mistyped the action.');
}

var payload = {
source: PayloadSources.SERVER_ACTION,
action: action
}
};

this.dispatch(payload)
this.dispatch(payload);
},

handleViewAction(action) {
dd('view action', action)
dd('view action', action);

if (!action.type) {
throw new Error('Empty action.type: you likely mistyped the action.')
throw new Error('Empty action.type: you likely mistyped the action.');
}

var payload = {
source: PayloadSources.VIEW_ACTION,
action: action
}
};

this.dispatch(payload)
this.dispatch(payload);
}
})
});
20 changes: 10 additions & 10 deletions app/mainApp.jsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import React from 'react'
import AppContainer from './containers/AppContainer'
import router from './routes/router'
import debug from './utils/debug'
import './app.css'
import React from 'react';
import AppContainer from './containers/AppContainer';
import router from './routes/router';
import debug from './utils/debug';
import './app.css';

var dd = debug('mainApp')
var dd = debug('mainApp');

window.location.hash = '/'
window.location.hash = '/';

router.run(function (Handler) {
dd('router.run', Handler)
React.render(<Handler />, document.getElementById('react-root'))
router.run(Handler => {
dd('router.run', Handler);
React.render(<Handler />, document.getElementById('react-root'));
});
2 changes: 1 addition & 1 deletion app/routes/async.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = [ 'SomePage', 'ReadmePage' ]
module.exports = [ 'SomePage', 'ReadmePage' ];
6 changes: 3 additions & 3 deletions app/routes/router.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import routes from './routes'
import Router from 'react-router'
import routes from './routes';
import Router from 'react-router';


// we can create a router before 'running' it
export default Router.create({
routes: routes,
location: Router.HashLocation
})
});
12 changes: 6 additions & 6 deletions app/routes/routes.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React from 'react'
import { Route, DefaultRoute } from 'react-router'
import AppContainer from '../containers/AppContainer'
import HomePageContainer from '../containers/HomePageContainer'
import AboutPageContainer from '../containers/AboutPageContainer'
import React from 'react';
import { Route, DefaultRoute } from 'react-router';
import AppContainer from '../containers/AppContainer';
import HomePageContainer from '../containers/HomePageContainer';
import AboutPageContainer from '../containers/AboutPageContainer';


export default (
<Route path="/" handler={AppContainer}>
<DefaultRoute name="home" handler={HomePageContainer} />
<Route name="about" handler={AboutPageContainer} />
</Route>
)
);
17 changes: 9 additions & 8 deletions app/stores/AppStore.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import AppDispatcher from '../dispatcher/AppDispatcher'
import ActionTypes from '../constants/ActionTypes'
import createStore from '../utils/createStore'
import AppDispatcher from '../dispatcher/AppDispatcher';
import ActionTypes from '../constants/ActionTypes';
import createStore from '../utils/createStore';


export default createStore({

})
});


AppDispatcher.register(function(payload) {
var action = payload.action
AppDispatcher.register(payload => {
var action = payload.action;
switch (action.type) {

case ActionTypes.ROUTE_CHANGE:
break;
default:

}
})
});
2 changes: 1 addition & 1 deletion app/utils/createActions.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export default function createActions(attributes) {
return attributes
return attributes;
}
16 changes: 8 additions & 8 deletions app/utils/createStore.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
import assign from 'object-assign'
import { EventEmitter } from 'events'
import assign from 'object-assign';
import { EventEmitter } from 'events';


var CHANGE_EVENT = 'change'
var CHANGE_EVENT = 'change';


export default function(attributes) {
return assign({}, EventEmitter.prototype, {

emitChange() {
this.emit(CHANGE_EVENT)
this.emit(CHANGE_EVENT);
},

addChangeListener(callback) {
this.on(CHANGE_EVENT, callback)
this.on(CHANGE_EVENT, callback);
},

onChange(callback) {
this.addChangeListener(callback)
this.addChangeListener(callback);
},

removeChangeListener(callback) {
this.removeListener(CHANGE_EVENT, callback)
this.removeListener(CHANGE_EVENT, callback);
}

}, attributes)
}, attributes);
}
6 changes: 3 additions & 3 deletions app/utils/debug.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import debug from 'debug'
import debug from 'debug';

global.dd = debug
global.dd = debug;

export default debug
export default debug;
Loading

0 comments on commit 982c676

Please sign in to comment.