1 | "use strict";
|
---|
2 | /**
|
---|
3 | * @license
|
---|
4 | * Copyright Google LLC All Rights Reserved.
|
---|
5 | *
|
---|
6 | * Use of this source code is governed by an MIT-style license that can be
|
---|
7 | * found in the LICENSE file at https://angular.io/license
|
---|
8 | */
|
---|
9 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
10 | exports.MiscImportsMigration = void 0;
|
---|
11 | const schematics_1 = require("@angular/cdk/schematics");
|
---|
12 | const ts = require("typescript");
|
---|
13 | /**
|
---|
14 | * Migration that detects import declarations that refer to outdated identifiers from
|
---|
15 | * Angular Material which cannot be updated automatically.
|
---|
16 | */
|
---|
17 | class MiscImportsMigration extends schematics_1.Migration {
|
---|
18 | constructor() {
|
---|
19 | super(...arguments);
|
---|
20 | // Only enable this rule if the migration targets version 6. The rule
|
---|
21 | // currently only includes migrations for V6 deprecations.
|
---|
22 | this.enabled = this.targetVersion === schematics_1.TargetVersion.V6;
|
---|
23 | }
|
---|
24 | visitNode(node) {
|
---|
25 | if (ts.isImportDeclaration(node)) {
|
---|
26 | this._visitImportDeclaration(node);
|
---|
27 | }
|
---|
28 | }
|
---|
29 | _visitImportDeclaration(node) {
|
---|
30 | if (!schematics_1.isMaterialImportDeclaration(node) || !node.importClause ||
|
---|
31 | !node.importClause.namedBindings) {
|
---|
32 | return;
|
---|
33 | }
|
---|
34 | const namedBindings = node.importClause.namedBindings;
|
---|
35 | if (ts.isNamedImports(namedBindings)) {
|
---|
36 | // Migration for: https://github.com/angular/components/pull/10405 (v6)
|
---|
37 | this._checkAnimationConstants(namedBindings);
|
---|
38 | }
|
---|
39 | }
|
---|
40 | /**
|
---|
41 | * Checks for named imports that refer to the deleted animation constants.
|
---|
42 | * https://github.com/angular/components/commit/9f3bf274c4f15f0b0fbd8ab7dbf1a453076e66d9
|
---|
43 | */
|
---|
44 | _checkAnimationConstants(namedImports) {
|
---|
45 | namedImports.elements.filter(element => ts.isIdentifier(element.name)).forEach(element => {
|
---|
46 | const importName = element.name.text;
|
---|
47 | if (importName === 'SHOW_ANIMATION' || importName === 'HIDE_ANIMATION') {
|
---|
48 | this.createFailureAtNode(element, `Found deprecated symbol "${importName}" which has been removed`);
|
---|
49 | }
|
---|
50 | });
|
---|
51 | }
|
---|
52 | }
|
---|
53 | exports.MiscImportsMigration = MiscImportsMigration;
|
---|
54 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWlzYy1pbXBvcnRzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vLi4vLi4vc3JjL21hdGVyaWFsL3NjaGVtYXRpY3MvbmctdXBkYXRlL21pZ3JhdGlvbnMvbWlzYy1jaGVja3MvbWlzYy1pbXBvcnRzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQTs7Ozs7O0dBTUc7OztBQUVILHdEQUE4RjtBQUM5RixpQ0FBaUM7QUFFakM7OztHQUdHO0FBQ0gsTUFBYSxvQkFBcUIsU0FBUSxzQkFBZTtJQUF6RDs7UUFFRSxxRUFBcUU7UUFDckUsMERBQTBEO1FBQzFELFlBQU8sR0FBRyxJQUFJLENBQUMsYUFBYSxLQUFLLDBCQUFhLENBQUMsRUFBRSxDQUFDO0lBb0NwRCxDQUFDO0lBbENVLFNBQVMsQ0FBQyxJQUFhO1FBQzlCLElBQUksRUFBRSxDQUFDLG1CQUFtQixDQUFDLElBQUksQ0FBQyxFQUFFO1lBQ2hDLElBQUksQ0FBQyx1QkFBdUIsQ0FBQyxJQUFJLENBQUMsQ0FBQztTQUNwQztJQUNILENBQUM7SUFFTyx1QkFBdUIsQ0FBQyxJQUEwQjtRQUN4RCxJQUFJLENBQUMsd0NBQTJCLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsWUFBWTtZQUN4RCxDQUFDLElBQUksQ0FBQyxZQUFZLENBQUMsYUFBYSxFQUFFO1lBQ3BDLE9BQU87U0F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