Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Restrict importing from enterprise in OSS codebase #23044

Merged
merged 3 commits into from
Jul 21, 2021

Conversation

courier-new
Copy link
Contributor

@courier-new courier-new commented Jul 20, 2021

Adds an ESLint rule with the same intention as ts-enterprise-import.sh to help provide earlier feedback about mixing enterprise code into the OSS codebase. For the many of us who have ESLint integration set up with our editors, this will provide the feedback at the time the code is being written, as opposed to at the time the checks are being run.

We can actually spot these pretty easily by just searching for the import pattern **/enterprise/* since most of our imports use relative paths: only an import from a file outside of enterprise would need to include enterprise in its path.

The error looks like this:

image

Tagging @sourcegraph/frontend-devs because I also upgraded ESLint in order to take advantage of the recently-added support for custom error messages with this rule's patterns eslint/eslint#11843. It doesn't appear to have caused other breaking changes, but not sure if others on the team have other concerns to check.

@courier-new courier-new added the dx Issues and PRs related to developer experience concerns label Jul 20, 2021
@courier-new courier-new self-assigned this Jul 20, 2021
@courier-new courier-new requested review from a team and eseliger July 20, 2021 20:48
@courier-new courier-new marked this pull request as ready for review July 20, 2021 21:02
Copy link
Member

@eseliger eseliger left a comment

Choose a reason for hiding this comment

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

Lovely! Great error message too 💯

Copy link
Member

@valerybugakov valerybugakov left a comment

Choose a reason for hiding this comment

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

Awesome 👏

@courier-new courier-new force-pushed the eslint-enterprise-imports-rule branch from 23a5b0c to 12cfc67 Compare July 21, 2021 16:07
@courier-new courier-new merged commit 2b6144a into main Jul 21, 2021
@courier-new courier-new deleted the eslint-enterprise-imports-rule branch July 21, 2021 16:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
dx Issues and PRs related to developer experience concerns
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants