misc-property-names-rule.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. const schematics_1 = require("@angular/cdk/schematics");
  11. const ts = require("typescript");
  12. /**
  13. * Rule that walks through every property access expression and and reports a failure if
  14. * a given property name no longer exists but cannot be automatically migrated.
  15. */
  16. class MiscPropertyNamesRule extends schematics_1.MigrationRule {
  17. constructor() {
  18. super(...arguments);
  19. // Only enable this rule if the migration targets version 6. The rule
  20. // currently only includes migrations for V6 deprecations.
  21. this.ruleEnabled = this.targetVersion === schematics_1.TargetVersion.V6;
  22. }
  23. visitNode(node) {
  24. if (ts.isPropertyAccessExpression(node)) {
  25. this._visitPropertyAccessExpression(node);
  26. }
  27. }
  28. _visitPropertyAccessExpression(node) {
  29. const hostType = this.typeChecker.getTypeAtLocation(node.expression);
  30. const typeName = hostType && hostType.symbol && hostType.symbol.getName();
  31. // Migration for: https://github.com/angular/components/pull/10398 (v6)
  32. if (typeName === 'MatListOption' && node.name.text === 'selectionChange') {
  33. this.createFailureAtNode(node, `Found deprecated property "selectionChange" of ` +
  34. `class "MatListOption". Use the "selectionChange" property on the ` +
  35. `parent "MatSelectionList" instead.`);
  36. }
  37. // Migration for: https://github.com/angular/components/pull/10413 (v6)
  38. if (typeName === 'MatDatepicker' && node.name.text === 'selectedChanged') {
  39. this.createFailureAtNode(node, `Found deprecated property "selectedChanged" of ` +
  40. `class "MatDatepicker". Use the "dateChange" or "dateInput" methods ` +
  41. `on "MatDatepickerInput" instead.`);
  42. }
  43. }
  44. }
  45. exports.MiscPropertyNamesRule = MiscPropertyNamesRule;
  46. //# sourceMappingURL=misc-property-names-rule.js.map