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

ESLint reccomended no-async-promise-executor broken in example #178

Open
srcrip opened this issue Feb 8, 2020 · 1 comment
Open

ESLint reccomended no-async-promise-executor broken in example #178

srcrip opened this issue Feb 8, 2020 · 1 comment

Comments

@srcrip
Copy link

srcrip commented Feb 8, 2020

The rule no-async-promise-executor seems to be set in the recommended group in new versions of ESLint. This trips the following code in the example:

entry-server.js

  return new Promise(async (resolve, reject) => {
    const { app, router, apolloProvider } = await createApp({
      ssr: true
    });

I just disabled the rule in my project but I don't fully understand the implications of doing so, so if someone knows a way to fix this in the example I think that'd be great given that this is now a recommended rule.

@Radiergummi
Copy link

Well, the following variant would work correctly without breaking this rule, and its much clearer anyway:

export default async context => {
    const {
              app,
              router,
              store,
          } = await createApp();

    router.push( prepareUrlForRouting( context.url ) );

    return new Promise( ( resolve, reject ) => {
        router.onReady( () => {
            context.rendered = () => {
                // After all preFetch hooks are resolved, our store is now
                // filled with the state needed to render the app.
                // When we attach the state to the context, and the `template` option
                // is used for the renderer, the state will automatically be
                // serialized and injected into the HTML as `window.__INITIAL_STATE__`.
                context.state = store.state;

            };

            resolve( app );
        }, reject );
    } );
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants