@typescript-eslint/eslint-plugin 8.73.1-alpha.3 → 8.73.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.
@@ -83,12 +83,16 @@ exports.default = (0, util_1.createRule)({
83
83
  node.type !== utils_1.AST_NODE_TYPES.AccessorProperty) {
84
84
  return lhsName;
85
85
  }
86
- if (!node.computed) {
87
- return node.key;
88
- }
89
86
  // If the property's computed, we have to attach the
90
87
  // annotation after the square bracket, not the enclosed expression
91
- return (0, util_1.nullThrows)(context.sourceCode.getTokenAfter(node.key), util_1.NullThrowsReasons.MissingToken(']', 'key'));
88
+ const keyEnd = node.computed
89
+ ? (0, util_1.nullThrows)(context.sourceCode.getTokenAfter(node.key), util_1.NullThrowsReasons.MissingToken(']', 'key'))
90
+ : node.key;
91
+ if (!node.optional) {
92
+ return keyEnd;
93
+ }
94
+ // An optional property's annotation goes after the `?`
95
+ return (0, util_1.nullThrows)(context.sourceCode.getTokenAfter(keyEnd), util_1.NullThrowsReasons.MissingToken('?', 'key'));
92
96
  }
93
97
  return [
94
98
  fixer.remove(typeArguments),
@@ -112,7 +116,10 @@ exports.default = (0, util_1.createRule)({
112
116
  *fix(fixer) {
113
117
  yield fixer.remove(lhs.parent);
114
118
  for (const comment of extraComments) {
115
- yield fixer.insertTextAfter(rhs.callee, context.sourceCode.getText(comment));
119
+ // A line comment runs to the end of the line, so it needs a
120
+ // line break to keep the type arguments out of it
121
+ const suffix = comment.type === utils_1.AST_TOKEN_TYPES.Line ? '\n' : '';
122
+ yield fixer.insertTextAfter(rhs.callee, context.sourceCode.getText(comment) + suffix);
116
123
  }
117
124
  yield fixer.insertTextAfter(rhs.callee, context.sourceCode.getText(lhs.typeArguments));
118
125
  if (!hasParens) {
@@ -306,7 +306,7 @@ exports.default = (0, util_1.createRule)({
306
306
  const receiverTypes = checker
307
307
  .getSymbolAtLocation(services.esTreeNodeToTSNodeMap.get(node).expression)
308
308
  ?.declarations?.flatMap(declaration => getMappedKeyConstraintTypes(checker, declaration)) ?? [];
309
- if (receiverTypes.length === 0) {
309
+ if (!receiverTypes.some(receiverType => (0, shared_1.getEnumTypes)(checker, receiverType).length > 0)) {
310
310
  return;
311
311
  }
312
312
  // declare const foo: { [key in Fruit]: string };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typescript-eslint/eslint-plugin",
3
- "version": "8.73.1-alpha.3",
3
+ "version": "8.73.1-alpha.4",
4
4
  "description": "TypeScript plugin for ESLint",
5
5
  "files": [
6
6
  "dist",
@@ -47,10 +47,10 @@
47
47
  ],
48
48
  "dependencies": {
49
49
  "@eslint-community/regexpp": "^4.12.2",
50
- "@typescript-eslint/scope-manager": "8.73.1-alpha.3",
51
- "@typescript-eslint/type-utils": "8.73.1-alpha.3",
52
- "@typescript-eslint/utils": "8.73.1-alpha.3",
53
- "@typescript-eslint/visitor-keys": "8.73.1-alpha.3",
50
+ "@typescript-eslint/scope-manager": "8.73.1-alpha.4",
51
+ "@typescript-eslint/type-utils": "8.73.1-alpha.4",
52
+ "@typescript-eslint/utils": "8.73.1-alpha.4",
53
+ "@typescript-eslint/visitor-keys": "8.73.1-alpha.4",
54
54
  "ignore": "^7.0.5",
55
55
  "natural-compare": "^1.4.0",
56
56
  "ts-api-utils": "^2.5.0"
@@ -60,8 +60,8 @@
60
60
  "@types/mdast": "^4.0.4",
61
61
  "@types/natural-compare": "^1.4.3",
62
62
  "@types/react": "^18.3.21",
63
- "@typescript-eslint/rule-schema-to-typescript-types": "8.73.1-alpha.3",
64
- "@typescript-eslint/rule-tester": "8.73.1-alpha.3",
63
+ "@typescript-eslint/rule-schema-to-typescript-types": "8.73.1-alpha.4",
64
+ "@typescript-eslint/rule-tester": "8.73.1-alpha.4",
65
65
  "@typescript/native": "npm:typescript@7.1.0-dev.20261009.1",
66
66
  "@vitest/coverage-v8": "^5.0.3",
67
67
  "ajv": "^6.12.6",
@@ -81,7 +81,7 @@
81
81
  "vitest": "^5.0.3"
82
82
  },
83
83
  "peerDependencies": {
84
- "@typescript-eslint/parser": "^8.73.1-alpha.3",
84
+ "@typescript-eslint/parser": "^8.73.1-alpha.4",
85
85
  "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0",
86
86
  "typescript": ">=4.8.4 <6.1.0"
87
87
  },