added prettier, removed seperate react eslint config, fixed missing
component display name Markdown.js, and added run method to app
This commit is contained in:
@@ -1,29 +1,27 @@
|
|||||||
{
|
{
|
||||||
"env": {
|
"parser": "babel-eslint",
|
||||||
"es6": true,
|
"plugins": [
|
||||||
"node": true,
|
"react"
|
||||||
"mocha": true
|
],
|
||||||
},
|
|
||||||
"parserOptions": {
|
"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": {
|
"rules": {
|
||||||
"indent": [
|
"react/prop-types": 0,
|
||||||
"error",
|
"react/react-in-jsx-scope": 0
|
||||||
2
|
|
||||||
],
|
|
||||||
"linebreak-style": [
|
|
||||||
"error",
|
|
||||||
"unix"
|
|
||||||
],
|
|
||||||
"quotes": [
|
|
||||||
"error",
|
|
||||||
"single"
|
|
||||||
],
|
|
||||||
"semi": [
|
|
||||||
"error",
|
|
||||||
"always"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
5
.prettierrc
Normal file
5
.prettierrc
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"semi": false,
|
||||||
|
"singleQuote": true,
|
||||||
|
"trailingComma": "es5"
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import fetch from 'isomorphic-unfetch';
|
import fetch from 'isomorphic-unfetch';
|
||||||
import mapUser from '../util/mapUser';
|
import mapUser from '../util/mapUser';
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import cm from 'codemirror';
|
import cm from 'codemirror';
|
||||||
import { getKey, isCtrlKey } from '../util/keys';
|
import { getKey, isCtrlKey } from '../util/keys';
|
||||||
|
|
||||||
|
|||||||
@@ -2,10 +2,13 @@ import dynamic from 'next/dynamic';
|
|||||||
import freezeSSR from '../util/freezeSSR';
|
import freezeSSR from '../util/freezeSSR';
|
||||||
|
|
||||||
const Markdown = dynamic(import('react-markdown'), freezeSSR('.Markdown'));
|
const Markdown = dynamic(import('react-markdown'), freezeSSR('.Markdown'));
|
||||||
const renderers = {
|
const link = props => (
|
||||||
link : props => (<a href={props.href}
|
<a {...props}
|
||||||
target='_blank' rel='noopener noreferrer'>{props.children}</a>)
|
target='_blank'
|
||||||
};
|
rel='noopener noreferrer'
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
const renderers = { link };
|
||||||
const AddRenderers = ({ className, source }) => (
|
const AddRenderers = ({ className, source }) => (
|
||||||
<Markdown {...{className, source, renderers}} />
|
<Markdown {...{className, source, renderers}} />
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import Router from 'next/router';
|
import Router from 'next/router';
|
||||||
import dynamic from 'next/dynamic';
|
import dynamic from 'next/dynamic';
|
||||||
import Page from '../comps/Page';
|
import Page from '../comps/Page';
|
||||||
|
|||||||
@@ -24,9 +24,8 @@
|
|||||||
"yarn": ">= 0.18.0"
|
"yarn": ">= 0.18.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"lint:node": "eslint ./src ./test --config .eslintrc.json",
|
"format": "prettier --write '**/*.js'",
|
||||||
"lint:react": "eslint ./pages ./redux ./util ./comps --config .eslintrc.react.json",
|
"lint": "eslint ./src ./test ./pages ./redux ./util ./comps --config .eslintrc.json",
|
||||||
"lint": "npm run lint:node && npm run lint:react",
|
|
||||||
"mocha": "cross-env NODE_ENV=production mocha test/ --recursive --exit",
|
"mocha": "cross-env NODE_ENV=production mocha test/ --recursive --exit",
|
||||||
"build": "next build",
|
"build": "next build",
|
||||||
"analyze": "cross-env ANALYZE=true next build",
|
"analyze": "cross-env ANALYZE=true next build",
|
||||||
@@ -80,6 +79,7 @@
|
|||||||
"eslint-plugin-react": "^7.8.2",
|
"eslint-plugin-react": "^7.8.2",
|
||||||
"mocha": "^5.1.1",
|
"mocha": "^5.1.1",
|
||||||
"nodemon": "^1.17.3",
|
"nodemon": "^1.17.3",
|
||||||
|
"prettier": "^1.13.4",
|
||||||
"redux-logger": "^3.0.6",
|
"redux-logger": "^3.0.6",
|
||||||
"request": "^2.85.0",
|
"request": "^2.85.0",
|
||||||
"request-promise": "^4.2.2",
|
"request-promise": "^4.2.2",
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import Router from 'next/router';
|
import Router from 'next/router';
|
||||||
import fetch from 'isomorphic-unfetch';
|
import fetch from 'isomorphic-unfetch';
|
||||||
|
|||||||
20
src/app.js
20
src/app.js
@@ -29,10 +29,24 @@ const nxt = require('next')({ dev, quiet: true });
|
|||||||
const nxtHandler = nxt.getRequestHandler();
|
const nxtHandler = nxt.getRequestHandler();
|
||||||
|
|
||||||
const app = express(feathers());
|
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(key, hostConfig[key])
|
||||||
));
|
));
|
||||||
app.set('didSetup', false);
|
app.set('didSetup', false);
|
||||||
|
|||||||
@@ -1,13 +1,10 @@
|
|||||||
const logger = require('winston');
|
const logger = require('winston');
|
||||||
const app = require('./app');
|
const app = require('./app');
|
||||||
const port = app.get('port');
|
const port = app.get('port');
|
||||||
const server = app.listen(port);
|
|
||||||
|
|
||||||
app.startNext();
|
app.run(port).then(() => {
|
||||||
|
|
||||||
server.on('listening', () =>
|
|
||||||
logger.info('MYKB listening at http://%s:%d', app.get('host'), port)
|
logger.info('MYKB listening at http://%s:%d', app.get('host'), port)
|
||||||
);
|
})
|
||||||
|
|
||||||
process.on('unhandledRejection', (reason, p) =>
|
process.on('unhandledRejection', (reason, p) =>
|
||||||
logger.error('Unhandled Rejection at: Promise ', p, reason)
|
logger.error('Unhandled Rejection at: Promise ', p, reason)
|
||||||
|
|||||||
@@ -13,12 +13,11 @@ const getUrl = pathname => url.format({
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('Feathers application tests', () => {
|
describe('Feathers application tests', () => {
|
||||||
before(function(done) {
|
before(async () => {
|
||||||
this.server = app.listen(port);
|
this.server = await app.run(port);
|
||||||
app.startNext().then(() => done());
|
|
||||||
});
|
});
|
||||||
|
|
||||||
after(function(done) {
|
after(done => {
|
||||||
this.server.close(done);
|
this.server.close(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -5487,6 +5487,10 @@ preserve@^0.2.0:
|
|||||||
version "0.2.0"
|
version "0.2.0"
|
||||||
resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b"
|
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:
|
private@^0.1.6:
|
||||||
version "0.1.8"
|
version "0.1.8"
|
||||||
resolved "https://registry.yarnpkg.com/private/-/private-0.1.8.tgz#2381edb3689f7a53d653190060fcf822d2f368ff"
|
resolved "https://registry.yarnpkg.com/private/-/private-0.1.8.tgz#2381edb3689f7a53d653190060fcf822d2f368ff"
|
||||||
|
|||||||
Reference in New Issue
Block a user