diff --git a/.eslintrc.json b/.eslintrc.json
index 03d8167..932a783 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -1,29 +1,27 @@
{
- "env": {
- "es6": true,
- "node": true,
- "mocha": true
- },
+ "parser": "babel-eslint",
+ "plugins": [
+ "react"
+ ],
"parserOptions": {
- "ecmaVersion": 2017
+ "ecmaVersion": 6,
+ "sourceType": "module",
+ "ecmaFeatures": {
+ "jsx": true
+ }
},
- "extends": "eslint:recommended",
+ "env": {
+ "es6": true,
+ "browser": true,
+ "node": true,
+ "mocha": true
+ },
+ "extends": [
+ "eslint:recommended",
+ "plugin:react/recommended"
+ ],
"rules": {
- "indent": [
- "error",
- 2
- ],
- "linebreak-style": [
- "error",
- "unix"
- ],
- "quotes": [
- "error",
- "single"
- ],
- "semi": [
- "error",
- "always"
- ]
+ "react/prop-types": 0,
+ "react/react-in-jsx-scope": 0
}
}
diff --git a/.eslintrc.react.json b/.eslintrc.react.json
deleted file mode 100644
index 4fa6d01..0000000
--- a/.eslintrc.react.json
+++ /dev/null
@@ -1,43 +0,0 @@
-{
- "parser": "babel-eslint",
- "plugins": [
- "react"
- ],
- "parserOptions": {
- "ecmaVersion": 6,
- "sourceType": "module",
- "ecmaFeatures": {
- "jsx": true
- }
- },
- "env": {
- "es6": true,
- "browser": true,
- "node": true,
- "mocha": true
- },
- "extends": [
- "eslint:recommended",
- "plugin:react/recommended"
- ],
- "rules": {
- "react/prop-types": 0,
- "react/react-in-jsx-scope": 0,
- "indent": [
- "error",
- 2
- ],
- "linebreak-style": [
- "error",
- "unix"
- ],
- "quotes": [
- "error",
- "single"
- ],
- "semi": [
- "error",
- "always"
- ]
- }
-}
diff --git a/.prettierrc b/.prettierrc
new file mode 100644
index 0000000..17b1d52
--- /dev/null
+++ b/.prettierrc
@@ -0,0 +1,5 @@
+{
+ "semi": false,
+ "singleQuote": true,
+ "trailingComma": "es5"
+}
\ No newline at end of file
diff --git a/comps/AddDoc.js b/comps/AddDoc.js
index 69f28e5..1b729a0 100644
--- a/comps/AddDoc.js
+++ b/comps/AddDoc.js
@@ -1,4 +1,4 @@
-import { Component } from 'react';
+import React, { Component } from 'react';
import { connect } from 'react-redux';
import fetch from 'isomorphic-unfetch';
import mapUser from '../util/mapUser';
diff --git a/comps/CodeMirror.js b/comps/CodeMirror.js
index c99b6ee..4f496e7 100644
--- a/comps/CodeMirror.js
+++ b/comps/CodeMirror.js
@@ -1,4 +1,4 @@
-import { Component } from 'react';
+import React, { Component } from 'react';
import cm from 'codemirror';
import { getKey, isCtrlKey } from '../util/keys';
diff --git a/comps/Markdown.js b/comps/Markdown.js
index d0afa88..679b189 100644
--- a/comps/Markdown.js
+++ b/comps/Markdown.js
@@ -2,10 +2,13 @@ import dynamic from 'next/dynamic';
import freezeSSR from '../util/freezeSSR';
const Markdown = dynamic(import('react-markdown'), freezeSSR('.Markdown'));
-const renderers = {
- link : props => ({props.children})
-};
+const link = props => (
+
+)
+const renderers = { link };
const AddRenderers = ({ className, source }) => (
);
diff --git a/comps/MngDoc.js b/comps/MngDoc.js
index 9c4df7e..a864bf6 100644
--- a/comps/MngDoc.js
+++ b/comps/MngDoc.js
@@ -1,4 +1,4 @@
-import { Component } from 'react';
+import React, { Component } from 'react';
import Router from 'next/router';
import dynamic from 'next/dynamic';
import Page from '../comps/Page';
diff --git a/package.json b/package.json
index 4e24a90..2c82bc0 100644
--- a/package.json
+++ b/package.json
@@ -24,9 +24,8 @@
"yarn": ">= 0.18.0"
},
"scripts": {
- "lint:node": "eslint ./src ./test --config .eslintrc.json",
- "lint:react": "eslint ./pages ./redux ./util ./comps --config .eslintrc.react.json",
- "lint": "npm run lint:node && npm run lint:react",
+ "format": "prettier --write '**/*.js'",
+ "lint": "eslint ./src ./test ./pages ./redux ./util ./comps --config .eslintrc.json",
"mocha": "cross-env NODE_ENV=production mocha test/ --recursive --exit",
"build": "next build",
"analyze": "cross-env ANALYZE=true next build",
@@ -80,6 +79,7 @@
"eslint-plugin-react": "^7.8.2",
"mocha": "^5.1.1",
"nodemon": "^1.17.3",
+ "prettier": "^1.13.4",
"redux-logger": "^3.0.6",
"request": "^2.85.0",
"request-promise": "^4.2.2",
diff --git a/pages/k.js b/pages/k.js
index 9229082..1f48e2a 100644
--- a/pages/k.js
+++ b/pages/k.js
@@ -1,4 +1,4 @@
-import { Component } from 'react';
+import React, { Component } from 'react';
import Link from 'next/link';
import Router from 'next/router';
import fetch from 'isomorphic-unfetch';
diff --git a/src/app.js b/src/app.js
index 8c85d65..4496e5a 100644
--- a/src/app.js
+++ b/src/app.js
@@ -29,10 +29,24 @@ const nxt = require('next')({ dev, quiet: true });
const nxtHandler = nxt.getRequestHandler();
const app = express(feathers());
-app.startNext = () => nxt.prepare();
-app.configure(configuration()); // Load app configuration
-Object.keys(hostConfig).forEach(key => ( // load host config
+app.run = async port => {
+ const server = app.listen(port);
+ await nxt.prepare();
+
+ if(dev) {
+ server.on('upgrade', (req, socket) => {
+ nxtHandler(req, socket, parse(stripBase(req.url), true));
+ });
+ }
+ return server;
+};
+
+// Load app configuration
+app.configure(configuration());
+
+// load host config
+Object.keys(hostConfig).forEach(key => (
app.set(key, hostConfig[key])
));
app.set('didSetup', false);
diff --git a/src/index.js b/src/index.js
index 1e92a68..955b0ce 100644
--- a/src/index.js
+++ b/src/index.js
@@ -1,13 +1,10 @@
const logger = require('winston');
const app = require('./app');
const port = app.get('port');
-const server = app.listen(port);
-app.startNext();
-
-server.on('listening', () =>
+app.run(port).then(() => {
logger.info('MYKB listening at http://%s:%d', app.get('host'), port)
-);
+})
process.on('unhandledRejection', (reason, p) =>
logger.error('Unhandled Rejection at: Promise ', p, reason)
diff --git a/test/app.test.js b/test/app.test.js
index bb32ebd..4fce51b 100644
--- a/test/app.test.js
+++ b/test/app.test.js
@@ -13,12 +13,11 @@ const getUrl = pathname => url.format({
});
describe('Feathers application tests', () => {
- before(function(done) {
- this.server = app.listen(port);
- app.startNext().then(() => done());
+ before(async () => {
+ this.server = await app.run(port);
});
- after(function(done) {
+ after(done => {
this.server.close(done);
});
diff --git a/yarn.lock b/yarn.lock
index 3c4f4ed..03356c2 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -5487,6 +5487,10 @@ preserve@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b"
+prettier@^1.13.4:
+ version "1.13.4"
+ resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.13.4.tgz#31bbae6990f13b1093187c731766a14036fa72e6"
+
private@^0.1.6:
version "0.1.8"
resolved "https://registry.yarnpkg.com/private/-/private-0.1.8.tgz#2381edb3689f7a53d653190060fcf822d2f368ff"