@typescript-eslint/eslint-plugin 8.42.1-alpha.8 → 8.43.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.
- package/dist/rules/array-type.js +1 -1
- package/dist/rules/consistent-type-exports.d.ts.map +1 -1
- package/dist/rules/consistent-type-exports.js +7 -8
- package/dist/rules/default-param-last.d.ts.map +1 -1
- package/dist/rules/default-param-last.js +1 -0
- package/dist/rules/dot-notation.d.ts.map +1 -1
- package/dist/rules/dot-notation.js +1 -0
- package/dist/rules/init-declarations.d.ts.map +1 -1
- package/dist/rules/init-declarations.js +1 -0
- package/dist/rules/member-ordering.d.ts.map +1 -1
- package/dist/rules/member-ordering.js +1 -0
- package/dist/rules/naming-convention.d.ts.map +1 -1
- package/dist/rules/naming-convention.js +1 -0
- package/dist/rules/no-confusing-void-expression.d.ts.map +1 -1
- package/dist/rules/no-confusing-void-expression.js +3 -3
- package/dist/rules/no-deprecated.d.ts.map +1 -1
- package/dist/rules/no-deprecated.js +24 -5
- package/dist/rules/no-floating-promises.d.ts.map +1 -1
- package/dist/rules/no-floating-promises.js +5 -2
- package/dist/rules/no-magic-numbers.d.ts.map +1 -1
- package/dist/rules/no-magic-numbers.js +1 -0
- package/dist/rules/no-unnecessary-type-conversion.d.ts.map +1 -1
- package/dist/rules/no-unnecessary-type-conversion.js +37 -1
- package/dist/rules/prefer-destructuring.d.ts.map +1 -1
- package/dist/rules/prefer-destructuring.js +1 -0
- package/dist/rules/prefer-return-this-type.d.ts.map +1 -1
- package/dist/rules/prefer-return-this-type.js +6 -0
- package/dist/util/collectUnusedVariables.d.ts.map +1 -1
- package/dist/util/collectUnusedVariables.js +2 -4
- package/package.json +8 -8
package/dist/rules/array-type.js
CHANGED
@@ -184,7 +184,7 @@ exports.default = (0, util_1.createRule)({
|
|
184
184
|
: isReadonlyArrayType && node.typeName.name !== 'ReadonlyArray'
|
185
185
|
? 'errorStringArraySimpleReadonly'
|
186
186
|
: 'errorStringArraySimple';
|
187
|
-
if (!typeParams
|
187
|
+
if (!typeParams) {
|
188
188
|
// Create an 'any' array
|
189
189
|
context.report({
|
190
190
|
node,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"consistent-type-exports.d.ts","sourceRoot":"","sources":["../../src/rules/consistent-type-exports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAY,MAAM,0BAA0B,CAAC;
|
1
|
+
{"version":3,"file":"consistent-type-exports.d.ts","sourceRoot":"","sources":["../../src/rules/consistent-type-exports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAY,MAAM,0BAA0B,CAAC;AAenE,MAAM,MAAM,OAAO,GAAG;IACpB;QACE,sCAAsC,EAAE,OAAO,CAAC;KACjD;CACF,CAAC;AAgBF,MAAM,MAAM,UAAU,GAClB,yBAAyB,GACzB,oBAAoB,GACpB,eAAe,CAAC;;AAEpB,wBA0RG"}
|
@@ -34,7 +34,6 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
34
34
|
})();
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
36
36
|
const utils_1 = require("@typescript-eslint/utils");
|
37
|
-
const tsutils = __importStar(require("ts-api-utils"));
|
38
37
|
const ts = __importStar(require("typescript"));
|
39
38
|
const util_1 = require("../util");
|
40
39
|
exports.default = (0, util_1.createRule)({
|
@@ -81,16 +80,16 @@ exports.default = (0, util_1.createRule)({
|
|
81
80
|
* can't be resolved.
|
82
81
|
*/
|
83
82
|
function isSymbolTypeBased(symbol) {
|
84
|
-
|
85
|
-
|
83
|
+
while (symbol && symbol.flags & ts.SymbolFlags.Alias) {
|
84
|
+
symbol = checker.getAliasedSymbol(symbol);
|
85
|
+
if (symbol.getDeclarations()?.find(ts.isTypeOnlyImportOrExportDeclaration)) {
|
86
|
+
return true;
|
87
|
+
}
|
86
88
|
}
|
87
|
-
|
88
|
-
? checker.getAliasedSymbol(symbol)
|
89
|
-
: symbol;
|
90
|
-
if (checker.isUnknownSymbol(aliasedSymbol)) {
|
89
|
+
if (!symbol || checker.isUnknownSymbol(symbol)) {
|
91
90
|
return undefined;
|
92
91
|
}
|
93
|
-
return !(
|
92
|
+
return !(symbol.flags & ts.SymbolFlags.Value);
|
94
93
|
}
|
95
94
|
return {
|
96
95
|
ExportAllDeclaration(node) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"default-param-last.d.ts","sourceRoot":"","sources":["../../src/rules/default-param-last.ts"],"names":[],"mappings":";AAMA,
|
1
|
+
{"version":3,"file":"default-param-last.d.ts","sourceRoot":"","sources":["../../src/rules/default-param-last.ts"],"names":[],"mappings":";AAMA,wBAgFG"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"dot-notation.d.ts","sourceRoot":"","sources":["../../src/rules/dot-notation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAMzD,OAAO,KAAK,EACV,2BAA2B,EAC3B,wBAAwB,EACzB,MAAM,SAAS,CAAC;AAKjB,QAAA,MAAM,QAAQ;;;;;;;;EAAoC,CAAC;AAEnD,MAAM,MAAM,OAAO,GAAG,wBAAwB,CAAC,OAAO,QAAQ,CAAC,CAAC;AAChE,MAAM,MAAM,UAAU,GAAG,2BAA2B,CAAC,OAAO,QAAQ,CAAC,CAAC;;;;;;;;AAYtE,
|
1
|
+
{"version":3,"file":"dot-notation.d.ts","sourceRoot":"","sources":["../../src/rules/dot-notation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAMzD,OAAO,KAAK,EACV,2BAA2B,EAC3B,wBAAwB,EACzB,MAAM,SAAS,CAAC;AAKjB,QAAA,MAAM,QAAQ;;;;;;;;EAAoC,CAAC;AAEnD,MAAM,MAAM,OAAO,GAAG,wBAAwB,CAAC,OAAO,QAAQ,CAAC,CAAC;AAChE,MAAM,MAAM,UAAU,GAAG,2BAA2B,CAAC,OAAO,QAAQ,CAAC,CAAC;;;;;;;;AAYtE,wBAgHG"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"init-declarations.d.ts","sourceRoot":"","sources":["../../src/rules/init-declarations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAIzD,OAAO,KAAK,EACV,2BAA2B,EAC3B,wBAAwB,EACzB,MAAM,SAAS,CAAC;AAKjB,QAAA,MAAM,QAAQ;;;;EAAyC,CAAC;AAExD,MAAM,MAAM,OAAO,GAAG,wBAAwB,CAAC,OAAO,QAAQ,CAAC,CAAC;AAChE,MAAM,MAAM,UAAU,GAAG,2BAA2B,CAAC,OAAO,QAAQ,CAAC,CAAC;;;;AAEtE,
|
1
|
+
{"version":3,"file":"init-declarations.d.ts","sourceRoot":"","sources":["../../src/rules/init-declarations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAIzD,OAAO,KAAK,EACV,2BAA2B,EAC3B,wBAAwB,EACzB,MAAM,SAAS,CAAC;AAKjB,QAAA,MAAM,QAAQ;;;;EAAyC,CAAC;AAExD,MAAM,MAAM,OAAO,GAAG,wBAAwB,CAAC,OAAO,QAAQ,CAAC,CAAC;AAChE,MAAM,MAAM,UAAU,GAAG,2BAA2B,CAAC,OAAO,QAAQ,CAAC,CAAC;;;;AAEtE,wBAiGG"}
|
@@ -12,6 +12,7 @@ exports.default = (0, util_1.createRule)({
|
|
12
12
|
docs: {
|
13
13
|
description: 'Require or disallow initialization in variable declarations',
|
14
14
|
extendsBaseRule: true,
|
15
|
+
frozen: true,
|
15
16
|
},
|
16
17
|
hasSuggestions: baseRule.meta.hasSuggestions,
|
17
18
|
messages: baseRule.meta.messages,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"member-ordering.d.ts","sourceRoot":"","sources":["../../src/rules/member-ordering.ts"],"names":[],"mappings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AK,aAAa,GAAG,UAAU,GAAG,QAAQ,CAAC,aAAa,CAAC;AAEzD,KAAK,cAAc,GACf,GAAG,aAAa,IAAI,OAAO,CACzB,UAAU,EACV,oBAAoB,GAAG,WAAW,GAAG,uBAAuB,CAC7D,EAAE,GACH,GAAG,aAAa,IAAI,WAAW,IAAI,qBAAqB,EAAE,GAC1D,GAAG,aAAa,cAAc,mBAAmB,EAAE,GACnD,GAAG,WAAW,IAAI,qBAAqB,EAAE,GACzC,aAAa,mBAAmB,EAAE,GAClC,UAAU,CAAC;AAEf,KAAK,UAAU,GAAG,cAAc,GAAG,cAAc,EAAE,CAAC;AAEpD,KAAK,iBAAiB,GAClB,gBAAgB,GAChB,iCAAiC,GACjC,SAAS,GACT,0BAA0B,CAAC;AAE/B,KAAK,KAAK,GAAG,YAAY,GAAG,iBAAiB,CAAC;AAE9C,UAAU,iBAAiB;IACzB,WAAW,CAAC,EAAE,OAAO,GAAG,UAAU,EAAE,CAAC;IACrC,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAED,KAAK,WAAW,GAAG,OAAO,GAAG,UAAU,EAAE,GAAG,iBAAiB,CAAC;AAG9D,KAAK,gBAAgB,GAAG,gBAAgB,GAAG,gBAAgB,CAAC;AAE5D,MAAM,MAAM,OAAO,GAAG;IACpB;QACE,OAAO,CAAC,EAAE,WAAW,CAAC;QACtB,gBAAgB,CAAC,EAAE,WAAW,CAAC;QAC/B,OAAO,CAAC,EAAE,WAAW,CAAC;QACtB,UAAU,CAAC,EAAE,WAAW,CAAC;QACzB,YAAY,CAAC,EAAE,WAAW,CAAC;KAC5B;CACF,CAAC;AAwCF,eAAO,MAAM,YAAY,EAAE,UAAU,EAyKpC,CAAC;;AAwaF,wBA4YG"}
|
@@ -519,6 +519,7 @@ exports.default = (0, util_1.createRule)({
|
|
519
519
|
type: 'suggestion',
|
520
520
|
docs: {
|
521
521
|
description: 'Require a consistent member declaration order',
|
522
|
+
frozen: true,
|
522
523
|
},
|
523
524
|
messages: {
|
524
525
|
incorrectGroupOrder: 'Member {{name}} should be declared before all {{rank}} definitions.',
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"naming-convention.d.ts","sourceRoot":"","sources":["../../src/rules/naming-convention.ts"],"names":[],"mappings":"AAOA,OAAO,EAAkB,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEpE,OAAO,KAAK,EAEV,QAAQ,EAET,MAAM,2BAA2B,CAAC;AAUnC,MAAM,MAAM,UAAU,GAClB,oBAAoB,GACpB,2BAA2B,GAC3B,cAAc,GACd,mBAAmB,GACnB,eAAe,GACf,sBAAsB,CAAC;AAK3B,MAAM,MAAM,OAAO,GAAG,QAAQ,EAAE,CAAC;;AA8BjC,
|
1
|
+
{"version":3,"file":"naming-convention.d.ts","sourceRoot":"","sources":["../../src/rules/naming-convention.ts"],"names":[],"mappings":"AAOA,OAAO,EAAkB,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEpE,OAAO,KAAK,EAEV,QAAQ,EAET,MAAM,2BAA2B,CAAC;AAUnC,MAAM,MAAM,UAAU,GAClB,oBAAoB,GACpB,2BAA2B,GAC3B,cAAc,GACd,mBAAmB,GACnB,eAAe,GACf,sBAAsB,CAAC;AAK3B,MAAM,MAAM,OAAO,GAAG,QAAQ,EAAE,CAAC;;AA8BjC,wBAopBG"}
|
@@ -37,6 +37,7 @@ exports.default = (0, util_1.createRule)({
|
|
37
37
|
docs: {
|
38
38
|
description: 'Enforce naming conventions for everything across a codebase',
|
39
39
|
// technically only requires type checking if the user uses "type" modifiers
|
40
|
+
frozen: true,
|
40
41
|
requiresTypeChecking: true,
|
41
42
|
},
|
42
43
|
messages: {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"no-confusing-void-expression.d.ts","sourceRoot":"","sources":["../../src/rules/no-confusing-void-expression.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
1
|
+
{"version":3,"file":"no-confusing-void-expression.d.ts","sourceRoot":"","sources":["../../src/rules/no-confusing-void-expression.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,QAAQ,EAET,MAAM,0BAA0B,CAAC;AAoBlC,MAAM,MAAM,OAAO,GAAG;IACpB;QACE,oBAAoB,CAAC,EAAE,OAAO,CAAC;QAC/B,kBAAkB,CAAC,EAAE,OAAO,CAAC;QAC7B,4BAA4B,CAAC,EAAE,OAAO,CAAC;KACxC;CACF,CAAC;AAEF,MAAM,MAAM,SAAS,GACjB,iBAAiB,GACjB,sBAAsB,GACtB,8BAA8B,GAC9B,uBAAuB,GACvB,2BAA2B,GAC3B,+BAA+B,GAC/B,yBAAyB,GACzB,kBAAkB,CAAC;;AAEvB,wBAibG"}
|
@@ -236,7 +236,7 @@ exports.default = (0, util_1.createRule)({
|
|
236
236
|
* @returns Invalid ancestor node if it was found. `null` otherwise.
|
237
237
|
*/
|
238
238
|
function findInvalidAncestor(node) {
|
239
|
-
const parent =
|
239
|
+
const parent = node.parent;
|
240
240
|
if (parent.type === utils_1.AST_NODE_TYPES.SequenceExpression &&
|
241
241
|
node !== parent.expressions[parent.expressions.length - 1]) {
|
242
242
|
return null;
|
@@ -282,13 +282,13 @@ exports.default = (0, util_1.createRule)({
|
|
282
282
|
/** Checks whether the return statement is the last statement in a function body. */
|
283
283
|
function isFinalReturn(node) {
|
284
284
|
// the parent must be a block
|
285
|
-
const block =
|
285
|
+
const block = node.parent;
|
286
286
|
if (block.type !== utils_1.AST_NODE_TYPES.BlockStatement) {
|
287
287
|
// e.g. `if (cond) return;` (not in a block)
|
288
288
|
return false;
|
289
289
|
}
|
290
290
|
// the block's parent must be a function
|
291
|
-
const blockParent =
|
291
|
+
const blockParent = block.parent;
|
292
292
|
if (![
|
293
293
|
utils_1.AST_NODE_TYPES.ArrowFunctionExpression,
|
294
294
|
utils_1.AST_NODE_TYPES.FunctionDeclaration,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"no-deprecated.d.ts","sourceRoot":"","sources":["../../src/rules/no-deprecated.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAiBpD,KAAK,UAAU,GAAG,YAAY,GAAG,sBAAsB,CAAC;AAExD,KAAK,OAAO,GAAG;IACb;QACE,KAAK,CAAC,EAAE,oBAAoB,EAAE,CAAC;KAChC;CACF,CAAC;;AAEF,
|
1
|
+
{"version":3,"file":"no-deprecated.d.ts","sourceRoot":"","sources":["../../src/rules/no-deprecated.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAiBpD,KAAK,UAAU,GAAG,YAAY,GAAG,sBAAsB,CAAC;AAExD,KAAK,OAAO,GAAG;IACb;QACE,KAAK,CAAC,EAAE,oBAAoB,EAAE,CAAC;KAChC;CACF,CAAC;;AAEF,wBAicG"}
|
@@ -153,15 +153,15 @@ exports.default = (0, util_1.createRule)({
|
|
153
153
|
return false;
|
154
154
|
}
|
155
155
|
}
|
156
|
-
function
|
156
|
+
function isInsideImport(node) {
|
157
157
|
let current = node;
|
158
158
|
while (true) {
|
159
159
|
switch (current.type) {
|
160
|
-
case utils_1.AST_NODE_TYPES.ExportAllDeclaration:
|
161
|
-
case utils_1.AST_NODE_TYPES.ExportNamedDeclaration:
|
162
160
|
case utils_1.AST_NODE_TYPES.ImportDeclaration:
|
163
161
|
return true;
|
164
162
|
case utils_1.AST_NODE_TYPES.ArrowFunctionExpression:
|
163
|
+
case utils_1.AST_NODE_TYPES.ExportAllDeclaration:
|
164
|
+
case utils_1.AST_NODE_TYPES.ExportNamedDeclaration:
|
165
165
|
case utils_1.AST_NODE_TYPES.BlockStatement:
|
166
166
|
case utils_1.AST_NODE_TYPES.ClassDeclaration:
|
167
167
|
case utils_1.AST_NODE_TYPES.TSInterfaceDeclaration:
|
@@ -293,7 +293,7 @@ exports.default = (0, util_1.createRule)({
|
|
293
293
|
return searchForDeprecationInAliasesChain(services.getSymbolAtLocation(node), true);
|
294
294
|
}
|
295
295
|
function checkIdentifier(node) {
|
296
|
-
if (isDeclaration(node) ||
|
296
|
+
if (isDeclaration(node) || isInsideImport(node)) {
|
297
297
|
return;
|
298
298
|
}
|
299
299
|
const reason = getDeprecationReason(node);
|
@@ -352,7 +352,26 @@ exports.default = (0, util_1.createRule)({
|
|
352
352
|
}
|
353
353
|
}
|
354
354
|
return {
|
355
|
-
Identifier
|
355
|
+
Identifier(node) {
|
356
|
+
const { parent } = node;
|
357
|
+
if (parent.type === utils_1.AST_NODE_TYPES.ExportNamedDeclaration ||
|
358
|
+
parent.type === utils_1.AST_NODE_TYPES.ExportAllDeclaration) {
|
359
|
+
return;
|
360
|
+
}
|
361
|
+
if (parent.type === utils_1.AST_NODE_TYPES.ExportSpecifier) {
|
362
|
+
// only deal with the alias (exported) side, not the local binding
|
363
|
+
if (parent.exported !== node) {
|
364
|
+
return;
|
365
|
+
}
|
366
|
+
const symbol = services.getSymbolAtLocation(node);
|
367
|
+
const aliasDeprecation = getJsDocDeprecation(symbol);
|
368
|
+
if (aliasDeprecation != null) {
|
369
|
+
return;
|
370
|
+
}
|
371
|
+
}
|
372
|
+
// whether it's a plain identifier or the exported alias
|
373
|
+
checkIdentifier(node);
|
374
|
+
},
|
356
375
|
JSXIdentifier(node) {
|
357
376
|
if (node.parent.type !== utils_1.AST_NODE_TYPES.JSXClosingElement) {
|
358
377
|
checkIdentifier(node);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"no-floating-promises.d.ts","sourceRoot":"","sources":["../../src/rules/no-floating-promises.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAY,MAAM,0BAA0B,CAAC;AAMnE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;
|
1
|
+
{"version":3,"file":"no-floating-promises.d.ts","sourceRoot":"","sources":["../../src/rules/no-floating-promises.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAY,MAAM,0BAA0B,CAAC;AAMnE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAoBpD,MAAM,MAAM,OAAO,GAAG;IACpB;QACE,sBAAsB,CAAC,EAAE,oBAAoB,EAAE,CAAC;QAChD,yBAAyB,CAAC,EAAE,oBAAoB,EAAE,CAAC;QACnD,cAAc,CAAC,EAAE,OAAO,CAAC;QACzB,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,UAAU,CAAC,EAAE,OAAO,CAAC;KACtB;CACF,CAAC;AAEF,MAAM,MAAM,SAAS,GACjB,UAAU,GACV,kBAAkB,GAClB,iBAAiB,GACjB,sBAAsB,GACtB,0BAA0B,GAC1B,iCAAiC,GACjC,qCAAqC,GACrC,cAAc,CAAC;;AAmBnB,wBAgaG"}
|
@@ -118,7 +118,7 @@ exports.default = (0, util_1.createRule)({
|
|
118
118
|
return;
|
119
119
|
}
|
120
120
|
const expression = (0, util_1.skipChainExpression)(node.expression);
|
121
|
-
if (
|
121
|
+
if (isKnownSafePromiseCall(expression)) {
|
122
122
|
return;
|
123
123
|
}
|
124
124
|
const { isUnhandled, nonFunctionHandler, promiseArray } = isUnhandledPromise(checker, expression);
|
@@ -189,11 +189,14 @@ exports.default = (0, util_1.createRule)({
|
|
189
189
|
fixer.insertTextAfterRange([expression.range[1], expression.range[1]], ')'),
|
190
190
|
];
|
191
191
|
}
|
192
|
-
function
|
192
|
+
function isKnownSafePromiseCall(node) {
|
193
193
|
if (node.type !== utils_1.AST_NODE_TYPES.CallExpression) {
|
194
194
|
return false;
|
195
195
|
}
|
196
196
|
const type = services.getTypeAtLocation(node.callee);
|
197
|
+
if ((0, util_1.valueMatchesSomeSpecifier)(node.callee, allowForKnownSafeCalls, services.program, type)) {
|
198
|
+
return true;
|
199
|
+
}
|
197
200
|
return (0, util_1.typeMatchesSomeSpecifier)(type, allowForKnownSafeCalls, services.program);
|
198
201
|
}
|
199
202
|
function isHigherPrecedenceThanUnary(node) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"no-magic-numbers.d.ts","sourceRoot":"","sources":["../../src/rules/no-magic-numbers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAKzD,OAAO,KAAK,EACV,2BAA2B,EAC3B,wBAAwB,EACzB,MAAM,SAAS,CAAC;AAKjB,QAAA,MAAM,QAAQ;;;;;;;;;;;EAAwC,CAAC;AAEvD,MAAM,MAAM,OAAO,GAAG,wBAAwB,CAAC,OAAO,QAAQ,CAAC,CAAC;AAChE,MAAM,MAAM,UAAU,GAAG,2BAA2B,CAAC,OAAO,QAAQ,CAAC,CAAC;;;;;;;;;;;AA+BtE,
|
1
|
+
{"version":3,"file":"no-magic-numbers.d.ts","sourceRoot":"","sources":["../../src/rules/no-magic-numbers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAKzD,OAAO,KAAK,EACV,2BAA2B,EAC3B,wBAAwB,EACzB,MAAM,SAAS,CAAC;AAKjB,QAAA,MAAM,QAAQ;;;;;;;;;;;EAAwC,CAAC;AAEvD,MAAM,MAAM,OAAO,GAAG,wBAAwB,CAAC,OAAO,QAAQ,CAAC,CAAC;AAChE,MAAM,MAAM,UAAU,GAAG,2BAA2B,CAAC,OAAO,QAAQ,CAAC,CAAC;;;;;;;;;;;AA+BtE,wBAgGG"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"no-unnecessary-type-conversion.d.ts","sourceRoot":"","sources":["../../src/rules/no-unnecessary-type-conversion.ts"],"names":[],"mappings":"AAgBA,KAAK,UAAU,GACX,eAAe,GACf,kBAAkB,GAClB,2BAA2B,CAAC;;AAEhC,
|
1
|
+
{"version":3,"file":"no-unnecessary-type-conversion.d.ts","sourceRoot":"","sources":["../../src/rules/no-unnecessary-type-conversion.ts"],"names":[],"mappings":"AAgBA,KAAK,UAAU,GACX,eAAe,GACf,kBAAkB,GAClB,2BAA2B,CAAC;;AAEhC,wBA0XG"}
|
@@ -300,7 +300,43 @@ exports.default = (0, util_1.createRule)({
|
|
300
300
|
handleUnaryOperator(node, ts.TypeFlags.NumberLike, 'number', 'Using the unary + operator on a number', false);
|
301
301
|
},
|
302
302
|
'UnaryExpression[operator = "~"] > UnaryExpression[operator = "~"]'(node) {
|
303
|
-
|
303
|
+
const outerNode = node.parent;
|
304
|
+
const type = services.getTypeAtLocation(node.argument);
|
305
|
+
if (tsutils.unionConstituents(type).every(t => {
|
306
|
+
return ((0, util_1.isTypeFlagSet)(t, ts.TypeFlags.NumberLiteral) &&
|
307
|
+
Number.isInteger(t.value));
|
308
|
+
})) {
|
309
|
+
const wrappingFixerParams = {
|
310
|
+
node: outerNode,
|
311
|
+
innerNode: [node.argument],
|
312
|
+
sourceCode: context.sourceCode,
|
313
|
+
};
|
314
|
+
context.report({
|
315
|
+
loc: {
|
316
|
+
start: outerNode.loc.start,
|
317
|
+
end: {
|
318
|
+
column: node.loc.start.column + 1,
|
319
|
+
line: node.loc.start.line,
|
320
|
+
},
|
321
|
+
},
|
322
|
+
messageId: 'unnecessaryTypeConversion',
|
323
|
+
data: { type: 'number', violation: 'Using ~~ on an integer' },
|
324
|
+
suggest: [
|
325
|
+
{
|
326
|
+
messageId: 'suggestRemove',
|
327
|
+
fix: (0, util_1.getWrappingFixer)(wrappingFixerParams),
|
328
|
+
},
|
329
|
+
{
|
330
|
+
messageId: 'suggestSatisfies',
|
331
|
+
data: { type: 'number' },
|
332
|
+
fix: (0, util_1.getWrappingFixer)({
|
333
|
+
...wrappingFixerParams,
|
334
|
+
wrap: expr => `${expr} satisfies number`,
|
335
|
+
}),
|
336
|
+
},
|
337
|
+
],
|
338
|
+
});
|
339
|
+
}
|
304
340
|
},
|
305
341
|
};
|
306
342
|
},
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"prefer-destructuring.d.ts","sourceRoot":"","sources":["../../src/rules/prefer-destructuring.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAOnE,OAAO,KAAK,EACV,2BAA2B,EAC3B,wBAAwB,EACzB,MAAM,SAAS,CAAC;AAKjB,QAAA,MAAM,QAAQ;;;;;;EAA4C,CAAC;AAE3D,KAAK,WAAW,GAAG,wBAAwB,CAAC,OAAO,QAAQ,CAAC,CAAC;AAC7D,KAAK,kBAAkB,GAAG;IACxB,uCAAuC,CAAC,EAAE,OAAO,CAAC;CACnD,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;AACnB,MAAM,MAAM,OAAO,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,kBAAkB,CAAC,CAAC;AAE3D,MAAM,MAAM,UAAU,GAAG,2BAA2B,CAAC,OAAO,QAAQ,CAAC,CAAC;;AA+CtE,
|
1
|
+
{"version":3,"file":"prefer-destructuring.d.ts","sourceRoot":"","sources":["../../src/rules/prefer-destructuring.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAOnE,OAAO,KAAK,EACV,2BAA2B,EAC3B,wBAAwB,EACzB,MAAM,SAAS,CAAC;AAKjB,QAAA,MAAM,QAAQ;;;;;;EAA4C,CAAC;AAE3D,KAAK,WAAW,GAAG,wBAAwB,CAAC,OAAO,QAAQ,CAAC,CAAC;AAC7D,KAAK,kBAAkB,GAAG;IACxB,uCAAuC,CAAC,EAAE,OAAO,CAAC;CACnD,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;AACnB,MAAM,MAAM,OAAO,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,kBAAkB,CAAC,CAAC;AAE3D,MAAM,MAAM,UAAU,GAAG,2BAA2B,CAAC,OAAO,QAAQ,CAAC,CAAC;;AA+CtE,wBAwHG"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"prefer-return-this-type.d.ts","sourceRoot":"","sources":["../../src/rules/prefer-return-this-type.ts"],"names":[],"mappings":";
|
1
|
+
{"version":3,"file":"prefer-return-this-type.d.ts","sourceRoot":"","sources":["../../src/rules/prefer-return-this-type.ts"],"names":[],"mappings":";AAgBA,wBAsKG"}
|
@@ -34,6 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
34
34
|
})();
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
36
36
|
const utils_1 = require("@typescript-eslint/utils");
|
37
|
+
const ts_api_utils_1 = require("ts-api-utils");
|
37
38
|
const ts = __importStar(require("typescript"));
|
38
39
|
const util_1 = require("../util");
|
39
40
|
exports.default = (0, util_1.createRule)({
|
@@ -109,6 +110,11 @@ exports.default = (0, util_1.createRule)({
|
|
109
110
|
hasReturnThis = true;
|
110
111
|
return;
|
111
112
|
}
|
113
|
+
if ((0, ts_api_utils_1.isUnionType)(type) &&
|
114
|
+
type.types.some(typePart => typePart === classType)) {
|
115
|
+
hasReturnClassType = true;
|
116
|
+
return true;
|
117
|
+
}
|
112
118
|
return;
|
113
119
|
});
|
114
120
|
return !hasReturnClassType && hasReturnThis;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"collectUnusedVariables.d.ts","sourceRoot":"","sources":["../../src/util/collectUnusedVariables.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,aAAa,EACd,MAAM,kCAAkC,CAAC;AAQ1C,OAAO,EAIL,QAAQ,EACT,MAAM,0BAA0B,CAAC;AAKlC,UAAU,gBAAgB;IACxB,QAAQ,CAAC,eAAe,EAAE,WAAW,CAAC,aAAa,CAAC,CAAC;IACrD,QAAQ,CAAC,aAAa,EAAE,WAAW,CAAC,aAAa,CAAC,CAAC;CACpD;
|
1
|
+
{"version":3,"file":"collectUnusedVariables.d.ts","sourceRoot":"","sources":["../../src/util/collectUnusedVariables.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,aAAa,EACd,MAAM,kCAAkC,CAAC;AAQ1C,OAAO,EAIL,QAAQ,EACT,MAAM,0BAA0B,CAAC;AAKlC,UAAU,gBAAgB;IACxB,QAAQ,CAAC,eAAe,EAAE,WAAW,CAAC,aAAa,CAAC,CAAC;IACrD,QAAQ,CAAC,aAAa,EAAE,WAAW,CAAC,aAAa,CAAC,CAAC;CACpD;AAixBD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,UAAU,SAAS,MAAM,EACzB,OAAO,SAAS,SAAS,OAAO,EAAE,EAElC,OAAO,EAAE,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,GAC3D,gBAAgB,CAQlB"}
|
@@ -306,8 +306,8 @@ function isMergableExported(variable) {
|
|
306
306
|
continue;
|
307
307
|
}
|
308
308
|
if ((MERGABLE_TYPES.has(def.node.type) &&
|
309
|
-
def.node.parent
|
310
|
-
def.node.parent
|
309
|
+
def.node.parent.type === utils_1.AST_NODE_TYPES.ExportNamedDeclaration) ||
|
310
|
+
def.node.parent.type === utils_1.AST_NODE_TYPES.ExportDefaultDeclaration) {
|
311
311
|
return true;
|
312
312
|
}
|
313
313
|
}
|
@@ -322,13 +322,11 @@ function isExported(variable) {
|
|
322
322
|
return variable.defs.some(definition => {
|
323
323
|
let node = definition.node;
|
324
324
|
if (node.type === utils_1.AST_NODE_TYPES.VariableDeclarator) {
|
325
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
326
325
|
node = node.parent;
|
327
326
|
}
|
328
327
|
else if (definition.type === utils_1.TSESLint.Scope.DefinitionType.Parameter) {
|
329
328
|
return false;
|
330
329
|
}
|
331
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
332
330
|
return node.parent.type.startsWith('Export');
|
333
331
|
});
|
334
332
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@typescript-eslint/eslint-plugin",
|
3
|
-
"version": "8.
|
3
|
+
"version": "8.43.0",
|
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.
|
63
|
-
"@typescript-eslint/type-utils": "8.
|
64
|
-
"@typescript-eslint/utils": "8.
|
65
|
-
"@typescript-eslint/visitor-keys": "8.
|
62
|
+
"@typescript-eslint/scope-manager": "8.43.0",
|
63
|
+
"@typescript-eslint/type-utils": "8.43.0",
|
64
|
+
"@typescript-eslint/utils": "8.43.0",
|
65
|
+
"@typescript-eslint/visitor-keys": "8.43.0",
|
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.
|
75
|
-
"@typescript-eslint/rule-tester": "8.
|
74
|
+
"@typescript-eslint/rule-schema-to-typescript-types": "8.43.0",
|
75
|
+
"@typescript-eslint/rule-tester": "8.43.0",
|
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.
|
95
|
+
"@typescript-eslint/parser": "^8.43.0",
|
96
96
|
"eslint": "^8.57.0 || ^9.0.0",
|
97
97
|
"typescript": ">=4.8.4 <6.0.0"
|
98
98
|
},
|