-
Notifications
You must be signed in to change notification settings - Fork 47
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
🚨 Lint against extraneous dependencies #670
Conversation
In all circumstances where it matters in this repo, the extraneous dependencies are guaranteed to be present and resolve to their expected versions. However, to better support Yarn 2+ and any other potential node loaders that might block on this, this eslint rule will help ensure that packages only import from their specific dependencies.
let url = percy.address.replace('http', 'ws'); | ||
|
||
if (process.env.__PERCY_BROWSERIFIED__) { | ||
return new window.WebSocket(url); | ||
} else { | ||
let socket = new (require('ws'))(url); | ||
/* eslint-disable-next-line import/no-extraneous-dependencies */ | ||
let { default: WebSocket } = await import('ws'); |
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.
While here, I also switched this to a dynamic import rather than a commonjs require in preparation for a full ES module adaptation in the future (dynamic imports will work in the current commonjs environment)
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.
🏁
Thanks for the work on this @wwilsman |
@hellodave76 If you're on Yarn 2+, you can use a |
thanks @wwilsman that worked 😃 |
What is this?
In all circumstances where it matters in this repo, the extraneous dependencies are guaranteed to be present and resolve to their expected versions. However, to better support Yarn 2+ and any other potential node loaders that might block on this, this eslint rule will help ensure that packages only import from their specific dependencies.
The rule is disabled in tests where it usually complains about other packages in the workspace which are always available during development.
Where utils were being transitively imported through
@percy/core
dependencies, are now imported through the@percy/core
package itself (with help of a recent change re-exporting client's request util).