feature(schematics): libraries should not be able to deep import themselves

This commit is contained in:
Victor Savkin 2018-05-20 12:11:05 -04:00
parent 6c81127eea
commit bee990a63c
2 changed files with 5 additions and 7 deletions

View File

@ -337,6 +337,7 @@ describe('Enforce Module Boundaries', () => {
{},
`${process.cwd()}/proj/libs/mylib/src/main.ts`,
`
import "@mycompany/mylib/src/another-file"
import "@mycompany/other/src/blah"
import "@mycompany/other/src/sublib/blah"
`,
@ -346,7 +347,7 @@ describe('Enforce Module Boundaries', () => {
root: 'libs/mylib',
type: ProjectType.lib,
tags: [],
files: [`libs/mylib/src/main.ts`]
files: [`libs/mylib/src/main.ts`, `libs/mylib/src/another-file.ts`]
},
{
name: 'otherName',
@ -370,6 +371,9 @@ describe('Enforce Module Boundaries', () => {
expect(failures[1].getFailure()).toEqual(
'deep imports into libraries are forbidden'
);
expect(failures[2].getFailure()).toEqual(
'deep imports into libraries are forbidden'
);
});
it('should error on importing a lazy-loaded library', () => {

View File

@ -137,12 +137,6 @@ class EnforceModuleBoundariesWalker extends Lint.RuleWalker {
return;
}
// same project => allow
if (sourceProject === targetProject) {
super.visitImportDeclaration(node);
return;
}
// cannot import apps
if (targetProject.type !== ProjectType.lib) {
this.addFailureAt(