misc-template-rule.js 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. /**
  12. * Rule that walks through every inline or external template and reports if there
  13. * are outdated usages of the Angular Material API that needs to be updated manually.
  14. */
  15. class MiscTemplateRule extends schematics_1.MigrationRule {
  16. constructor() {
  17. super(...arguments);
  18. // Only enable this rule if the migration targets version 6. The rule
  19. // currently only includes migrations for V6 deprecations.
  20. this.ruleEnabled = this.targetVersion === schematics_1.TargetVersion.V6;
  21. }
  22. visitTemplate(template) {
  23. // Migration for: https://github.com/angular/components/pull/10398 (v6)
  24. schematics_1.findOutputsOnElementWithTag(template.content, 'selectionChange', [
  25. 'mat-list-option'
  26. ]).forEach(offset => {
  27. this.failures.push({
  28. filePath: template.filePath,
  29. position: template.getCharacterAndLineOfPosition(template.start + offset),
  30. message: `Found deprecated "selectionChange" output binding on "mat-list-option". ` +
  31. `Use "selectionChange" on "mat-selection-list" instead.`
  32. });
  33. });
  34. // Migration for: https://github.com/angular/components/pull/10413 (v6)
  35. schematics_1.findOutputsOnElementWithTag(template.content, 'selectedChanged', [
  36. 'mat-datepicker'
  37. ]).forEach(offset => {
  38. this.failures.push({
  39. filePath: template.filePath,
  40. position: template.getCharacterAndLineOfPosition(template.start + offset),
  41. message: `Found deprecated "selectedChanged" output binding on "mat-datepicker". ` +
  42. `Use "dateChange" or "dateInput" on "<input [matDatepicker]>" instead.`
  43. });
  44. });
  45. // Migration for: https://github.com/angular/components/commit/f0bf6e7 (v6)
  46. schematics_1.findInputsOnElementWithTag(template.content, 'selected', [
  47. 'mat-button-toggle-group'
  48. ]).forEach(offset => {
  49. this.failures.push({
  50. filePath: template.filePath,
  51. position: template.getCharacterAndLineOfPosition(template.start + offset),
  52. message: `Found deprecated "selected" input binding on "mat-radio-button-group". ` +
  53. `Use "value" instead.`
  54. });
  55. });
  56. }
  57. }
  58. exports.MiscTemplateRule = MiscTemplateRule;
  59. //# sourceMappingURL=misc-template-rule.js.map