How to restrict imports to TS files under a folder (especially React)

Viewed 112

I have a React project that's getting large, but I'm not ready to split into submodules . So I'd like the folder structure to reflect what will eventually be a spinoff package.

As I'm working with that setup I'd like to constrain the allowed imports to that sub folder, to especially not import React, so it'll be easier to split apart when the time is right.

example

/src
   /ui  #import React freely
   /core #Don't allow React to be imported

// /core/request.ts

import React from 'react';  // Lint Error, cannot import React under this folder!

...
<code>
...


and if it did, it would show a lint error.

Any ideas?

0 Answers
Related