@typescript-eslint/eslint-plugin 8.45.1-alpha.2 → 8.45.1-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.
@@ -35,7 +35,6 @@ var __importStar = (this && this.__importStar) || (function () {
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  const utils_1 = require("@typescript-eslint/utils");
37
37
  const tsutils = __importStar(require("ts-api-utils"));
38
- const ts = __importStar(require("typescript"));
39
38
  const util_1 = require("../util");
40
39
  const promiseUtils_1 = require("../util/promiseUtils");
41
40
  const messageBase = 'Promises must be awaited, end with a call to .catch, or end with a call to .then with a rejection handler.';
@@ -141,8 +140,9 @@ exports.default = (0, util_1.createRule)({
141
140
  {
142
141
  messageId: 'floatingFixVoid',
143
142
  fix(fixer) {
144
- const tsNode = services.esTreeNodeToTSNodeMap.get(node.expression);
145
- if (isHigherPrecedenceThanUnary(tsNode)) {
143
+ if ((0, util_1.isParenthesized)(expression, context.sourceCode) ||
144
+ (0, util_1.getOperatorPrecedenceForNode)(expression) >
145
+ util_1.OperatorPrecedence.Unary) {
146
146
  return fixer.insertTextBefore(node, 'void ');
147
147
  }
148
148
  return [
@@ -180,8 +180,8 @@ exports.default = (0, util_1.createRule)({
180
180
  expression.operator === 'void') {
181
181
  return fixer.replaceTextRange([expression.range[0], expression.range[0] + 4], 'await');
182
182
  }
183
- const tsNode = services.esTreeNodeToTSNodeMap.get(node.expression);
184
- if (isHigherPrecedenceThanUnary(tsNode)) {
183
+ if ((0, util_1.isParenthesized)(expression, context.sourceCode) ||
184
+ (0, util_1.getOperatorPrecedenceForNode)(expression) > util_1.OperatorPrecedence.Unary) {
185
185
  return fixer.insertTextBefore(node, 'await ');
186
186
  }
187
187
  return [
@@ -199,13 +199,6 @@ exports.default = (0, util_1.createRule)({
199
199
  }
200
200
  return (0, util_1.typeMatchesSomeSpecifier)(type, allowForKnownSafeCalls, services.program);
201
201
  }
202
- function isHigherPrecedenceThanUnary(node) {
203
- const operator = ts.isBinaryExpression(node)
204
- ? node.operatorToken.kind
205
- : ts.SyntaxKind.Unknown;
206
- const nodePrecedence = (0, util_1.getOperatorPrecedence)(node.kind, operator);
207
- return nodePrecedence > util_1.OperatorPrecedence.Unary;
208
- }
209
202
  function isAsyncIife(node) {
210
203
  if (node.expression.type !== utils_1.AST_NODE_TYPES.CallExpression) {
211
204
  return false;
@@ -28,6 +28,10 @@ export declare enum OperatorPrecedence {
28
28
  Lowest = 0,
29
29
  Invalid = -1
30
30
  }
31
+ /**
32
+ * Note that this does not take into account parenthesization. You should check
33
+ * for parenthesization separately if it's relevant to your usage.
34
+ */
31
35
  export declare function getOperatorPrecedenceForNode(node: TSESTree.Node): OperatorPrecedence;
32
36
  type TSESTreeOperatorKind = ValueOf<TSESTree.BinaryOperatorToText> | ValueOf<TSESTree.PunctuatorTokenToText>;
33
37
  export declare function getOperatorPrecedence(nodeKind: SyntaxKind, operatorKind: SyntaxKind, hasArguments?: boolean): OperatorPrecedence;
@@ -175,6 +175,10 @@ var OperatorPrecedence;
175
175
  // parsing to stop.
176
176
  OperatorPrecedence[OperatorPrecedence["Invalid"] = -1] = "Invalid";
177
177
  })(OperatorPrecedence || (exports.OperatorPrecedence = OperatorPrecedence = {}));
178
+ /**
179
+ * Note that this does not take into account parenthesization. You should check
180
+ * for parenthesization separately if it's relevant to your usage.
181
+ */
178
182
  function getOperatorPrecedenceForNode(node) {
179
183
  switch (node.type) {
180
184
  case utils_1.AST_NODE_TYPES.SpreadElement:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typescript-eslint/eslint-plugin",
3
- "version": "8.45.1-alpha.2",
3
+ "version": "8.45.1-alpha.4",
4
4
  "description": "TypeScript plugin for ESLint",
5
5
  "files": [
6
6
  "dist",
@@ -59,10 +59,10 @@
59
59
  },
60
60
  "dependencies": {
61
61
  "@eslint-community/regexpp": "^4.10.0",
62
- "@typescript-eslint/scope-manager": "8.45.1-alpha.2",
63
- "@typescript-eslint/type-utils": "8.45.1-alpha.2",
64
- "@typescript-eslint/utils": "8.45.1-alpha.2",
65
- "@typescript-eslint/visitor-keys": "8.45.1-alpha.2",
62
+ "@typescript-eslint/scope-manager": "8.45.1-alpha.4",
63
+ "@typescript-eslint/type-utils": "8.45.1-alpha.4",
64
+ "@typescript-eslint/utils": "8.45.1-alpha.4",
65
+ "@typescript-eslint/visitor-keys": "8.45.1-alpha.4",
66
66
  "graphemer": "^1.4.0",
67
67
  "ignore": "^7.0.0",
68
68
  "natural-compare": "^1.4.0",
@@ -71,8 +71,8 @@
71
71
  "devDependencies": {
72
72
  "@types/mdast": "^4.0.3",
73
73
  "@types/natural-compare": "*",
74
- "@typescript-eslint/rule-schema-to-typescript-types": "8.45.1-alpha.2",
75
- "@typescript-eslint/rule-tester": "8.45.1-alpha.2",
74
+ "@typescript-eslint/rule-schema-to-typescript-types": "8.45.1-alpha.4",
75
+ "@typescript-eslint/rule-tester": "8.45.1-alpha.4",
76
76
  "@vitest/coverage-v8": "^3.1.3",
77
77
  "ajv": "^6.12.6",
78
78
  "cross-fetch": "*",
@@ -92,7 +92,7 @@
92
92
  "vitest": "^3.1.3"
93
93
  },
94
94
  "peerDependencies": {
95
- "@typescript-eslint/parser": "^8.45.1-alpha.2",
95
+ "@typescript-eslint/parser": "^8.45.1-alpha.4",
96
96
  "eslint": "^8.57.0 || ^9.0.0",
97
97
  "typescript": ">=4.8.4 <6.0.0"
98
98
  },