feature(schematics): libraries should not be able to deep import themselves
This commit is contained in:
parent
6c81127eea
commit
bee990a63c
@ -337,6 +337,7 @@ describe('Enforce Module Boundaries', () => {
|
|||||||
{},
|
{},
|
||||||
`${process.cwd()}/proj/libs/mylib/src/main.ts`,
|
`${process.cwd()}/proj/libs/mylib/src/main.ts`,
|
||||||
`
|
`
|
||||||
|
import "@mycompany/mylib/src/another-file"
|
||||||
import "@mycompany/other/src/blah"
|
import "@mycompany/other/src/blah"
|
||||||
import "@mycompany/other/src/sublib/blah"
|
import "@mycompany/other/src/sublib/blah"
|
||||||
`,
|
`,
|
||||||
@ -346,7 +347,7 @@ describe('Enforce Module Boundaries', () => {
|
|||||||
root: 'libs/mylib',
|
root: 'libs/mylib',
|
||||||
type: ProjectType.lib,
|
type: ProjectType.lib,
|
||||||
tags: [],
|
tags: [],
|
||||||
files: [`libs/mylib/src/main.ts`]
|
files: [`libs/mylib/src/main.ts`, `libs/mylib/src/another-file.ts`]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'otherName',
|
name: 'otherName',
|
||||||
@ -370,6 +371,9 @@ describe('Enforce Module Boundaries', () => {
|
|||||||
expect(failures[1].getFailure()).toEqual(
|
expect(failures[1].getFailure()).toEqual(
|
||||||
'deep imports into libraries are forbidden'
|
'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', () => {
|
it('should error on importing a lazy-loaded library', () => {
|
||||||
|
|||||||
@ -137,12 +137,6 @@ class EnforceModuleBoundariesWalker extends Lint.RuleWalker {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// same project => allow
|
|
||||||
if (sourceProject === targetProject) {
|
|
||||||
super.visitImportDeclaration(node);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// cannot import apps
|
// cannot import apps
|
||||||
if (targetProject.type !== ProjectType.lib) {
|
if (targetProject.type !== ProjectType.lib) {
|
||||||
this.addFailureAt(
|
this.addFailureAt(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user