UNPKG

@angular/material

Version:
50 lines 1.96 kB
"use strict"; /** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ Object.defineProperty(exports, "__esModule", { value: true }); const schematics_1 = require("@angular/cdk/schematics"); const chalk_1 = require("chalk"); const tslint_1 = require("tslint"); const ts = require("typescript"); /** * Rule that detects import declarations that refer to outdated identifiers from Angular Material * or the CDK which cannot be updated automatically. */ class Rule extends tslint_1.Rules.TypedRule { applyWithProgram(sourceFile, program) { return this.applyWithWalker(new Walker(sourceFile, this.getOptions(), program)); } } exports.Rule = Rule; class Walker extends tslint_1.ProgramAwareRuleWalker { visitImportDeclaration(node) { if (!schematics_1.isMaterialImportDeclaration(node) || !node.importClause || !node.importClause.namedBindings) { return; } const namedBindings = node.importClause.namedBindings; if (ts.isNamedImports(namedBindings)) { this._checkAnimationConstants(namedBindings); } } /** * Checks for named imports that refer to the deleted animation constants. * https://github.com/angular/components/commit/9f3bf274c4f15f0b0fbd8ab7dbf1a453076e66d9 */ _checkAnimationConstants(namedImports) { namedImports.elements.filter(element => ts.isIdentifier(element.name)).forEach(element => { const importName = element.name.text; if (importName === 'SHOW_ANIMATION' || importName === 'HIDE_ANIMATION') { this.addFailureAtNode(element, `Found deprecated symbol "${chalk_1.red(importName)}" which has been removed`); } }); } } exports.Walker = Walker; //# sourceMappingURL=checkImportsMiscRule.js.map