Skip to content

Commit

Permalink
Replace JSHint with ESLint
Browse files Browse the repository at this point in the history
Closes #71
  • Loading branch information
koistya committed Feb 28, 2015
1 parent 8017f96 commit be2faed
Show file tree
Hide file tree
Showing 14 changed files with 44 additions and 62 deletions.
16 changes: 16 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"parser": "babel-eslint",
"env": {
"browser": true,
"node": true
},
"globals": {
"__DEV__": true,
"__SERVER__": true
},
"rules": {
// Code style
"indent": [2, 2],
"quotes": [2, "single"]
}
}
21 changes: 0 additions & 21 deletions .jshintrc

This file was deleted.

3 changes: 1 addition & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ gulp.task('serve', ['build:watch'], function(cb) {
}
if (!started) {
started = true;
gulp.watch(src.server, function (file) {
gulp.watch(src.server, function() {
$.util.log('Restarting development server.');
server.kill('SIGTERM');
server = startup();
Expand Down Expand Up @@ -195,7 +195,6 @@ gulp.task('deploy', function() {
// Remove temp folder
if (argv.clean) {
var os = require('os');
var path = require('path');
var repoPath = path.join(os.tmpdir(), 'tmpRepo');
$.util.log('Delete ' + $.util.colors.magenta(repoPath));
del.sync(repoPath, {force: true});
Expand Down
9 changes: 3 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@
"devDependencies": {
"autoprefixer-loader": "^1.1.0",
"babel-core": "^4.6.1",
"babel-eslint": "^1.0.12",
"babel-loader": "^4.0.0",
"browser-sync": "^2.2.1",
"css-loader": "^0.9.1",
"del": "^1.1.1",
"eslint": "^0.15.1",
"gulp": "^3.8.11",
"gulp-autoprefixer": "^2.1.0",
"gulp-cache": "^0.2.8",
Expand All @@ -38,7 +40,6 @@
"gulp-if": "^1.2.5",
"gulp-imagemin": "^2.2.1",
"gulp-jsbeautifier": "^0.0.4",
"gulp-jshint": "^1.9.2",
"gulp-less": "^3.0.1",
"gulp-load-plugins": "^0.8.1",
"gulp-minify-css": "^0.5.0",
Expand All @@ -50,9 +51,6 @@
"gulp-uglify": "^1.1.0",
"gulp-util": "^3.0.4",
"jest-cli": "^0.4.0",
"jshint": "^2.6.2",
"jshint-loader": "^0.8.3",
"jshint-stylish": "^1.0.1",
"less": "^2.4.0",
"less-loader": "^2.0.0",
"minimist": "^1.1.0",
Expand All @@ -74,8 +72,7 @@
},
"scripts": {
"start": "gulp",
"test": "jshint && jest",
"jshint": "jshint ./src gulpfile.js",
"test": "eslint src gulpfile.js webpack.config.js && jest",
"preupdate-webdriver": "npm install",
"update-webdriver": "webdriver-manager update"
}
Expand Down
3 changes: 0 additions & 3 deletions src/components/App/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import './App.less';

import React from 'react';
import invariant from 'react/lib/invariant';
import AppActions from '../../actions/AppActions';
import NavigationMixin from './NavigationMixin';
import AppStore from '../../stores/AppStore';
import Navbar from '../Navbar';
Expand Down Expand Up @@ -41,7 +40,6 @@ export default React.createClass({
}

return (
/* jshint ignore:start */
<div className="App">
<Navbar />
{
Expand All @@ -67,7 +65,6 @@ export default React.createClass({
</div>
</div>
</div>
/* jshint ignore:end */
);
}

Expand Down
14 changes: 7 additions & 7 deletions src/components/App/NavigationMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

'use strict';

import React from 'react';
import ExecutionEnvironment from 'react/lib/ExecutionEnvironment';
import AppActions from '../../actions/AppActions';

Expand All @@ -27,11 +26,12 @@ var NavigationMixin = {
},

handlePopState(event) {
if (event.state) {
var path = event.state.path;
// TODO: Replace current location
// replace(path, event.state);
} else {
//if (event.state) {
// TODO: Replace current location
// var path = event.state.path;
// replace(path, event.state);
//}
if (!event.state) {
AppActions.navigateTo(window.location.pathname);
}
},
Expand Down Expand Up @@ -59,7 +59,7 @@ var NavigationMixin = {

// Ensure non-hash for the same path
var link = el.getAttribute('href');
if (el.pathname === location.pathname && (el.hash || '#' === link)) {
if (el.pathname === location.pathname && (el.hash || link === '#')) {
return;
}

Expand Down
6 changes: 2 additions & 4 deletions src/components/ContentPage/ContentPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@ export default React.createClass({
},

render() {
var { className, title, body, other } = this.props;
var { className, body, other } = this.props;

/* jshint ignore:start */
return <div className={'ContentPage ' + className}
dangerouslySetInnerHTML={{__html: body}} />;
/* jshint ignore:end */
dangerouslySetInnerHTML={{__html: body}} {...other} />;
}

});
2 changes: 0 additions & 2 deletions src/components/HomePage/HomePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ export default React.createClass({
},

render() {
/* jshint ignore:start */
return <div className="ContentPage"
dangerouslySetInnerHTML={{__html: this.props.body}} />;
/* jshint ignore:end */
}

});
2 changes: 0 additions & 2 deletions src/components/Navbar/Navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export default React.createClass({

render() {
return (
/* jshint ignore:start */
<div className="navbar-top" role="navigation">
<div className="container">
<a className="navbar-brand row" href="/">
Expand All @@ -23,7 +22,6 @@ export default React.createClass({
</a>
</div>
</div>
/* jshint ignore:end */
);
}

Expand Down
2 changes: 0 additions & 2 deletions src/components/NotFoundPage/NotFoundPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@ export default React.createClass({

render() {
return (
/* jshint ignore:start */
<div>
<h1>Page Not Found</h1>
<p>Sorry, but the page you were trying to view does not exist.</p>
</div>
/* jshint ignore:end */
);
}

Expand Down
2 changes: 0 additions & 2 deletions src/components/TextBox/TextBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,11 @@ export default React.createClass({

render() {
return (
/* jshint ignore:start */
<div className="TextBox">
{this.props.maxLines > 1 ?
<textarea {...this.props} className="TextBox-input" ref="input" key="input" rows={this.props.maxLines} /> :
<input {...this.props} className="TextBox-input" ref="input" key="input" />}
</div>
/* jshint ignore:end */
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ server.use(express.static(path.join(__dirname)));
// Page API
// -----------------------------------------------------------------------------
server.get('/api/page/*', function(req, res) {
var path = req.path.substr(9);
var page = AppStore.getPage(path);
var urlPath = req.path.substr(9);
var page = AppStore.getPage(urlPath);
res.send(page);
});

Expand Down
20 changes: 12 additions & 8 deletions src/stores/AppStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,28 @@ import assign from 'react/lib/Object.assign';

var CHANGE_EVENT = 'change';

var _pages = {};
var _loading = false;
var pages = {};
var loading = false;

if (__SERVER__) {
_pages['/'] = {title: 'Home Page'};
_pages['/privacy'] = {title: 'Privacy Policy'};
pages['/'] = {title: 'Home Page'};
pages['/privacy'] = {title: 'Privacy Policy'};
}

var AppStore = assign({}, EventEmitter.prototype, {

isLoading() {
return loading;
},

/**
* Gets page data by the given URL path.
*
* @param {String} path URL path.
* @returns {*} Page data.
*/
getPage(path) {
return path in _pages ? _pages[path] : {
return path in pages ? pages[path] : {
title: 'Page Not Found',
type: 'notfound'
};
Expand Down Expand Up @@ -75,10 +79,11 @@ AppStore.dispatcherToken = Dispatcher.register((payload) => {

case ActionTypes.LOAD_PAGE:
if (action.source === PayloadSources.VIEW_ACTION) {
_loading = true;
loading = true;
} else {
loading = false;
if (!action.err) {
_pages[action.path] = action.page;
pages[action.path] = action.page;
}
}
AppStore.emitChange();
Expand All @@ -92,4 +97,3 @@ AppStore.dispatcherToken = Dispatcher.register((payload) => {
});

module.exports = AppStore;

2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ var serverConfig = _.merge({}, config, {
// Remove style-loader
return _.merge(loader, {
loader: loader.loader = loader.loader.replace('style-loader!', '')
})
});
})
}
});
Expand Down

0 comments on commit be2faed

Please sign in to comment.