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:
JJ Kasper
2018-06-01 16:31:14 -05:00
parent 0316746cae
commit 53ac8a6793
13 changed files with 66 additions and 89 deletions

View File

@@ -1,29 +1,27 @@
{
"parser": "babel-eslint",
"plugins": [
"react"
],
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"env": {
"es6": true,
"browser": true,
"node": true,
"mocha": true
},
"parserOptions": {
"ecmaVersion": 2017
},
"extends": "eslint:recommended",
"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
}
}

View File

@@ -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
View File

@@ -0,0 +1,5 @@
{
"semi": false,
"singleQuote": true,
"trailingComma": "es5"
}

View File

@@ -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';

View File

@@ -1,4 +1,4 @@
import { Component } from 'react';
import React, { Component } from 'react';
import cm from 'codemirror';
import { getKey, isCtrlKey } from '../util/keys';

View File

@@ -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 => (<a href={props.href}
target='_blank' rel='noopener noreferrer'>{props.children}</a>)
};
const link = props => (
<a {...props}
target='_blank'
rel='noopener noreferrer'
/>
)
const renderers = { link };
const AddRenderers = ({ className, source }) => (
<Markdown {...{className, source, renderers}} />
);

View File

@@ -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';

View File

@@ -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",

View File

@@ -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';

View File

@@ -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);

View File

@@ -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)

View File

@@ -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);
});

View File

@@ -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"