@angular-eslint/eslint-plugin-template 17.0.2-alpha.3 → 17.0.2-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -59,6 +59,7 @@
59
59
  | [`no-interpolation-in-attributes`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin-template/docs/rules/no-interpolation-in-attributes.md) | Ensures that property-binding is used instead of interpolation in attributes. | | | | |
60
60
  | [`no-negated-async`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin-template/docs/rules/no-negated-async.md) | Ensures that async pipe results, as well as values used with the async pipe, are not negated | :white_check_mark: | | :bulb: | |
61
61
  | [`no-positive-tabindex`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin-template/docs/rules/no-positive-tabindex.md) | Ensures that the `tabindex` attribute is not positive | | | :bulb: | |
62
+ | [`prefer-control-flow`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin-template/docs/rules/prefer-control-flow.md) | Ensures that the built-in control flow is used. | | | | |
62
63
  | [`prefer-ngsrc`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin-template/docs/rules/prefer-ngsrc.md) | Ensures ngSrc is used instead of src for img elements | | | | |
63
64
  | [`role-has-required-aria`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin-template/docs/rules/role-has-required-aria.md) | [Accessibility] Ensures elements with ARIA roles have all required properties for that role. | | | :bulb: | :accessibility: |
64
65
  | [`table-scope`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin-template/docs/rules/table-scope.md) | [Accessibility] Ensures that the `scope` attribute is only used on the `<th>` element | | :wrench: | | :accessibility: |
@@ -24,6 +24,7 @@
24
24
  "@angular-eslint/template/no-interpolation-in-attributes": "error",
25
25
  "@angular-eslint/template/no-negated-async": "error",
26
26
  "@angular-eslint/template/no-positive-tabindex": "error",
27
+ "@angular-eslint/template/prefer-control-flow": "error",
27
28
  "@angular-eslint/template/prefer-ngsrc": "error",
28
29
  "@angular-eslint/template/prefer-self-closing-tags": "error",
29
30
  "@angular-eslint/template/role-has-required-aria": "error",
package/dist/index.js CHANGED
@@ -53,6 +53,7 @@ const no_interpolation_in_attributes_1 = __importStar(require("./rules/no-interp
53
53
  const no_negated_async_1 = __importStar(require("./rules/no-negated-async"));
54
54
  const no_positive_tabindex_1 = __importStar(require("./rules/no-positive-tabindex"));
55
55
  const prefer_ngsrc_1 = __importStar(require("./rules/prefer-ngsrc"));
56
+ const prefer_control_flow_1 = __importStar(require("./rules/prefer-control-flow"));
56
57
  const prefer_self_closing_tags_1 = __importStar(require("./rules/prefer-self-closing-tags"));
57
58
  const role_has_required_aria_1 = __importStar(require("./rules/role-has-required-aria"));
58
59
  const table_scope_1 = __importStar(require("./rules/table-scope"));
@@ -89,6 +90,7 @@ module.exports = {
89
90
  [no_interpolation_in_attributes_1.RULE_NAME]: no_interpolation_in_attributes_1.default,
90
91
  [no_negated_async_1.RULE_NAME]: no_negated_async_1.default,
91
92
  [no_positive_tabindex_1.RULE_NAME]: no_positive_tabindex_1.default,
93
+ [prefer_control_flow_1.RULE_NAME]: prefer_control_flow_1.default,
92
94
  [prefer_self_closing_tags_1.RULE_NAME]: prefer_self_closing_tags_1.default,
93
95
  [prefer_ngsrc_1.RULE_NAME]: prefer_ngsrc_1.default,
94
96
  [role_has_required_aria_1.RULE_NAME]: role_has_required_aria_1.default,
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RULE_NAME = exports.MESSAGE_ID = void 0;
4
+ const create_eslint_rule_1 = require("../utils/create-eslint-rule");
5
+ const utils_1 = require("@angular-eslint/utils");
6
+ exports.MESSAGE_ID = 'preferControlFlow';
7
+ exports.RULE_NAME = 'prefer-control-flow';
8
+ exports.default = (0, create_eslint_rule_1.createESLintRule)({
9
+ name: exports.RULE_NAME,
10
+ meta: {
11
+ type: 'suggestion',
12
+ docs: {
13
+ description: 'Ensures that the built-in control flow is used.',
14
+ },
15
+ schema: [],
16
+ messages: {
17
+ [exports.MESSAGE_ID]: 'Use built-in control flow instead of directive {{name}}.',
18
+ },
19
+ },
20
+ defaultOptions: [],
21
+ create(context) {
22
+ const parserServices = (0, utils_1.getTemplateParserServices)(context);
23
+ return {
24
+ 'BoundAttribute[name=/^ngFor|ngIf|ngSwitch$/]'({ sourceSpan, name, }) {
25
+ // For these names, the parent ngIf or ngFor already throws an error
26
+ const redundantNames = ['ngIfElse', 'ngIfThen', 'ngForTrackBy'];
27
+ if (redundantNames.includes(name)) {
28
+ return;
29
+ }
30
+ const loc = parserServices.convertNodeSourceSpanToLoc(sourceSpan);
31
+ context.report({
32
+ messageId: exports.MESSAGE_ID,
33
+ loc,
34
+ data: { name },
35
+ });
36
+ },
37
+ };
38
+ },
39
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular-eslint/eslint-plugin-template",
3
- "version": "17.0.2-alpha.3",
3
+ "version": "17.0.2-alpha.4",
4
4
  "description": "ESLint plugin for Angular Templates",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -17,8 +17,8 @@
17
17
  "LICENSE"
18
18
  ],
19
19
  "dependencies": {
20
- "@angular-eslint/bundled-angular-compiler": "17.0.2-alpha.3",
21
- "@angular-eslint/utils": "17.0.2-alpha.3",
20
+ "@angular-eslint/bundled-angular-compiler": "17.0.2-alpha.4",
21
+ "@angular-eslint/utils": "17.0.2-alpha.4",
22
22
  "@typescript-eslint/type-utils": "6.10.0",
23
23
  "@typescript-eslint/utils": "6.10.0",
24
24
  "aria-query": "5.3.0",