@angular-eslint/eslint-plugin-template 19.3.1-alpha.5 → 19.3.1-alpha.6

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,17 +1,17 @@
1
1
  {
2
- "parser": "@angular-eslint/template-parser",
3
- "plugins": ["@angular-eslint/template"],
4
- "rules": {
5
- "@angular-eslint/template/alt-text": "error",
6
- "@angular-eslint/template/click-events-have-key-events": "error",
7
- "@angular-eslint/template/elements-content": "error",
8
- "@angular-eslint/template/interactive-supports-focus": "error",
9
- "@angular-eslint/template/label-has-associated-control": "error",
10
- "@angular-eslint/template/mouse-events-have-key-events": "error",
11
- "@angular-eslint/template/no-autofocus": "error",
12
- "@angular-eslint/template/no-distracting-elements": "error",
13
- "@angular-eslint/template/role-has-required-aria": "error",
14
- "@angular-eslint/template/table-scope": "error",
15
- "@angular-eslint/template/valid-aria": "error"
16
- }
2
+ "parser": "@angular-eslint/template-parser",
3
+ "plugins": ["@angular-eslint/template"],
4
+ "rules": {
5
+ "@angular-eslint/template/alt-text": "error",
6
+ "@angular-eslint/template/click-events-have-key-events": "error",
7
+ "@angular-eslint/template/elements-content": "error",
8
+ "@angular-eslint/template/interactive-supports-focus": "error",
9
+ "@angular-eslint/template/label-has-associated-control": "error",
10
+ "@angular-eslint/template/mouse-events-have-key-events": "error",
11
+ "@angular-eslint/template/no-autofocus": "error",
12
+ "@angular-eslint/template/no-distracting-elements": "error",
13
+ "@angular-eslint/template/role-has-required-aria": "error",
14
+ "@angular-eslint/template/table-scope": "error",
15
+ "@angular-eslint/template/valid-aria": "error"
16
+ }
17
17
  }
@@ -1,37 +1,37 @@
1
1
  {
2
- "parser": "@angular-eslint/template-parser",
3
- "plugins": ["@angular-eslint/template"],
4
- "rules": {
5
- "@angular-eslint/template/alt-text": "error",
6
- "@angular-eslint/template/attributes-order": "error",
7
- "@angular-eslint/template/banana-in-box": "error",
8
- "@angular-eslint/template/button-has-type": "error",
9
- "@angular-eslint/template/click-events-have-key-events": "error",
10
- "@angular-eslint/template/conditional-complexity": "error",
11
- "@angular-eslint/template/cyclomatic-complexity": "error",
12
- "@angular-eslint/template/elements-content": "error",
13
- "@angular-eslint/template/eqeqeq": "error",
14
- "@angular-eslint/template/i18n": "error",
15
- "@angular-eslint/template/interactive-supports-focus": "error",
16
- "@angular-eslint/template/label-has-associated-control": "error",
17
- "@angular-eslint/template/mouse-events-have-key-events": "error",
18
- "@angular-eslint/template/no-any": "error",
19
- "@angular-eslint/template/no-autofocus": "error",
20
- "@angular-eslint/template/no-call-expression": "error",
21
- "@angular-eslint/template/no-distracting-elements": "error",
22
- "@angular-eslint/template/no-duplicate-attributes": "error",
23
- "@angular-eslint/template/no-inline-styles": "error",
24
- "@angular-eslint/template/no-interpolation-in-attributes": "error",
25
- "@angular-eslint/template/no-negated-async": "error",
26
- "@angular-eslint/template/no-positive-tabindex": "error",
27
- "@angular-eslint/template/prefer-contextual-for-variables": "error",
28
- "@angular-eslint/template/prefer-control-flow": "error",
29
- "@angular-eslint/template/prefer-ngsrc": "error",
30
- "@angular-eslint/template/prefer-self-closing-tags": "error",
31
- "@angular-eslint/template/prefer-static-string-properties": "error",
32
- "@angular-eslint/template/role-has-required-aria": "error",
33
- "@angular-eslint/template/table-scope": "error",
34
- "@angular-eslint/template/use-track-by-function": "error",
35
- "@angular-eslint/template/valid-aria": "error"
36
- }
2
+ "parser": "@angular-eslint/template-parser",
3
+ "plugins": ["@angular-eslint/template"],
4
+ "rules": {
5
+ "@angular-eslint/template/alt-text": "error",
6
+ "@angular-eslint/template/attributes-order": "error",
7
+ "@angular-eslint/template/banana-in-box": "error",
8
+ "@angular-eslint/template/button-has-type": "error",
9
+ "@angular-eslint/template/click-events-have-key-events": "error",
10
+ "@angular-eslint/template/conditional-complexity": "error",
11
+ "@angular-eslint/template/cyclomatic-complexity": "error",
12
+ "@angular-eslint/template/elements-content": "error",
13
+ "@angular-eslint/template/eqeqeq": "error",
14
+ "@angular-eslint/template/i18n": "error",
15
+ "@angular-eslint/template/interactive-supports-focus": "error",
16
+ "@angular-eslint/template/label-has-associated-control": "error",
17
+ "@angular-eslint/template/mouse-events-have-key-events": "error",
18
+ "@angular-eslint/template/no-any": "error",
19
+ "@angular-eslint/template/no-autofocus": "error",
20
+ "@angular-eslint/template/no-call-expression": "error",
21
+ "@angular-eslint/template/no-distracting-elements": "error",
22
+ "@angular-eslint/template/no-duplicate-attributes": "error",
23
+ "@angular-eslint/template/no-inline-styles": "error",
24
+ "@angular-eslint/template/no-interpolation-in-attributes": "error",
25
+ "@angular-eslint/template/no-negated-async": "error",
26
+ "@angular-eslint/template/no-positive-tabindex": "error",
27
+ "@angular-eslint/template/prefer-contextual-for-variables": "error",
28
+ "@angular-eslint/template/prefer-control-flow": "error",
29
+ "@angular-eslint/template/prefer-ngsrc": "error",
30
+ "@angular-eslint/template/prefer-self-closing-tags": "error",
31
+ "@angular-eslint/template/prefer-static-string-properties": "error",
32
+ "@angular-eslint/template/role-has-required-aria": "error",
33
+ "@angular-eslint/template/table-scope": "error",
34
+ "@angular-eslint/template/use-track-by-function": "error",
35
+ "@angular-eslint/template/valid-aria": "error"
36
+ }
37
37
  }
@@ -1,9 +1,9 @@
1
1
  {
2
- "parser": "@typescript-eslint/parser",
3
- "parserOptions": {
4
- "ecmaVersion": 2020,
5
- "sourceType": "module"
6
- },
7
- "plugins": ["@angular-eslint/template"],
8
- "processor": "@angular-eslint/template/extract-inline-html"
2
+ "parser": "@typescript-eslint/parser",
3
+ "parserOptions": {
4
+ "ecmaVersion": 2020,
5
+ "sourceType": "module"
6
+ },
7
+ "plugins": ["@angular-eslint/template"],
8
+ "processor": "@angular-eslint/template/extract-inline-html"
9
9
  }
@@ -1,9 +1,9 @@
1
1
  {
2
- "parser": "@angular-eslint/template-parser",
3
- "plugins": ["@angular-eslint/template"],
4
- "rules": {
5
- "@angular-eslint/template/banana-in-box": "error",
6
- "@angular-eslint/template/eqeqeq": "error",
7
- "@angular-eslint/template/no-negated-async": "error"
8
- }
2
+ "parser": "@angular-eslint/template-parser",
3
+ "plugins": ["@angular-eslint/template"],
4
+ "rules": {
5
+ "@angular-eslint/template/banana-in-box": "error",
6
+ "@angular-eslint/template/eqeqeq": "error",
7
+ "@angular-eslint/template/no-negated-async": "error"
8
+ }
9
9
  }
package/dist/index.js CHANGED
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
37
  };
@@ -1 +1 @@
1
- {"version":3,"file":"no-any.d.ts","sourceRoot":"","sources":["../../src/rules/no-any.ts"],"names":[],"mappings":"AASA,MAAM,MAAM,OAAO,GAAG,EAAE,CAAC;AACzB,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,kBAAkB,CAAC;AACtD,eAAO,MAAM,SAAS,WAAW,CAAC;;AAGlC,wBA0DG"}
1
+ {"version":3,"file":"no-any.d.ts","sourceRoot":"","sources":["../../src/rules/no-any.ts"],"names":[],"mappings":"AAWA,MAAM,MAAM,OAAO,GAAG,EAAE,CAAC;AACzB,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,kBAAkB,CAAC;AACtD,eAAO,MAAM,SAAS,WAAW,CAAC;;AAGlC,wBA0FG"}
@@ -24,34 +24,62 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
24
24
  create(context) {
25
25
  (0, utils_1.ensureTemplateParser)(context);
26
26
  const sourceCode = context.sourceCode;
27
+ const isAnyCall = (node) => {
28
+ if (!(node.receiver instanceof bundled_angular_compiler_1.PropertyRead)) {
29
+ return false;
30
+ }
31
+ if (node.receiver.name !== ANY_TYPE_CAST_FUNCTION_NAME) {
32
+ return false;
33
+ }
34
+ if (!(
35
+ // this.$any() is also valid usage of the native Angular $any()
36
+ (node.receiver.receiver instanceof bundled_angular_compiler_1.ThisReceiver ||
37
+ node.receiver.receiver instanceof bundled_angular_compiler_1.ImplicitReceiver))) {
38
+ return false;
39
+ }
40
+ return true;
41
+ };
42
+ const reportAnyCall = (node) => {
43
+ const { start, end } = node.sourceSpan;
44
+ const nameSpan = node.receiver.nameSpan;
45
+ context.report({
46
+ messageId: 'noAny',
47
+ loc: {
48
+ start: sourceCode.getLocFromIndex(start),
49
+ end: sourceCode.getLocFromIndex(end),
50
+ },
51
+ suggest: [
52
+ {
53
+ messageId: 'suggestRemoveAny',
54
+ fix: (fixer) => [
55
+ fixer.removeRange([nameSpan.start, nameSpan.end + 1]),
56
+ fixer.removeRange([end - 1, end]),
57
+ ],
58
+ },
59
+ ],
60
+ });
61
+ };
62
+ /**
63
+ * Handles KeyedRead.KeyedRead cases like
64
+ * $any(attributeList)['NPSScore']['another']
65
+ */
66
+ const findAndReportAnyCalls = (node) => {
67
+ if (node instanceof bundled_angular_compiler_1.Call && isAnyCall(node)) {
68
+ reportAnyCall(node);
69
+ }
70
+ else if (node instanceof bundled_angular_compiler_1.KeyedRead) {
71
+ findAndReportAnyCalls(node.receiver);
72
+ }
73
+ };
27
74
  return {
28
- [`Call[receiver.name="${ANY_TYPE_CAST_FUNCTION_NAME}"]`]({ receiver, sourceSpan: { end, start }, }) {
29
- if (!(receiver instanceof bundled_angular_compiler_1.PropertyRead)) {
75
+ [`Call[receiver.name="${ANY_TYPE_CAST_FUNCTION_NAME}"]`](node) {
76
+ if (!isAnyCall(node)) {
30
77
  return;
31
78
  }
32
- if (!(
33
- // this.$any() is also valid usage of the native Angular $any()
34
- (receiver.receiver instanceof bundled_angular_compiler_1.ThisReceiver ||
35
- receiver.receiver instanceof bundled_angular_compiler_1.ImplicitReceiver))) {
36
- return;
37
- }
38
- const nameSpan = receiver.nameSpan;
39
- context.report({
40
- messageId: 'noAny',
41
- loc: {
42
- start: sourceCode.getLocFromIndex(start),
43
- end: sourceCode.getLocFromIndex(end),
44
- },
45
- suggest: [
46
- {
47
- messageId: 'suggestRemoveAny',
48
- fix: (fixer) => [
49
- fixer.removeRange([nameSpan.start, nameSpan.end + 1]),
50
- fixer.removeRange([end - 1, end]),
51
- ],
52
- },
53
- ],
54
- });
79
+ reportAnyCall(node);
80
+ },
81
+ KeyedRead(node) {
82
+ findAndReportAnyCalls(node);
55
83
  },
56
84
  };
57
85
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular-eslint/eslint-plugin-template",
3
- "version": "19.3.1-alpha.5",
3
+ "version": "19.3.1-alpha.6",
4
4
  "description": "ESLint plugin for Angular Templates",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -20,13 +20,13 @@
20
20
  "dependencies": {
21
21
  "aria-query": "5.3.2",
22
22
  "axobject-query": "4.1.0",
23
- "@angular-eslint/bundled-angular-compiler": "19.3.1-alpha.5",
24
- "@angular-eslint/utils": "19.3.1-alpha.5"
23
+ "@angular-eslint/bundled-angular-compiler": "19.3.1-alpha.6",
24
+ "@angular-eslint/utils": "19.3.1-alpha.6"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@types/aria-query": "5.0.4",
28
- "@angular-eslint/template-parser": "19.3.1-alpha.5",
29
- "@angular-eslint/test-utils": "19.3.1-alpha.5"
28
+ "@angular-eslint/template-parser": "19.3.1-alpha.6",
29
+ "@angular-eslint/test-utils": "19.3.1-alpha.6"
30
30
  },
31
31
  "peerDependencies": {
32
32
  "@typescript-eslint/types": "^7.11.0 || ^8.0.0",