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 Plugin] No extraneous dependencies in imports #13670

Merged
merged 4 commits into from
Feb 10, 2021

Conversation

deyaaeldeen
Copy link
Member

Makes sure that we add deps for the source code in package.json's dependencies section and not in the other ones. Fixes #5564

@deyaaeldeen deyaaeldeen changed the title [ESLint Plugin] No no-extraneous-dependencies in imports [ESLint Plugin] No extraneous dependencies in imports Feb 9, 2021
ghost pushed a commit that referenced this pull request Feb 9, 2021
Use `TokenCredential` from `core-auth` instead of `identity` package so that the latter need not be pulled into dependencies list from devDependencies in #13670
@ghost
Copy link

ghost commented Feb 9, 2021

Hello @deyaaeldeen!

Because this pull request has the auto-merge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

"axios": "^0.21.1",
"events": "^3.0.0",
"express": "^4.16.3",
Copy link
Contributor

Choose a reason for hiding this comment

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

Please check with @jonathandturner if this was left as dev dependency on purpose. As noted in #13103, this increases the bundle size significantly

cc @xirzec

Copy link
Member Author

Choose a reason for hiding this comment

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

@ramya-rao-a I was curios about this as well, it looks weird to depend on express in the SDK. Either way, it is my understanding that if someone tries to use interactive browser credentials in identity now and they do not happen to have express installed, they will get an error because it is being used in the source code. So I believe this is a bug in a shipped package and have to be fixed by at least adding express as a dependency for the time being. That being said, I understand the bundle size concern and for now I would recommend to the customer to mark express as external in their webpack configs if they do not need the interactive browser creds module.

Copy link
Contributor

Choose a reason for hiding this comment

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

If I recall correctly, I added it so that interactive browser would work correctly. Currently, IBC isn't optional functionality, it's part of the core features of identity.

We could look into writing that part of the IBC functionality differently.

Copy link
Member

Choose a reason for hiding this comment

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

peerDependency could be an option here.

Copy link
Member

Choose a reason for hiding this comment

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

Taking a runtime dep on express for IBC feels bad. I'd like to rewrite if possible. In a past life I wrote a very small HTTP server in C# in order to do code coverage, so it's not as bad/crazy as it sounds.

Copy link
Member Author

Choose a reason for hiding this comment

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

@ramya-rao-a if we are not adding express as a dep, I think we may as well remove IBC all together until we have a good implementation for it.

Copy link
Member

@maorleger maorleger Feb 10, 2021

Choose a reason for hiding this comment

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

is this the only usage of express for IBC? Maybe we can replace it with vanilla node counterparts instead as a quick(ish) fix (in a separate PR / issue)?

Like would it work if we replaced express with http+url (for query string parsing)?

I'm curious about longer term - Since this in the browser I think I'm missing how it works today. 😄 Edit: specifically who spins up the express server and how does it work from a browser

Copy link
Member

Choose a reason for hiding this comment

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

I'm a little uncomfortable shipping a GA version of identity that depends on express, but since it's not breaking to remove a dependency, I would be fine shipping as is and refactoring this during the month so we can release a version that doesn't depend on express in March.

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like we already shipped 1.2.3 and the next Identity release will be preview. So, lets go ahead with this and ensure we do the refactoring for IBC this month

Copy link
Member Author

Choose a reason for hiding this comment

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

Sounds good. I will merge the PR as is. Perhaps we should consider a patch release with this PR change.

Copy link
Member

@witemple-msft witemple-msft left a comment

Choose a reason for hiding this comment

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

This looks good to me. For what it's worth, I took a look at Airbnb's configuration of this same plugin, since it has thousands upon thousands of users. It's worth looking over to see if there's anything we can add to this config. For example, they include karma.conf.js in the devDependencies list.

https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/rules/imports.js

@deyaaeldeen deyaaeldeen merged commit 97daca4 into Azure:master Feb 10, 2021
@deyaaeldeen deyaaeldeen deleted the eslint-plugin-no-extra-imports branch February 10, 2021 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lint check to avoid importing external modules that are not declared in the package.json's dependencies
7 participants