@angular-eslint/eslint-plugin-template 17.2.2-alpha.7 → 17.2.2-alpha.9

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.
@@ -53,13 +53,13 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
53
53
  end: sourceCode.getLocFromIndex(end),
54
54
  }, messageId: 'eqeqeq', data }, (isStringNonNumericValue(left) || isStringNonNumericValue(right)
55
55
  ? {
56
- fix: (fixer) => getFix({ node, left, right, start, end, fixer }),
56
+ fix: (fixer) => getFix({ node, right, end, sourceCode, fixer }),
57
57
  }
58
58
  : {
59
59
  suggest: [
60
60
  {
61
61
  messageId: 'suggestStrictEquality',
62
- fix: (fixer) => getFix({ node, left, right, start, end, fixer }),
62
+ fix: (fixer) => getFix({ node, right, end, sourceCode, fixer }),
63
63
  data,
64
64
  },
65
65
  ],
@@ -71,19 +71,33 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
71
71
  function getSpanLength({ span: { start, end } }) {
72
72
  return end - start;
73
73
  }
74
- const getFix = ({ node, left, right, start, end, fixer, }) => {
75
- var _a;
76
- const { source } = (_a = (0, get_nearest_node_from_1.getNearestNodeFrom)(node, isASTWithSource)) !== null && _a !== void 0 ? _a : {};
74
+ const getFix = ({ node, right, end, sourceCode, fixer, }) => {
75
+ const { source, ast } = (0, get_nearest_node_from_1.getNearestNodeFrom)(node, isASTWithSource);
77
76
  if (!source)
78
77
  return null;
79
- return fixer.insertTextAfterRange([start + getSpanLength(left) + 1, end - getSpanLength(right) - 1], '=');
78
+ let startOffet = 0;
79
+ while (!isInterpolation(ast) && isLeadingTriviaChar(source[startOffet])) {
80
+ startOffet++;
81
+ }
82
+ const endRange = end - startOffet - getSpanLength(right) - 1;
83
+ let eqOffset = 0;
84
+ while (sourceCode.text[endRange - eqOffset] !== '=') {
85
+ eqOffset++;
86
+ }
87
+ return fixer.insertTextAfterRange([endRange - eqOffset, endRange - eqOffset], '=');
80
88
  };
89
+ function isLeadingTriviaChar(char) {
90
+ return char === '\n' || char === ' ';
91
+ }
81
92
  function isASTWithSource(node) {
82
93
  return node instanceof bundled_angular_compiler_1.ASTWithSource;
83
94
  }
84
95
  function isLiteralPrimitive(node) {
85
96
  return node instanceof bundled_angular_compiler_1.LiteralPrimitive;
86
97
  }
98
+ function isInterpolation(node) {
99
+ return node instanceof bundled_angular_compiler_1.Interpolation;
100
+ }
87
101
  function isNumeric(value) {
88
102
  return (!Number.isNaN(Number.parseFloat(String(value))) &&
89
103
  Number.isFinite(Number(value)));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular-eslint/eslint-plugin-template",
3
- "version": "17.2.2-alpha.7",
3
+ "version": "17.2.2-alpha.9",
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.2.2-alpha.7",
21
- "@angular-eslint/utils": "17.2.2-alpha.7",
20
+ "@angular-eslint/bundled-angular-compiler": "17.2.2-alpha.9",
21
+ "@angular-eslint/utils": "17.2.2-alpha.9",
22
22
  "@typescript-eslint/type-utils": "7.2.0",
23
23
  "@typescript-eslint/utils": "7.2.0",
24
24
  "aria-query": "5.3.0",