@typescript-eslint/eslint-plugin
Advanced tools
Comparing version
@@ -90,3 +90,3 @@ "use strict"; | ||
const hasAsyncIteratorSymbol = tsutils | ||
.unionTypeParts(type) | ||
.unionConstituents(type) | ||
.some(typePart => tsutils.getWellKnownSymbolPropertyOfType(typePart, 'asyncIterator', checker) != null); | ||
@@ -122,3 +122,3 @@ if (!hasAsyncIteratorSymbol) { | ||
const hasAsyncDisposeSymbol = tsutils | ||
.unionTypeParts(type) | ||
.unionConstituents(type) | ||
.some(typePart => tsutils.getWellKnownSymbolPropertyOfType(typePart, 'asyncDispose', checker) != null); | ||
@@ -125,0 +125,0 @@ if (!hasAsyncDisposeSymbol) { |
@@ -69,3 +69,3 @@ "use strict"; | ||
return tsutils | ||
.unionTypeParts(type) | ||
.unionConstituents(type) | ||
.filter((subType) => (0, util_1.isTypeFlagSet)(subType, ts.TypeFlags.EnumLiteral)); | ||
@@ -72,0 +72,0 @@ } |
@@ -330,3 +330,3 @@ "use strict"; | ||
return tsutils | ||
.unionTypeParts(returnType) | ||
.unionConstituents(returnType) | ||
.some(tsutils.isIntrinsicVoidType); | ||
@@ -346,3 +346,3 @@ }); | ||
return tsutils | ||
.unionTypeParts(returnType) | ||
.unionConstituents(returnType) | ||
.some(tsutils.isIntrinsicVoidType); | ||
@@ -354,3 +354,3 @@ } | ||
return tsutils | ||
.unionTypeParts(functionType) | ||
.unionConstituents(functionType) | ||
.some(isFunctionReturnTypeIncludesVoid); | ||
@@ -357,0 +357,0 @@ } |
@@ -40,2 +40,3 @@ "use strict"; | ||
const util_1 = require("../util"); | ||
const promiseUtils_1 = require("../util/promiseUtils"); | ||
const messageBase = 'Promises must be awaited, end with a call to .catch, or end with a call to .then with a rejection handler.'; | ||
@@ -260,10 +261,7 @@ const messageBaseVoid = 'Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler' + | ||
// rejection handler handles the promise. | ||
const { callee } = node; | ||
if (callee.type === utils_1.AST_NODE_TYPES.MemberExpression) { | ||
const methodName = (0, util_1.getStaticMemberAccessValue)(callee, context); | ||
const catchRejectionHandler = methodName === 'catch' && node.arguments.length >= 1 | ||
? node.arguments[0] | ||
: undefined; | ||
if (catchRejectionHandler) { | ||
if (isValidRejectionHandler(catchRejectionHandler)) { | ||
const promiseHandlingMethodCall = (0, promiseUtils_1.parseCatchCall)(node, context) ?? (0, promiseUtils_1.parseThenCall)(node, context); | ||
if (promiseHandlingMethodCall != null) { | ||
const onRejected = promiseHandlingMethodCall.onRejected; | ||
if (onRejected != null) { | ||
if (isValidRejectionHandler(onRejected)) { | ||
return { isUnhandled: false }; | ||
@@ -273,18 +271,8 @@ } | ||
} | ||
const thenRejectionHandler = methodName === 'then' && node.arguments.length >= 2 | ||
? node.arguments[1] | ||
: undefined; | ||
if (thenRejectionHandler) { | ||
if (isValidRejectionHandler(thenRejectionHandler)) { | ||
return { isUnhandled: false }; | ||
} | ||
return { isUnhandled: true, nonFunctionHandler: true }; | ||
} | ||
// `x.finally()` is transparent to resolution of the promise, so check `x`. | ||
// ("object" in this context is the `x` in `x.finally()`) | ||
const promiseFinallyObject = methodName === 'finally' ? callee.object : undefined; | ||
if (promiseFinallyObject) { | ||
return isUnhandledPromise(checker, promiseFinallyObject); | ||
} | ||
return { isUnhandled: true }; | ||
} | ||
const promiseFinallyCall = (0, promiseUtils_1.parseFinallyCall)(node, context); | ||
if (promiseFinallyCall != null) { | ||
return isUnhandledPromise(checker, promiseFinallyCall.object); | ||
} | ||
// All other cases are unhandled. | ||
@@ -315,3 +303,3 @@ return { isUnhandled: true }; | ||
for (const ty of tsutils | ||
.unionTypeParts(type) | ||
.unionConstituents(type) | ||
.map(t => checker.getApparentType(t))) { | ||
@@ -341,3 +329,3 @@ if (checker.isArrayType(ty)) { | ||
// Otherwise, we always consider the built-in Promise to be Promise-like... | ||
const typeParts = tsutils.unionTypeParts(checker.getApparentType(type)); | ||
const typeParts = tsutils.unionConstituents(checker.getApparentType(type)); | ||
if (typeParts.some(typePart => (0, util_1.isBuiltinSymbolLike)(services.program, typePart, 'Promise'))) { | ||
@@ -371,3 +359,3 @@ return true; | ||
function hasMatchingSignature(type, matcher) { | ||
for (const t of tsutils.unionTypeParts(type)) { | ||
for (const t of tsutils.unionConstituents(type)) { | ||
if (t.getCallSignatures().some(matcher)) { | ||
@@ -381,3 +369,3 @@ return true; | ||
const type = checker.getApparentType(checker.getTypeOfSymbolAtLocation(param, node)); | ||
for (const t of tsutils.unionTypeParts(type)) { | ||
for (const t of tsutils.unionConstituents(type)) { | ||
if (t.getCallSignatures().length !== 0) { | ||
@@ -384,0 +372,0 @@ return true; |
@@ -82,3 +82,3 @@ "use strict"; | ||
const argType = services.getTypeAtLocation(node.argument); | ||
const unionParts = tsutils.unionTypeParts(argType); | ||
const unionParts = tsutils.unionConstituents(argType); | ||
if (unionParts.every(part => part.flags & (ts.TypeFlags.Void | ts.TypeFlags.Undefined))) { | ||
@@ -85,0 +85,0 @@ context.report({ |
@@ -554,3 +554,3 @@ "use strict"; | ||
const type = checker.getTypeAtLocation(node); | ||
for (const subType of tsutils.unionTypeParts(checker.getApparentType(type))) { | ||
for (const subType of tsutils.unionConstituents(checker.getApparentType(type))) { | ||
if (tsutils.isThenableType(checker, node, subType)) { | ||
@@ -568,3 +568,3 @@ return true; | ||
const type = checker.getTypeAtLocation(node); | ||
for (const subType of tsutils.unionTypeParts(checker.getApparentType(type))) { | ||
for (const subType of tsutils.unionConstituents(checker.getApparentType(type))) { | ||
const thenProp = subType.getProperty('then'); | ||
@@ -581,3 +581,3 @@ // If one of the alternates has no then property, it is not thenable in all | ||
let hasThenableSignature = false; | ||
for (const subType of tsutils.unionTypeParts(thenType)) { | ||
for (const subType of tsutils.unionConstituents(thenType)) { | ||
for (const signature of subType.getCallSignatures()) { | ||
@@ -608,3 +608,3 @@ if (signature.parameters.length !== 0 && | ||
const type = checker.getApparentType(checker.getTypeOfSymbolAtLocation(param, node)); | ||
for (const subType of tsutils.unionTypeParts(type)) { | ||
for (const subType of tsutils.unionConstituents(type)) { | ||
if (subType.getCallSignatures().length !== 0) { | ||
@@ -648,3 +648,3 @@ return true; | ||
// See https://github.com/microsoft/TypeScript/issues/48077 | ||
for (const subType of tsutils.unionTypeParts(type)) { | ||
for (const subType of tsutils.unionConstituents(type)) { | ||
// Standard function calls and `new` have two different types of signatures | ||
@@ -706,3 +706,3 @@ const signatures = ts.isCallExpression(node) | ||
function isThenableReturningFunctionType(checker, node, type) { | ||
for (const subType of tsutils.unionTypeParts(type)) { | ||
for (const subType of tsutils.unionConstituents(type)) { | ||
if (anySignatureIsThenableType(checker, node, subType)) { | ||
@@ -719,3 +719,3 @@ return true; | ||
let hadVoidReturn = false; | ||
for (const subType of tsutils.unionTypeParts(type)) { | ||
for (const subType of tsutils.unionConstituents(type)) { | ||
for (const signature of subType.getCallSignatures()) { | ||
@@ -739,3 +739,3 @@ const returnType = signature.getReturnType(); | ||
return tsutils | ||
.unionTypeParts(type) | ||
.unionConstituents(type) | ||
.some(t => anySignatureIsThenableType(checker, node, t)); | ||
@@ -742,0 +742,0 @@ } |
@@ -100,3 +100,3 @@ "use strict"; | ||
function getMapSpreadSuggestions(node, type) { | ||
const types = tsutils.unionTypeParts(type); | ||
const types = tsutils.unionConstituents(type); | ||
if (types.some(t => !isMap(services.program, t))) { | ||
@@ -212,3 +212,3 @@ return null; | ||
return tsutils | ||
.typeParts(type) | ||
.typeConstituents(type) | ||
.some(t => !!tsutils.getWellKnownSymbolPropertyOfType(t, 'iterator', checker)); | ||
@@ -215,0 +215,0 @@ } |
@@ -171,3 +171,3 @@ "use strict"; | ||
? [type] | ||
: tsutils.unionTypeParts(type); | ||
: tsutils.unionConstituents(type); | ||
} | ||
@@ -174,0 +174,0 @@ exports.default = (0, util_1.createRule)({ |
@@ -47,3 +47,3 @@ "use strict"; | ||
function isAlwaysNullish(type) { | ||
return tsutils.unionTypeParts(type).every(isNullishType); | ||
return tsutils.unionConstituents(type).every(isNullishType); | ||
} | ||
@@ -55,3 +55,3 @@ /** | ||
function isPossiblyNullish(type) { | ||
return tsutils.unionTypeParts(type).some(isNullishType); | ||
return tsutils.unionConstituents(type).some(isNullishType); | ||
} | ||
@@ -203,3 +203,3 @@ function toStaticValue(type) { | ||
return tsutils | ||
.unionTypeParts(nodeType) | ||
.unionConstituents(nodeType) | ||
.some(part => checker.isArrayType(part)); | ||
@@ -210,3 +210,3 @@ } | ||
return tsutils | ||
.unionTypeParts(nodeType) | ||
.unionConstituents(nodeType) | ||
.some(part => checker.isTupleType(part)); | ||
@@ -230,3 +230,3 @@ } | ||
return tsutils | ||
.unionTypeParts(type) | ||
.unionConstituents(type) | ||
.some(part => (0, util_1.isTypeAnyType)(part) || | ||
@@ -233,0 +233,0 @@ (0, util_1.isTypeUnknownType)(part) || |
@@ -80,3 +80,3 @@ "use strict"; | ||
function isEnumMemberType(type) { | ||
return tsutils.typeParts(type).some(t => { | ||
return tsutils.typeConstituents(type).some(t => { | ||
const symbol = t.getSymbol(); | ||
@@ -83,0 +83,0 @@ return !!(symbol?.valueDeclaration && ts.isEnumMember(symbol.valueDeclaration)); |
@@ -174,6 +174,6 @@ "use strict"; | ||
const uncastParts = tsutils | ||
.unionTypeParts(uncast) | ||
.unionConstituents(uncast) | ||
.filter(part => !(0, util_1.isTypeFlagSet)(part, ts.TypeFlags.Undefined)); | ||
const castParts = tsutils | ||
.unionTypeParts(cast) | ||
.unionConstituents(cast) | ||
.filter(part => !(0, util_1.isTypeFlagSet)(part, ts.TypeFlags.Undefined)); | ||
@@ -180,0 +180,0 @@ if (uncastParts.length !== castParts.length) { |
@@ -37,3 +37,3 @@ "use strict"; | ||
const utils_1 = require("@typescript-eslint/utils"); | ||
const ts_api_utils_1 = require("ts-api-utils"); | ||
const tsutils = __importStar(require("ts-api-utils")); | ||
const ts = __importStar(require("typescript")); | ||
@@ -61,3 +61,5 @@ const util_1 = require("../util"); | ||
function doesUnderlyingTypeMatchFlag(type, typeFlag) { | ||
return (0, ts_api_utils_1.unionTypeParts)(type).every(t => (0, util_1.isTypeFlagSet)(t, typeFlag)); | ||
return tsutils | ||
.unionConstituents(type) | ||
.every(t => (0, util_1.isTypeFlagSet)(t, typeFlag)); | ||
} | ||
@@ -64,0 +66,0 @@ const services = (0, util_1.getParserServices)(context); |
@@ -49,3 +49,3 @@ "use strict"; | ||
function isNumberLike(type) { | ||
const typeParts = tsutils.intersectionTypeParts(type); | ||
const typeParts = tsutils.intersectionConstituents(type); | ||
return typeParts.some(typePart => { | ||
@@ -56,3 +56,3 @@ return tsutils.isTypeFlagSet(typePart, ts.TypeFlags.Number | ts.TypeFlags.NumberLike); | ||
function isStringLike(type) { | ||
const typeParts = tsutils.intersectionTypeParts(type); | ||
const typeParts = tsutils.intersectionConstituents(type); | ||
return typeParts.some(typePart => { | ||
@@ -121,4 +121,4 @@ return tsutils.isTypeFlagSet(typePart, ts.TypeFlags.String | ts.TypeFlags.StringLike); | ||
// ``` | ||
const leftTypeParts = tsutils.unionTypeParts(leftType); | ||
const rightTypeParts = tsutils.unionTypeParts(rightType); | ||
const leftTypeParts = tsutils.unionConstituents(leftType); | ||
const rightTypeParts = tsutils.unionConstituents(rightType); | ||
// If a type exists in both sides, we consider this comparison safe: | ||
@@ -125,0 +125,0 @@ // |
@@ -64,3 +64,3 @@ "use strict"; | ||
if (tsutils | ||
.unionTypeParts(argType) | ||
.unionConstituents(argType) | ||
.some(type => !tsutils.isTypeFlagSet(type, ts.TypeFlags.Any | | ||
@@ -67,0 +67,0 @@ ts.TypeFlags.Never | |
@@ -63,3 +63,3 @@ "use strict"; | ||
} | ||
return tsutils.unionTypeParts(type); | ||
return tsutils.unionConstituents(type); | ||
}; | ||
@@ -66,0 +66,0 @@ const couldBeNullish = (type) => { |
@@ -6,2 +6,3 @@ import type { TypeOrValueSpecifier } from '../util'; | ||
allow?: TypeOrValueSpecifier[]; | ||
allowRethrowing?: boolean; | ||
allowThrowingAny?: boolean; | ||
@@ -8,0 +9,0 @@ allowThrowingUnknown?: boolean; |
@@ -37,4 +37,6 @@ "use strict"; | ||
const utils_1 = require("@typescript-eslint/utils"); | ||
const ts_api_utils_1 = require("ts-api-utils"); | ||
const ts = __importStar(require("typescript")); | ||
const util_1 = require("../util"); | ||
const promiseUtils_1 = require("../util/promiseUtils"); | ||
exports.default = (0, util_1.createRule)({ | ||
@@ -63,2 +65,6 @@ name: 'only-throw-error', | ||
}, | ||
allowRethrowing: { | ||
type: 'boolean', | ||
description: 'Whether to allow rethrowing caught values that are not `Error` objects.', | ||
}, | ||
allowThrowingAny: { | ||
@@ -79,2 +85,3 @@ type: 'boolean', | ||
allow: [], | ||
allowRethrowing: true, | ||
allowThrowingAny: true, | ||
@@ -87,2 +94,39 @@ allowThrowingUnknown: true, | ||
const allow = options.allow; | ||
function isRethrownError(node) { | ||
if (node.type !== utils_1.AST_NODE_TYPES.Identifier) { | ||
return false; | ||
} | ||
const scope = context.sourceCode.getScope(node); | ||
const smVariable = (0, util_1.nullThrows)((0, util_1.findVariable)(scope, node), `Variable ${node.name} should exist in scope manager`); | ||
const variableDefinitions = smVariable.defs.filter(def => def.isVariableDefinition); | ||
if (variableDefinitions.length !== 1) { | ||
return false; | ||
} | ||
const def = smVariable.defs[0]; | ||
// try { /* ... */ } catch (x) { throw x; } | ||
if (def.node.type === utils_1.AST_NODE_TYPES.CatchClause) { | ||
return true; | ||
} | ||
// promise.catch(x => { throw x; }) | ||
// promise.then(onFulfilled, x => { throw x; }) | ||
if (def.node.type === utils_1.AST_NODE_TYPES.ArrowFunctionExpression && | ||
def.node.params.length >= 1 && | ||
def.node.params[0] === def.name && | ||
def.node.parent.type === utils_1.AST_NODE_TYPES.CallExpression) { | ||
const callExpression = def.node.parent; | ||
const parsedPromiseHandlingCall = (0, promiseUtils_1.parseCatchCall)(callExpression, context) ?? | ||
(0, promiseUtils_1.parseThenCall)(callExpression, context); | ||
if (parsedPromiseHandlingCall != null) { | ||
const { object, onRejected } = parsedPromiseHandlingCall; | ||
if (onRejected === def.node) { | ||
const tsObjectNode = services.esTreeNodeToTSNodeMap.get(object); | ||
// make sure we're actually dealing with a promise | ||
if ((0, ts_api_utils_1.isThenableType)(services.program.getTypeChecker(), tsObjectNode)) { | ||
return true; | ||
} | ||
} | ||
} | ||
} | ||
return false; | ||
} | ||
function checkThrowArgument(node) { | ||
@@ -93,2 +137,5 @@ if (node.type === utils_1.AST_NODE_TYPES.AwaitExpression || | ||
} | ||
if (options.allowRethrowing && isRethrownError(node)) { | ||
return; | ||
} | ||
const type = services.getTypeAtLocation(node); | ||
@@ -95,0 +142,0 @@ if ((0, util_1.typeMatchesSomeSpecifier)(type, allow, services.program)) { |
@@ -112,3 +112,3 @@ "use strict"; | ||
let isAtLeastOneArrayishComponent = false; | ||
for (const unionPart of tsutils.unionTypeParts(type)) { | ||
for (const unionPart of tsutils.unionConstituents(type)) { | ||
if (tsutils.isIntrinsicNullType(unionPart) || | ||
@@ -121,3 +121,3 @@ tsutils.isIntrinsicUndefinedType(unionPart)) { | ||
const isArrayOrIntersectionThereof = tsutils | ||
.intersectionTypeParts(unionPart) | ||
.intersectionConstituents(unionPart) | ||
.every(intersectionPart => checker.isArrayType(intersectionPart) || | ||
@@ -124,0 +124,0 @@ checker.isTupleType(intersectionPart)); |
@@ -198,5 +198,5 @@ "use strict"; | ||
if (tsutils | ||
.typeParts(type) | ||
.typeConstituents(type) | ||
.some(t => tsutils | ||
.intersectionTypeParts(t) | ||
.intersectionConstituents(t) | ||
.some(t => tsutils.isTypeFlagSet(t, ignorableFlags)))) { | ||
@@ -203,0 +203,0 @@ return false; |
@@ -46,3 +46,3 @@ "use strict"; | ||
const typeFlag = typeFlagIn | ts.TypeFlags.Any | ts.TypeFlags.Unknown; | ||
const types = (0, ts_api_utils_1.unionTypeParts)(parserServices.getTypeAtLocation(node)); | ||
const types = (0, ts_api_utils_1.unionConstituents)(parserServices.getTypeAtLocation(node)); | ||
for (const type of types) { | ||
@@ -49,0 +49,0 @@ if ((0, util_1.isTypeFlagSet)(type, typeFlag)) { |
@@ -42,5 +42,5 @@ "use strict"; | ||
if (!requireNullish || | ||
maybeNullishNodes.some(node => (0, ts_api_utils_1.unionTypeParts)(parserServices.getTypeAtLocation(node)).some(t => (0, type_utils_1.isTypeFlagSet)(t, ts.TypeFlags.Null | ts.TypeFlags.Undefined)))) { | ||
maybeNullishNodes.some(node => (0, ts_api_utils_1.unionConstituents)(parserServices.getTypeAtLocation(node)).some(t => (0, type_utils_1.isTypeFlagSet)(t, ts.TypeFlags.Null | ts.TypeFlags.Undefined)))) { | ||
context.report(descriptor); | ||
} | ||
} |
@@ -75,3 +75,3 @@ "use strict"; | ||
const type = parserServices.getTypeAtLocation(node); | ||
const types = (0, ts_api_utils_1.unionTypeParts)(type); | ||
const types = (0, ts_api_utils_1.unionConstituents)(type); | ||
if (disallowFalseyLiteral && | ||
@@ -78,0 +78,0 @@ /* |
@@ -59,5 +59,5 @@ "use strict"; | ||
return tsutils | ||
.unionTypeParts(type) | ||
.unionConstituents(type) | ||
.every(unionPart => tsutils | ||
.intersectionTypeParts(unionPart) | ||
.intersectionConstituents(unionPart) | ||
.every(t => checker.isArrayType(t) || checker.isTupleType(t))); | ||
@@ -64,0 +64,0 @@ } |
@@ -150,3 +150,3 @@ "use strict"; | ||
const argumentType = services.getTypeAtLocation(argumentNode); | ||
const argumentTypes = collectArgumentTypes(tsutils.unionTypeParts(argumentType)); | ||
const argumentTypes = collectArgumentTypes(tsutils.unionConstituents(argumentType)); | ||
switch (argumentTypes) { | ||
@@ -153,0 +153,0 @@ case ArgumentType.RegExp: |
@@ -159,3 +159,3 @@ "use strict"; | ||
// RegExps also contain ts.TypeFlags.Any & ts.TypeFlags.Object | ||
for (const subBaseType of tsutils.unionTypeParts(baseType)) { | ||
for (const subBaseType of tsutils.unionConstituents(baseType)) { | ||
const typeName = (0, util_1.getTypeName)(typeChecker, subBaseType); | ||
@@ -225,9 +225,9 @@ if (typeName === 'RegExp' | ||
return type.isIntersection() | ||
? tsutils.intersectionTypeParts(type).every(tsutils.isObjectType) | ||
: tsutils.unionTypeParts(type).every(tsutils.isObjectType); | ||
? tsutils.intersectionConstituents(type).every(tsutils.isObjectType) | ||
: tsutils.unionConstituents(type).every(tsutils.isObjectType); | ||
} | ||
function isTypeFlagSetInUnion(type, flag) { | ||
return tsutils | ||
.unionTypeParts(type) | ||
.unionConstituents(type) | ||
.some(subType => tsutils.isTypeFlagSet(subType, flag)); | ||
} |
@@ -240,3 +240,3 @@ "use strict"; | ||
const flattenTypes = [ | ||
...new Set(returnTypes.flatMap(type => tsutils.unionTypeParts(type))), | ||
...new Set(returnTypes.flatMap(type => tsutils.unionConstituents(type))), | ||
]; | ||
@@ -778,3 +778,3 @@ const types = inspectVariantTypes(flattenTypes); | ||
const type = (0, util_1.getConstrainedTypeAtLocation)(services, node); | ||
const types = inspectVariantTypes(tsutils.unionTypeParts(type)); | ||
const types = inspectVariantTypes(tsutils.unionConstituents(type)); | ||
const reportType = determineReportType(types); | ||
@@ -804,3 +804,3 @@ if (reportType != null) { | ||
// If incoming type is boolean, there will be two type objects with | ||
// intrinsicName set "true" and "false" each because of ts-api-utils.unionTypeParts() | ||
// intrinsicName set "true" and "false" each because of ts-api-utils.unionConstituents() | ||
if (booleans.length === 1) { | ||
@@ -807,0 +807,0 @@ variantTypes.add(tsutils.isTrueLiteralType(booleans[0]) ? 'truthy boolean' : 'boolean'); |
@@ -125,4 +125,4 @@ "use strict"; | ||
const missingLiteralBranchTypes = []; | ||
for (const unionPart of tsutils.unionTypeParts(discriminantType)) { | ||
for (const intersectionPart of tsutils.intersectionTypeParts(unionPart)) { | ||
for (const unionPart of tsutils.unionConstituents(discriminantType)) { | ||
for (const intersectionPart of tsutils.intersectionConstituents(unionPart)) { | ||
if (caseTypes.has(intersectionPart) || | ||
@@ -288,6 +288,6 @@ !isTypeLiteralLikeType(intersectionPart)) { | ||
return tsutils | ||
.unionTypeParts(type) | ||
.unionConstituents(type) | ||
.some(type => tsutils | ||
.intersectionTypeParts(type) | ||
.intersectionConstituents(type) | ||
.every(subType => !isTypeLiteralLikeType(subType))); | ||
} |
@@ -218,4 +218,4 @@ "use strict"; | ||
for (const intersectionPart of tsutils | ||
.unionTypeParts(services.getTypeAtLocation(node)) | ||
.flatMap(unionPart => tsutils.intersectionTypeParts(unionPart))) { | ||
.unionConstituents(services.getTypeAtLocation(node)) | ||
.flatMap(unionPart => tsutils.intersectionConstituents(unionPart))) { | ||
const reported = checkIfMethodAndReport(property.key, intersectionPart.getProperty(property.key.name)); | ||
@@ -222,0 +222,0 @@ if (reported) { |
@@ -66,3 +66,3 @@ "use strict"; | ||
function isFlaggableHandlerType(type) { | ||
for (const unionPart of tsutils.unionTypeParts(type)) { | ||
for (const unionPart of tsutils.unionConstituents(type)) { | ||
const callSignatures = tsutils.getCallSignaturesOfType(unionPart); | ||
@@ -69,0 +69,0 @@ if (callSignatures.length === 0) { |
@@ -61,5 +61,5 @@ "use strict"; | ||
return tsutils | ||
.unionTypeParts(type) | ||
.flatMap(part => tsutils.intersectionTypeParts(part)) | ||
.unionConstituents(type) | ||
.flatMap(part => tsutils.intersectionConstituents(part)) | ||
.some(t => checker.isArrayType(t) || checker.isTupleType(t)); | ||
} |
@@ -44,6 +44,6 @@ "use strict"; | ||
const isPossiblyFalsy = (type) => tsutils | ||
.unionTypeParts(type) | ||
.unionConstituents(type) | ||
// Intersections like `string & {}` can also be possibly falsy, | ||
// requiring us to look into the intersection. | ||
.flatMap(type => tsutils.intersectionTypeParts(type)) | ||
.flatMap(type => tsutils.intersectionConstituents(type)) | ||
// PossiblyFalsy flag includes literal values, so exclude ones that | ||
@@ -55,4 +55,4 @@ // are definitely truthy | ||
const isPossiblyTruthy = (type) => tsutils | ||
.unionTypeParts(type) | ||
.map(type => tsutils.intersectionTypeParts(type)) | ||
.unionConstituents(type) | ||
.map(type => tsutils.intersectionConstituents(type)) | ||
.some(intersectionParts => | ||
@@ -59,0 +59,0 @@ // It is possible to define intersections that are always falsy, |
{ | ||
"name": "@typescript-eslint/eslint-plugin", | ||
"version": "8.31.2-alpha.8", | ||
"version": "8.32.0", | ||
"description": "TypeScript plugin for ESLint", | ||
@@ -53,4 +53,3 @@ "files": [ | ||
"build": "tsc -b tsconfig.build.json", | ||
"clean": "tsc -b tsconfig.build.json --clean", | ||
"postclean": "rimraf dist && rimraf coverage", | ||
"clean": "rimraf dist/ coverage/", | ||
"format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore", | ||
@@ -61,3 +60,3 @@ "generate:breaking-changes": "tsx tools/generate-breaking-changes.mts", | ||
"test": "vitest --run --config=$INIT_CWD/vitest.config.mts", | ||
"test-single": "vitest --run --config=$INIT_CWD/vitest.config.mts", | ||
"test-single": "vitest --run --config=$INIT_CWD/vitest.config.mts --no-coverage", | ||
"check-types": "npx nx typecheck" | ||
@@ -67,10 +66,10 @@ }, | ||
"@eslint-community/regexpp": "^4.10.0", | ||
"@typescript-eslint/scope-manager": "8.31.2-alpha.8", | ||
"@typescript-eslint/type-utils": "8.31.2-alpha.8", | ||
"@typescript-eslint/utils": "8.31.2-alpha.8", | ||
"@typescript-eslint/visitor-keys": "8.31.2-alpha.8", | ||
"@typescript-eslint/scope-manager": "8.32.0", | ||
"@typescript-eslint/type-utils": "8.32.0", | ||
"@typescript-eslint/utils": "8.32.0", | ||
"@typescript-eslint/visitor-keys": "8.32.0", | ||
"graphemer": "^1.4.0", | ||
"ignore": "^5.3.1", | ||
"natural-compare": "^1.4.0", | ||
"ts-api-utils": "^2.0.1" | ||
"ts-api-utils": "^2.1.0" | ||
}, | ||
@@ -81,5 +80,5 @@ "devDependencies": { | ||
"@types/natural-compare": "*", | ||
"@typescript-eslint/rule-schema-to-typescript-types": "8.31.2-alpha.8", | ||
"@typescript-eslint/rule-tester": "8.31.2-alpha.8", | ||
"@vitest/coverage-v8": "^3.1.1", | ||
"@typescript-eslint/rule-schema-to-typescript-types": "8.32.0", | ||
"@typescript-eslint/rule-tester": "8.32.0", | ||
"@vitest/coverage-v8": "^3.1.2", | ||
"ajv": "^6.12.6", | ||
@@ -90,3 +89,3 @@ "cross-fetch": "*", | ||
"markdown-table": "^3.0.3", | ||
"marked": "^5.1.2", | ||
"marked": "^15.0.0", | ||
"mdast-util-from-markdown": "^2.0.0", | ||
@@ -101,3 +100,3 @@ "mdast-util-mdx": "^3.0.0", | ||
"unist-util-visit": "^5.0.0", | ||
"vitest": "^3.1.1" | ||
"vitest": "^3.1.2" | ||
}, | ||
@@ -104,0 +103,0 @@ "peerDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
2525560
0.31%817
0.37%39701
0.41%0
-100%+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated