From 1892e2bd76a98de6cee94d1586b01c6349d4f66f Mon Sep 17 00:00:00 2001 From: PC Drew Date: Mon, 22 Apr 2019 16:23:15 -0600 Subject: [PATCH 1/2] Clean up lint process so that Lerna runs lint on all packages and eslint is the standard. Incorporate the React ESlint rules as well. --- .eslintrc | 6 + .../babel-plugin-react-server/package.json | 2 +- .../babel-preset-react-server/.eslintignore | 1 + packages/babel-preset-react-server/index.js | 20 +- .../babel-preset-react-server/package.json | 1 + packages/babel-preset-react-server/test.js | 6 +- packages/flab/.eslintignore | 2 + packages/flab/minify.js | 2 +- packages/flab/package.json | 1 + packages/flab/stringify.js | 2 +- packages/react-server-cli/gulpfile.babel.js | 16 +- packages/react-server-cli/package.json | 2 +- .../in-files/customRoutes.js | 2 +- .../in-files/routes.js | 2 +- .../react-server-cli/test/parseCliArgs.js | 312 +++++++++--------- .../gulpfile.js | 10 - .../package.json | 2 +- packages/react-server-examples/.eslintignore | 1 + .../bike-share/components/error.js | 4 +- .../bike-share/components/footer.js | 4 +- .../bike-share/components/header.js | 4 +- .../code-splitting/components/Header.js | 10 +- .../react-server-examples/gulpfile.babel.js | 21 -- .../meteor-site/components/Table.js | 14 +- .../meteor-site/stores/reducers.js | 4 +- packages/react-server-examples/package.json | 2 +- .../redux-basic/components/Counter.js | 40 +-- .../redux-basic/pages/store.js | 4 +- .../styled-components/test.js | 2 +- .../test/test.js | 78 ++--- .../__tests__/asyncRender/AsyncElementPage.js | 2 +- .../package.json | 2 +- .../react-server-module-tagger/package.json | 2 +- packages/react-server-redux/package.json | 1 + .../react-server-redux/src/RootProvider.js | 3 +- .../react-server-test-pages/gulpfile.babel.js | 18 - packages/react-server-test-pages/package.json | 5 +- .../pages/error/logs.js | 12 +- .../pages/navigation/common.js | 12 + .../pages/navigation/data-bundle-cache.js | 7 + .../pages/navigation/forwardEven.js | 4 + .../pages/navigation/forwardOdd.js | 4 + .../pages/navigation/navigateTo.js | 5 + .../pages/navigation/playground.js | 16 +- .../pages/root/error.js | 4 + .../pages/root/order.js | 4 + .../pages/root/reduxAdapter.js | 8 +- packages/react-server-website/.eslintignore | 2 + .../react-server-website/components/Header.js | 11 +- .../components/Markdown.js | 3 +- .../components/doc-body.js | 10 +- .../components/doc-contents.js | 16 +- .../components/page-title.js | 14 +- .../components/source-body.js | 4 + .../components/source-contents.js | 16 +- packages/react-server-website/package.json | 2 +- .../react-server-website/pages/source-api.js | 2 +- packages/react-server-website/test.js | 8 +- .../__tests__/ReactServerAgentSpec.js | 40 +-- .../react-server/core/__bench__/handlePage.js | 4 +- .../core/__bench__/loggingClient.js | 4 +- .../core/components/RootContainer.js | 2 +- .../core/components/RootElement.js | 9 +- .../react-server/core/components/TheFold.js | 2 +- .../__tests__/FragmentDataCacheSpec.js | 30 +- packages/react-server/gulpfile.js | 25 +- packages/react-server/package.json | 2 +- 67 files changed, 461 insertions(+), 431 deletions(-) create mode 100644 packages/babel-preset-react-server/.eslintignore create mode 100644 packages/flab/.eslintignore create mode 100644 packages/react-server-examples/.eslintignore delete mode 100644 packages/react-server-examples/gulpfile.babel.js delete mode 100644 packages/react-server-test-pages/gulpfile.babel.js create mode 100644 packages/react-server-website/.eslintignore diff --git a/.eslintrc b/.eslintrc index 4b29dfd9d..989f16b34 100644 --- a/.eslintrc +++ b/.eslintrc @@ -19,6 +19,10 @@ "plugins": [ "react" ], + "extends": [ + "eslint:recommended", + "plugin:react/recommended" + ], "rules": { "react/jsx-uses-vars": 2, "camelcase": 0, @@ -59,6 +63,7 @@ "except-parens" ], "no-constant-condition": 2, + "no-console": 1, "no-dupe-args": 2, "no-dupe-keys": 2, "no-empty": 2, @@ -98,6 +103,7 @@ "double" ], "react/jsx-uses-react": 2, + "react/react-in-jsx-scope": 1, // make this a warning for now, until things can be refactored "semi": [ 0, "always" diff --git a/packages/babel-plugin-react-server/package.json b/packages/babel-plugin-react-server/package.json index fd0321480..e4e79f08a 100644 --- a/packages/babel-plugin-react-server/package.json +++ b/packages/babel-plugin-react-server/package.json @@ -10,7 +10,7 @@ }, "scripts": { "clean": "rm -rf lib npm-debug.log*", - "lint": "eslint src/ test/index.js", + "lint": "eslint src test/index.js", "build": "../../node_modules/.bin/babel --root-mode upward src -d lib", "test": "mocha --compilers js:babel-register", "test:watch": "npm run test -- --watch", diff --git a/packages/babel-preset-react-server/.eslintignore b/packages/babel-preset-react-server/.eslintignore new file mode 100644 index 000000000..1be0c1dea --- /dev/null +++ b/packages/babel-preset-react-server/.eslintignore @@ -0,0 +1 @@ +tst diff --git a/packages/babel-preset-react-server/index.js b/packages/babel-preset-react-server/index.js index d306467c1..49737673a 100644 --- a/packages/babel-preset-react-server/index.js +++ b/packages/babel-preset-react-server/index.js @@ -1,11 +1,11 @@ module.exports = { - plugins: [ - require('babel-plugin-react-server'), - require('babel-plugin-transform-runtime'), - ], - presets: [ - require('babel-preset-es2015'), - require('babel-preset-react'), - require('babel-preset-stage-0'), - ], -} + plugins: [ + require('babel-plugin-react-server'), + require('babel-plugin-transform-runtime'), + ], + presets: [ + require('babel-preset-es2015'), + require('babel-preset-react'), + require('babel-preset-stage-0'), + ], +}; diff --git a/packages/babel-preset-react-server/package.json b/packages/babel-preset-react-server/package.json index e0e44b301..b6b4ef470 100644 --- a/packages/babel-preset-react-server/package.json +++ b/packages/babel-preset-react-server/package.json @@ -5,6 +5,7 @@ "main": "index.js", "scripts": { "clean": "rimraf npm-debug.log*", + "lint": "eslint .", "prepublish": "npm run clean" }, "repository": "redfin/react-server", diff --git a/packages/babel-preset-react-server/test.js b/packages/babel-preset-react-server/test.js index df93cdaea..f0d2d6fdc 100644 --- a/packages/babel-preset-react-server/test.js +++ b/packages/babel-preset-react-server/test.js @@ -7,7 +7,7 @@ test('module can be required', t => { require('.'); t.pass(); } catch (e) { - console.error(e); + console.error(e); //eslint-disable-line no-console t.fail(); } }); @@ -23,7 +23,7 @@ function readFile(filename) { return new Promise((resolve, reject) => { fs.readFile(filename, (err, data) => { if (err) { - console.error(err); + console.error(err); //eslint-disable-line no-console reject(err); } else { resolve(data.toString()); @@ -33,5 +33,5 @@ function readFile(filename) { } function trim(str) { - return str.replace(/^\s+|\s+$/, ''); + return str.replace(/^\s+|\s+$/, ''); } diff --git a/packages/flab/.eslintignore b/packages/flab/.eslintignore new file mode 100644 index 000000000..ec26a0719 --- /dev/null +++ b/packages/flab/.eslintignore @@ -0,0 +1,2 @@ +string +LAB.src.js diff --git a/packages/flab/minify.js b/packages/flab/minify.js index 8298c0690..c80766bd5 100644 --- a/packages/flab/minify.js +++ b/packages/flab/minify.js @@ -1,4 +1,4 @@ -require("get-stdin")().then(src => console.log( +require("get-stdin")().then(src => console.log( // eslint-disable-line no-console "\n"+ "/*! LAB.js (LABjs :: Loading And Blocking JavaScript)\n"+ " v2.0.3 (c) Kyle Simpson\n"+ diff --git a/packages/flab/package.json b/packages/flab/package.json index e5b14de65..1d6998d83 100644 --- a/packages/flab/package.json +++ b/packages/flab/package.json @@ -13,6 +13,7 @@ "build-src": "node stringify.js < LAB.src.js > string/src.js", "build-min": "node minify.js < LAB.src.js | node stringify.js > string/min.js", "clean": "rimraf string", + "lint": "eslint .", "test": "echo \"No tests yet...\"" }, "repository": { diff --git a/packages/flab/stringify.js b/packages/flab/stringify.js index 864dc0b26..77efe5dcc 100644 --- a/packages/flab/stringify.js +++ b/packages/flab/stringify.js @@ -1,4 +1,4 @@ -require("get-stdin")().then(src => console.log( +require("get-stdin")().then(src => console.log( // eslint-disable-line no-console 'module.exports = ' + src .replace(/\\/g, '\\\\') .replace(/"/g, '\\"') diff --git a/packages/react-server-cli/gulpfile.babel.js b/packages/react-server-cli/gulpfile.babel.js index 762e625f5..5e0778172 100644 --- a/packages/react-server-cli/gulpfile.babel.js +++ b/packages/react-server-cli/gulpfile.babel.js @@ -1,4 +1,3 @@ -import eslint from "gulp-eslint"; import gulp from "gulp"; import babel from "gulp-babel"; import changed from "gulp-changed"; @@ -14,20 +13,7 @@ gulp.task("default", () => { .pipe(gulp.dest(dest)); }); -gulp.task("eslint", [], () => { - return gulp.src("src/**/*.js") - // eslint() attaches the lint output to the eslint property - // of the file object so it can be used by other modules. - .pipe(eslint()) - // eslint.format() outputs the lint results to the console. - // Alternatively use eslint.formatEach() (see Docs). - .pipe(eslint.format()) - // To have the process exit with an error code (1) on - // lint error, return the stream and pipe to failOnError last. - .pipe(eslint.failAfterError()); -}); - -gulp.task("test", ["default", "eslint"], () => { +gulp.task("test", ["default"], () => { return gulp.src("target/__tests__/**/*[Ss]pec.js") .pipe(jasmine({})); }); diff --git a/packages/react-server-cli/package.json b/packages/react-server-cli/package.json index 1b410cd8e..989fbd0b1 100644 --- a/packages/react-server-cli/package.json +++ b/packages/react-server-cli/package.json @@ -7,7 +7,7 @@ "ava-watch": "ava --watch", "build": "gulp", "clean": "rimraf target npm-debug.log*", - "lint": "gulp eslint", + "lint": "eslint src test", "prepublish": "npm run build", "test": "ava && gulp test", "watch": "gulp && gulp watch" diff --git a/packages/react-server-cli/test/fixtures/commands/start-reactserverrc/in-files/customRoutes.js b/packages/react-server-cli/test/fixtures/commands/start-reactserverrc/in-files/customRoutes.js index 3e8c13173..e9a42cbe1 100644 --- a/packages/react-server-cli/test/fixtures/commands/start-reactserverrc/in-files/customRoutes.js +++ b/packages/react-server-cli/test/fixtures/commands/start-reactserverrc/in-files/customRoutes.js @@ -1,3 +1,3 @@ module.exports = { - routes: {} + routes: {}, }; diff --git a/packages/react-server-cli/test/fixtures/commands/start-routes-with-error/in-files/routes.js b/packages/react-server-cli/test/fixtures/commands/start-routes-with-error/in-files/routes.js index 60245c063..90a2f247e 100644 --- a/packages/react-server-cli/test/fixtures/commands/start-routes-with-error/in-files/routes.js +++ b/packages/react-server-cli/test/fixtures/commands/start-routes-with-error/in-files/routes.js @@ -1 +1 @@ -undeclaredVariable(); +undeclaredVariable(); // eslint-disable-line no-undef diff --git a/packages/react-server-cli/test/parseCliArgs.js b/packages/react-server-cli/test/parseCliArgs.js index e18917763..1ceb391ff 100644 --- a/packages/react-server-cli/test/parseCliArgs.js +++ b/packages/react-server-cli/test/parseCliArgs.js @@ -8,24 +8,24 @@ const defaultArgs = ['/usr/local/bin/node', '/usr/local/bin/react-server']; test('react-server-cli:parseCliArgs::routesFile can be modified using --routes-file flag', async t => { const args = [ ...defaultArgs, - 'compile', - '--routes-file', - 'customRoutes.js' - ]; - const parsedArgs = await parseCliArgs(args); - t.is(parsedArgs.routesFile, 'customRoutes.js', 'routesFile option is customRoutes.js'); + 'compile', + '--routes-file', + 'customRoutes.js', + ]; + const parsedArgs = await parseCliArgs(args); + t.is(parsedArgs.routesFile, 'customRoutes.js', 'routesFile option is customRoutes.js'); }); // routesFile options can be modified using --routesFile argument test('react-server-cli:parseCliArgs::routesFile can be modified using --routesFile flag', async t => { const args = [ ...defaultArgs, - 'compile', - '--routesFile', - 'customRoutes.js' - ]; - const parsedArgs = await parseCliArgs(args); - t.is(parsedArgs.routesFile, 'customRoutes.js', 'routesFile option is customRoutes.js'); + 'compile', + '--routesFile', + 'customRoutes.js', + ]; + const parsedArgs = await parseCliArgs(args); + t.is(parsedArgs.routesFile, 'customRoutes.js', 'routesFile option is customRoutes.js'); }); @@ -34,38 +34,38 @@ test('react-server-cli:parseCliArgs::routesFile can be modified using --routesFi test('react-server-cli:parseCliArgs::port will be undefined if no argument is provided', async t => { const args = [ ...defaultArgs, - 'compile' - ]; - const parsedArgs = await parseCliArgs(args); - t.is(parsedArgs.port, undefined, 'port is undefined if no argument is provided'); + 'compile', + ]; + const parsedArgs = await parseCliArgs(args); + t.is(parsedArgs.port, undefined, 'port is undefined if no argument is provided'); }); // port option can be modified using --port argument test('react-server-cli:parseCliArgs::port option can be modified using --port argument', async t => { const args = [ ...defaultArgs, - 'compile', - '--port', - '8080' - ]; - const parsedArgs = await parseCliArgs(args); - t.is(typeof parsedArgs.port, 'number', 'port is a number'); - t.is(parsedArgs.port, 8080, 'port is 8080'); - t.true(Object.keys(defaultOptions).indexOf('port') > -1, 'port key exists in defaultOptions'); + 'compile', + '--port', + '8080', + ]; + const parsedArgs = await parseCliArgs(args); + t.is(typeof parsedArgs.port, 'number', 'port is a number'); + t.is(parsedArgs.port, 8080, 'port is 8080'); + t.true(Object.keys(defaultOptions).indexOf('port') > -1, 'port key exists in defaultOptions'); }); // port option can be modified using -p argument test('react-server-cli:parseCliArgs::port option can be modified using -p argument', async t => { const args = [ ...defaultArgs, - 'compile', - '-p', - '8080' - ]; - const parsedArgs = await parseCliArgs(args); - t.is(typeof parsedArgs.port, 'number', 'port is a number'); - t.is(parsedArgs.port, 8080, 'port is 8080'); - t.true(Object.keys(defaultOptions).indexOf('port') > -1, 'port key exists in defaultOptions'); + 'compile', + '-p', + '8080', + ]; + const parsedArgs = await parseCliArgs(args); + t.is(typeof parsedArgs.port, 'number', 'port is a number'); + t.is(parsedArgs.port, 8080, 'port is 8080'); + t.true(Object.keys(defaultOptions).indexOf('port') > -1, 'port key exists in defaultOptions'); }); @@ -74,23 +74,23 @@ test('react-server-cli:parseCliArgs::port option can be modified using -p argume test('react-server-cli:parseCliArgs::host will be undefined if no argument is provided', async t => { const args = [ ...defaultArgs, - 'compile' - ]; - const parsedArgs = await parseCliArgs(args); - t.is(parsedArgs.host, undefined, 'host is undefined if no argument is provided'); + 'compile', + ]; + const parsedArgs = await parseCliArgs(args); + t.is(parsedArgs.host, undefined, 'host is undefined if no argument is provided'); }); // host option can be modified using --host argument test('react-server-cli:parseCliArgs::host option can be modified using --host argument', async t => { const args = [ ...defaultArgs, - 'compile', - '--host', - 'www.myhost.dev' - ]; - const parsedArgs = await parseCliArgs(args); - t.is(parsedArgs.host, 'www.myhost.dev', 'host is www.myhost.dev'); - t.true(Object.keys(defaultOptions).indexOf('host') > -1, 'host key exists in defaultOptions'); + 'compile', + '--host', + 'www.myhost.dev', + ]; + const parsedArgs = await parseCliArgs(args); + t.is(parsedArgs.host, 'www.myhost.dev', 'host is www.myhost.dev'); + t.true(Object.keys(defaultOptions).indexOf('host') > -1, 'host key exists in defaultOptions'); }); @@ -99,38 +99,38 @@ test('react-server-cli:parseCliArgs::host option can be modified using --host ar test('react-server-cli:parseCliArgs::jsPort will be undefined if no argument is provided', async t => { const args = [ ...defaultArgs, - 'compile' - ]; - const parsedArgs = await parseCliArgs(args); - t.is(parsedArgs.jsPort, undefined, 'jsPort is undefined if no argument is provided'); + 'compile', + ]; + const parsedArgs = await parseCliArgs(args); + t.is(parsedArgs.jsPort, undefined, 'jsPort is undefined if no argument is provided'); }); // jsPort options can be modified using --js-port argument test('react-server-cli:parseCliArgs::jsPort can be modified using --js-port flag', async t => { const args = [ ...defaultArgs, - 'compile', - '--js-port', - '8081' - ]; - const parsedArgs = await parseCliArgs(args); - t.is(typeof parsedArgs.jsPort, 'number', 'jsPort is a number'); - t.is(parsedArgs.jsPort, 8081, 'jsPort option is 8081'); - t.true(Object.keys(defaultOptions).indexOf('jsPort') > -1, 'jsPort key exists in defaultOptions'); + 'compile', + '--js-port', + '8081', + ]; + const parsedArgs = await parseCliArgs(args); + t.is(typeof parsedArgs.jsPort, 'number', 'jsPort is a number'); + t.is(parsedArgs.jsPort, 8081, 'jsPort option is 8081'); + t.true(Object.keys(defaultOptions).indexOf('jsPort') > -1, 'jsPort key exists in defaultOptions'); }); // jsPort options can be modified using --jsPort argument test('react-server-cli:parseCliArgs::jsPort can be modified using --jsPort flag', async t => { const args = [ ...defaultArgs, - 'compile', - '--jsPort', - '8081' - ]; - const parsedArgs = await parseCliArgs(args); - t.is(typeof parsedArgs.jsPort, 'number', 'jsPort is a number'); - t.is(parsedArgs.jsPort, 8081, 'jsPort option is 8081'); - t.true(Object.keys(defaultOptions).indexOf('jsPort') > -1, 'jsPort key exists in defaultOptions'); + 'compile', + '--jsPort', + '8081', + ]; + const parsedArgs = await parseCliArgs(args); + t.is(typeof parsedArgs.jsPort, 'number', 'jsPort is a number'); + t.is(parsedArgs.jsPort, 8081, 'jsPort option is 8081'); + t.true(Object.keys(defaultOptions).indexOf('jsPort') > -1, 'jsPort key exists in defaultOptions'); }); @@ -139,60 +139,60 @@ test('react-server-cli:parseCliArgs::jsPort can be modified using --jsPort flag' test('react-server-cli:parseCliArgs::httpsOptions defaults to false', async t => { const args = [ ...defaultArgs, - 'compile' - ]; - const parsedArgs = await parseCliArgs(args); - t.is(parsedArgs.httpsOptions, false, 'Default httpsOptions is false'); + 'compile', + ]; + const parsedArgs = await parseCliArgs(args); + t.is(parsedArgs.httpsOptions, false, 'Default httpsOptions is false'); }); // httpsOptions will be false if https is false test('react-server-cli:parseCliArgs::httpsOptions will be false if https is false', async t => { const args = [ ...defaultArgs, - 'compile', - '--https', - 'false' - ]; - const parsedArgs = await parseCliArgs(args); - t.is(parsedArgs.httpsOptions, false, 'httpsOptions is false if https is false'); + 'compile', + '--https', + 'false', + ]; + const parsedArgs = await parseCliArgs(args); + t.is(parsedArgs.httpsOptions, false, 'httpsOptions is false if https is false'); }); // httpsOptions will be an object with two keys; key and cert, if option flag https is set test('react-server-cli:parseCliArgs::httpsOptions will be an object with two keys; key and cert', async t => { const args = [ ...defaultArgs, - 'compile', - '--https', - 'true' - ]; - const parsedArgs = await parseCliArgs(args); - t.is(typeof parsedArgs.httpsOptions, 'object', 'httpsOptions is an object'); - t.is(typeof parsedArgs.httpsOptions.key, 'string', 'httpsOptions property key is a string'); - t.is(typeof parsedArgs.httpsOptions.cert, 'string', 'httpsOptions property cert is a string'); - t.is(parsedArgs.httpsOptions.key.slice(0,31), '-----BEGIN RSA PRIVATE KEY-----', 'httpsOptions property key is a RSA private key'); - t.is(parsedArgs.httpsOptions.cert.slice(0,27), '-----BEGIN CERTIFICATE-----', 'httpsOptions property cert is a https certificate'); + 'compile', + '--https', + 'true', + ]; + const parsedArgs = await parseCliArgs(args); + t.is(typeof parsedArgs.httpsOptions, 'object', 'httpsOptions is an object'); + t.is(typeof parsedArgs.httpsOptions.key, 'string', 'httpsOptions property key is a string'); + t.is(typeof parsedArgs.httpsOptions.cert, 'string', 'httpsOptions property cert is a string'); + t.is(parsedArgs.httpsOptions.key.slice(0,31), '-----BEGIN RSA PRIVATE KEY-----', 'httpsOptions property key is a RSA private key'); + t.is(parsedArgs.httpsOptions.cert.slice(0,27), '-----BEGIN CERTIFICATE-----', 'httpsOptions property cert is a https certificate'); }); // httpsOptions will be an object containing key, cert, ca, pfx, and passphrase if --https-key and --https-cert is provided as an argument test('react-server-cli:parseCliArgs::httpsOptions will be an object containing key, cert, ca, pfx, and passphrase if --https-key and --https-cert is provided as an argument', async t => { const args = [ ...defaultArgs, - 'compile', - '--https-key', - '.babelrc', - '--https-cert', - '.babelrc' - ]; - const parsedArgs = await parseCliArgs(args); - t.is(parsedArgs.httpsKey, '.babelrc', 'httpsKey is .babelrc'); - t.is(parsedArgs.httpsCert, '.babelrc', 'httpsCert is .babelrc'); - - t.is(typeof parsedArgs.httpsOptions, 'object', 'httpsOptions is an object'); - t.true(Buffer.isBuffer(parsedArgs.httpsOptions.key), 'httpsOptions property key is a buffer from reading a file'); - t.true(Buffer.isBuffer(parsedArgs.httpsOptions.cert), 'httpsOptions property cert is a buffer from reading a file'); - t.is(typeof parsedArgs.httpsOptions.ca, 'undefined', 'httpsOptions property ca is undefined'); - t.is(typeof parsedArgs.httpsOptions.pfx, 'undefined', 'httpsOptions property pfx is undefined'); - t.is(typeof parsedArgs.httpsOptions.passphrase, 'undefined', 'httpsOptions property passphrase is undefined'); + 'compile', + '--https-key', + '.babelrc', + '--https-cert', + '.babelrc', + ]; + const parsedArgs = await parseCliArgs(args); + t.is(parsedArgs.httpsKey, '.babelrc', 'httpsKey is .babelrc'); + t.is(parsedArgs.httpsCert, '.babelrc', 'httpsCert is .babelrc'); + + t.is(typeof parsedArgs.httpsOptions, 'object', 'httpsOptions is an object'); + t.true(Buffer.isBuffer(parsedArgs.httpsOptions.key), 'httpsOptions property key is a buffer from reading a file'); + t.true(Buffer.isBuffer(parsedArgs.httpsOptions.cert), 'httpsOptions property cert is a buffer from reading a file'); + t.is(typeof parsedArgs.httpsOptions.ca, 'undefined', 'httpsOptions property ca is undefined'); + t.is(typeof parsedArgs.httpsOptions.pfx, 'undefined', 'httpsOptions property pfx is undefined'); + t.is(typeof parsedArgs.httpsOptions.passphrase, 'undefined', 'httpsOptions property passphrase is undefined'); }); @@ -201,36 +201,36 @@ test('react-server-cli:parseCliArgs::httpsOptions will be an object containing k test('react-server-cli:parseCliArgs::hot will be undefined if no argument is provided', async t => { const args = [ ...defaultArgs, - 'compile' - ]; - const parsedArgs = await parseCliArgs(args); - t.is(parsedArgs.hot, undefined, 'hot is undefined if no argument is provided'); + 'compile', + ]; + const parsedArgs = await parseCliArgs(args); + t.is(parsedArgs.hot, undefined, 'hot is undefined if no argument is provided'); }); // hot option can be turned on using --hot argument test('react-server-cli:parseCliArgs::hot option can be turned on using --hot argument', async t => { const args = [ ...defaultArgs, - 'compile', - '--hot' - ]; - const parsedArgs = await parseCliArgs(args); - t.is(typeof parsedArgs.hot, 'boolean', 'hot is true'); - t.is(parsedArgs.hot, true, 'hot is true'); - t.true(Object.keys(defaultOptions).indexOf('hot') > -1, 'hot key exists in defaultOptions'); + 'compile', + '--hot', + ]; + const parsedArgs = await parseCliArgs(args); + t.is(typeof parsedArgs.hot, 'boolean', 'hot is true'); + t.is(parsedArgs.hot, true, 'hot is true'); + t.true(Object.keys(defaultOptions).indexOf('hot') > -1, 'hot key exists in defaultOptions'); }); // hot option can be turned on using -h argument test('react-server-cli:parseCliArgs::hot option can be turned on using -h argument', async t => { const args = [ ...defaultArgs, - 'compile', - '-h' - ]; - const parsedArgs = await parseCliArgs(args); - t.is(typeof parsedArgs.hot, 'boolean', 'hot is true'); - t.is(parsedArgs.hot, true, 'hot is true'); - t.true(Object.keys(defaultOptions).indexOf('hot') > -1, 'hot key exists in defaultOptions'); + 'compile', + '-h', + ]; + const parsedArgs = await parseCliArgs(args); + t.is(typeof parsedArgs.hot, 'boolean', 'hot is true'); + t.is(parsedArgs.hot, true, 'hot is true'); + t.true(Object.keys(defaultOptions).indexOf('hot') > -1, 'hot key exists in defaultOptions'); }); @@ -239,36 +239,36 @@ test('react-server-cli:parseCliArgs::hot option can be turned on using -h argume test('react-server-cli:parseCliArgs::minify will be undefined if no argument is provided', async t => { const args = [ ...defaultArgs, - 'compile' - ]; - const parsedArgs = await parseCliArgs(args); - t.is(parsedArgs.minify, undefined, 'minify is undefined if no argument is provided'); + 'compile', + ]; + const parsedArgs = await parseCliArgs(args); + t.is(parsedArgs.minify, undefined, 'minify is undefined if no argument is provided'); }); // minify option can be turned on using --minify argument test('react-server-cli:parseCliArgs::minify option can be turned on using --minify argument', async t => { const args = [ ...defaultArgs, - 'compile', - '--minify' - ]; - const parsedArgs = await parseCliArgs(args); - t.is(typeof parsedArgs.minify, 'boolean', 'minify is true'); - t.is(parsedArgs.minify, true, 'minify is true'); - t.true(Object.keys(defaultOptions).indexOf('minify') > -1, 'minify key exists in defaultOptions'); + 'compile', + '--minify', + ]; + const parsedArgs = await parseCliArgs(args); + t.is(typeof parsedArgs.minify, 'boolean', 'minify is true'); + t.is(parsedArgs.minify, true, 'minify is true'); + t.true(Object.keys(defaultOptions).indexOf('minify') > -1, 'minify key exists in defaultOptions'); }); // minify option can be turned on using -m argument test('react-server-cli:parseCliArgs::minify option can be turned on using -m argument', async t => { const args = [ ...defaultArgs, - 'compile', - '-m' - ]; - const parsedArgs = await parseCliArgs(args); - t.is(typeof parsedArgs.minify, 'boolean', 'minify is true'); - t.is(parsedArgs.minify, true, 'minify is true'); - t.true(Object.keys(defaultOptions).indexOf('minify') > -1, 'minify key exists in defaultOptions'); + 'compile', + '-m', + ]; + const parsedArgs = await parseCliArgs(args); + t.is(typeof parsedArgs.minify, 'boolean', 'minify is true'); + t.is(parsedArgs.minify, true, 'minify is true'); + t.true(Object.keys(defaultOptions).indexOf('minify') > -1, 'minify key exists in defaultOptions'); }); @@ -277,36 +277,36 @@ test('react-server-cli:parseCliArgs::minify option can be turned on using -m arg test('react-server-cli:parseCliArgs::longTermCaching will be undefined if no argument is provided', async t => { const args = [ ...defaultArgs, - 'compile' - ]; - const parsedArgs = await parseCliArgs(args); - t.is(parsedArgs.longTermCaching, undefined, 'longTermCaching is undefined if no argument is provided'); + 'compile', + ]; + const parsedArgs = await parseCliArgs(args); + t.is(parsedArgs.longTermCaching, undefined, 'longTermCaching is undefined if no argument is provided'); }); // longTermCaching option can be turned on using --longTermCaching argument test('react-server-cli:parseCliArgs::longTermCaching option can be turned on using --longTermCaching argument', async t => { const args = [ ...defaultArgs, - 'compile', - '--longTermCaching' - ]; - const parsedArgs = await parseCliArgs(args); - t.is(typeof parsedArgs.longTermCaching, 'boolean', 'longTermCaching is true'); - t.is(parsedArgs.longTermCaching, true, 'longTermCaching is true'); - t.true(Object.keys(defaultOptions).indexOf('longTermCaching') > -1, 'longTermCaching key exists in defaultOptions'); + 'compile', + '--longTermCaching', + ]; + const parsedArgs = await parseCliArgs(args); + t.is(typeof parsedArgs.longTermCaching, 'boolean', 'longTermCaching is true'); + t.is(parsedArgs.longTermCaching, true, 'longTermCaching is true'); + t.true(Object.keys(defaultOptions).indexOf('longTermCaching') > -1, 'longTermCaching key exists in defaultOptions'); }); // longTermCaching option can be turned on using --long-term-caching argument test('react-server-cli:parseCliArgs::longTermCaching option can be turned on using --long-term-caching argument', async t => { const args = [ ...defaultArgs, - 'compile', - '--long-term-caching' - ]; - const parsedArgs = await parseCliArgs(args); - t.is(typeof parsedArgs.longTermCaching, 'boolean', 'longTermCaching is true'); - t.is(parsedArgs.longTermCaching, true, 'longTermCaching is true'); - t.true(Object.keys(defaultOptions).indexOf('longTermCaching') > -1, 'longTermCaching key exists in defaultOptions'); + 'compile', + '--long-term-caching', + ]; + const parsedArgs = await parseCliArgs(args); + t.is(typeof parsedArgs.longTermCaching, 'boolean', 'longTermCaching is true'); + t.is(parsedArgs.longTermCaching, true, 'longTermCaching is true'); + t.true(Object.keys(defaultOptions).indexOf('longTermCaching') > -1, 'longTermCaching key exists in defaultOptions'); }); // **** compileOnStartup **** @@ -314,7 +314,7 @@ test('react-server-cli:parseCliArgs::longTermCaching option can be turned on usi test('react-server-cli:parseCliArgs::compileOnStartup will be undefined if no argument is provided', async t => { const args = [ ...defaultArgs, - 'compile' + 'compile', ]; const parsedArgs = await parseCliArgs(args); t.is(parsedArgs.compileOnStartup, undefined, 'compileOnStartup is undefined if no argument is provided'); @@ -325,7 +325,7 @@ test('react-server-cli:parseCliArgs::compileOnStartup option can be turned on us const args = [ ...defaultArgs, 'compile', - '--compileOnStartup' + '--compileOnStartup', ]; const parsedArgs = await parseCliArgs(args); t.is(typeof parsedArgs.compileOnStartup, 'boolean', 'compileOnStartup is true'); @@ -338,7 +338,7 @@ test('react-server-cli:parseCliArgs::compileOnStartup option can be turned on us const args = [ ...defaultArgs, 'compile', - '--compile-on-startup' + '--compile-on-startup', ]; const parsedArgs = await parseCliArgs(args); t.is(typeof parsedArgs.compileOnStartup, 'boolean', 'compileOnStartup is true'); diff --git a/packages/react-server-data-bundle-cache/gulpfile.js b/packages/react-server-data-bundle-cache/gulpfile.js index 4820858c8..1169e8e0d 100644 --- a/packages/react-server-data-bundle-cache/gulpfile.js +++ b/packages/react-server-data-bundle-cache/gulpfile.js @@ -1,7 +1,5 @@ -const path = require('path'); const gulp = require('gulp'); const babel = require('gulp-babel'); -const eslint = require('gulp-eslint'); const rename = require('gulp-rename'); const tagger = require('react-server-gulp-module-tagger'); @@ -19,11 +17,3 @@ gulp.task('build-lib', () => gulp.src(SRC) .pipe(babel()) .pipe(gulp.dest("./lib")) ); - -gulp.task('eslint', [], () => gulp.src(SRC) - .pipe(eslint()) - .pipe(eslint.format()) - .pipe(eslint.failAfterError()) -); - -gulp.task('test', ['eslint']); diff --git a/packages/react-server-data-bundle-cache/package.json b/packages/react-server-data-bundle-cache/package.json index dbd4d971a..02c6b234d 100644 --- a/packages/react-server-data-bundle-cache/package.json +++ b/packages/react-server-data-bundle-cache/package.json @@ -9,7 +9,7 @@ "scripts": { "build": "gulp build", "clean": "rimraf lib npm-debug.log* index.js", - "lint": "gulp eslint", + "lint": "eslint src", "prepublish": "npm run build" }, "dependencies": { diff --git a/packages/react-server-examples/.eslintignore b/packages/react-server-examples/.eslintignore new file mode 100644 index 000000000..ee197f470 --- /dev/null +++ b/packages/react-server-examples/.eslintignore @@ -0,0 +1 @@ +**/__clientTemp/** diff --git a/packages/react-server-examples/bike-share/components/error.js b/packages/react-server-examples/bike-share/components/error.js index 638dc63da..ee50dd770 100644 --- a/packages/react-server-examples/bike-share/components/error.js +++ b/packages/react-server-examples/bike-share/components/error.js @@ -1,5 +1,7 @@ import React from 'react'; -export default () => { +const Error = () => { return (
404 - The page you were looking for was not found.
); }; + +export default Error; diff --git a/packages/react-server-examples/bike-share/components/footer.js b/packages/react-server-examples/bike-share/components/footer.js index 053f9ccac..2f927a9bf 100644 --- a/packages/react-server-examples/bike-share/components/footer.js +++ b/packages/react-server-examples/bike-share/components/footer.js @@ -3,7 +3,7 @@ import {logging} from 'react-server'; const logger = logging.getLogger(__LOGGER__); -export default () => { +const Footer = () => { logger.info('rendering the footer'); return (
Brought to you by @@ -12,3 +12,5 @@ export default () => { citybik.es
); }; + +export default Footer; diff --git a/packages/react-server-examples/bike-share/components/header.js b/packages/react-server-examples/bike-share/components/header.js index 35e12baf4..7a6d0b7eb 100644 --- a/packages/react-server-examples/bike-share/components/header.js +++ b/packages/react-server-examples/bike-share/components/header.js @@ -3,7 +3,9 @@ import {logging} from 'react-server'; const logger = logging.getLogger(__LOGGER__); -export default () => { +const Header = () => { logger.info('rendering the header'); return (

React Server city bikes page

); }; + +export default Header; diff --git a/packages/react-server-examples/code-splitting/components/Header.js b/packages/react-server-examples/code-splitting/components/Header.js index 57da5e714..53485e520 100644 --- a/packages/react-server-examples/code-splitting/components/Header.js +++ b/packages/react-server-examples/code-splitting/components/Header.js @@ -1,9 +1,10 @@ import React from 'react'; import {logging} from 'react-server'; +import PropTypes from "prop-types"; const logger = logging.getLogger(__LOGGER__); -export default ({ headerText }) => { +const Header = ({ headerText }) => { logger.info("rendering the header"); return ( @@ -11,4 +12,9 @@ export default ({ headerText }) => { React-Server { headerText } ); -} +}; +Header.propTypes = { + headerText: PropTypes.string, +}; + +export default Header diff --git a/packages/react-server-examples/gulpfile.babel.js b/packages/react-server-examples/gulpfile.babel.js deleted file mode 100644 index 8a89755e9..000000000 --- a/packages/react-server-examples/gulpfile.babel.js +++ /dev/null @@ -1,21 +0,0 @@ -import eslint from "gulp-eslint"; -import gulp from "gulp"; - -gulp.task("eslint", [], () => { - return gulp.src(["./**/*.js", '!./**/node_modules/**', '!./**/__clientTemp/**']) - // eslint() attaches the lint output to the eslint property - // of the file object so it can be used by other modules. - .pipe(eslint({ - configFile: "../../.eslintrc", - useEslintrc: false, - })) - // eslint.format() outputs the lint results to the console. - // Alternatively use eslint.formatEach() (see Docs). - .pipe(eslint.format()) - // To have the process exit with an error code (1) on - // lint error, return the stream and pipe to failOnError last. - .pipe(eslint.failAfterError()); -}); - -// there are no tests for this project :( -gulp.task("test", ["eslint"]); diff --git a/packages/react-server-examples/meteor-site/components/Table.js b/packages/react-server-examples/meteor-site/components/Table.js index 930cc2992..2f880f336 100644 --- a/packages/react-server-examples/meteor-site/components/Table.js +++ b/packages/react-server-examples/meteor-site/components/Table.js @@ -18,6 +18,9 @@ const Header = ({ onHeaderClick }) => ( ); +Header.propTypes = { + onHeaderClick: PropTypes.func.isRequired, +}; const Row = ({ id, name, mass, year, selected, onRowClick }) => { const selectedClass = selected ? "info pointer" : "pointer"; @@ -27,6 +30,14 @@ const Row = ({ id, name, mass, year, selected, onRowClick }) => { ); }; +Row.propTypes = { + id: PropTypes.string.isRequired, + name: PropTypes.string.isRequired, + mass: PropTypes.string.isRequired, + year: PropTypes.string.isRequired, + selected: PropTypes.bool, + onRowClick: PropTypes.func.isRequired, +}; const Table = ({ header, meteors, onRowClick, onHeaderClick }) => ( @@ -44,6 +55,7 @@ const Table = ({ header, meteors, onRowClick, onHeaderClick }) => ( ); Table.propTypes = { + header: PropTypes.string.isRequired, meteors: PropTypes.arrayOf(PropTypes.shape({ id: PropTypes.string.isRequired, name: PropTypes.string.isRequired, @@ -53,6 +65,6 @@ Table.propTypes = { }).isRequired).isRequired, onHeaderClick: PropTypes.func.isRequired, onRowClick: PropTypes.func.isRequired, -} +}; export default Table; diff --git a/packages/react-server-examples/meteor-site/stores/reducers.js b/packages/react-server-examples/meteor-site/stores/reducers.js index 9c3429270..bdb7e7e19 100644 --- a/packages/react-server-examples/meteor-site/stores/reducers.js +++ b/packages/react-server-examples/meteor-site/stores/reducers.js @@ -54,7 +54,7 @@ const meteors = (state = { meteors: state.meteors.map(t => meteor(t, action)), }); } - case SORT_METEORS: + case SORT_METEORS: // eslint-disable-line no-fallthrough if (state.meteors) { switch (action.id) { case "mass": @@ -72,7 +72,7 @@ const meteors = (state = { }); } } - default: + default: // eslint-disable-line no-fallthrough return state; } } diff --git a/packages/react-server-examples/package.json b/packages/react-server-examples/package.json index eb95df1d0..4fe891d79 100644 --- a/packages/react-server-examples/package.json +++ b/packages/react-server-examples/package.json @@ -2,7 +2,7 @@ "name": "react-server-examples", "private": true, "scripts": { - "lint": "gulp eslint", + "lint": "eslint .", "clean": "rimraf npm-debug.log*" } } diff --git a/packages/react-server-examples/redux-basic/components/Counter.js b/packages/react-server-examples/redux-basic/components/Counter.js index 919957449..1496d2276 100644 --- a/packages/react-server-examples/redux-basic/components/Counter.js +++ b/packages/react-server-examples/redux-basic/components/Counter.js @@ -20,27 +20,27 @@ class Counter extends Component { } render() { - const { value, onIncrement, onDecrement } = this.props + const {value, onIncrement, onDecrement} = this.props return ( -

- Clicked: {value} times - {' '} - - {' '} - - {' '} - - {' '} - -

+

+ Clicked: {value} times + {' '} + + {' '} + + {' '} + + {' '} + +

) } } diff --git a/packages/react-server-examples/redux-basic/pages/store.js b/packages/react-server-examples/redux-basic/pages/store.js index 293c87899..9c9f4e620 100644 --- a/packages/react-server-examples/redux-basic/pages/store.js +++ b/packages/react-server-examples/redux-basic/pages/store.js @@ -2,6 +2,6 @@ import { createStore } from 'redux' import reducer from './counter-app/reducer' export default createStore( - reducer, - typeof window !== 'undefined' && window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__() + reducer, + typeof window !== 'undefined' && window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__() ) diff --git a/packages/react-server-examples/styled-components/test.js b/packages/react-server-examples/styled-components/test.js index 90f57019b..3b88d1f27 100644 --- a/packages/react-server-examples/styled-components/test.js +++ b/packages/react-server-examples/styled-components/test.js @@ -6,7 +6,7 @@ let rs; test.before('start the server', async () => { rs = cp.spawn('npm', ['start']); - rs.stderr.on('data', data => console.error(`ERR: ${data}`)); + rs.stderr.on('data', data => console.error(`ERR: ${data}`)); // eslint-disable-line no-console await sleep(10000); }); diff --git a/packages/react-server-gulp-module-tagger/test/test.js b/packages/react-server-gulp-module-tagger/test/test.js index d1e34434e..3d2cfd552 100644 --- a/packages/react-server-gulp-module-tagger/test/test.js +++ b/packages/react-server-gulp-module-tagger/test/test.js @@ -5,58 +5,58 @@ import path from 'path'; import del from 'del'; getTestCases().forEach((dir) => { - test(`testing fixture in ${dir}`, async t => { - await runGulp(dir); - const expected = await readFile(path.join('test', 'fixtures', dir, 'expected.js')); - const actual = await readFile(path.join('test', 'fixtures', dir, 'build', 'actual.js')); - t.is(actual.toString(), expected.toString()); - }); + test(`testing fixture in ${dir}`, async t => { + await runGulp(dir); + const expected = await readFile(path.join('test', 'fixtures', dir, 'expected.js')); + const actual = await readFile(path.join('test', 'fixtures', dir, 'build', 'actual.js')); + t.is(actual.toString(), expected.toString()); + }); }); test('module can be required', t => { - try { - require('..'); - t.pass(); - } catch (e) { - t.fail(); - } + try { + require('..'); + t.pass(); + } catch (e) { + t.fail(); + } }); test.after.always('cleanup', async t => { - const promises = []; - const fixtures = getTestCases(); - fixtures.forEach(fixture => { - promises.push(del(path.join('test', 'fixtures', fixture, 'build'))); - }) - await Promise.all(promises); + const promises = []; + const fixtures = getTestCases(); + fixtures.forEach(fixture => { + promises.push(del(path.join('test', 'fixtures', fixture, 'build'))); + }) + await Promise.all(promises); }); function getTestCases() { - return fs.readdirSync(path.join('test', 'fixtures')); + return fs.readdirSync(path.join('test', 'fixtures')); } function readFile(filename) { - return new Promise((resolve, reject) => { - fs.readFile(filename, (err, data) => { - if (err) { - reject(err); - } else { - resolve(data); - } - }); - }); + return new Promise((resolve, reject) => { + fs.readFile(filename, (err, data) => { + if (err) { + reject(err); + } else { + resolve(data); + } + }); + }); } function runGulp(dir) { - return new Promise((resolve, reject) => { - dir = path.join(__dirname, 'fixtures', dir); - cp.exec('gulp', { cwd: dir }, (err, stdout, stderr) => { - if (err) { - console.error(stderr); - reject(err); - } else { - resolve(stdout); - } - }); - }); + return new Promise((resolve, reject) => { + dir = path.join(__dirname, 'fixtures', dir); + cp.exec('gulp', { cwd: dir }, (err, stdout, stderr) => { + if (err) { + console.error(stderr); + reject(err); + } else { + resolve(stdout); + } + }); + }); } diff --git a/packages/react-server-integration-tests/src/__tests__/asyncRender/AsyncElementPage.js b/packages/react-server-integration-tests/src/__tests__/asyncRender/AsyncElementPage.js index 29b300a74..d743082b0 100644 --- a/packages/react-server-integration-tests/src/__tests__/asyncRender/AsyncElementPage.js +++ b/packages/react-server-integration-tests/src/__tests__/asyncRender/AsyncElementPage.js @@ -17,4 +17,4 @@ class AsyncElementPage { } } -module.exports = AsyncElementPage; \ No newline at end of file +module.exports = AsyncElementPage; diff --git a/packages/react-server-middleware-json-response/package.json b/packages/react-server-middleware-json-response/package.json index 8e7415937..833a6bbb4 100644 --- a/packages/react-server-middleware-json-response/package.json +++ b/packages/react-server-middleware-json-response/package.json @@ -7,7 +7,7 @@ "prepublish": "npm run build", "build": "babel --root-mode upward index.src.js --out-file index.js", "clean": "rimraf index.js", - "lint": "eslint src" + "lint": "eslint index.src.js" }, "repository": { "type": "git", diff --git a/packages/react-server-module-tagger/package.json b/packages/react-server-module-tagger/package.json index b60316d89..8c608fe0e 100644 --- a/packages/react-server-module-tagger/package.json +++ b/packages/react-server-module-tagger/package.json @@ -4,7 +4,7 @@ "description": "calculates module level config", "main": "index.js", "scripts": { - "lint": "eslint *.js", + "lint": "eslint .", "test": "ava test.js", "clean": "rimraf npm-debug.log*" }, diff --git a/packages/react-server-redux/package.json b/packages/react-server-redux/package.json index efb37c45c..ac329e6bc 100644 --- a/packages/react-server-redux/package.json +++ b/packages/react-server-redux/package.json @@ -6,6 +6,7 @@ "scripts": { "build": "gulp build", "clean": "rimraf target npm-debug.log*", + "lint": "eslint src test", "test": "ava test/*.spec.js", "prepublish": "npm run build" }, diff --git a/packages/react-server-redux/src/RootProvider.js b/packages/react-server-redux/src/RootProvider.js index 310862f05..5f44bd5cd 100644 --- a/packages/react-server-redux/src/RootProvider.js +++ b/packages/react-server-redux/src/RootProvider.js @@ -37,4 +37,5 @@ module.exports = RootProvider; RootProvider.propTypes = { store: PropTypes.object.isRequired, -} + children: PropTypes.node.isRequired, +}; diff --git a/packages/react-server-test-pages/gulpfile.babel.js b/packages/react-server-test-pages/gulpfile.babel.js deleted file mode 100644 index 9e50df5ec..000000000 --- a/packages/react-server-test-pages/gulpfile.babel.js +++ /dev/null @@ -1,18 +0,0 @@ -const eslint = require("gulp-eslint"); -const gulp = require("gulp"); - -const SRC = ["**/*.js", "!node_modules/**", "!__clientTemp/**"]; - -gulp.task("travis-ci", ["build"]); - -gulp.task("build", ["eslint"]); - -gulp.task("eslint", [], () => gulp.src(SRC) - .pipe(eslint()) - .pipe(eslint.format()) - .pipe(eslint.failAfterError()) -); - -// There are no tests for this project, currently. -// Just make sure it lints and passes nsp. -gulp.task("test", ["eslint"]); diff --git a/packages/react-server-test-pages/package.json b/packages/react-server-test-pages/package.json index a20896c18..da422afab 100644 --- a/packages/react-server-test-pages/package.json +++ b/packages/react-server-test-pages/package.json @@ -5,11 +5,8 @@ "description": "Some pages to test out features of react-server", "main": "index.js", "scripts": { - "prepublish": "npm run build", - "build": "gulp build", "start": "react-server start", - "lint": "gulp eslint", - "test": "gulp test", + "lint": "eslint .", "clean": "rimraf npm-debug.log* __clientTemp target" }, "author": "Bo Borgerson", diff --git a/packages/react-server-test-pages/pages/error/logs.js b/packages/react-server-test-pages/pages/error/logs.js index 3ab90a527..d5963d5c1 100644 --- a/packages/react-server-test-pages/pages/error/logs.js +++ b/packages/react-server-test-pages/pages/error/logs.js @@ -2,13 +2,13 @@ import Q from 'q'; import { Component } from 'react'; import { RootElement } from 'react-server'; -class RenderError extends Component { +class RenderError extends Component { // eslint-disable-line react/require-render-return render() { throw new Error('Error in render'); } } -const ReceiveProps = OriginalComponent => class extends Component { +const ReceiveProps = OriginalComponent => class extends Component { // eslint-disable-line react/display-name constructor(props) { super(props); this.state = { @@ -33,7 +33,7 @@ const ReceiveProps = OriginalComponent => class extends Component { }; const ComponentWillReceivePropsError = ReceiveProps( - class extends Component { + class extends Component { // eslint-disable-line react/display-name componentWillReceiveProps() { throw Error('Error in componentWillReceiveProps'); } @@ -44,7 +44,7 @@ const ComponentWillReceivePropsError = ReceiveProps( ); const ComponentDidReceivePropsError = ReceiveProps( - class extends Component { + class extends Component { // eslint-disable-line react/display-name componentDidReceiveProps() { throw Error('Error in componentDidReceiveProps'); } @@ -55,7 +55,7 @@ const ComponentDidReceivePropsError = ReceiveProps( ); const ComponentWillUpdateError = ReceiveProps( - class extends Component { + class extends Component { // eslint-disable-line react/display-name componentWillUpdate() { throw Error('Error in componentWillUpdate'); } @@ -66,7 +66,7 @@ const ComponentWillUpdateError = ReceiveProps( ); const ComponentDidUpdateError = ReceiveProps( - class extends Component { + class extends Component { // eslint-disable-line react/display-name componentDidUpdate() { throw Error('Error in componentDidUpdate'); } diff --git a/packages/react-server-test-pages/pages/navigation/common.js b/packages/react-server-test-pages/pages/navigation/common.js index db089c1d5..b58877442 100644 --- a/packages/react-server-test-pages/pages/navigation/common.js +++ b/packages/react-server-test-pages/pages/navigation/common.js @@ -1,5 +1,6 @@ import _ from "lodash"; import {Component} from "react"; +import PropTypes from "prop-types"; import {ReactServerAgent} from "react-server"; // Each row listens to `navigateStart'. @@ -52,6 +53,17 @@ export const PagePointer = ({page, row}) =>
{+page === +row ? "➟" : ""}
; +PagePointer.propTypes = { + page: PropTypes.number, + row: PropTypes.number, +}; + export const RowIndex = ({row}) =>
Row {row}
; +RowIndex.propTypes = { + row: PropTypes.number, +}; export const RowMS = ({ms}) =>
{ms}ms
; +RowMS.propTypes = { + ms: PropTypes.number, +}; diff --git a/packages/react-server-test-pages/pages/navigation/data-bundle-cache.js b/packages/react-server-test-pages/pages/navigation/data-bundle-cache.js index 18542d10f..29137ee4f 100644 --- a/packages/react-server-test-pages/pages/navigation/data-bundle-cache.js +++ b/packages/react-server-test-pages/pages/navigation/data-bundle-cache.js @@ -1,3 +1,4 @@ +import PropTypes from "prop-types"; import React from "react"; import DataBundleCache from "react-server-data-bundle-cache"; import { @@ -22,6 +23,9 @@ const BASE = "/navigation/data-bundle-cache"; const LINK = page => `${BASE}?page=${page}` const BundleLink = ({row}) => Go +BundleLink.propTypes = { + row: PropTypes.number, +}; class PreloadLink extends React.Component { constructor(props) { @@ -43,6 +47,9 @@ class PreloadLink extends React.Component { } } +PreloadLink.propTypes = { + row: PropTypes.number, +}; let _cacheEnabled = false; diff --git a/packages/react-server-test-pages/pages/navigation/forwardEven.js b/packages/react-server-test-pages/pages/navigation/forwardEven.js index c98f6ace7..0bdda80fc 100644 --- a/packages/react-server-test-pages/pages/navigation/forwardEven.js +++ b/packages/react-server-test-pages/pages/navigation/forwardEven.js @@ -1,6 +1,10 @@ +import PropTypes from "prop-types"; import {ReactServerAgent, RootElement} from "react-server"; const Even = ({body}) =>
Hey look I'm even because I am {body}
; +Even.propTypes = { + body: PropTypes.any, +}; export default class ForwardEvenPage { handleRoute() { diff --git a/packages/react-server-test-pages/pages/navigation/forwardOdd.js b/packages/react-server-test-pages/pages/navigation/forwardOdd.js index aad497e19..909998d68 100644 --- a/packages/react-server-test-pages/pages/navigation/forwardOdd.js +++ b/packages/react-server-test-pages/pages/navigation/forwardOdd.js @@ -1,6 +1,10 @@ import {ReactServerAgent, RootElement} from "react-server"; +import PropTypes from "prop-types"; const Odd = ({body}) =>
Hey look I'm odd because I am {body}
; +Odd.propTypes = { + body: PropTypes.any, +}; export default class ForwardOddPage { handleRoute() { diff --git a/packages/react-server-test-pages/pages/navigation/navigateTo.js b/packages/react-server-test-pages/pages/navigation/navigateTo.js index 9eb6e7991..66c1dfe0c 100644 --- a/packages/react-server-test-pages/pages/navigation/navigateTo.js +++ b/packages/react-server-test-pages/pages/navigation/navigateTo.js @@ -1,4 +1,5 @@ import {navigateTo} from "react-server"; +import PropTypes from "prop-types"; const go = page => navigateTo( `/navigation/navigateTo?cur=${page}`, @@ -10,6 +11,10 @@ const Nav = ({cur}) =>
go(cur+1)}>
Click for next page
+Nav.propTypes = { + cur: PropTypes.number, +}; + export default class NavigateToPage { getElements() { return