|
| 1 | +<!-- WARNING: Generated documentation. Edit docs and examples in the rule and examples file ('rules/no-directive-replace.js', 'examples/no-directive-replace.js'). --> |
| 2 | + |
| 3 | +# no-directive-replace - disallow the deprecated directive replace property |
| 4 | + |
| 5 | +This rule disallows the replace attribute in a directive definition object. |
| 6 | +The replace property of a directive definition object is deprecated since angular 1.3 ([latest angular docs](https://docs.angularjs.org/api/ng/service/$compile). |
| 7 | + |
| 8 | +The option `ignoreReplaceFalse` let you ignore directive definitions with replace set to false. |
| 9 | + |
| 10 | +## Examples |
| 11 | + |
| 12 | +The following patterns are considered problems with default config; |
| 13 | + |
| 14 | + /*eslint angular/no-directive-replace: 2*/ |
| 15 | + |
| 16 | + // invalid |
| 17 | + angular.module('myModule').directive('helloWorld', function() { |
| 18 | + return { |
| 19 | + template: '<h2>Hello World!</h2>', |
| 20 | + replace: true |
| 21 | + }; |
| 22 | + }); // error: Directive definition property replace is deprecated. |
| 23 | + |
| 24 | + // invalid |
| 25 | + angular.module('myModule').directive('helloWorld', function() { |
| 26 | + var directiveDefinition = {}; |
| 27 | + directiveDefinition.templateUrl = 'helloWorld.html'; |
| 28 | + directiveDefinition.replace = true; |
| 29 | + return directiveDefinition; |
| 30 | + }); // error: Directive definition property replace is deprecated. |
| 31 | + |
| 32 | +The following patterns are **not** considered problems with default config; |
| 33 | + |
| 34 | + /*eslint angular/no-directive-replace: 2*/ |
| 35 | + |
| 36 | + // valid |
| 37 | + angular.module('myModule').directive('helloWorld', function() { |
| 38 | + return { |
| 39 | + template: '<h2>Hello World!</h2>' |
| 40 | + }; |
| 41 | + }); |
| 42 | + |
| 43 | +The following patterns are **not** considered problems when configured `{"ignoreReplaceFalse":true}`: |
| 44 | + |
| 45 | + /*eslint angular/no-directive-replace: [2,{"ignoreReplaceFalse":true}]*/ |
| 46 | + |
| 47 | + // valid |
| 48 | + angular.module('myModule').directive('helloWorld', function() { |
| 49 | + return { |
| 50 | + template: '<h2>Hello World!</h2>', |
| 51 | + replace: false |
| 52 | + }; |
| 53 | + }); |
| 54 | + |
| 55 | +The following patterns are considered problems when configured `{"ignoreReplaceFalse":false}`: |
| 56 | + |
| 57 | + /*eslint angular/no-directive-replace: [2,{"ignoreReplaceFalse":false}]*/ |
| 58 | + |
| 59 | + // invalid |
| 60 | + angular.module('myModule').directive('helloWorld', function() { |
| 61 | + return { |
| 62 | + template: '<h2>Hello World!</h2>', |
| 63 | + replace: true |
| 64 | + }; |
| 65 | + }); // error: Directive definition property replace is deprecated. |
| 66 | + |
| 67 | +## Version |
| 68 | + |
| 69 | +This rule was introduced in eslint-plugin-angular 0.15.0 |
| 70 | + |
| 71 | +## Links |
| 72 | + |
| 73 | +* [Rule source](../rules/no-directive-replace.js) |
| 74 | +* [Example source](../examples/no-directive-replace.js) |
0 commit comments