Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

package.json updates #1159

Merged
merged 12 commits into from
Oct 24, 2018
3 changes: 3 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ env:

rules:
no-console: 0
function-paren-newline: 0
object-curly-newline: 0

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After updating eslint these two rules produced over 120 errors. I disabled them in the .eslintrc file


# https://github.com/benmosher/eslint-plugin-import/issues/340
import/no-extraneous-dependencies: 0
Expand Down
1 change: 1 addition & 0 deletions node_package/src/buildConsoleReplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import scriptSanitizedVal from './scriptSanitizedVal';

export function consoleReplay() {
// console.history is a global polyfill used in server rendering.
// $FlowFixMe
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per this flow article, flow is now throwing errors for unknown property access in conditionals. I flagged this with $FlowFixMe for the time being to suppress the error. @justin808 what are your thoughts on fixing this?

if (!(console.history instanceof Array)) {
return '';
}
Expand Down
2 changes: 1 addition & 1 deletion node_package/src/clientStartup.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ function renderInit() {
}

export function clientStartup(context) {
const document = context.document;
const { document } = context;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reformatted to satiate eslint


// Check if server rendering
if (!document) {
Expand Down
2 changes: 1 addition & 1 deletion node_package/src/serverRenderReactComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ See https://github.com/shakacode/react_on_rails#renderer-functions`);

if (reactElementOrRouterResult.redirectLocation) {
if (trace) {
const redirectLocation = reactElementOrRouterResult.redirectLocation;
const { redirectLocation } = reactElementOrRouterResult;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More destructuring to make eslint happy

const redirectPath = redirectLocation.pathname + redirectLocation.search;
console.log(`\
ROUTER REDIRECT: ${name} to dom node with id: ${domNodeId}, redirect to ${redirectPath}`,
Expand Down
2 changes: 1 addition & 1 deletion node_package/tests/ReactOnRails.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ test('ReactOnRails render returns a virtual DOM element for component', (assert)
ReactOnRails.register({ R1 });

// eslint-disable-next-line no-underscore-dangle
const actual = ReactOnRails.render('R1', {}, 'root')._reactInternalInstance._currentElement.type;
const actual = ReactOnRails.render('R1', {}, 'root')._reactInternalFiber.type;
Copy link
Contributor Author

@coopersamuel coopersamuel Oct 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When updating to React v16 there was a breaking change that caused the below test to fail

test('ReactOnRails render returns a virtual DOM element for component', (assert) => {
  assert.plan(1);
  const R1 = createReactClass({
    render() {
      return (
        <div> WORLD </div>
      );
    },
  });
  ReactOnRails.register({ R1 });
  // eslint-disable-next-line no-underscore-dangle
  const actual = ReactOnRails.render('R1', {}, 'root')._reactInternalInstance._currentElement.type;
  assert.deepEqual(actual, R1,
    'ReactOnRails render should return a virtual DOM element for component');
});

The error occurred because _reactInternalInstance was deprecated in React 16. The object returned from ReactDOM.render() for v15.6 looked like this (simplified):

{
    _reactInternalInstance: {
        _currentElement: {
            type: // Stuff here
        }
    }
}

After upgrading to React v16, the object looked like this (again, simplified):

{
    _reactInternalFiber: {
        type: // Stuff here
    },
    _reactInternalInstance: {
        // EMPTY!
    }
}

A one line update to the test above resulted in all tests passing
const actual = ReactOnRails.render('R1', {}, 'root')._reactInternalFiber.type;

assert.deepEqual(actual, R1,
'ReactOnRails render should return a virtual DOM element for component');
});
Expand Down
7 changes: 5 additions & 2 deletions node_package/tests/buildConsoleReplay.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,11 @@ console.warn.apply(console, ["other message","{\\"c\\":3,\\"d\\":4}"]);`;
test('consoleReplay replays converts script tag inside of object string to be safe ', (assert) => {
assert.plan(1);
console.history = [
{ arguments: ['some message </script><script>alert(\'WTF\')</script>',
{ a: 'Wow</script><script>alert(\'WTF\')</script>', b: 2 }],
{
arguments: [
'some message </script><script>alert(\'WTF\')</script>',
{ a: 'Wow</script><script>alert(\'WTF\')</script>', b: 2 },
],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reformatted for eslint

level: 'log',
},
{ arguments: ['other message', { c: 3, d: 4 }], level: 'warn' },
Expand Down
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@
"@babel/types": "^7.0.0",
"babel-loader": "^8.0.2",
"babel-tape-runner": "^3.0.0",
"babelify": "^7.3.0",
"babelify": "^10.0.0",
"blue-tape": "^1.0.0",
"create-react-class": "^15.6.0",
"eslint": "^3.19.0",
"eslint-config-shakacode": "^15.0.0",
"eslint": "^5.7.0",
"eslint-config-shakacode": "^16.0.1",
"eslint-plugin-import": "^2.6.1",
"eslint-plugin-jsx-a11y": "^5.1.1",
"eslint-plugin-jsx-a11y": "^6.1.2",
"eslint-plugin-react": "^7.1.0",
"flow-bin": "^0.51.1",
"flow-bin": "^0.83.0",
"jsdom": "^11.1.0",
"prop-types": "^15.5.10",
"react": "^15.6.1",
"react-dom": "^15.6.1",
"react": "^16.5.2",
"react-dom": "^16.5.2",
"react-transform-hmr": "^1.0.4",
"redux": "^3.7.2",
"release-it": "^2.8.2",
"tap-spec": "^4.1.1",
"redux": "^4.0.1",
"release-it": "^7.6.2",
"tap-spec": "^5.0.0",
"tape": "^4.7.0",
"webpack": "^3.4.1",
"webpack-manifest-plugin": "^1.2.1"
Expand Down
10 changes: 5 additions & 5 deletions spec/dummy/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ GIT
PATH
remote: ../..
specs:
react_on_rails (11.1.1)
react_on_rails (11.1.8)
addressable
connection_pool
execjs (~> 2.5)
Expand Down Expand Up @@ -130,7 +130,7 @@ GEM
json (2.1.0)
launchy (2.4.3)
addressable (~> 2.3)
libv8 (6.3.292.48.1)
libv8 (6.7.288.46.1)
listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
Expand All @@ -146,8 +146,8 @@ GEM
mimemagic (0.3.2)
mini_mime (1.0.0)
mini_portile2 (2.3.0)
mini_racer (0.1.15)
libv8 (~> 6.3)
mini_racer (0.2.3)
libv8 (>= 6.3)
minitest (5.11.3)
msgpack (1.2.4)
multi_json (1.13.1)
Expand Down Expand Up @@ -352,4 +352,4 @@ DEPENDENCIES
webpacker

BUNDLED WITH
1.16.3
1.16.4
Loading