@typescript-eslint/eslint-plugin
Advanced tools
Comparing version
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const utils_1 = require("@typescript-eslint/utils"); | ||
const tsutils = __importStar(require("ts-api-utils")); | ||
const util_1 = require("../util"); | ||
@@ -99,6 +123,6 @@ class FunctionSignature { | ||
messages: { | ||
unsafeArgument: 'Unsafe argument of type `{{sender}}` assigned to a parameter of type `{{receiver}}`.', | ||
unsafeTupleSpread: 'Unsafe spread of a tuple type. The argument is of type `{{sender}}` and is assigned to a parameter of type `{{receiver}}`.', | ||
unsafeArraySpread: 'Unsafe spread of an `any` array type.', | ||
unsafeSpread: 'Unsafe spread of an `any` type.', | ||
unsafeArgument: 'Unsafe argument of type {{sender}} assigned to a parameter of type {{receiver}}.', | ||
unsafeTupleSpread: 'Unsafe spread of a tuple type. The argument is {{sender}} and is assigned to a parameter of type {{receiver}}.', | ||
unsafeArraySpread: 'Unsafe spread of an {{sender}} array type.', | ||
unsafeSpread: 'Unsafe spread of an {{sender}} type.', | ||
}, | ||
@@ -111,2 +135,21 @@ schema: [], | ||
const checker = services.program.getTypeChecker(); | ||
function describeType(type) { | ||
if (tsutils.isIntrinsicErrorType(type)) { | ||
return 'error typed'; | ||
} | ||
return `\`${checker.typeToString(type)}\``; | ||
} | ||
function describeTypeForSpread(type) { | ||
if (checker.isArrayType(type) && | ||
tsutils.isIntrinsicErrorType(checker.getTypeArguments(type)[0])) { | ||
return 'error'; | ||
} | ||
return describeType(type); | ||
} | ||
function describeTypeForTuple(type) { | ||
if (tsutils.isIntrinsicErrorType(type)) { | ||
return 'error typed'; | ||
} | ||
return `of type \`${checker.typeToString(type)}\``; | ||
} | ||
function checkUnsafeArguments(args, callee, node) { | ||
@@ -134,2 +177,3 @@ if (args.length === 0) { | ||
context.report({ | ||
data: { sender: describeType(spreadArgType) }, | ||
node: argument, | ||
@@ -143,2 +187,3 @@ messageId: 'unsafeSpread', | ||
context.report({ | ||
data: { sender: describeTypeForSpread(spreadArgType) }, | ||
node: argument, | ||
@@ -165,4 +210,4 @@ messageId: 'unsafeArraySpread', | ||
data: { | ||
sender: checker.typeToString(tupleType), | ||
receiver: checker.typeToString(parameterType), | ||
sender: describeTypeForTuple(tupleType), | ||
receiver: describeType(parameterType), | ||
}, | ||
@@ -197,4 +242,4 @@ }); | ||
data: { | ||
sender: checker.typeToString(argumentType), | ||
receiver: checker.typeToString(parameterType), | ||
sender: describeType(argumentType), | ||
receiver: describeType(parameterType), | ||
}, | ||
@@ -201,0 +246,0 @@ }); |
{ | ||
"name": "@typescript-eslint/eslint-plugin", | ||
"version": "8.4.1-alpha.12", | ||
"version": "8.4.1-alpha.13", | ||
"description": "TypeScript plugin for ESLint", | ||
@@ -63,6 +63,6 @@ "files": [ | ||
"@eslint-community/regexpp": "^4.10.0", | ||
"@typescript-eslint/scope-manager": "8.4.1-alpha.12", | ||
"@typescript-eslint/type-utils": "8.4.1-alpha.12", | ||
"@typescript-eslint/utils": "8.4.1-alpha.12", | ||
"@typescript-eslint/visitor-keys": "8.4.1-alpha.12", | ||
"@typescript-eslint/scope-manager": "8.4.1-alpha.13", | ||
"@typescript-eslint/type-utils": "8.4.1-alpha.13", | ||
"@typescript-eslint/utils": "8.4.1-alpha.13", | ||
"@typescript-eslint/visitor-keys": "8.4.1-alpha.13", | ||
"graphemer": "^1.4.0", | ||
@@ -78,4 +78,4 @@ "ignore": "^5.3.1", | ||
"@types/natural-compare": "*", | ||
"@typescript-eslint/rule-schema-to-typescript-types": "8.4.1-alpha.12", | ||
"@typescript-eslint/rule-tester": "8.4.1-alpha.12", | ||
"@typescript-eslint/rule-schema-to-typescript-types": "8.4.1-alpha.13", | ||
"@typescript-eslint/rule-tester": "8.4.1-alpha.13", | ||
"ajv": "^6.12.6", | ||
@@ -82,0 +82,0 @@ "cross-env": "^7.0.3", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
2622343
0.1%29929
0.15%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed