4

Is there a simple way to prevent folder1 to import anything from folder2 in modern JS?


My context is a ReactNative/Expo detached app which somehow contain 2 distinct apps in one (think Uber customer and Uber driver, in a single native app).

I want to make a clear separation of the 2 codebases, and have a shared common folder which both apps can import. Code of one app should never be able to import code of the other app.

I am ok to any valid solution as long as it can make my test script and CI fail. I've looked at ESLint but couldn't find anything to do that.

I don't want to use LernaJS or Yarn Workspaces as symlinks don't yet work reliably on Metro bundler and I don't want to try a new packager like Haul just for that when simpler solutions might exist.

Sebastien Lorber
  • 89,644
  • 67
  • 288
  • 419

1 Answers1

0

eslint-plugin-import plugin has useful rule. Could be what you're looking for: https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-restricted-paths.md

Aurimas
  • 93
  • 5