commit be2faedb18f908e3da6c72c50deea7e6046abefc
parent 8017f9610e90b9e649397a4b84b771c3711fabe7
Author: Konstantin Tarkus <hello@tarkus.me>
Date: Sun, 1 Mar 2015 00:47:15 +0300
Replace JSHint with ESLint
Closes #71
Diffstat:
14 files changed, 44 insertions(+), 62 deletions(-)
diff --git a/.eslintrc b/.eslintrc
@@ -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"]
+ }
+}
diff --git a/.jshintrc b/.jshintrc
@@ -1,21 +0,0 @@
-{
- "camelcase": true,
- "immed": true,
- "indent": 2,
- "latedef": true,
- "newcap": true,
- "quotmark": "single",
-
- "esnext": true,
- "globalstrict": true,
-
- "browser": true,
- "node": true,
-
- "globals": {
- "require": false,
- "__dirname": false,
- "__DEV__": false,
- "__SERVER__": false
- }
-}
diff --git a/gulpfile.js b/gulpfile.js
@@ -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();
@@ -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});
diff --git a/package.json b/package.json
@@ -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",
@@ -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",
@@ -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",
@@ -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"
}
diff --git a/src/components/App/App.js b/src/components/App/App.js
@@ -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';
@@ -41,7 +40,6 @@ export default React.createClass({
}
return (
- /* jshint ignore:start */
<div className="App">
<Navbar />
{
@@ -67,7 +65,6 @@ export default React.createClass({
</div>
</div>
</div>
- /* jshint ignore:end */
);
}
diff --git a/src/components/App/NavigationMixin.js b/src/components/App/NavigationMixin.js
@@ -8,7 +8,6 @@
'use strict';
-import React from 'react';
import ExecutionEnvironment from 'react/lib/ExecutionEnvironment';
import AppActions from '../../actions/AppActions';
@@ -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);
}
},
@@ -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;
}
diff --git a/src/components/ContentPage/ContentPage.js b/src/components/ContentPage/ContentPage.js
@@ -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} />;
}
});
diff --git a/src/components/HomePage/HomePage.js b/src/components/HomePage/HomePage.js
@@ -17,10 +17,8 @@ export default React.createClass({
},
render() {
- /* jshint ignore:start */
return <div className="ContentPage"
dangerouslySetInnerHTML={{__html: this.props.body}} />;
- /* jshint ignore:end */
}
});
diff --git a/src/components/Navbar/Navbar.js b/src/components/Navbar/Navbar.js
@@ -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="/">
@@ -23,7 +22,6 @@ export default React.createClass({
</a>
</div>
</div>
- /* jshint ignore:end */
);
}
diff --git a/src/components/NotFoundPage/NotFoundPage.js b/src/components/NotFoundPage/NotFoundPage.js
@@ -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 */
);
}
diff --git a/src/components/TextBox/TextBox.js b/src/components/TextBox/TextBox.js
@@ -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 */
);
}
diff --git a/src/server.js b/src/server.js
@@ -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);
});
diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js
@@ -16,16 +16,20 @@ 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.
*
@@ -33,7 +37,7 @@ var AppStore = assign({}, EventEmitter.prototype, {
* @returns {*} Page data.
*/
getPage(path) {
- return path in _pages ? _pages[path] : {
+ return path in pages ? pages[path] : {
title: 'Page Not Found',
type: 'notfound'
};
@@ -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();
@@ -92,4 +97,3 @@ AppStore.dispatcherToken = Dispatcher.register((payload) => {
});
module.exports = AppStore;
-
diff --git a/webpack.config.js b/webpack.config.js
@@ -140,7 +140,7 @@ var serverConfig = _.merge({}, config, {
// Remove style-loader
return _.merge(loader, {
loader: loader.loader = loader.loader.replace('style-loader!', '')
- })
+ });
})
}
});