title: Disallow barrel file imports within the same library in Nrwl Nx
body: <p>Suppose we have an app and a library in <code>Nrwl Nx</code>.</p>
  
  <pre><code>/apps
    /myApp
  
  /libs
    /myLib
      /components
         /my.component.ts
         /other.component.ts
      /index.ts
  </code></pre>
  
  <p>I have already set tags in <code>nx.json</code> and <code>nx-enforce-module-boundaries</code> rule to block importing the app inside the lib. It works and this part is fine.</p>
  
  <p>Another thing I wanted to do is enforcing using barrel files within libraries. So I created a path in <code>tsconfig.ts</code></p>
  
  <pre><code>"paths": {
     "@myNs/my-lib": ["libs/myLib/index.ts"]
  }
  </code></pre>
  
  <p>I faced the problem. Suppose we have something exported from <code>index.ts</code>.</p>
  
  <pre><code>// index.ts
  export { MyComponent } from './components/my.component';
  </code></pre>
  
  <p>Now if we use some autoimporting IDE feature (e.g. from <code>WebStorm</code> or <code>VS Code</code>). They will be importing <code>MyComponent</code> using the path <code>@myNs/my-lib</code> - and this is expected, because I have just configured it like so.</p>
  
  <p>A real problem appears when I want to autoimport something inside <code>myLib</code> (these imports should be relative, not <code>@myNs/my-lib</code>) - according to logic and this article (<a href="https://blog.strongbrew.io/opinionated-guidelines-for-large-nx-angular-projects/" rel="nofollow noreferrer">[Interesting article here]</a>):</p>
  
  <blockquote>
    <p><strong>Never let a lib import from its own Barrel file</strong></p>
    
    <p>The TypeScript modules within a particular lib should not care what
    functionality that lib exposes, so it shouldn’t use its own barrel
    file at any point.</p>
    
    <p>If a module imports something from its own barrel file, it almost
    always results in circular reference errors. Therefore, imports from
    inside of the module should use relative path imports.</p>
  </blockquote>
  
  <p>So I found a workaround to block TS path-like imports inside lib. I have added a rule inside <code>libs/myLib/tslint.json</code>:</p>
  
  <pre><code>"rules": {
     "import-blacklist": [true, "@myNs/my-lib"]
  }
  </code></pre>
  
  <p>Anyway, it doesn't fix autoimporting feature, just disallows to use wrong imports inside the lib.</p>
  
  <p>Another problem is there are still wrong imports allowed.
  Suppose <code>OtherComponent</code> wants to import <code>MyComponent</code> Then there are three possibilities:</p>
  
  <pre class="lang-js prettyprint-override"><code>import { MyComponent } from './my.component'; // the correct way
  import { MyComponent } from '.'; // not the best, but also the correct way
  import { MyComponent } from '..'; // using barrel file - not correct (look at the citation above), but still successfuly validated by TSLint
  </code></pre>
  
  <p>Questions:</p>
  
  <ol>
  <li>How to disallow barrel file imports inside the same lib?</li>
  <li>How to configure IDEs to have relative paths inside lib and TypeScript paths outside (<code>@myNs/my-lib</code>)?</li>
  </ol>