@angular-eslint/eslint-plugin-template 22.5.1-alpha.3 → 22.5.1-alpha.31

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.
@@ -1 +1 @@
1
- {"version":3,"file":"conditional-complexity.d.ts","sourceRoot":"","sources":["../../src/rules/conditional-complexity.ts"],"names":[],"mappings":"AAiBA,MAAM,MAAM,OAAO,GAAG,CAAC;IAAE,aAAa,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAClD,MAAM,MAAM,UAAU,GAAG,uBAAuB,CAAC;AACjD,eAAO,MAAM,SAAS,2BAA2B,CAAC;;;;AAIlD,wBAsFG;AA2DH,eAAO,MAAM,mBAAmB;;CAG/B,CAAC"}
1
+ {"version":3,"file":"conditional-complexity.d.ts","sourceRoot":"","sources":["../../src/rules/conditional-complexity.ts"],"names":[],"mappings":"AAoBA,MAAM,MAAM,OAAO,GAAG,CAAC;IAAE,aAAa,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAClD,MAAM,MAAM,UAAU,GAAG,uBAAuB,CAAC;AACjD,eAAO,MAAM,SAAS,2BAA2B,CAAC;;;;AAIlD,wBA4HG;AA2DH,eAAO,MAAM,mBAAmB;;CAG/B,CAAC"}
@@ -34,6 +34,22 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
34
34
  create(context, [{ maxComplexity }]) {
35
35
  (0, utils_1.ensureTemplateParser)(context);
36
36
  const sourceCode = context.sourceCode;
37
+ function checkControlFlowExpression(expression) {
38
+ const ast = expression instanceof bundled_angular_compiler_1.ASTWithSource ? expression.ast : expression;
39
+ const totalComplexity = getTotalComplexity(extractPossibleBinaryOrConditionalFrom(ast));
40
+ if (totalComplexity <= maxComplexity) {
41
+ return;
42
+ }
43
+ const { sourceSpan: { start, end }, } = ast;
44
+ context.report({
45
+ loc: {
46
+ start: sourceCode.getLocFromIndex(start),
47
+ end: sourceCode.getLocFromIndex(end),
48
+ },
49
+ messageId: 'conditionalComplexity',
50
+ data: { maxComplexity, totalComplexity },
51
+ });
52
+ }
37
53
  return {
38
54
  BoundAttribute(node) {
39
55
  if (!node.value.source ||
@@ -73,6 +89,18 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
73
89
  });
74
90
  }
75
91
  },
92
+ IfBlockBranch({ expression }) {
93
+ if (!expression) {
94
+ return;
95
+ }
96
+ checkControlFlowExpression(expression);
97
+ },
98
+ SwitchBlock({ expression }) {
99
+ checkControlFlowExpression(expression);
100
+ },
101
+ LetDeclaration({ value }) {
102
+ checkControlFlowExpression(value);
103
+ },
76
104
  };
77
105
  },
78
106
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular-eslint/eslint-plugin-template",
3
- "version": "22.5.1-alpha.3",
3
+ "version": "22.5.1-alpha.31",
4
4
  "description": "ESLint plugin for Angular Templates",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -19,17 +19,17 @@
19
19
  "LICENSE"
20
20
  ],
21
21
  "dependencies": {
22
- "@angular-eslint/bundled-angular-compiler": "22.5.1-alpha.3",
23
- "@angular-eslint/utils": "22.5.1-alpha.3",
22
+ "@angular-eslint/bundled-angular-compiler": "22.5.1-alpha.31",
23
+ "@angular-eslint/utils": "22.5.1-alpha.31",
24
24
  "aria-query": "5.3.2",
25
25
  "axobject-query": "4.1.0"
26
26
  },
27
27
  "devDependencies": {
28
- "@angular-eslint/test-utils": "22.5.1-alpha.3",
28
+ "@angular-eslint/test-utils": "22.5.1-alpha.31",
29
29
  "@types/aria-query": "5.0.4"
30
30
  },
31
31
  "peerDependencies": {
32
- "@angular-eslint/template-parser": "22.5.1-alpha.3",
32
+ "@angular-eslint/template-parser": "22.5.1-alpha.31",
33
33
  "@typescript-eslint/types": "^8.0.0",
34
34
  "@typescript-eslint/utils": "^8.0.0",
35
35
  "eslint": "^9.0.0 || ^10.0.0",