diff --git a/.eslintignore b/.eslintignore index be0525f92..a72ae1563 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,9 +1,5 @@ **/node_modules coverage -index.js -emojis.js -marked.js - example/dist example/demo-bundle.* example/reference-bundle.* diff --git a/example/fixtures/requestmodel.json b/example/fixtures/requestmodel.json index 9ea753a82..39a41841f 100644 --- a/example/fixtures/requestmodel.json +++ b/example/fixtures/requestmodel.json @@ -1,173 +1,320 @@ -{ - "_id" : "some_id", - "group" : { - "id" : "someid", - "label" : "readme" - }, - "request" : { - "log" : { - "creator" : { - "name" : "readmeio", - "version" : "0.0.0", - "comment" : "linux/v8.11.2" - }, - "entries" : [ +{ + "_id": "some_id", + "group": { + "id": "someid", + "label": "readme" + }, + "request": { + "log": { + "creator": { + "name": "readmeio", + "version": "0.0.0", + "comment": "linux/v8.11.2" + }, + "entries": [ { - "request" : { - "postData" : { - "mimeType" : "application/json", - "params" : [ + "request": { + "postData": { + "mimeType": "application/json", + "params": [ ] - }, - "method" : "GET", - "url" : "https://dash.readme.io/api/v1/docs/search?query=test", - "httpVersion" : "1.1", - "headers" : [ - { - "name" : "user-agent", - "value" : "curl/7.54.0", - "_id" : "5b74bf05774f44001dd990f1" - }, - { - "name" : "host", - "value" : "readme.readme.io", - "_id" : "5b74bf05774f44001dd990f6" - }, - { - "name" : "connection", - "value" : "close", - "_id" : "5b74bf05774f44001dd990f5" - }, - { - "name" : "x-forwarded-host", - "value" : "dash.readme.io", - "_id" : "5b74bf05774f44001dd990f4" - }, - { - "name" : "accept", - "value" : "*/*", - "_id" : "5b74bf05774f44001dd990f3" - }, - { - "name" : "x-forwarded-for", - "value" : "136.24.201.16, 54.210.159.126", - "_id" : "5b74bf05774f44001dd990f0" - }, - { - "name" : "x-forwarded-port", - "value" : "443", - "_id" : "5b74bf05774f44001dd990ef" - }, - { - "name" : "x-forwarded-proto", - "value" : "https", - "_id" : "5b74bf05774f44001dd990ee" - }, - { - "name" : "x-request-id", - "value" : "b2dd95ae-04fb-4e44-ad0a-2e5b73162317", - "_id" : "5b74bf05774f44001dd990ed" - }, - { - "name" : "via", - "value" : "1.1 vegur", - "_id" : "5b74bf05774f44001dd990ec" - }, - { - "name" : "connect-time", - "value" : "0", - "_id" : "5b74bf05774f44001dd990eb" + }, + "method": "GET", + "url": "https://dash.readme.io/api/v1/docs/search?query=test", + "httpVersion": "1.1", + "headers": [ + { + "name": "user-agent", + "value": "curl/7.54.0", + "_id": "5b74bf05774f44001dd990f1" + }, + { + "name": "host", + "value": "readme.readme.io", + "_id": "5b74bf05774f44001dd990f6" + }, + { + "name": "connection", + "value": "close", + "_id": "5b74bf05774f44001dd990f5" + }, + { + "name": "x-forwarded-host", + "value": "dash.readme.io", + "_id": "5b74bf05774f44001dd990f4" + }, + { + "name": "accept", + "value": "*/*", + "_id": "5b74bf05774f44001dd990f3" + }, + { + "name": "x-forwarded-for", + "value": "136.24.201.16, 54.210.159.126", + "_id": "5b74bf05774f44001dd990f0" + }, + { + "name": "x-forwarded-port", + "value": "443", + "_id": "5b74bf05774f44001dd990ef" + }, + { + "name": "x-forwarded-proto", + "value": "https", + "_id": "5b74bf05774f44001dd990ee" + }, + { + "name": "x-request-id", + "value": "b2dd95ae-04fb-4e44-ad0a-2e5b73162317", + "_id": "5b74bf05774f44001dd990ed" + }, + { + "name": "via", + "value": "1.1 vegur", + "_id": "5b74bf05774f44001dd990ec" + }, + { + "name": "connect-time", + "value": "0", + "_id": "5b74bf05774f44001dd990eb" } - ], - "queryString" : [ + ], + "queryString": [ { - "name" : "query", - "value" : "test", - "_id" : "5b74bf05774f44001dd990f7" + "name": "query", + "value": "test", + "_id": "5b74bf05774f44001dd990f7" } ] - }, - "response" : { - "status" : 400, - "statusText" : "Bad Request", - "headers" : [ - { - "name" : "x-xss-protection", - "value" : "1; mode=block", - "_id" : "5b74bf05774f44001dd99102" - }, - { - "name" : "x-dns-prefetch-control", - "value" : "off", - "_id" : "5b74bf05774f44001dd99101" - }, - { - "name" : "x-frame-options", - "value" : "Deny", - "_id" : "5b74bf05774f44001dd99100" - }, - { - "name" : "strict-transport-security", - "value" : "max-age=15552000; includeSubDomains", - "_id" : "5b74bf05774f44001dd990ff" - }, - { - "name" : "x-download-options", - "value" : "noopen", - "_id" : "5b74bf05774f44001dd990fe" - }, - { - "name" : "x-content-type-options", - "value" : "nosniff", - "_id" : "5b74bf05774f44001dd990fd" - }, - { - "name" : "x-powered-by", - "value" : "Express", - "_id" : "5b74bf05774f44001dd990fc" - }, - { - "name" : "content-type", - "value" : "application/json; charset=utf-8", - "_id" : "5b74bf05774f44001dd990fb" - }, - { - "name" : "content-length", - "value" : "80", - "_id" : "5b74bf05774f44001dd990fa" - }, - { - "name" : "etag", - "value" : "W/\"50-iwDQZvKva0kjfFp1QELFLv23tQg\"", - "_id" : "5b74bf05774f44001dd990f9" - }, - { - "name" : "vary", - "value" : "Accept-Encoding", - "_id" : "5b74bf05774f44001dd990f8" + }, + "response": { + "status": 400, + "statusText": "Bad Request", + "headers": [ + { + "name": "x-xss-protection", + "value": "1; mode=block", + "_id": "5b74bf05774f44001dd99102" + }, + { + "name": "x-dns-prefetch-control", + "value": "off", + "_id": "5b74bf05774f44001dd99101" + }, + { + "name": "x-frame-options", + "value": "Deny", + "_id": "5b74bf05774f44001dd99100" + }, + { + "name": "strict-transport-security", + "value": "max-age=15552000; includeSubDomains", + "_id": "5b74bf05774f44001dd990ff" + }, + { + "name": "x-download-options", + "value": "noopen", + "_id": "5b74bf05774f44001dd990fe" + }, + { + "name": "x-content-type-options", + "value": "nosniff", + "_id": "5b74bf05774f44001dd990fd" + }, + { + "name": "x-powered-by", + "value": "Express", + "_id": "5b74bf05774f44001dd990fc" + }, + { + "name": "content-type", + "value": "application/json; charset=utf-8", + "_id": "5b74bf05774f44001dd990fb" + }, + { + "name": "content-length", + "value": "80", + "_id": "5b74bf05774f44001dd990fa" + }, + { + "name": "etag", + "value": "W/\"50-iwDQZvKva0kjfFp1QELFLv23tQg\"", + "_id": "5b74bf05774f44001dd990f9" + }, + { + "name": "vary", + "value": "Accept-Encoding", + "_id": "5b74bf05774f44001dd990f8" } - ], - "content" : [ + ], + "content": [ { - "text" : "{\"error\":\"Bad Request\",\"description\":\"You must provide a version\",\"errors\":null}", - "size" : 80, - "mimeType" : "application/json; charset=utf-8", - "_id" : "5b74bf05774f44001dd99103" + "text": "{\"error\":\"Bad Request\",\"description\":\"You must provide a version\",\"errors\":null}", + "size": 80, + "mimeType": "application/json; charset=utf-8", + "_id": "5b74bf05774f44001dd99103" } ] - }, - "pageref" : "", - "startedDateTime" : "2018-08-16T00:02:12.999+0000", - "time" : 3, - "_id" : "5b74bf05774f44001dd99104" + }, + "pageref": "", + "startedDateTime": "2018-08-16T00:02:12.999+0000", + "time": 3, + "_id": "5b74bf05774f44001dd99104" } ] } - }, - "subdomain" : "readme", - "clientIPAddress" : "someip", - "development" : false, - "createdAt" : "2018-08-16T00:02:13.081+0000", - "updatedAt" : "2018-08-16T00:02:13.081+0000" + }, + "subdomain": "readme", + "clientIPAddress": "someip", + "development": false, + "creator": { + "name": "readmeio", + "version": "0.0.0", + "comment": "linux/v8.11.2" + }, + "startedDateTime": "2018-08-16T00:02:12.999+0000", + "responseTime": 3, + "method": "GET", + "url": "https://dash.readme.io/api/v1/docs/search?query=test", + "httpVersion": "1.1", + "requestHeaders": [ + { + "name": "user-agent", + "value": "curl/7.54.0", + "_id": "5b74bf05774f44001dd990f1" + }, + { + "name": "host", + "value": "readme.readme.io", + "_id": "5b74bf05774f44001dd990f6" + }, + { + "name": "connection", + "value": "close", + "_id": "5b74bf05774f44001dd990f5" + }, + { + "name": "x-forwarded-host", + "value": "dash.readme.io", + "_id": "5b74bf05774f44001dd990f4" + }, + { + "name": "accept", + "value": "*/*", + "_id": "5b74bf05774f44001dd990f3" + }, + { + "name": "x-forwarded-for", + "value": "136.24.201.16, 54.210.159.126", + "_id": "5b74bf05774f44001dd990f0" + }, + { + "name": "x-forwarded-port", + "value": "443", + "_id": "5b74bf05774f44001dd990ef" + }, + { + "name": "x-forwarded-proto", + "value": "https", + "_id": "5b74bf05774f44001dd990ee" + }, + { + "name": "x-request-id", + "value": "b2dd95ae-04fb-4e44-ad0a-2e5b73162317", + "_id": "5b74bf05774f44001dd990ed" + }, + { + "name": "via", + "value": "1.1 vegur", + "_id": "5b74bf05774f44001dd990ec" + }, + { + "name": "connect-time", + "value": "0", + "_id": "5b74bf05774f44001dd990eb" + } + ], + "queryString": [ + { + "name": "query", + "value": "test", + "_id": "5b74bf05774f44001dd990f7" + } + ], + "requestBody": { + "mimeType": "application/json", + "params": [ + + ] + }, + "status": 400, + "statusText": "Bad Request", + "headers": [ + { + "name": "x-xss-protection", + "value": "1; mode=block", + "_id": "5b74bf05774f44001dd99102" + }, + { + "name": "x-dns-prefetch-control", + "value": "off", + "_id": "5b74bf05774f44001dd99101" + }, + { + "name": "x-frame-options", + "value": "Deny", + "_id": "5b74bf05774f44001dd99100" + }, + { + "name": "strict-transport-security", + "value": "max-age=15552000; includeSubDomains", + "_id": "5b74bf05774f44001dd990ff" + }, + { + "name": "x-download-options", + "value": "noopen", + "_id": "5b74bf05774f44001dd990fe" + }, + { + "name": "x-content-type-options", + "value": "nosniff", + "_id": "5b74bf05774f44001dd990fd" + }, + { + "name": "x-powered-by", + "value": "Express", + "_id": "5b74bf05774f44001dd990fc" + }, + { + "name": "content-type", + "value": "application/json; charset=utf-8", + "_id": "5b74bf05774f44001dd990fb" + }, + { + "name": "content-length", + "value": "80", + "_id": "5b74bf05774f44001dd990fa" + }, + { + "name": "etag", + "value": "W/\"50-iwDQZvKva0kjfFp1QELFLv23tQg\"", + "_id": "5b74bf05774f44001dd990f9" + }, + { + "name": "vary", + "value": "Accept-Encoding", + "_id": "5b74bf05774f44001dd990f8" + } + ], + "responseBody": [ + { + "text": "{\"error\":\"Bad Request\",\"description\":\"You must provide a version\",\"errors\":null}", + "size": 80, + "mimeType": "application/json; charset=utf-8", + "_id": "5b74bf05774f44001dd99103" + } + ], + "createdAt": "2018-08-16T00:02:13.081+0000", + "updatedAt": "2018-08-16T00:02:13.081+0000" } diff --git a/lib/babel-jest.js b/lib/babel-jest.js index 462b18fd9..d209f8c34 100644 --- a/lib/babel-jest.js +++ b/lib/babel-jest.js @@ -1,5 +1,8 @@ +/* eslint import/no-extraneous-dependencies: ["error", {"devDependencies": true }] */ const babelJest = require('babel-jest'); const path = require('path'); -const babelRc = JSON.parse(require('fs').readFileSync(path.join(__dirname, '..', '.babelrc'), 'utf8')); +const babelRc = JSON.parse( + require('fs').readFileSync(path.join(__dirname, '..', '.babelrc'), 'utf8'), +); module.exports = babelJest.createTransformer(babelRc); diff --git a/package.json b/package.json index ee959ce40..4d5540f66 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "scripts": { "build": "./build.sh & lerna run build", "deploy": "gh-pages --dotfiles -d example/dist", - "lint": "eslint example --ext js --ext jsx", + "lint": "eslint example lib *.js --ext js --ext jsx", "publish": "lerna publish", "start": "node scripts/update-example-swagger-files && webpack-dev-server", "test": "node scripts/update-example-swagger-files && npm run lint && lerna run test --stream", diff --git a/webpack.config.js b/webpack.config.js index 9fdde3efa..e171e2bc9 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -5,10 +5,6 @@ const common = require('./webpack.common'); const log = require('./example/fixtures/requestmodel.json'); module.exports = merge(common, { - output: { - path: path.resolve(__dirname, 'example'), - filename: '[name]-bundle.js', - }, devServer: { contentBase: './example', publicPath: '/example/', @@ -16,21 +12,25 @@ module.exports = merge(common, { port: 9966, hot: true, watchContentBase: true, - before: (app) => { + before: app => { app.get('/api/logs', (req, res) => { // Simulate some loading time setTimeout(() => { // res.json([]); // no data state - res.json([...Array(5).keys()].map(() => - ({ ...log, _id: Math.random().toString(5)}), - )); + res.json( + [...new Array(5).keys()].map(() => ({ ...log, _id: Math.random().toString(5) })), + ); }, 500); }); }, }, - plugins: [ - new webpack.NamedModulesPlugin(), - new webpack.HotModuleReplacementPlugin(), - ], devtool: 'cheap-module-source-map', + optimization: { + namedChunks: true, + }, + output: { + path: path.resolve(__dirname, 'example'), + filename: '[name]-bundle.js', + }, + plugins: [new webpack.HotModuleReplacementPlugin()], });