Skip to content

Commit a8cff1e

Browse files
devversionjelbourn
authored andcommitted
build: add lint rule to avoid relative cross entry-point imports/exports (#17741)
Adds a new lint rule to avoid relative cross entry-point imports and exports. If a public entry-point imports from another entry-point it should use the public module name in order to comply with the Angular Package format, and to avoid unnecessary code inlining when creating flat entry-point bundles. Restructures the cdk testing fake-event code into `cdk/testing/testbed` since that is where the fake event code is primarily used. This makes the new lint rule happy, and also improves the public API of `cdk/testing` since interfaces like `ElementDimensions` are part of the `TestElement` class and should therefore be exported.
1 parent e02bb82 commit a8cff1e

20 files changed

+134
-33
lines changed

src/cdk/testing/private/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ ts_library(
1010
),
1111
module_name = "@angular/cdk/testing/private",
1212
deps = [
13-
"//src/cdk/testing",
13+
"//src/cdk/testing/testbed",
1414
"@npm//@angular/core",
1515
"@npm//@types/jasmine",
1616
],

src/cdk/testing/private/public-api.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
export * from '../fake-events'; // Re-exported for convenince.
109
export * from './expect-async-error';
1110
export * from './wrapped-error-message';
1211
export * from './mock-ng-zone';
1312
export * from './text-dedent';
13+
14+
// Re-exported for convenience.
15+
export * from '../testbed/fake-events';

src/cdk/testing/protractor/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ ts_library(
1111
module_name = "@angular/cdk/testing/protractor",
1212
deps = [
1313
"//src/cdk/testing",
14-
"//src/cdk/testing/private",
1514
"@npm//protractor",
1615
],
1716
)

src/cdk/testing/protractor/protractor-element.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9+
import {ElementDimensions, ModifierKeys, TestElement, TestKey} from '@angular/cdk/testing';
910
import {browser, ElementFinder, Key} from 'protractor';
10-
import {ElementDimensions} from '../element-dimensions';
11-
import {TestElement, TestKey} from '../test-element';
12-
import {ModifierKeys} from '../fake-events';
1311

1412
/** Maps the `TestKey` constants to Protractor's `Key` constants. */
1513
const keyMap = {

src/cdk/testing/protractor/protractor-harness-environment.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {HarnessEnvironment} from '@angular/cdk/testing';
9+
import {HarnessEnvironment, HarnessLoader, TestElement} from '@angular/cdk/testing';
1010
import {by, element as protractorElement, ElementFinder} from 'protractor';
11-
import {HarnessLoader} from '../component-harness';
12-
import {TestElement} from '../test-element';
1311
import {ProtractorElement} from './protractor-element';
1412

1513
/** A `HarnessEnvironment` implementation for Protractor. */

src/cdk/testing/public-api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@
99
export * from './component-harness';
1010
export * from './harness-environment';
1111
export * from './test-element';
12+
export * from './element-dimensions';

src/cdk/testing/test-element.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@
77
*/
88

99
import {ElementDimensions} from './element-dimensions';
10-
import {ModifierKeys} from './fake-events';
10+
11+
/** Modifier keys that may be held while typing. */
12+
export interface ModifierKeys {
13+
control?: boolean;
14+
alt?: boolean;
15+
shift?: boolean;
16+
meta?: boolean;
17+
}
1118

1219
/** An enum of non-text keys that can be used with the `sendKeys` method. */
1320
// NOTE: This is a separate enum from `@angular/cdk/keycodes` because we don't necessarily want to

src/cdk/testing/testbed/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ ts_library(
1212
deps = [
1313
"//src/cdk/keycodes",
1414
"//src/cdk/testing",
15-
"//src/cdk/testing/private",
1615
"@npm//@angular/core",
1716
"@npm//rxjs",
1817
],

src/cdk/testing/fake-events/dispatch-events.ts renamed to src/cdk/testing/testbed/fake-events/dispatch-events.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9+
import {ModifierKeys} from '@angular/cdk/testing';
910
import {
1011
createFakeEvent,
1112
createKeyboardEvent,
1213
createMouseEvent,
1314
createTouchEvent,
14-
ModifierKeys
1515
} from './event-objects';
1616

1717
/**

0 commit comments

Comments
 (0)