@typescript-eslint/eslint-plugin 8.52.1-alpha.8 → 8.53.0

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.
@@ -148,6 +148,7 @@ declare const _default: {
148
148
  'no-return-await': "off";
149
149
  '@typescript-eslint/return-await': "error";
150
150
  '@typescript-eslint/strict-boolean-expressions': "error";
151
+ '@typescript-eslint/strict-void-return': "error";
151
152
  '@typescript-eslint/switch-exhaustiveness-check': "error";
152
153
  '@typescript-eslint/triple-slash-reference': "error";
153
154
  '@typescript-eslint/unbound-method': "error";
@@ -155,6 +155,7 @@ module.exports = {
155
155
  'no-return-await': 'off',
156
156
  '@typescript-eslint/return-await': 'error',
157
157
  '@typescript-eslint/strict-boolean-expressions': 'error',
158
+ '@typescript-eslint/strict-void-return': 'error',
158
159
  '@typescript-eslint/switch-exhaustiveness-check': 'error',
159
160
  '@typescript-eslint/triple-slash-reference': 'error',
160
161
  '@typescript-eslint/unbound-method': 'error',
@@ -62,6 +62,7 @@ declare const _default: {
62
62
  '@typescript-eslint/restrict-template-expressions': "off";
63
63
  '@typescript-eslint/return-await': "off";
64
64
  '@typescript-eslint/strict-boolean-expressions': "off";
65
+ '@typescript-eslint/strict-void-return': "off";
65
66
  '@typescript-eslint/switch-exhaustiveness-check': "off";
66
67
  '@typescript-eslint/unbound-method': "off";
67
68
  '@typescript-eslint/use-unknown-in-catch-callback-variable': "off";
@@ -65,6 +65,7 @@ module.exports = {
65
65
  '@typescript-eslint/restrict-template-expressions': 'off',
66
66
  '@typescript-eslint/return-await': 'off',
67
67
  '@typescript-eslint/strict-boolean-expressions': 'off',
68
+ '@typescript-eslint/strict-void-return': 'off',
68
69
  '@typescript-eslint/switch-exhaustiveness-check': 'off',
69
70
  '@typescript-eslint/unbound-method': 'off',
70
71
  '@typescript-eslint/use-unknown-in-catch-callback-variable': 'off',
@@ -168,6 +168,7 @@ exports.default = (plugin, parser) => [
168
168
  'no-return-await': 'off',
169
169
  '@typescript-eslint/return-await': 'error',
170
170
  '@typescript-eslint/strict-boolean-expressions': 'error',
171
+ '@typescript-eslint/strict-void-return': 'error',
171
172
  '@typescript-eslint/switch-exhaustiveness-check': 'error',
172
173
  '@typescript-eslint/triple-slash-reference': 'error',
173
174
  '@typescript-eslint/unbound-method': 'error',
@@ -70,6 +70,7 @@ exports.default = (_plugin, _parser) => ({
70
70
  '@typescript-eslint/restrict-template-expressions': 'off',
71
71
  '@typescript-eslint/return-await': 'off',
72
72
  '@typescript-eslint/strict-boolean-expressions': 'off',
73
+ '@typescript-eslint/strict-void-return': 'off',
73
74
  '@typescript-eslint/switch-exhaustiveness-check': 'off',
74
75
  '@typescript-eslint/unbound-method': 'off',
75
76
  '@typescript-eslint/use-unknown-in-catch-callback-variable': 'off',
package/dist/index.d.ts CHANGED
@@ -150,6 +150,7 @@ declare const _default: {
150
150
  'no-return-await': "off";
151
151
  '@typescript-eslint/return-await': "error";
152
152
  '@typescript-eslint/strict-boolean-expressions': "error";
153
+ '@typescript-eslint/strict-void-return': "error";
153
154
  '@typescript-eslint/switch-exhaustiveness-check': "error";
154
155
  '@typescript-eslint/triple-slash-reference': "error";
155
156
  '@typescript-eslint/unbound-method': "error";
@@ -228,6 +229,7 @@ declare const _default: {
228
229
  '@typescript-eslint/restrict-template-expressions': "off";
229
230
  '@typescript-eslint/return-await': "off";
230
231
  '@typescript-eslint/strict-boolean-expressions': "off";
232
+ '@typescript-eslint/strict-void-return': "off";
231
233
  '@typescript-eslint/switch-exhaustiveness-check': "off";
232
234
  '@typescript-eslint/unbound-method': "off";
233
235
  '@typescript-eslint/use-unknown-in-catch-callback-variable': "off";
@@ -1096,6 +1098,11 @@ declare const _default: {
1096
1098
  'strict-boolean-expressions': import("@typescript-eslint/utils/ts-eslint").RuleModule<import("./rules/strict-boolean-expressions").MessageId, import("./rules/strict-boolean-expressions").Options, import("../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
1097
1099
  name: string;
1098
1100
  };
1101
+ 'strict-void-return': import("@typescript-eslint/utils/ts-eslint").RuleModule<"asyncFunc" | "nonVoidFunc" | "nonVoidReturn", [{
1102
+ allowReturnAny?: boolean;
1103
+ }], import("../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
1104
+ name: string;
1105
+ };
1099
1106
  'switch-exhaustiveness-check': import("@typescript-eslint/utils/ts-eslint").RuleModule<import("./rules/switch-exhaustiveness-check").MessageIds, import("./rules/switch-exhaustiveness-check").Options, import("../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
1100
1107
  name: string;
1101
1108
  };
@@ -172,6 +172,7 @@ declare const _default: {
172
172
  'no-return-await': "off";
173
173
  '@typescript-eslint/return-await': "error";
174
174
  '@typescript-eslint/strict-boolean-expressions': "error";
175
+ '@typescript-eslint/strict-void-return': "error";
175
176
  '@typescript-eslint/switch-exhaustiveness-check': "error";
176
177
  '@typescript-eslint/triple-slash-reference': "error";
177
178
  '@typescript-eslint/unbound-method': "error";
@@ -250,6 +251,7 @@ declare const _default: {
250
251
  '@typescript-eslint/restrict-template-expressions': "off";
251
252
  '@typescript-eslint/return-await': "off";
252
253
  '@typescript-eslint/strict-boolean-expressions': "off";
254
+ '@typescript-eslint/strict-void-return': "off";
253
255
  '@typescript-eslint/switch-exhaustiveness-check': "off";
254
256
  '@typescript-eslint/unbound-method': "off";
255
257
  '@typescript-eslint/use-unknown-in-catch-callback-variable': "off";
@@ -1119,6 +1121,11 @@ declare const _default: {
1119
1121
  'strict-boolean-expressions': TSESLint.RuleModule<import("./rules/strict-boolean-expressions").MessageId, import("./rules/strict-boolean-expressions").Options, import("../rules").ESLintPluginDocs, TSESLint.RuleListener> & {
1120
1122
  name: string;
1121
1123
  };
1124
+ 'strict-void-return': TSESLint.RuleModule<"asyncFunc" | "nonVoidFunc" | "nonVoidReturn", [{
1125
+ allowReturnAny?: boolean;
1126
+ }], import("../rules").ESLintPluginDocs, TSESLint.RuleListener> & {
1127
+ name: string;
1128
+ };
1122
1129
  'switch-exhaustiveness-check': TSESLint.RuleModule<import("./rules/switch-exhaustiveness-check").MessageIds, import("./rules/switch-exhaustiveness-check").Options, import("../rules").ESLintPluginDocs, TSESLint.RuleListener> & {
1123
1130
  name: string;
1124
1131
  };
@@ -419,6 +419,11 @@ declare const rules: {
419
419
  'strict-boolean-expressions': import("@typescript-eslint/utils/ts-eslint").RuleModule<import("./strict-boolean-expressions").MessageId, import("./strict-boolean-expressions").Options, import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
420
420
  name: string;
421
421
  };
422
+ 'strict-void-return': import("@typescript-eslint/utils/ts-eslint").RuleModule<"asyncFunc" | "nonVoidFunc" | "nonVoidReturn", [{
423
+ allowReturnAny?: boolean;
424
+ }], import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
425
+ name: string;
426
+ };
422
427
  'switch-exhaustiveness-check': import("@typescript-eslint/utils/ts-eslint").RuleModule<import("./switch-exhaustiveness-check").MessageIds, import("./switch-exhaustiveness-check").Options, import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
423
428
  name: string;
424
429
  };
@@ -129,6 +129,7 @@ const restrict_template_expressions_1 = __importDefault(require("./restrict-temp
129
129
  const return_await_1 = __importDefault(require("./return-await"));
130
130
  const sort_type_constituents_1 = __importDefault(require("./sort-type-constituents"));
131
131
  const strict_boolean_expressions_1 = __importDefault(require("./strict-boolean-expressions"));
132
+ const strict_void_return_1 = __importDefault(require("./strict-void-return"));
132
133
  const switch_exhaustiveness_check_1 = __importDefault(require("./switch-exhaustiveness-check"));
133
134
  const triple_slash_reference_1 = __importDefault(require("./triple-slash-reference"));
134
135
  const typedef_1 = __importDefault(require("./typedef"));
@@ -263,6 +264,7 @@ const rules = {
263
264
  'return-await': return_await_1.default,
264
265
  'sort-type-constituents': sort_type_constituents_1.default,
265
266
  'strict-boolean-expressions': strict_boolean_expressions_1.default,
267
+ 'strict-void-return': strict_void_return_1.default,
266
268
  'switch-exhaustiveness-check': switch_exhaustiveness_check_1.default,
267
269
  'triple-slash-reference': triple_slash_reference_1.default,
268
270
  typedef: typedef_1.default,
@@ -1,4 +1,4 @@
1
- export type MessageIds = 'unsafeCall' | 'unsafeCallThis' | 'unsafeNew' | 'unsafeTemplateTag';
1
+ export type MessageIds = 'errorCall' | 'errorCallThis' | 'errorNew' | 'errorTemplateTag' | 'unsafeCall' | 'unsafeCallThis' | 'unsafeNew' | 'unsafeTemplateTag';
2
2
  declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<MessageIds, [], import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
3
3
  name: string;
4
4
  };
@@ -45,13 +45,17 @@ exports.default = (0, util_1.createRule)({
45
45
  requiresTypeChecking: true,
46
46
  },
47
47
  messages: {
48
- unsafeCall: 'Unsafe call of a(n) {{type}} typed value.',
48
+ errorCall: 'Unsafe call of a type that could not be resolved.',
49
+ errorCallThis: 'Unsafe call of a `this` type that could not be resolved.',
50
+ errorNew: 'Unsafe construction of a type that could not be resolved.',
51
+ errorTemplateTag: 'Unsafe use of a template tag whose type could not be resolved.',
52
+ unsafeCall: 'Unsafe call of {{type}} typed value.',
49
53
  unsafeCallThis: [
50
- 'Unsafe call of a(n) {{type}} typed value. `this` is typed as {{type}}.',
54
+ 'Unsafe call of {{type}} typed value. `this` is typed as {{type}}.',
51
55
  'You can try to fix this by turning on the `noImplicitThis` compiler option, or adding a `this` parameter to the function.',
52
56
  ].join('\n'),
53
- unsafeNew: 'Unsafe construction of a(n) {{type}} typed value.',
54
- unsafeTemplateTag: 'Unsafe use of a(n) {{type}} typed template tag.',
57
+ unsafeNew: 'Unsafe construction of {{type}} typed value.',
58
+ unsafeTemplateTag: 'Unsafe use of {{type}} typed template tag.',
55
59
  },
56
60
  schema: [],
57
61
  },
@@ -60,7 +64,7 @@ exports.default = (0, util_1.createRule)({
60
64
  const services = (0, util_1.getParserServices)(context);
61
65
  const compilerOptions = services.program.getCompilerOptions();
62
66
  const isNoImplicitThis = tsutils.isStrictCompilerOptionEnabled(compilerOptions, 'noImplicitThis');
63
- function checkCall(node, reportingNode, messageId) {
67
+ function checkCall(node, reportingNode, unsafeMessageId, errorMessageId) {
64
68
  const type = (0, util_1.getConstrainedTypeAtLocation)(services, node);
65
69
  if ((0, util_1.isTypeAnyType)(type)) {
66
70
  if (!isNoImplicitThis) {
@@ -68,15 +72,16 @@ exports.default = (0, util_1.createRule)({
68
72
  const thisExpression = (0, util_1.getThisExpression)(node);
69
73
  if (thisExpression &&
70
74
  (0, util_1.isTypeAnyType)((0, util_1.getConstrainedTypeAtLocation)(services, thisExpression))) {
71
- messageId = 'unsafeCallThis';
75
+ unsafeMessageId = 'unsafeCallThis';
76
+ errorMessageId = 'errorCallThis';
72
77
  }
73
78
  }
74
79
  const isErrorType = tsutils.isIntrinsicErrorType(type);
75
80
  context.report({
76
81
  node: reportingNode,
77
- messageId,
82
+ messageId: isErrorType ? errorMessageId : unsafeMessageId,
78
83
  data: {
79
- type: isErrorType ? '`error` type' : '`any`',
84
+ type: 'an `any`',
80
85
  },
81
86
  });
82
87
  return;
@@ -98,7 +103,7 @@ exports.default = (0, util_1.createRule)({
98
103
  return;
99
104
  }
100
105
  const callSignatures = type.getCallSignatures();
101
- if (messageId === 'unsafeNew') {
106
+ if (unsafeMessageId === 'unsafeNew') {
102
107
  if (callSignatures.some(signature => !tsutils.isIntrinsicVoidType(signature.getReturnType()))) {
103
108
  return;
104
109
  }
@@ -108,9 +113,9 @@ exports.default = (0, util_1.createRule)({
108
113
  }
109
114
  context.report({
110
115
  node: reportingNode,
111
- messageId,
116
+ messageId: unsafeMessageId,
112
117
  data: {
113
- type: '`Function`',
118
+ type: 'a `Function`',
114
119
  },
115
120
  });
116
121
  return;
@@ -118,13 +123,13 @@ exports.default = (0, util_1.createRule)({
118
123
  }
119
124
  return {
120
125
  'CallExpression > *.callee'(node) {
121
- checkCall(node, node, 'unsafeCall');
126
+ checkCall(node, node, 'unsafeCall', 'errorCall');
122
127
  },
123
128
  NewExpression(node) {
124
- checkCall(node.callee, node, 'unsafeNew');
129
+ checkCall(node.callee, node, 'unsafeNew', 'errorNew');
125
130
  },
126
131
  'TaggedTemplateExpression > *.tag'(node) {
127
- checkCall(node, node, 'unsafeTemplateTag');
132
+ checkCall(node, node, 'unsafeTemplateTag', 'errorTemplateTag');
128
133
  },
129
134
  };
130
135
  },
@@ -3,7 +3,7 @@ export type Options = [
3
3
  allowOptionalChaining?: boolean;
4
4
  }
5
5
  ];
6
- export type MessageIds = 'unsafeComputedMemberAccess' | 'unsafeMemberExpression' | 'unsafeThisMemberExpression';
6
+ export type MessageIds = 'errorComputedMemberAccess' | 'errorMemberExpression' | 'errorThisMemberExpression' | 'unsafeComputedMemberAccess' | 'unsafeMemberExpression' | 'unsafeThisMemberExpression';
7
7
  declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<MessageIds, Options, import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
8
8
  name: string;
9
9
  };
@@ -42,10 +42,6 @@ var State;
42
42
  State[State["Safe"] = 2] = "Safe";
43
43
  State[State["Chained"] = 3] = "Chained";
44
44
  })(State || (State = {}));
45
- function createDataType(type) {
46
- const isErrorType = tsutils.isIntrinsicErrorType(type);
47
- return isErrorType ? '`error` typed' : '`any`';
48
- }
49
45
  exports.default = (0, util_1.createRule)({
50
46
  name: 'no-unsafe-member-access',
51
47
  meta: {
@@ -56,8 +52,14 @@ exports.default = (0, util_1.createRule)({
56
52
  requiresTypeChecking: true,
57
53
  },
58
54
  messages: {
59
- unsafeComputedMemberAccess: 'Computed name {{property}} resolves to an {{type}} value.',
60
- unsafeMemberExpression: 'Unsafe member access {{property}} on an {{type}} value.',
55
+ errorComputedMemberAccess: 'The type of computed name {{property}} cannot be resolved.',
56
+ errorMemberExpression: 'Unsafe member access {{property}} on a type that cannot be resolved.',
57
+ errorThisMemberExpression: [
58
+ 'Unsafe member access {{property}}. The type of `this` cannot be resolved.',
59
+ 'You can try to fix this by turning on the `noImplicitThis` compiler option, or adding a `this` parameter to the function.',
60
+ ].join('\n'),
61
+ unsafeComputedMemberAccess: 'Computed name {{property}} resolves to an `any` value.',
62
+ unsafeMemberExpression: 'Unsafe member access {{property}} on an `any` value.',
61
63
  unsafeThisMemberExpression: [
62
64
  'Unsafe member access {{property}} on an `any` value. `this` is typed as `any`.',
63
65
  'You can try to fix this by turning on the `noImplicitThis` compiler option, or adding a `this` parameter to the function.',
@@ -116,20 +118,28 @@ exports.default = (0, util_1.createRule)({
116
118
  stateCache.set(node, state);
117
119
  if (state === State.Unsafe) {
118
120
  const propertyName = context.sourceCode.getText(node.property);
119
- let messageId = 'unsafeMemberExpression';
121
+ let messageId;
120
122
  if (!isNoImplicitThis) {
121
123
  // `this.foo` or `this.foo[bar]`
122
124
  const thisExpression = (0, util_1.getThisExpression)(node);
123
- if (thisExpression &&
124
- (0, util_1.isTypeAnyType)((0, util_1.getConstrainedTypeAtLocation)(services, thisExpression))) {
125
- messageId = 'unsafeThisMemberExpression';
125
+ if (thisExpression) {
126
+ const thisType = (0, util_1.getConstrainedTypeAtLocation)(services, thisExpression);
127
+ if ((0, util_1.isTypeAnyType)(thisType)) {
128
+ messageId = tsutils.isIntrinsicErrorType(thisType)
129
+ ? 'errorThisMemberExpression'
130
+ : 'unsafeThisMemberExpression';
131
+ }
126
132
  }
127
133
  }
134
+ if (!messageId) {
135
+ messageId = tsutils.isIntrinsicErrorType(type)
136
+ ? 'errorMemberExpression'
137
+ : 'unsafeMemberExpression';
138
+ }
128
139
  context.report({
129
140
  node: node.property,
130
141
  messageId,
131
142
  data: {
132
- type: createDataType(type),
133
143
  property: node.computed ? `[${propertyName}]` : `.${propertyName}`,
134
144
  },
135
145
  });
@@ -159,9 +169,10 @@ exports.default = (0, util_1.createRule)({
159
169
  const propertyName = context.sourceCode.getText(node);
160
170
  context.report({
161
171
  node,
162
- messageId: 'unsafeComputedMemberAccess',
172
+ messageId: tsutils.isIntrinsicErrorType(type)
173
+ ? 'errorComputedMemberAccess'
174
+ : 'unsafeComputedMemberAccess',
163
175
  data: {
164
- type: createDataType(type),
165
176
  property: `[${propertyName}]`,
166
177
  },
167
178
  });
@@ -1,5 +1,5 @@
1
1
  import { TSESLint } from '@typescript-eslint/utils';
2
- export type MessageIds = 'unusedVar' | 'usedIgnoredVar' | 'usedOnlyAsType';
2
+ export type MessageIds = 'removeUnusedImportDeclaration' | 'removeUnusedVar' | 'unusedVar' | 'usedIgnoredVar' | 'usedOnlyAsType';
3
3
  export type Options = [
4
4
  'all' | 'local' | {
5
5
  args?: 'after-used' | 'all' | 'none';
@@ -7,6 +7,9 @@ export type Options = [
7
7
  caughtErrors?: 'all' | 'none';
8
8
  caughtErrorsIgnorePattern?: string;
9
9
  destructuredArrayIgnorePattern?: string;
10
+ enableAutofixRemoval?: {
11
+ imports?: boolean;
12
+ };
10
13
  ignoreClassWithStaticInitBlock?: boolean;
11
14
  ignoreRestSiblings?: boolean;
12
15
  ignoreUsingDeclarations?: boolean;