-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
chore(requires-writer): update auto-generated code to not trigger no-mixed-operators eslint warnings/errors #26356
chore(requires-writer): update auto-generated code to not trigger no-mixed-operators eslint warnings/errors #26356
Conversation
…mixed-operators eslint warnings/errors
Gatsby Cloud Build Report🚩 Your build failed. See the build logs here Errors Error in "/usr/src/app/www/www/node_modules/gatsby-plugin-page-creator/gatsby-node.js": Cannot find module 'gatsby-cli/lib/reporter' Require stack: - /usr/src/app/www/www/node_modules/gatsby-plugin-page-creator/is-valid-collection-path-implementation.js - /usr/src/app/www/www/node_modules/gatsby-plugin-page-creator/create-pages-from-collection-builder.js - /usr/src/app/www/www/node_modules/gatsby-plugin-page-creator/create-page-wrapper.js - /usr/src/app/www/www/node_modules/gatsby-plugin-page-creator/gatsby-node.js - /usr/src/app/www/www/node_modules/gatsby/dist/bootstrap/resolve-module-exports.js - /usr/src/app/www/www/node_modules/gatsby/dist/bootstrap/load-plugins/validate.js - /usr/src/app/www/www/node_modules/gatsby/dist/bootstrap/load-plugins/load.js - /usr/src/app/www/www/node_modules/gatsby/dist/bootstrap/load-plugins/index.js - /usr/src/app/www/www/node_modules/gatsby/dist/services/initialize.js - /usr/src/app/www/www/node_modules/gatsby/dist/services/index.js - /usr/src/app/www/www/node_modules/gatsby/dist/bootstrap/index.js - /usr/src/app/www/www/node_modules/gatsby/dist/commands/build.js - /usr/src/app/www/www/node_modules/gatsby/node_modules/gatsby-cli/lib/create-cli.js - /usr/src/app/www/www/node_modules/gatsby/node_modules/gatsby-cli/lib/index.js - /usr/src/app/www/www/node_modules/gatsby/dist/bin/gatsby.js - /usr/src/app/www/www/node_modules/gatsby/cli.js |
Gatsby Cloud Build Report🚩 Your build failed. See the build logs here Errors Error in "/usr/src/app/www/examples/gatsbygram/node_modules/gatsby-plugin-page-creator/gatsby-node.js": Cannot find module 'gatsby-cli/lib/reporter' Require stack: - /usr/src/app/www/examples/gatsbygram/node_modules/gatsby-plugin-page-creator/is-valid-collection-path-implementation.js - /usr/src/app/www/examples/gatsbygram/node_modules/gatsby-plugin-page-creator/create-pages-from-collection-builder.js - /usr/src/app/www/examples/gatsbygram/node_modules/gatsby-plugin-page-creator/create-page-wrapper.js - /usr/src/app/www/examples/gatsbygram/node_modules/gatsby-plugin-page-creator/gatsby-node.js - /usr/src/app/www/examples/gatsbygram/node_modules/gatsby/dist/bootstrap/resolve-module-exports.js - /usr/src/app/www/examples/gatsbygram/node_modules/gatsby/dist/bootstrap/load-plugins/validate.js - /usr/src/app/www/examples/gatsbygram/node_modules/gatsby/dist/bootstrap/load-plugins/load.js - /usr/src/app/www/examples/gatsbygram/node_modules/gatsby/dist/bootstrap/load-plugins/index.js - /usr/src/app/www/examples/gatsbygram/node_modules/gatsby/dist/services/initialize.js - /usr/src/app/www/examples/gatsbygram/node_modules/gatsby/dist/services/index.js - /usr/src/app/www/examples/gatsbygram/node_modules/gatsby/dist/bootstrap/index.js - /usr/src/app/www/examples/gatsbygram/node_modules/gatsby/dist/commands/build.js - /usr/src/app/www/examples/gatsbygram/node_modules/gatsby/node_modules/gatsby-cli/lib/create-cli.js - /usr/src/app/www/examples/gatsbygram/node_modules/gatsby/node_modules/gatsby-cli/lib/index.js - /usr/src/app/www/examples/gatsbygram/node_modules/gatsby/dist/bin/gatsby.js - /usr/src/app/www/examples/gatsbygram/node_modules/gatsby/cli.js |
@@ -195,7 +195,7 @@ export const writeAll = async (state: IGatsbyState): Promise<boolean> => { | |||
let syncRequires = `${hotImport} | |||
|
|||
// prefer default export if available | |||
const preferDefault = m => m && m.default || m | |||
const preferDefault = m => (m && m.default) || m |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess in the future this will be
const preferDefault = m => (m && m.default) || m | |
const preferDefault = m => m?.default ?? m |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case I'm not sure which one is more readable :)
But I think we could use your suggestions because this file should be handled by babel so both optional chaining and nullish coalescing operator should work just fine (tho users do have option to use their own custom babel config, so probably keeping old style would result in less potential for problems)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Old syntax is less bytes when transpiled
Published in |
Description
Code we generate in
(a)sync-requires.js
(virtual) modules currently doesn't passno-mixed-operators
eslint rule. This is quick change to make it pass. This is for cases when users might use some custom eslint setups (tho I probably should follow up and see if we have documentation foreslint-loader
modifications anywhere and possibly adjustignore
setting there to ignore modules from_this_is_virtual_fs_path_/$virtual
(as user might have very speciffic rules that would warn/error on code we autogenerate)Related Issues
Fixes #26319