misc-class-names-rule.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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 looks for class name identifiers that have been removed but
  14. * cannot be automatically migrated.
  15. */
  16. class MiscClassNamesRule 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.isIdentifier(node)) {
  25. this._visitIdentifier(node);
  26. }
  27. }
  28. _visitIdentifier(identifier) {
  29. // Migration for: https://github.com/angular/components/pull/10279 (v6)
  30. if (identifier.getText() === 'MatDrawerToggleResult') {
  31. this.createFailureAtNode(identifier, `Found "MatDrawerToggleResult" which has changed from a class type to a string ` +
  32. `literal type. Your code may need to be updated.`);
  33. }
  34. // Migration for: https://github.com/angular/components/pull/10398 (v6)
  35. if (identifier.getText() === 'MatListOptionChange') {
  36. this.createFailureAtNode(identifier, `Found usage of "MatListOptionChange" which has been removed. Please listen for ` +
  37. `"selectionChange" on "MatSelectionList" instead.`);
  38. }
  39. }
  40. }
  41. exports.MiscClassNamesRule = MiscClassNamesRule;
  42. //# sourceMappingURL=misc-class-names-rule.js.map