noHostMetadataPropertyRule.js 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. "use strict";
  2. var __extends = (this && this.__extends) || (function () {
  3. var extendStatics = function (d, b) {
  4. extendStatics = Object.setPrototypeOf ||
  5. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  6. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  7. return extendStatics(d, b);
  8. };
  9. return function (d, b) {
  10. extendStatics(d, b);
  11. function __() { this.constructor = d; }
  12. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  13. };
  14. })();
  15. var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
  16. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  17. return cooked;
  18. };
  19. Object.defineProperty(exports, "__esModule", { value: true });
  20. var utils_1 = require("tslint/lib/utils");
  21. var metadataPropertyBase_1 = require("./metadataPropertyBase");
  22. var utils_2 = require("./util/utils");
  23. var METADATA_PROPERTY_NAME = 'host';
  24. var STYLE_GUIDE_LINK = 'https://angular.io/styleguide#style-06-03';
  25. var Rule = (function (_super) {
  26. __extends(Rule, _super);
  27. function Rule(options) {
  28. return _super.call(this, {
  29. errorMessage: Rule.FAILURE_STRING,
  30. propertyName: METADATA_PROPERTY_NAME
  31. }, options) || this;
  32. }
  33. Rule.metadata = {
  34. description: "Disallows usage of the `" + METADATA_PROPERTY_NAME + "` metadata property.",
  35. descriptionDetails: "See more at " + STYLE_GUIDE_LINK + ".",
  36. options: null,
  37. optionsDescription: 'Not configurable.',
  38. rationale: utils_1.dedent(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n If you ever need to rename the property associated\n with @", " or the method associated\n with @", ", you can modify it in a single place.\n "], ["\n If you ever need to rename the property associated\n with @", " or the method associated\n with @", ", you can modify it in a single place.\n "])), utils_2.AngularInnerClassDecorators.HostBinding, utils_2.AngularInnerClassDecorators.HostListener),
  39. ruleName: 'no-host-metadata-property',
  40. type: 'style',
  41. typescriptOnly: true
  42. };
  43. Rule.FAILURE_STRING = utils_1.dedent(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n Use @", " or\n @", " rather than the `", "` metadata property (", ")\n "], ["\n Use @", " or\n @", " rather than the \\`", "\\` metadata property (", ")\n "])), utils_2.AngularInnerClassDecorators.HostBinding, utils_2.AngularInnerClassDecorators.HostListener, METADATA_PROPERTY_NAME, STYLE_GUIDE_LINK);
  44. return Rule;
  45. }(metadataPropertyBase_1.MetadataPropertyBase));
  46. exports.Rule = Rule;
  47. var templateObject_1, templateObject_2;