@fimbul/mimir
Advanced tools
Comparing version 0.24.0 to 0.25.0-dev.20210309
{ | ||
"name": "@fimbul/mimir", | ||
"version": "0.24.0", | ||
"version": "0.25.0-dev.20210309", | ||
"description": "Core rules of the Fimbullinter project", | ||
@@ -29,7 +29,7 @@ "main": "recommended.yaml", | ||
"dependencies": { | ||
"@fimbul/ymir": "^0.24.0", | ||
"@fimbul/ymir": "0.24.0", | ||
"chalk": "^4.0.0", | ||
"debug": "^4.0.0", | ||
"tslib": "^2.0.0", | ||
"tsutils": "^3.19.1" | ||
"tsutils": "^3.21.0" | ||
}, | ||
@@ -36,0 +36,0 @@ "peerDependencies": { |
@@ -8,3 +8,3 @@ "use strict"; | ||
function isIterationProtocolAvailable(compilerOptions) { | ||
return compilerOptions.target >= ts.ScriptTarget.ES2015 || tsutils_1.isCompilerOptionEnabled(compilerOptions, 'downlevelIteration'); | ||
return compilerOptions.target >= ts.ScriptTarget.ES2015 || (0, tsutils_1.isCompilerOptionEnabled)(compilerOptions, 'downlevelIteration'); | ||
} | ||
@@ -15,3 +15,3 @@ function isExpressionIterable(node, checker, compilerOptions, matchIndexSignature) { | ||
? isIterable(checker.getApparentType(type), checker, node, matchIndexSignature) | ||
: tsutils_1.unionTypeParts(utils_1.tryGetBaseConstraintType(type, checker)).every((t) => isArrayLike(t, compilerOptions)); | ||
: (0, tsutils_1.unionTypeParts)((0, utils_1.tryGetBaseConstraintType)(type, checker)).every((t) => isArrayLike(t, compilerOptions)); | ||
} | ||
@@ -21,3 +21,3 @@ exports.isExpressionIterable = isExpressionIterable; | ||
var _a, _b; | ||
if (tsutils_1.isTypeReference(type)) | ||
if ((0, tsutils_1.isTypeReference)(type)) | ||
type = type.target; | ||
@@ -31,3 +31,3 @@ if (type.getNumberIndexType() === undefined) | ||
return true; | ||
if (tsutils_1.isIntersectionType(type)) | ||
if ((0, tsutils_1.isIntersectionType)(type)) | ||
return type.types.some((t) => isArrayLike(t, compilerOptions)); | ||
@@ -40,3 +40,3 @@ return !!((_b = type.getBaseTypes()) === null || _b === void 0 ? void 0 : _b.some((t) => isArrayLike(t, compilerOptions))); | ||
return false; | ||
const iteratorFn = tsutils_1.getPropertyOfType(type, '__@iterator'); | ||
const iteratorFn = (0, tsutils_1.getWellKnownSymbolPropertyOfType)(type, 'iterator', checker); | ||
if (!isPresentPublicAndRequired(iteratorFn)) | ||
@@ -50,8 +50,8 @@ return false; | ||
if (!isPresentAndPublic(done) || | ||
tsutils_1.someTypePart(tsutils_1.removeOptionalityFromType(checker, checker.getTypeOfSymbolAtLocation(done, node)), tsutils_1.isUnionType, (t) => !tsutils_1.isTypeFlagSet(t, ts.TypeFlags.BooleanLike))) | ||
(0, tsutils_1.someTypePart)((0, tsutils_1.removeOptionalityFromType)(checker, checker.getTypeOfSymbolAtLocation(done, node)), tsutils_1.isUnionType, (t) => !(0, tsutils_1.isTypeFlagSet)(t, ts.TypeFlags.BooleanLike))) | ||
return false; | ||
const value = tsutils_1.getIteratorYieldResultFromIteratorResult(iteratorResult, node, checker).getProperty('value'); | ||
const value = (0, tsutils_1.getIteratorYieldResultFromIteratorResult)(iteratorResult, node, checker).getProperty('value'); | ||
return isPresentAndPublic(value) && | ||
(!matchIndexSignature || | ||
utils_1.typesAreEqual(checker.getTypeOfSymbolAtLocation(value, node), indexType, checker)); | ||
(0, utils_1.typesAreEqual)(checker.getTypeOfSymbolAtLocation(value, node), indexType, checker)); | ||
}); | ||
@@ -90,3 +90,3 @@ }); | ||
function isPresentPublicAndRequired(symbol) { | ||
return isPresentAndPublic(symbol) && !tsutils_1.isSymbolFlagSet(symbol, ts.SymbolFlags.Optional); | ||
return isPresentAndPublic(symbol) && !(0, tsutils_1.isSymbolFlagSet)(symbol, ts.SymbolFlags.Optional); | ||
} | ||
@@ -96,4 +96,4 @@ function isPresentAndPublic(symbol) { | ||
(symbol.declarations === undefined || | ||
symbol.declarations.every((d) => !tsutils_1.isModifierFlagSet(d, ts.ModifierFlags.NonPublicAccessibilityModifier))); | ||
symbol.declarations.every((d) => !(0, tsutils_1.isModifierFlagSet)(d, ts.ModifierFlags.NonPublicAccessibilityModifier))); | ||
} | ||
//# sourceMappingURL=iteration.js.map |
@@ -12,3 +12,3 @@ "use strict"; | ||
if (flags & ts.ModifierFlags.Abstract) | ||
return `Abstract property '${name}' in class '${printClass(tsutils_1.getSymbolOfClassLikeDeclaration(useDuringClassInitialization.parent, checker), checker)}' cannot be accessed during class initialization.`; | ||
return `Abstract property '${name}' in class '${printClass((0, tsutils_1.getSymbolOfClassLikeDeclaration)(useDuringClassInitialization.parent, checker), checker)}' cannot be accessed during class initialization.`; | ||
if ( | ||
@@ -18,3 +18,3 @@ // checking use before assign in constructor requires control flow graph | ||
// only checking read access | ||
tsutils_1.getAccessKind(node) & tsutils_1.AccessKind.Read && | ||
(0, tsutils_1.getAccessKind)(node) & tsutils_1.AccessKind.Read && | ||
isPropertyUsedBeforeAssign(symbol.valueDeclaration, useDuringClassInitialization, compilerOptions, checker)) | ||
@@ -28,3 +28,3 @@ return `Property '${name}' is used before its initialization.`; | ||
if (flags & ts.ModifierFlags.Abstract && | ||
symbol.declarations.every((d) => tsutils_1.hasModifier(d.modifiers, ts.SyntaxKind.AbstractKeyword))) | ||
symbol.declarations.every((d) => (0, tsutils_1.hasModifier)(d.modifiers, ts.SyntaxKind.AbstractKeyword))) | ||
return `Abstract member '${name}' in class '${printClass(getDeclaringClassOfMember(symbol.valueDeclaration, checker), checker)}' cannot be accessed via the 'super' keyword.`; | ||
@@ -62,3 +62,3 @@ } | ||
case ts.SyntaxKind.ClassExpression: { | ||
const declaredType = tsutils_1.getInstanceTypeOfClassLikeDeclaration(node, checker); | ||
const declaredType = (0, tsutils_1.getInstanceTypeOfClassLikeDeclaration)(node, checker); | ||
if (baseClasses.every((baseClass) => hasBase(declaredType, baseClass, typeContainsDeclaration))) | ||
@@ -82,3 +82,3 @@ return declaredType; | ||
let thisType = checker.getTypeFromTypeNode(thisParameter.type); | ||
if (tsutils_1.isTypeParameter(thisType)) { | ||
if ((0, tsutils_1.isTypeParameter)(thisType)) { | ||
const constraint = thisType.getConstraint(); | ||
@@ -89,3 +89,3 @@ if (constraint === undefined) | ||
} | ||
if (tsutils_1.isTypeReference(thisType)) | ||
if ((0, tsutils_1.isTypeReference)(thisType)) | ||
thisType = thisType.target; | ||
@@ -119,3 +119,3 @@ return baseClasses.every((baseClass) => hasBase(thisType, baseClass, typeContainsDeclaration)) ? thisType : undefined; | ||
case ts.SyntaxKind.SetAccessor: | ||
return tsutils_1.hasModifier(node.modifiers, ts.SyntaxKind.StaticKeyword); | ||
return (0, tsutils_1.hasModifier)(node.modifiers, ts.SyntaxKind.StaticKeyword); | ||
case ts.SyntaxKind.Constructor: | ||
@@ -143,3 +143,3 @@ return false; | ||
while (true) { | ||
if (tsutils_1.isFunctionScopeBoundary(node)) | ||
if ((0, tsutils_1.isFunctionScopeBoundary)(node)) | ||
return node.kind === ts.SyntaxKind.Constructor ? node : undefined; | ||
@@ -154,3 +154,3 @@ if (node.kind === ts.SyntaxKind.PropertyDeclaration) | ||
var _a; | ||
if (tsutils_1.isTypeReference(t)) { | ||
if ((0, tsutils_1.isTypeReference)(t)) { | ||
t = t.target; | ||
@@ -162,3 +162,3 @@ if (check(t, needle)) | ||
return true; | ||
return tsutils_1.isIntersectionType(t) && t.types.some(recur); | ||
return (0, tsutils_1.isIntersectionType)(t) && t.types.some(recur); | ||
})(type); | ||
@@ -179,3 +179,3 @@ } | ||
const { parameters } = node; | ||
return parameters.length !== 0 && tsutils_1.isThisParameter(parameters[0]) ? parameters[0] : undefined; | ||
return parameters.length !== 0 && (0, tsutils_1.isThisParameter)(parameters[0]) ? parameters[0] : undefined; | ||
} | ||
@@ -218,3 +218,3 @@ case ts.SyntaxKind.ClassDeclaration: | ||
function isPropertyUsedBeforeAssign(prop, usedIn, compilerOptions, checker) { | ||
if (tsutils_1.isParameterDeclaration(prop)) | ||
if ((0, tsutils_1.isParameterDeclaration)(prop)) | ||
// when emitting native class fields, parameter properties cannot be used in other property's initializers in the same class | ||
@@ -231,10 +231,10 @@ return prop.parent.parent === usedIn.parent && isEmittingNativeClassFields(compilerOptions); | ||
// NOT OK if [[Define]] semantics are used, because it overrides the property from the base class | ||
if (!tsutils_1.hasModifier(prop.modifiers, ts.SyntaxKind.DeclareKeyword) && | ||
tsutils_1.isCompilerOptionEnabled(compilerOptions, 'useDefineForClassFields')) | ||
if (!(0, tsutils_1.hasModifier)(prop.modifiers, ts.SyntaxKind.DeclareKeyword) && | ||
(0, tsutils_1.isCompilerOptionEnabled)(compilerOptions, 'useDefineForClassFields')) | ||
return true; | ||
} | ||
return tsutils_1.getBaseClassMemberOfClassElement(prop, checker) === undefined; | ||
return (0, tsutils_1.getBaseClassMemberOfClassElement)(prop, checker) === undefined; | ||
} | ||
function isEmittingNativeClassFields(compilerOptions) { | ||
return compilerOptions.target === ts.ScriptTarget.ESNext && tsutils_1.isCompilerOptionEnabled(compilerOptions, 'useDefineForClassFields'); | ||
return compilerOptions.target === ts.ScriptTarget.ESNext && (0, tsutils_1.isCompilerOptionEnabled)(compilerOptions, 'useDefineForClassFields'); | ||
} | ||
@@ -244,10 +244,10 @@ function getDeclaringClassOfMember(node, checker) { | ||
case ts.SyntaxKind.PropertyDeclaration: // regular property | ||
return tsutils_1.getSymbolOfClassLikeDeclaration(node.parent, checker); | ||
return (0, tsutils_1.getSymbolOfClassLikeDeclaration)(node.parent, checker); | ||
case ts.SyntaxKind.Parameter: // parameter property | ||
return tsutils_1.getSymbolOfClassLikeDeclaration(node.parent.parent, checker); | ||
return (0, tsutils_1.getSymbolOfClassLikeDeclaration)(node.parent.parent, checker); | ||
case ts.SyntaxKind.MethodDeclaration: | ||
case ts.SyntaxKind.GetAccessor: | ||
case ts.SyntaxKind.SetAccessor: | ||
if (tsutils_1.isClassLikeDeclaration(node.parent)) | ||
return tsutils_1.getSymbolOfClassLikeDeclaration(node.parent, checker); | ||
if ((0, tsutils_1.isClassLikeDeclaration)(node.parent)) | ||
return (0, tsutils_1.getSymbolOfClassLikeDeclaration)(node.parent, checker); | ||
// falls through | ||
@@ -254,0 +254,0 @@ // JS special property assignment declarations |
@@ -12,3 +12,3 @@ "use strict"; | ||
while (wrap.next !== undefined) { | ||
if (tsutils_1.isTypeNodeKind(wrap.kind)) { | ||
if ((0, tsutils_1.isTypeNodeKind)(wrap.kind)) { | ||
wrap = wrap.skip; | ||
@@ -23,10 +23,10 @@ } | ||
checkNode(node) { | ||
if (tsutils_1.isExpression(node)) { | ||
if (!tsutils_1.isIdentifier(node) || tsutils_1.getUsageDomain(node) !== undefined) | ||
if ((0, tsutils_1.isExpression)(node)) { | ||
if (!(0, tsutils_1.isIdentifier)(node) || (0, tsutils_1.getUsageDomain)(node) !== undefined) | ||
this.checkAssignment(node); | ||
} | ||
else if (tsutils_1.isPropertyDeclaration(node)) { | ||
else if ((0, tsutils_1.isPropertyDeclaration)(node)) { | ||
this.checkClassProperty(node, node.parent); | ||
} | ||
else if (tsutils_1.isMethodDeclaration(node)) { | ||
else if ((0, tsutils_1.isMethodDeclaration)(node)) { | ||
const parent = node.parent; | ||
@@ -45,9 +45,9 @@ if (parent.kind === ts.SyntaxKind.ObjectLiteralExpression) { | ||
let errorNode = node; | ||
if (tsutils_1.isArrowFunction(node)) { | ||
errorNode = tsutils_1.getModifier(node, ts.SyntaxKind.AsyncKeyword) || node.equalsGreaterThanToken; | ||
if ((0, tsutils_1.isArrowFunction)(node)) { | ||
errorNode = (0, tsutils_1.getModifier)(node, ts.SyntaxKind.AsyncKeyword) || node.equalsGreaterThanToken; | ||
} | ||
else if (tsutils_1.isFunctionExpression(node)) { | ||
errorNode = tsutils_1.getModifier(node, ts.SyntaxKind.AsyncKeyword) || | ||
else if ((0, tsutils_1.isFunctionExpression)(node)) { | ||
errorNode = (0, tsutils_1.getModifier)(node, ts.SyntaxKind.AsyncKeyword) || | ||
node.name || | ||
tsutils_1.getChildOfKind(node, ts.SyntaxKind.FunctionKeyword); | ||
(0, tsutils_1.getChildOfKind)(node, ts.SyntaxKind.FunctionKeyword); | ||
} | ||
@@ -60,3 +60,3 @@ this.addFindingAtNode(errorNode, "A 'Promise'-returning function should not be assigned to a 'void'-returning function type."); | ||
node.name.kind === ts.SyntaxKind.PrivateIdentifier || | ||
tsutils_1.hasModifier(node.modifiers, ts.SyntaxKind.StaticKeyword)) | ||
(0, tsutils_1.hasModifier)(node.modifiers, ts.SyntaxKind.StaticKeyword)) | ||
return; | ||
@@ -72,3 +72,3 @@ const checker = this.checker; | ||
} | ||
const property = tsutils_1.getSingleLateBoundPropertyNameOfPropertyName(node.name, this.checker); | ||
const property = (0, tsutils_1.getSingleLateBoundPropertyNameOfPropertyName)(node.name, this.checker); | ||
if (property === undefined) | ||
@@ -80,6 +80,6 @@ return; | ||
if (returnTypeMatches(this.getTypeOfProperty(checker.getTypeAtLocation(base), symbolName, base), checker, isVoidType)) | ||
return this.addFindingAtNode(tsutils_1.getModifier(node, ts.SyntaxKind.AsyncKeyword) || node.name, `Overriding 'void'-returning method '${displayName}' of base type with a 'Promise'-returning method is unsafe.`); | ||
return this.addFindingAtNode((0, tsutils_1.getModifier)(node, ts.SyntaxKind.AsyncKeyword) || node.name, `Overriding 'void'-returning method '${displayName}' of base type with a 'Promise'-returning method is unsafe.`); | ||
} | ||
getTypeOfProperty(classType, name, node) { | ||
const propertySymbol = tsutils_1.getPropertyOfType(classType, name); | ||
const propertySymbol = (0, tsutils_1.getPropertyOfType)(classType, name); | ||
return propertySymbol && this.checker.getTypeOfSymbolAtLocation(propertySymbol, node); | ||
@@ -91,7 +91,7 @@ } | ||
return; | ||
for (const { displayName, symbolName } of tsutils_1.getLateBoundPropertyNamesOfPropertyName(node.name, this.checker).names) { | ||
const property = tsutils_1.getPropertyOfType(contextualType, symbolName); | ||
for (const { displayName, symbolName } of (0, tsutils_1.getLateBoundPropertyNamesOfPropertyName)(node.name, this.checker).names) { | ||
const property = (0, tsutils_1.getPropertyOfType)(contextualType, symbolName); | ||
const propertyType = property !== undefined | ||
? this.checker.getTypeOfSymbolAtLocation(property, parent) | ||
: tsutils_1.isNumericPropertyName(symbolName) && contextualType.getNumberIndexType() || contextualType.getStringIndexType(); | ||
: (0, tsutils_1.isNumericPropertyName)(symbolName) && contextualType.getNumberIndexType() || contextualType.getStringIndexType(); | ||
if (!returnTypeMatches(propertyType, this.checker, isVoidType)) | ||
@@ -101,7 +101,7 @@ continue; | ||
if (signature !== undefined && typeContainsThenable(signature.getReturnType(), this.checker, node)) | ||
return this.addFindingAtNode(tsutils_1.getModifier(node, ts.SyntaxKind.AsyncKeyword) || node.name, `'Promise'-returning method '${displayName}' should not be assigned to a 'void'-returning function type.`); | ||
return this.addFindingAtNode((0, tsutils_1.getModifier)(node, ts.SyntaxKind.AsyncKeyword) || node.name, `'Promise'-returning method '${displayName}' should not be assigned to a 'void'-returning function type.`); | ||
} | ||
} | ||
}; | ||
Rule = tslib_1.__decorate([ | ||
Rule = (0, tslib_1.__decorate)([ | ||
ymir_1.excludeDeclarationFiles | ||
@@ -113,7 +113,7 @@ ], Rule); | ||
return false; | ||
const callSignatures = tsutils_1.removeOptionalityFromType(checker, type).getCallSignatures(); | ||
const callSignatures = (0, tsutils_1.removeOptionalityFromType)(checker, type).getCallSignatures(); | ||
return callSignatures.length !== 0 && callSignatures.every((signature) => predicate(signature.getReturnType(), checker, param)); | ||
} | ||
function typeContainsThenable(type, checker, node) { | ||
return tsutils_1.unionTypeParts(type).some((t) => tsutils_1.isThenableType(checker, node, t)); | ||
return (0, tsutils_1.unionTypeParts)(type).some((t) => (0, tsutils_1.isThenableType)(checker, node, t)); | ||
} | ||
@@ -120,0 +120,0 @@ function isVoidType(type) { |
@@ -14,7 +14,7 @@ "use strict"; | ||
for (let match = re.exec(this.sourceFile.text); match !== null; match = re.exec(this.sourceFile.text)) { | ||
const { node } = tsutils_1.getWrappedNodeAtPosition(wrappedAst !== null && wrappedAst !== void 0 ? wrappedAst : (wrappedAst = this.context.getWrappedAst()), match.index); | ||
const { node } = (0, tsutils_1.getWrappedNodeAtPosition)(wrappedAst !== null && wrappedAst !== void 0 ? wrappedAst : (wrappedAst = this.context.getWrappedAst()), match.index); | ||
if (node.kind !== ts.SyntaxKind.AsyncKeyword || node.end !== re.lastIndex) | ||
continue; | ||
const parent = node.parent; | ||
if (utils_1.isAsyncFunction(parent)) | ||
if ((0, utils_1.isAsyncFunction)(parent)) | ||
parent.body.statements.forEach(this.visitStatement, this); | ||
@@ -24,12 +24,12 @@ } | ||
visitStatement(node) { | ||
if (tsutils_1.isExpressionStatement(node)) { | ||
if (tsutils_1.isCallExpression(node.expression) && tsutils_1.isThenableType(this.checker, node.expression)) | ||
if ((0, tsutils_1.isExpressionStatement)(node)) { | ||
if ((0, tsutils_1.isCallExpression)(node.expression) && (0, tsutils_1.isThenableType)(this.checker, node.expression)) | ||
this.addFindingAtNode(node, "Return value of async function call was discarded. Did you mean to 'await' its result?"); | ||
return; | ||
} | ||
for (const statement of utils_1.childStatements(node)) | ||
for (const statement of (0, utils_1.childStatements)(node)) | ||
this.visitStatement(statement); | ||
} | ||
}; | ||
Rule = tslib_1.__decorate([ | ||
Rule = (0, tslib_1.__decorate)([ | ||
ymir_1.excludeDeclarationFiles | ||
@@ -36,0 +36,0 @@ ], Rule); |
@@ -14,4 +14,4 @@ "use strict"; | ||
for (let match = re.exec(this.sourceFile.text); match !== null; match = re.exec(this.sourceFile.text)) { | ||
const { node } = tsutils_1.getWrappedNodeAtPosition(wrappedAst !== null && wrappedAst !== void 0 ? wrappedAst : (wrappedAst = this.context.getWrappedAst()), match.index); | ||
if (tsutils_1.isAwaitExpression(node)) { | ||
const { node } = (0, tsutils_1.getWrappedNodeAtPosition)(wrappedAst !== null && wrappedAst !== void 0 ? wrappedAst : (wrappedAst = this.context.getWrappedAst()), match.index); | ||
if ((0, tsutils_1.isAwaitExpression)(node)) { | ||
if (node.expression.pos !== re.lastIndex || | ||
@@ -21,3 +21,3 @@ this.maybePromiseLike(this.checker.getTypeAtLocation(node.expression), node.expression)) | ||
const fix = [ymir_1.Replacement.delete(match.index, node.expression.getStart(this.sourceFile))]; | ||
if (utils_1.expressionNeedsParensWhenReplacingNode(node.expression, node)) | ||
if ((0, utils_1.expressionNeedsParensWhenReplacingNode)(node.expression, node)) | ||
fix.push(ymir_1.Replacement.append(match.index, '('), ymir_1.Replacement.append(node.expression.end, ')')); | ||
@@ -28,3 +28,3 @@ this.addFinding(match.index, node.end, "Unnecessary 'await' of a non-Promise value.", fix); | ||
const parent = node.parent; | ||
if (tsutils_1.isForOfStatement(parent) && !this.isAsyncIterable(parent.expression)) { | ||
if ((0, tsutils_1.isForOfStatement)(parent) && !this.isAsyncIterable(parent.expression)) { | ||
const start = node.pos - 'for'.length; | ||
@@ -40,3 +40,3 @@ this.addFinding(start, parent.statement.pos, "Unnecessary 'for await' of a non-AsyncIterable value.", ymir_1.Replacement.delete(start + 'for'.length, re.lastIndex)); | ||
return true; | ||
for (const t of tsutils_1.unionTypeParts(type)) | ||
for (const t of (0, tsutils_1.unionTypeParts)(type)) | ||
if (this.isThenable(t, node)) | ||
@@ -58,3 +58,3 @@ return true; | ||
return true; | ||
for (const t of tsutils_1.unionTypeParts(type)) | ||
for (const t of (0, tsutils_1.unionTypeParts)(type)) | ||
/* | ||
@@ -65,3 +65,3 @@ * We already know this type implements the iteration protocol, we just need to know if it involves Promises. | ||
*/ | ||
if (tsutils_1.getPropertyOfType(t, '__@asyncIterator') !== undefined || this.isIterableOfPromises(t, node)) | ||
if ((0, tsutils_1.getWellKnownSymbolPropertyOfType)(t, 'asyncIterator', this.checker) !== undefined || this.isIterableOfPromises(t, node)) | ||
return true; | ||
@@ -71,3 +71,3 @@ return false; | ||
isIterableOfPromises(type, node) { | ||
const symbol = tsutils_1.getPropertyOfType(type, '__@iterator'); | ||
const symbol = (0, tsutils_1.getWellKnownSymbolPropertyOfType)(type, 'iterator', this.checker); | ||
if (symbol === undefined) | ||
@@ -89,3 +89,3 @@ return false; | ||
for (const nextSignature of nextType.getCallSignatures()) { | ||
const nextReturnType = tsutils_1.getIteratorYieldResultFromIteratorResult(nextSignature.getReturnType(), node, this.checker); | ||
const nextReturnType = (0, tsutils_1.getIteratorYieldResultFromIteratorResult)(nextSignature.getReturnType(), node, this.checker); | ||
if (nextReturnType.flags & ts.TypeFlags.Any) | ||
@@ -101,3 +101,3 @@ return true; | ||
}; | ||
Rule = tslib_1.__decorate([ | ||
Rule = (0, tslib_1.__decorate)([ | ||
ymir_1.excludeDeclarationFiles | ||
@@ -104,0 +104,0 @@ ], Rule); |
@@ -19,3 +19,3 @@ "use strict"; | ||
const text = node.text; | ||
if (isWhitelisted(text) || (tsutils_1.getUsageDomain(node) & tsutils_1.UsageDomain.Value) === 0) | ||
if (isWhitelisted(text) || ((0, tsutils_1.getUsageDomain)(node) & tsutils_1.UsageDomain.Value) === 0) | ||
continue; | ||
@@ -36,3 +36,3 @@ const symbol = this.checker.getSymbolAtLocation(node); | ||
if (this.window === undefined) { | ||
const declaration = sourceFile.statements.find((d) => tsutils_1.isInterfaceDeclaration(d) && d.name.text === 'Window'); | ||
const declaration = sourceFile.statements.find((d) => (0, tsutils_1.isInterfaceDeclaration)(d) && d.name.text === 'Window'); | ||
this.window = this.checker.getDeclaredTypeOfSymbol(this.checker.getSymbolAtLocation(declaration.name)); | ||
@@ -43,3 +43,3 @@ } | ||
}; | ||
Rule = tslib_1.__decorate([ | ||
Rule = (0, tslib_1.__decorate)([ | ||
ymir_1.excludeDeclarationFiles | ||
@@ -61,3 +61,3 @@ ], Rule); | ||
} | ||
return tsutils_1.isSourceFile(node) && /^lib(?:\.dom)?\.d\.ts$/.test(path.basename(node.fileName)) ? node : undefined; | ||
return (0, tsutils_1.isSourceFile)(node) && /^lib(?:\.dom)?\.d\.ts$/.test(path.basename(node.fileName)) ? node : undefined; | ||
} | ||
@@ -64,0 +64,0 @@ function isWhitelisted(name) { |
@@ -14,8 +14,8 @@ "use strict"; | ||
for (let match = re.exec(this.sourceFile.text); match !== null; match = re.exec(this.sourceFile.text)) { | ||
const { node } = tsutils_1.getWrappedNodeAtPosition(wrappedAst !== null && wrappedAst !== void 0 ? wrappedAst : (wrappedAst = this.context.getWrappedAst()), match.index); | ||
if (!tsutils_1.isDeleteExpression(node) || node.expression.pos !== re.lastIndex) | ||
const { node } = (0, tsutils_1.getWrappedNodeAtPosition)(wrappedAst !== null && wrappedAst !== void 0 ? wrappedAst : (wrappedAst = this.context.getWrappedAst()), match.index); | ||
if (!(0, tsutils_1.isDeleteExpression)(node) || node.expression.pos !== re.lastIndex) | ||
continue; | ||
const { expression } = node; | ||
if (tsutils_1.isElementAccessExpression(expression)) { | ||
for (const { symbol, name } of utils_1.elementAccessSymbols(expression, this.checker)) | ||
if ((0, tsutils_1.isElementAccessExpression)(expression)) { | ||
for (const { symbol, name } of (0, utils_1.elementAccessSymbols)(expression, this.checker)) | ||
this.checkSymbol(symbol, node, name); | ||
@@ -34,7 +34,7 @@ } | ||
}; | ||
Rule = tslib_1.__decorate([ | ||
Rule = (0, tslib_1.__decorate)([ | ||
ymir_1.excludeDeclarationFiles, | ||
ymir_1.requiresCompilerOption('strictNullChecks') | ||
(0, ymir_1.requiresCompilerOption)('strictNullChecks') | ||
], Rule); | ||
exports.Rule = Rule; | ||
//# sourceMappingURL=delete-only-optional-property.js.map |
@@ -29,3 +29,3 @@ "use strict"; | ||
containsYield = true; | ||
if (tsutils_1.isFunctionScopeBoundary(wrap.node)) { | ||
if ((0, tsutils_1.isFunctionScopeBoundary)(wrap.node)) { | ||
// can iterate as linked list again for nested functions | ||
@@ -45,3 +45,3 @@ this.iterate(wrap.next, wrap.skip); | ||
}; | ||
Rule = tslib_1.__decorate([ | ||
Rule = (0, tslib_1.__decorate)([ | ||
ymir_1.excludeDeclarationFiles | ||
@@ -48,0 +48,0 @@ ], Rule); |
@@ -14,3 +14,3 @@ "use strict"; | ||
for (let match = re.exec(text); match !== null; match = re.exec(text)) { | ||
const { node } = tsutils_1.getWrappedNodeAtPosition(wrappedAst !== null && wrappedAst !== void 0 ? wrappedAst : (wrappedAst = this.context.getWrappedAst()), match.index); | ||
const { node } = (0, tsutils_1.getWrappedNodeAtPosition)(wrappedAst !== null && wrappedAst !== void 0 ? wrappedAst : (wrappedAst = this.context.getWrappedAst()), match.index); | ||
if (node.kind === ts.SyntaxKind.NewExpression && | ||
@@ -23,3 +23,3 @@ text[node.end - 1] !== ')' && | ||
}; | ||
Rule = tslib_1.__decorate([ | ||
Rule = (0, tslib_1.__decorate)([ | ||
ymir_1.excludeDeclarationFiles | ||
@@ -26,0 +26,0 @@ ], Rule); |
@@ -11,3 +11,3 @@ "use strict"; | ||
apply() { | ||
for (const { caseBlock: { clauses } } of utils_1.switchStatements(this.context)) | ||
for (const { caseBlock: { clauses } } of (0, utils_1.switchStatements)(this.context)) | ||
for (const clause of clauses) | ||
@@ -19,3 +19,3 @@ for (const statement of clause.statements) | ||
}; | ||
Rule = tslib_1.__decorate([ | ||
Rule = (0, tslib_1.__decorate)([ | ||
ymir_1.excludeDeclarationFiles | ||
@@ -31,3 +31,3 @@ ], Rule); | ||
case ts.SyntaxKind.EnumDeclaration: | ||
return !tsutils_1.hasModifier(node.modifiers, ts.SyntaxKind.ConstKeyword); | ||
return !(0, tsutils_1.hasModifier)(node.modifiers, ts.SyntaxKind.ConstKeyword); | ||
default: | ||
@@ -34,0 +34,0 @@ return false; |
@@ -14,3 +14,3 @@ "use strict"; | ||
for (let match = re.exec(text); match !== null; match = re.exec(text)) { | ||
const { node } = tsutils_1.getWrappedNodeAtPosition(wrappedAst !== null && wrappedAst !== void 0 ? wrappedAst : (wrappedAst = this.context.getWrappedAst()), match.index); | ||
const { node } = (0, tsutils_1.getWrappedNodeAtPosition)(wrappedAst !== null && wrappedAst !== void 0 ? wrappedAst : (wrappedAst = this.context.getWrappedAst()), match.index); | ||
if (node.kind === ts.SyntaxKind.DebuggerStatement) { | ||
@@ -26,3 +26,3 @@ const start = node.getStart(this.sourceFile); | ||
}; | ||
Rule = tslib_1.__decorate([ | ||
Rule = (0, tslib_1.__decorate)([ | ||
ymir_1.excludeDeclarationFiles | ||
@@ -38,5 +38,5 @@ ], Rule); | ||
default: | ||
return !tsutils_1.isIterationStatement(statement.parent); | ||
return !(0, tsutils_1.isIterationStatement)(statement.parent); | ||
} | ||
} | ||
//# sourceMappingURL=no-debugger.js.map |
@@ -12,3 +12,3 @@ "use strict"; | ||
apply() { | ||
for (const { caseBlock: { clauses } } of utils_1.switchStatements(this.context)) { | ||
for (const { caseBlock: { clauses } } of (0, utils_1.switchStatements)(this.context)) { | ||
const expressionsSeen = new Set(); | ||
@@ -47,3 +47,3 @@ const valuesSeen = new Set(); | ||
let prefixFn = identity; | ||
while (tsutils_1.isPrefixUnaryExpression(node)) { | ||
while ((0, tsutils_1.isPrefixUnaryExpression)(node)) { | ||
const next = makePrefixFn(node, prefixFn); | ||
@@ -55,11 +55,11 @@ if (next === undefined) | ||
} | ||
if (tsutils_1.isTextualLiteral(node)) | ||
if ((0, tsutils_1.isTextualLiteral)(node)) | ||
return [formatPrimitive(prefixFn(node.text))]; | ||
if (tsutils_1.isNumericLiteral(node)) | ||
if ((0, tsutils_1.isNumericLiteral)(node)) | ||
return [formatPrimitive(prefixFn(+node.text))]; | ||
if (_3_2_1.isBigIntLiteral(node)) | ||
if ((0, _3_2_1.isBigIntLiteral)(node)) | ||
return [formatPrimitive(prefixFn({ base10Value: node.text.slice(0, -1), negative: false }))]; | ||
if (node.kind === ts.SyntaxKind.NullKeyword) | ||
return [formatPrimitive(prefixFn(null))]; | ||
if (tsutils_1.isIdentifier(node) && node.originalKeywordKind === ts.SyntaxKind.UndefinedKeyword) | ||
if ((0, tsutils_1.isIdentifier)(node) && node.originalKeywordKind === ts.SyntaxKind.UndefinedKeyword) | ||
return [formatPrimitive(prefixFn(undefined))]; | ||
@@ -70,13 +70,13 @@ if (node.kind === ts.SyntaxKind.TrueKeyword) | ||
return [formatPrimitive(prefixFn(false))]; | ||
if (this.context.compilerOptions === undefined || !tsutils_1.isStrictCompilerOptionEnabled(this.context.compilerOptions, 'strictNullChecks')) | ||
if (this.context.compilerOptions === undefined || !(0, tsutils_1.isStrictCompilerOptionEnabled)(this.context.compilerOptions, 'strictNullChecks')) | ||
return []; | ||
const checker = this.program.getTypeChecker(); | ||
const result = new Set(); | ||
for (const t of tsutils_1.unionTypeParts(utils_1.tryGetBaseConstraintType(checker.getTypeAtLocation(node), checker))) { | ||
for (const t of (0, tsutils_1.unionTypeParts)((0, utils_1.tryGetBaseConstraintType)(checker.getTypeAtLocation(node), checker))) { | ||
// TODO handle intersection types | ||
if (tsutils_1.isLiteralType(t)) { | ||
if ((0, tsutils_1.isLiteralType)(t)) { | ||
result.add(formatPrimitive(prefixFn(t.value))); | ||
} | ||
else if (t.flags & ts.TypeFlags.BooleanLiteral) { | ||
result.add(formatPrimitive(prefixFn(tsutils_1.isBooleanLiteralType(t, true)))); | ||
result.add(formatPrimitive(prefixFn((0, tsutils_1.isBooleanLiteralType)(t, true)))); | ||
} | ||
@@ -97,3 +97,3 @@ else if (t.flags & ts.TypeFlags.Undefined) { | ||
}; | ||
Rule = tslib_1.__decorate([ | ||
Rule = (0, tslib_1.__decorate)([ | ||
ymir_1.excludeDeclarationFiles | ||
@@ -161,3 +161,3 @@ ], Rule); | ||
return isBigInt(v) | ||
? tsutils_1.formatPseudoBigInt(v) | ||
? (0, tsutils_1.formatPseudoBigInt)(v) | ||
: typeof v === 'string' | ||
@@ -164,0 +164,0 @@ ? `"${v}"` |
@@ -19,3 +19,3 @@ "use strict"; | ||
!checkedObjects.has(node.parent.pos) && | ||
!tsutils_1.isReassignmentTarget(node.parent)) { | ||
!(0, tsutils_1.isReassignmentTarget)(node.parent)) { | ||
checkedObjects.add(node.parent.pos); | ||
@@ -58,3 +58,3 @@ this.checkObject(node.parent); | ||
default: { | ||
const lateBound = tsutils_1.getLateBoundPropertyNamesOfPropertyName(property.name, this.checker); | ||
const lateBound = (0, tsutils_1.getLateBoundPropertyNamesOfPropertyName)(property.name, this.checker); | ||
if (!lateBound.known) | ||
@@ -75,11 +75,11 @@ return emptyPropertyInfo; | ||
}; | ||
Rule = tslib_1.__decorate([ | ||
Rule = (0, tslib_1.__decorate)([ | ||
ymir_1.excludeDeclarationFiles, | ||
ymir_1.requiresCompilerOption('strictNullChecks') | ||
(0, ymir_1.requiresCompilerOption)('strictNullChecks') | ||
], Rule); | ||
exports.Rule = Rule; | ||
function getPropertyInfoFromType(type) { | ||
if (tsutils_1.isUnionType(type)) | ||
if ((0, tsutils_1.isUnionType)(type)) | ||
return type.types.map(getPropertyInfoFromType).reduce(unionPropertyInfo); | ||
if (tsutils_1.isIntersectionType(type)) | ||
if ((0, tsutils_1.isIntersectionType)(type)) | ||
return type.types.map(getPropertyInfoFromType).reduce(intersectPropertyInfo); | ||
@@ -92,3 +92,3 @@ if (type.flags & ts.TypeFlags.Instantiable) { | ||
} | ||
if (!tsutils_1.isObjectType(type)) | ||
if (!(0, tsutils_1.isObjectType)(type)) | ||
return emptyPropertyInfo; | ||
@@ -112,3 +112,3 @@ const result = { | ||
for (const declaration of prop.declarations) | ||
if (tsutils_1.isClassLikeDeclaration(declaration.parent)) | ||
if ((0, tsutils_1.isClassLikeDeclaration)(declaration.parent)) | ||
return false; | ||
@@ -115,0 +115,0 @@ return true; |
@@ -12,7 +12,7 @@ "use strict"; | ||
var _a; | ||
for (const { caseBlock: { clauses } } of utils_1.switchStatements(this.context)) { | ||
for (const { caseBlock: { clauses } } of (0, utils_1.switchStatements)(this.context)) { | ||
for (let i = 1; i < clauses.length; ++i) { | ||
if (clauses[i - 1].statements.length !== 0 && | ||
!ts.forEachLeadingCommentRange(this.sourceFile.text, clauses[i].pos, isFallthroughComment, this.sourceFile.text) && | ||
!tsutils_1.endsControlFlow(clauses[i - 1], (_a = this.program) === null || _a === void 0 ? void 0 : _a.getTypeChecker())) { | ||
!(0, tsutils_1.endsControlFlow)(clauses[i - 1], (_a = this.program) === null || _a === void 0 ? void 0 : _a.getTypeChecker())) { | ||
const kind = clauses[i].kind === ts.SyntaxKind.CaseClause ? 'case' : 'default'; | ||
@@ -26,3 +26,3 @@ const start = clauses[i].getStart(this.sourceFile); | ||
}; | ||
Rule = tslib_1.__decorate([ | ||
Rule = (0, tslib_1.__decorate)([ | ||
ymir_1.excludeDeclarationFiles | ||
@@ -29,0 +29,0 @@ ], Rule); |
@@ -59,3 +59,3 @@ "use strict"; | ||
getType(node) { | ||
const type = utils_1.tryGetBaseConstraintType(this.checker.getTypeAtLocation(node), this.checker); | ||
const type = (0, utils_1.tryGetBaseConstraintType)(this.checker.getTypeAtLocation(node), this.checker); | ||
if (type.flags & (ts.TypeFlags.Any | ts.TypeFlags.Never)) | ||
@@ -66,4 +66,4 @@ return 128 /* Any */; | ||
let result = 0; | ||
for (let t of tsutils_1.unionTypeParts(type)) { | ||
if (tsutils_1.isIntersectionType(t)) | ||
for (let t of (0, tsutils_1.unionTypeParts)(type)) { | ||
if ((0, tsutils_1.isIntersectionType)(t)) | ||
// handle tagged types by extracting the primitive | ||
@@ -104,3 +104,3 @@ t = t.types.find(({ flags }) => (flags & ts.TypeFlags.Object) === 0) || t; | ||
type &= this.options; | ||
if (type === 0) | ||
if (!type) | ||
return; | ||
@@ -107,0 +107,0 @@ this.addFindingAtNode(node, `Unexpected implicit string coercion of '${formatType(type)}'.`); |
@@ -20,5 +20,5 @@ "use strict"; | ||
checkAssertion(node) { | ||
if (tsutils_1.isConstAssertion(node)) | ||
if ((0, tsutils_1.isConstAssertion)(node)) | ||
return; | ||
const assertedType = utils_1.tryGetBaseConstraintType(this.checker.getTypeFromTypeNode(node.type), this.checker); | ||
const assertedType = (0, utils_1.tryGetBaseConstraintType)(this.checker.getTypeFromTypeNode(node.type), this.checker); | ||
const assertedLiterals = getLiteralsByType(assertedType); | ||
@@ -36,3 +36,3 @@ if (isEmpty(assertedLiterals)) | ||
}; | ||
Rule = tslib_1.__decorate([ | ||
Rule = (0, tslib_1.__decorate)([ | ||
ymir_1.excludeDeclarationFiles, | ||
@@ -102,7 +102,7 @@ ymir_1.typescriptOnly | ||
if (!seenBigint) | ||
result.bigint = append(result.bigint, tsutils_1.formatPseudoBigInt(t.value)); | ||
result.bigint = append(result.bigint, (0, tsutils_1.formatPseudoBigInt)(t.value)); | ||
} | ||
else if (t.flags & ts.TypeFlags.BooleanLiteral) { | ||
if (!seenBoolean) { | ||
const current = tsutils_1.isBooleanLiteralType(t, true); | ||
const current = (0, tsutils_1.isBooleanLiteralType)(t, true); | ||
if (result.boolean === undefined) { | ||
@@ -133,4 +133,4 @@ result.boolean = current; | ||
function* typeParts(type) { | ||
for (const t of tsutils_1.unionTypeParts(type)) { | ||
if (tsutils_1.isIntersectionType(t)) { | ||
for (const t of (0, tsutils_1.unionTypeParts)(type)) { | ||
if ((0, tsutils_1.isIntersectionType)(t)) { | ||
yield* t.types; | ||
@@ -137,0 +137,0 @@ } |
@@ -10,3 +10,3 @@ "use strict"; | ||
for (const node of this.context.getFlatAst()) | ||
if (tsutils_1.isSignatureDeclaration(node) && node.typeParameters !== undefined) | ||
if ((0, tsutils_1.isSignatureDeclaration)(node) && node.typeParameters !== undefined) | ||
this.checkTypeParameters(node.typeParameters, node); | ||
@@ -16,6 +16,6 @@ } | ||
var _a; | ||
(_a = this.usage) !== null && _a !== void 0 ? _a : (this.usage = tsutils_1.collectVariableUsage(this.sourceFile)); | ||
(_a = this.usage) !== null && _a !== void 0 ? _a : (this.usage = (0, tsutils_1.collectVariableUsage)(this.sourceFile)); | ||
outer: for (const typeParameter of typeParameters) { | ||
let usedInParameters = false; | ||
let usedInReturnOrExtends = tsutils_1.isFunctionWithBody(signature); | ||
let usedInReturnOrExtends = (0, tsutils_1.isFunctionWithBody)(signature); | ||
for (const use of this.usage.get(typeParameter.name).uses) { | ||
@@ -53,3 +53,3 @@ if (use.location.pos > signature.parameters.pos && use.location.pos < signature.parameters.end) { | ||
}; | ||
Rule = tslib_1.__decorate([ | ||
Rule = (0, tslib_1.__decorate)([ | ||
ymir_1.typescriptOnly | ||
@@ -56,0 +56,0 @@ ], Rule); |
@@ -13,12 +13,12 @@ "use strict"; | ||
for (let match = re.exec(this.sourceFile.text); match !== null; match = re.exec(this.sourceFile.text)) { | ||
const { node } = tsutils_1.getWrappedNodeAtPosition(wrappedAst !== null && wrappedAst !== void 0 ? wrappedAst : (wrappedAst = this.context.getWrappedAst()), match.index); | ||
if (!tsutils_1.isIdentifier(node) || node.text !== 'NaN' || node.end !== match.index + 3) | ||
const { node } = (0, tsutils_1.getWrappedNodeAtPosition)(wrappedAst !== null && wrappedAst !== void 0 ? wrappedAst : (wrappedAst = this.context.getWrappedAst()), match.index); | ||
if (!(0, tsutils_1.isIdentifier)(node) || node.text !== 'NaN' || node.end !== match.index + 3) | ||
continue; | ||
let parent = node.parent; | ||
if (tsutils_1.isPropertyAccessExpression(parent)) { | ||
if (!tsutils_1.isIdentifier(parent.expression) || parent.expression.text !== 'Number') | ||
if ((0, tsutils_1.isPropertyAccessExpression)(parent)) { | ||
if (!(0, tsutils_1.isIdentifier)(parent.expression) || parent.expression.text !== 'Number') | ||
continue; | ||
parent = parent.parent; | ||
} | ||
if (parent.kind === ts.SyntaxKind.CaseClause || tsutils_1.isBinaryExpression(parent) && isEqualityCheck(parent.operatorToken.kind)) | ||
if (parent.kind === ts.SyntaxKind.CaseClause || (0, tsutils_1.isBinaryExpression)(parent) && isEqualityCheck(parent.operatorToken.kind)) | ||
this.addFindingAtNode(parent, "Comparing with 'NaN' always yields 'false'. Consider using 'isNaN' instead."); | ||
@@ -28,3 +28,3 @@ } | ||
}; | ||
Rule = tslib_1.__decorate([ | ||
Rule = (0, tslib_1.__decorate)([ | ||
ymir_1.excludeDeclarationFiles | ||
@@ -31,0 +31,0 @@ ], Rule); |
@@ -14,3 +14,3 @@ "use strict"; | ||
for (let match = re.exec(this.sourceFile.text); match !== null; match = re.exec(this.sourceFile.text)) { | ||
const { node } = tsutils_1.getWrappedNodeAtPosition(wrappedAst !== null && wrappedAst !== void 0 ? wrappedAst : (wrappedAst = this.context.getWrappedAst()), re.lastIndex); | ||
const { node } = (0, tsutils_1.getWrappedNodeAtPosition)(wrappedAst !== null && wrappedAst !== void 0 ? wrappedAst : (wrappedAst = this.context.getWrappedAst()), re.lastIndex); | ||
if (node.pos !== re.lastIndex) | ||
@@ -20,3 +20,3 @@ continue; | ||
case ts.SyntaxKind.SpreadAssignment: | ||
if (tsutils_1.isReassignmentTarget(node.parent.parent)) | ||
if ((0, tsutils_1.isReassignmentTarget)(node.parent.parent)) | ||
continue; | ||
@@ -30,7 +30,7 @@ // falls through | ||
checkObjectSpread(node) { | ||
if (iteration_1.isExpressionIterable(node, this.checker, this.context.compilerOptions, false)) | ||
if ((0, iteration_1.isExpressionIterable)(node, this.checker, this.context.compilerOptions, false)) | ||
this.addFindingAtNode(node, 'Spreading an Iterable type into an object is most likely a mistake. Did you intend to use array spread instead?'); | ||
} | ||
}; | ||
Rule = tslib_1.__decorate([ | ||
Rule = (0, tslib_1.__decorate)([ | ||
ymir_1.excludeDeclarationFiles | ||
@@ -37,0 +37,0 @@ ], Rule); |
@@ -15,3 +15,3 @@ "use strict"; | ||
continue; | ||
const { node } = tsutils_1.getWrappedNodeAtPosition(wrappedAst !== null && wrappedAst !== void 0 ? wrappedAst : (wrappedAst = this.context.getWrappedAst()), match.index); | ||
const { node } = (0, tsutils_1.getWrappedNodeAtPosition)(wrappedAst !== null && wrappedAst !== void 0 ? wrappedAst : (wrappedAst = this.context.getWrappedAst()), match.index); | ||
switch (node.kind) { | ||
@@ -29,3 +29,3 @@ case ts.SyntaxKind.StringLiteral: | ||
}; | ||
Rule = tslib_1.__decorate([ | ||
Rule = (0, tslib_1.__decorate)([ | ||
ymir_1.excludeDeclarationFiles | ||
@@ -32,0 +32,0 @@ ], Rule); |
@@ -19,9 +19,9 @@ "use strict"; | ||
// TODO remove this check once https://github.com/microsoft/TypeScript/issues/41021 is fixed | ||
if (tsutils_1.isTypeFlagSet(type, ts.TypeFlags.Never)) | ||
if ((0, tsutils_1.isTypeFlagSet)(type, ts.TypeFlags.Never)) | ||
return this.addFindingAtNode(node, "Invalid element access on type 'never'."); | ||
const { names } = tsutils_1.getLateBoundPropertyNames(node.argumentExpression, this.checker); | ||
const { names } = (0, tsutils_1.getLateBoundPropertyNames)(node.argumentExpression, this.checker); | ||
if (names.length === 0) | ||
return; | ||
for (const { symbol, name } of utils_1.propertiesOfType(type, names)) { | ||
const error = restricted_property_1.getRestrictedElementAccessError(this.checker, symbol, name, node, type, this.context.compilerOptions); | ||
for (const { symbol, name } of (0, utils_1.propertiesOfType)(type, names)) { | ||
const error = (0, restricted_property_1.getRestrictedElementAccessError)(this.checker, symbol, name, node, type, this.context.compilerOptions); | ||
if (error !== undefined) | ||
@@ -32,3 +32,3 @@ this.addFindingAtNode(node, error); | ||
}; | ||
Rule = tslib_1.__decorate([ | ||
Rule = (0, tslib_1.__decorate)([ | ||
ymir_1.excludeDeclarationFiles | ||
@@ -35,0 +35,0 @@ ], Rule); |
@@ -15,7 +15,7 @@ "use strict"; | ||
for (let match = re.exec(this.sourceFile.text); match !== null; match = re.exec(this.sourceFile.text)) { | ||
const { node } = tsutils_1.getWrappedNodeAtPosition(wrappedAst !== null && wrappedAst !== void 0 ? wrappedAst : (wrappedAst = this.context.getWrappedAst()), re.lastIndex - 1); | ||
if (tsutils_1.isAwaitExpression(node) && re.lastIndex === node.expression.pos && isUnnecessaryAwait(node)) { | ||
const { node } = (0, tsutils_1.getWrappedNodeAtPosition)(wrappedAst !== null && wrappedAst !== void 0 ? wrappedAst : (wrappedAst = this.context.getWrappedAst()), re.lastIndex - 1); | ||
if ((0, tsutils_1.isAwaitExpression)(node) && re.lastIndex === node.expression.pos && isUnnecessaryAwait(node)) { | ||
const keywordStart = node.expression.pos - 'await'.length; | ||
const replacements = [ymir_1.Replacement.delete(keywordStart, node.expression.getStart(this.sourceFile))]; | ||
if (utils_1.expressionNeedsParensWhenReplacingNode(node.expression, node)) | ||
if ((0, utils_1.expressionNeedsParensWhenReplacingNode)(node.expression, node)) | ||
replacements.push(ymir_1.Replacement.append(keywordStart, '('), ymir_1.Replacement.append(node.expression.end, ')')); | ||
@@ -27,3 +27,3 @@ this.addFinding(keywordStart, node.expression.pos, FAIL_MESSAGE, replacements); | ||
}; | ||
Rule = tslib_1.__decorate([ | ||
Rule = (0, tslib_1.__decorate)([ | ||
ymir_1.excludeDeclarationFiles | ||
@@ -65,5 +65,5 @@ ], Rule); | ||
while (node.parent !== undefined) { | ||
if (tsutils_1.isFunctionScopeBoundary(node)) | ||
if ((0, tsutils_1.isFunctionScopeBoundary)(node)) | ||
return false; // stop at function boundaries | ||
if (tsutils_1.isTryStatement(node.parent)) { | ||
if ((0, tsutils_1.isTryStatement)(node.parent)) { | ||
if ( | ||
@@ -70,0 +70,0 @@ // statements inside the try block always have an error handler, either catch or finally |
@@ -16,6 +16,6 @@ "use strict"; | ||
for (const node of this.context.getFlatAst()) { | ||
if (!tsutils_1.isVariableStatement(node) || | ||
tsutils_1.getVariableDeclarationKind(node.declarationList) === tsutils_1.VariableDeclarationKind.Const || | ||
tsutils_1.hasModifier(node.modifiers, ts.SyntaxKind.ExportKeyword, ts.SyntaxKind.DeclareKeyword) || | ||
tsutils_1.isAmbientModuleBlock(node.parent)) | ||
if (!(0, tsutils_1.isVariableStatement)(node) || | ||
(0, tsutils_1.getVariableDeclarationKind)(node.declarationList) === tsutils_1.VariableDeclarationKind.Const || | ||
(0, tsutils_1.hasModifier)(node.modifiers, ts.SyntaxKind.ExportKeyword, ts.SyntaxKind.DeclareKeyword) || | ||
(0, tsutils_1.isAmbientModuleBlock)(node.parent)) | ||
continue; | ||
@@ -29,3 +29,3 @@ for (const declaration of node.declarationList.declarations) | ||
if (this.usage === undefined) | ||
this.usage = tsutils_1.collectVariableUsage(this.sourceFile); | ||
this.usage = (0, tsutils_1.collectVariableUsage)(this.sourceFile); | ||
const variableInfo = this.usage.get(node); | ||
@@ -36,3 +36,3 @@ if (!variableInfo.inGlobalScope && !variableInfo.exported && !variableInfo.uses.some(utils_1.isVariableReassignment)) | ||
}; | ||
Rule = tslib_1.__decorate([ | ||
Rule = (0, tslib_1.__decorate)([ | ||
ymir_1.excludeDeclarationFiles | ||
@@ -39,0 +39,0 @@ ], Rule); |
@@ -132,3 +132,3 @@ "use strict"; | ||
}; | ||
Rule = tslib_1.__decorate([ | ||
Rule = (0, tslib_1.__decorate)([ | ||
ymir_1.excludeDeclarationFiles | ||
@@ -135,0 +135,0 @@ ], Rule); |
@@ -49,6 +49,6 @@ "use strict"; | ||
while (true) { | ||
if (tsutils_1.isLabeledStatement(node)) { | ||
if ((0, tsutils_1.isLabeledStatement)(node)) { | ||
node = node.statement; | ||
} | ||
else if (tsutils_1.isBlock(node)) { | ||
else if ((0, tsutils_1.isBlock)(node)) { | ||
const next = node.statements.find(isExecutableStatement); | ||
@@ -67,6 +67,6 @@ if (next === undefined) | ||
var _a; | ||
if (tsutils_1.endsControlFlow(statement, (_a = this.program) === null || _a === void 0 ? void 0 : _a.getTypeChecker())) | ||
if ((0, tsutils_1.endsControlFlow)(statement, (_a = this.program) === null || _a === void 0 ? void 0 : _a.getTypeChecker())) | ||
return true; | ||
const labels = []; | ||
while (tsutils_1.isLabeledStatement(statement)) { | ||
while ((0, tsutils_1.isLabeledStatement)(statement)) { | ||
labels.push(statement.label.text); | ||
@@ -81,3 +81,3 @@ statement = statement.statement; | ||
return getConstantIterationCondition(statement) === true && | ||
!tsutils_1.getControlFlowEnd(statement.statement).statements.some((jump) => jump.kind === ts.SyntaxKind.BreakStatement && | ||
!(0, tsutils_1.getControlFlowEnd)(statement.statement).statements.some((jump) => jump.kind === ts.SyntaxKind.BreakStatement && | ||
(jump.label === undefined || labels.includes(jump.label.text))); | ||
@@ -88,3 +88,3 @@ } | ||
}; | ||
Rule = tslib_1.__decorate([ | ||
Rule = (0, tslib_1.__decorate)([ | ||
ymir_1.excludeDeclarationFiles | ||
@@ -101,5 +101,5 @@ ], Rule); | ||
case ts.SyntaxKind.EnumDeclaration: | ||
return !tsutils_1.hasModifier(node.modifiers, ts.SyntaxKind.ConstKeyword); | ||
return !(0, tsutils_1.hasModifier)(node.modifiers, ts.SyntaxKind.ConstKeyword); | ||
case ts.SyntaxKind.VariableStatement: | ||
return tsutils_1.isBlockScopedVariableDeclarationList(node.declarationList) || | ||
return (0, tsutils_1.isBlockScopedVariableDeclarationList)(node.declarationList) || | ||
node.declarationList.declarations.some((d) => d.initializer !== undefined); | ||
@@ -106,0 +106,0 @@ case ts.SyntaxKind.Block: |
@@ -12,5 +12,5 @@ "use strict"; | ||
for (let match = re.exec(this.sourceFile.text); match !== null; match = re.exec(this.sourceFile.text)) { | ||
const { node } = tsutils_1.getWrappedNodeAtPosition(wrappedAst !== null && wrappedAst !== void 0 ? wrappedAst : (wrappedAst = this.context.getWrappedAst()), match.index); | ||
if (tsutils_1.isTryStatement(node) && node.finallyBlock !== undefined && node.finallyBlock.pos === match.index + 'finally'.length) | ||
for (const statement of tsutils_1.getControlFlowEnd(node.finallyBlock).statements) | ||
const { node } = (0, tsutils_1.getWrappedNodeAtPosition)(wrappedAst !== null && wrappedAst !== void 0 ? wrappedAst : (wrappedAst = this.context.getWrappedAst()), match.index); | ||
if ((0, tsutils_1.isTryStatement)(node) && node.finallyBlock !== undefined && node.finallyBlock.pos === match.index + 'finally'.length) | ||
for (const statement of (0, tsutils_1.getControlFlowEnd)(node.finallyBlock).statements) | ||
this.addFindingAtNode(statement.getChildAt(0, this.sourceFile), "Unsafe use of control flow statement inside 'finally'."); | ||
@@ -20,3 +20,3 @@ } | ||
}; | ||
Rule = tslib_1.__decorate([ | ||
Rule = (0, tslib_1.__decorate)([ | ||
ymir_1.excludeDeclarationFiles | ||
@@ -23,0 +23,0 @@ ], Rule); |
@@ -14,25 +14,25 @@ "use strict"; | ||
// TODO maybe check Type["property"] | ||
if (tsutils_1.isIdentifier(node)) { | ||
if ((0, tsutils_1.isIdentifier)(node)) { | ||
if (shouldCheckIdentifier(node)) | ||
this.checkSymbol(this.checker.getSymbolAtLocation(node), node, node.text); | ||
} | ||
else if (tsutils_1.isPropertyAccessExpression(node)) { | ||
else if ((0, tsutils_1.isPropertyAccessExpression)(node)) { | ||
this.checkSymbol(this.checker.getSymbolAtLocation(node), node, node.name.text); | ||
} | ||
else if (tsutils_1.isElementAccessExpression(node)) { | ||
else if ((0, tsutils_1.isElementAccessExpression)(node)) { | ||
this.checkElementAccess(node); | ||
} | ||
else if (tsutils_1.isPropertyAssignment(node)) { | ||
if (tsutils_1.isReassignmentTarget(node.parent)) | ||
else if ((0, tsutils_1.isPropertyAssignment)(node)) { | ||
if ((0, tsutils_1.isReassignmentTarget)(node.parent)) | ||
this.checkObjectDestructuring(node); | ||
} | ||
else if (tsutils_1.isShorthandPropertyAssignment(node)) { | ||
else if ((0, tsutils_1.isShorthandPropertyAssignment)(node)) { | ||
this.checkSymbol(this.checker.getShorthandAssignmentValueSymbol(node), node, node.name.text); | ||
if (tsutils_1.isReassignmentTarget(node.parent)) | ||
if ((0, tsutils_1.isReassignmentTarget)(node.parent)) | ||
this.checkObjectDestructuring(node); | ||
} | ||
else if (tsutils_1.isCallLikeExpression(node)) { | ||
else if ((0, tsutils_1.isCallLikeExpression)(node)) { | ||
this.checkSignature(node); | ||
} | ||
else if (tsutils_1.isObjectBindingPattern(node)) { | ||
else if ((0, tsutils_1.isObjectBindingPattern)(node)) { | ||
this.checkObjectBindingPattern(node); | ||
@@ -46,5 +46,5 @@ } | ||
checkObjectDestructuring(node) { | ||
const type = utils_1.tryGetBaseConstraintType(this.checker.getTypeOfAssignmentPattern(node.parent), this.checker); | ||
for (const { symbolName, displayName } of tsutils_1.getLateBoundPropertyNamesOfPropertyName(node.name, this.checker).names) { | ||
const symbol = tsutils_1.getPropertyOfType(type, symbolName); | ||
const type = (0, utils_1.tryGetBaseConstraintType)(this.checker.getTypeOfAssignmentPattern(node.parent), this.checker); | ||
for (const { symbolName, displayName } of (0, tsutils_1.getLateBoundPropertyNamesOfPropertyName)(node.name, this.checker).names) { | ||
const symbol = (0, tsutils_1.getPropertyOfType)(type, symbolName); | ||
if (symbol !== undefined) | ||
@@ -58,5 +58,5 @@ this.checkStability(symbol, node.name, displayName, describeWithName); | ||
checkObjectBindingPattern(node) { | ||
const type = utils_1.tryGetBaseConstraintType(this.checker.getTypeAtLocation(node), this.checker); | ||
for (const { node: nameNode, symbolName, displayName } of utils_1.destructuredProperties(node, this.checker)) { | ||
const symbol = tsutils_1.getPropertyOfType(type, symbolName); | ||
const type = (0, utils_1.tryGetBaseConstraintType)(this.checker.getTypeAtLocation(node), this.checker); | ||
for (const { node: nameNode, symbolName, displayName } of (0, utils_1.destructuredProperties)(node, this.checker)) { | ||
const symbol = (0, tsutils_1.getPropertyOfType)(type, symbolName); | ||
if (symbol !== undefined) | ||
@@ -67,3 +67,3 @@ this.checkStability(symbol, nameNode, displayName, describeWithName); | ||
checkElementAccess(node) { | ||
for (const { symbol, name } of utils_1.elementAccessSymbols(node, this.checker)) | ||
for (const { symbol, name } of (0, utils_1.elementAccessSymbols)(node, this.checker)) | ||
this.checkSymbol(symbol, node, name); | ||
@@ -124,6 +124,6 @@ } | ||
const expr = getExpressionOfCallLike(node); | ||
if (tsutils_1.isIdentifier(expr)) { | ||
if ((0, tsutils_1.isIdentifier)(expr)) { | ||
name = expr.text; | ||
} | ||
else if (tsutils_1.isPropertyAccessExpression(expr)) { | ||
else if ((0, tsutils_1.isPropertyAccessExpression)(expr)) { | ||
name = expr.name.text; | ||
@@ -180,3 +180,3 @@ } | ||
default: | ||
return tsutils_1.getUsageDomain(node) !== undefined; | ||
return (0, tsutils_1.getUsageDomain)(node) !== undefined; | ||
} | ||
@@ -183,0 +183,0 @@ } |
@@ -22,7 +22,7 @@ "use strict"; | ||
for (const node of this.context.getFlatAst()) { | ||
if (tsutils_1.isBinaryExpression(node)) { | ||
if ((0, tsutils_1.isBinaryExpression)(node)) { | ||
if (node.operatorToken.kind === ts.SyntaxKind.CommaToken && !isIndirectEval(node)) | ||
this.checkNode(node.left); | ||
} | ||
else if (tsutils_1.isExpressionStatement(node)) { | ||
else if ((0, tsutils_1.isExpressionStatement)(node)) { | ||
// allow `void asyncFn()` to mute 'await-async-result' | ||
@@ -32,3 +32,3 @@ if (!isDirective(node) && node.expression.kind !== ts.SyntaxKind.VoidExpression) | ||
} | ||
else if (tsutils_1.isForStatement(node)) { | ||
else if ((0, tsutils_1.isForStatement)(node)) { | ||
if (node.initializer !== undefined && node.initializer.kind !== ts.SyntaxKind.VariableDeclarationList) | ||
@@ -39,3 +39,3 @@ this.checkNode(node.initializer); | ||
} | ||
else if (tsutils_1.isVoidExpression(node) && !isAllowedVoidExpression(node.expression)) { | ||
else if ((0, tsutils_1.isVoidExpression)(node) && !isAllowedVoidExpression(node.expression)) { | ||
this.checkNode(node.expression); | ||
@@ -75,3 +75,3 @@ } | ||
default: | ||
return tsutils_1.isAssignmentKind(tokenKind); | ||
return (0, tsutils_1.isAssignmentKind)(tokenKind); | ||
} | ||
@@ -95,3 +95,3 @@ } | ||
}; | ||
Rule = tslib_1.__decorate([ | ||
Rule = (0, tslib_1.__decorate)([ | ||
ymir_1.excludeDeclarationFiles | ||
@@ -108,3 +108,3 @@ ], Rule); | ||
const parent = statement.parent; | ||
if (!utils_1.hasDirectivePrologue(parent)) | ||
if (!(0, utils_1.hasDirectivePrologue)(parent)) | ||
return false; | ||
@@ -121,8 +121,8 @@ for (let i = parent.statements.indexOf(statement) - 1; i >= 0; --i) | ||
expr = expr.expression; | ||
return tsutils_1.isNumericLiteral(expr) && expr.text === '0'; | ||
return (0, tsutils_1.isNumericLiteral)(expr) && expr.text === '0'; | ||
} | ||
/** Allow `(0, eval)('foo')` */ | ||
function isIndirectEval(node) { | ||
return tsutils_1.isIdentifier(node.right) && node.right.text === 'eval' && | ||
tsutils_1.isNumericLiteral(node.left) && node.left.text === '0' && | ||
return (0, tsutils_1.isIdentifier)(node.right) && node.right.text === 'eval' && | ||
(0, tsutils_1.isNumericLiteral)(node.left) && node.left.text === '0' && | ||
node.parent.kind === ts.SyntaxKind.ParenthesizedExpression && | ||
@@ -129,0 +129,0 @@ node.parent.parent.kind === ts.SyntaxKind.CallExpression; |
@@ -22,3 +22,3 @@ "use strict"; | ||
}; | ||
Rule = tslib_1.__decorate([ | ||
Rule = (0, tslib_1.__decorate)([ | ||
ymir_1.excludeDeclarationFiles | ||
@@ -28,7 +28,7 @@ ], Rule); | ||
function usesLabel(node, label) { | ||
if (tsutils_1.isBreakOrContinueStatement(node)) | ||
if ((0, tsutils_1.isBreakOrContinueStatement)(node)) | ||
return node.label !== undefined && node.label.text === label; | ||
if (tsutils_1.isLabeledStatement(node)) | ||
if ((0, tsutils_1.isLabeledStatement)(node)) | ||
return node.label.text !== label && usesLabel(node.statement, label); | ||
for (const statement of utils_1.childStatements(node)) | ||
for (const statement of (0, utils_1.childStatements)(node)) | ||
if (usesLabel(statement, label)) | ||
@@ -35,0 +35,0 @@ return true; |
@@ -16,3 +16,3 @@ "use strict"; | ||
super(...arguments); | ||
this.strictNullChecks = tsutils_1.isStrictCompilerOptionEnabled(this.context.compilerOptions, 'strictNullChecks'); | ||
this.strictNullChecks = (0, tsutils_1.isStrictCompilerOptionEnabled)(this.context.compilerOptions, 'strictNullChecks'); | ||
} | ||
@@ -42,3 +42,3 @@ apply() { | ||
node.type !== undefined && | ||
!utils_1.isAmbientVariableDeclaration(node) && (!tsutils_1.isStrictCompilerOptionEnabled(this.context.compilerOptions, 'strictNullChecks') || | ||
!(0, utils_1.isAmbientVariableDeclaration)(node) && (!(0, tsutils_1.isStrictCompilerOptionEnabled)(this.context.compilerOptions, 'strictNullChecks') || | ||
// type does not allow undefined | ||
@@ -53,7 +53,7 @@ getNullableFlagsOfReceiver(this.checker.getTypeAtLocation(node.name)) & ts.TypeFlags.Undefined)) | ||
node.type !== undefined && | ||
!utils_1.isAmbientPropertyDeclaration(node) && | ||
!tsutils_1.hasModifier(node.modifiers, ts.SyntaxKind.AbstractKeyword, ts.SyntaxKind.StaticKeyword) && ( | ||
!(0, utils_1.isAmbientPropertyDeclaration)(node) && | ||
!(0, tsutils_1.hasModifier)(node.modifiers, ts.SyntaxKind.AbstractKeyword, ts.SyntaxKind.StaticKeyword) && ( | ||
// properties with string or computed name are not checked | ||
node.name.kind !== ts.SyntaxKind.Identifier && node.name.kind !== ts.SyntaxKind.PrivateIdentifier || | ||
!tsutils_1.isStrictCompilerOptionEnabled(this.context.compilerOptions, 'strictPropertyInitialization') || | ||
!(0, tsutils_1.isStrictCompilerOptionEnabled)(this.context.compilerOptions, 'strictPropertyInitialization') || | ||
getNullableFlagsOfReceiver(this.checker.getTypeAtLocation(node)) & ts.TypeFlags.Undefined // type allows undefined | ||
@@ -67,6 +67,6 @@ )) | ||
const originalType = this.checker.getTypeAtLocation(node.expression); | ||
const flags = getNullableFlags(utils_1.tryGetBaseConstraintType(originalType, this.checker), ts.isOptionalChain(node) | ||
? (t) => tsutils_1.isOptionalChainingUndefinedMarkerType(this.checker, t) ? 0 : t.flags | ||
const flags = getNullableFlags((0, utils_1.tryGetBaseConstraintType)(originalType, this.checker), ts.isOptionalChain(node) | ||
? (t) => (0, tsutils_1.isOptionalChainingUndefinedMarkerType)(this.checker, t) ? 0 : t.flags | ||
: undefined); | ||
if (flags !== 0) { // type is nullable | ||
if (flags) { // type is nullable | ||
const contextualType = this.getSafeContextualType(node); | ||
@@ -85,4 +85,4 @@ if (contextualType === undefined || (flags & ~getNullableFlagsOfReceiver(contextualType))) | ||
checkTypeAssertion(node) { | ||
if (tsutils_1.isConstAssertion(node)) { | ||
if (tsutils_1.isInConstContext(node)) | ||
if ((0, tsutils_1.isConstAssertion)(node)) { | ||
if ((0, tsutils_1.isInConstContext)(node)) | ||
this.reportUselessTypeAssertion(node, 'This assertion is unnecessary as it is already in a const context.'); | ||
@@ -92,12 +92,12 @@ return; | ||
let targetType = this.checker.getTypeFromTypeNode(node.type); | ||
if ((targetType.flags & ts.TypeFlags.Literal) !== 0 && !tsutils_1.isInConstContext(node) || // allow "foo" as "foo" to avoid widening | ||
tsutils_1.isTupleType(tsutils_1.isTypeReference(targetType) ? targetType.target : targetType)) | ||
if ((targetType.flags & ts.TypeFlags.Literal) !== 0 && !(0, tsutils_1.isInConstContext)(node) || // allow "foo" as "foo" to avoid widening | ||
(0, tsutils_1.isTupleType)((0, tsutils_1.isTypeReference)(targetType) ? targetType.target : targetType)) | ||
return; | ||
let sourceType = this.checker.getTypeAtLocation(node.expression); | ||
if ((targetType.flags & (ts.TypeFlags.TypeVariable | ts.TypeFlags.Instantiable)) === 0) { | ||
targetType = utils_1.tryGetBaseConstraintType(targetType, this.checker); | ||
sourceType = utils_1.tryGetBaseConstraintType(sourceType, this.checker); | ||
targetType = (0, utils_1.tryGetBaseConstraintType)(targetType, this.checker); | ||
sourceType = (0, utils_1.tryGetBaseConstraintType)(sourceType, this.checker); | ||
} | ||
let message = FAIL_MESSAGE; | ||
if (!utils_1.typesAreEqual(sourceType, targetType, this.checker)) { | ||
if (!(0, utils_1.typesAreEqual)(sourceType, targetType, this.checker)) { | ||
const contextualType = this.getSafeContextualType(node); | ||
@@ -109,5 +109,5 @@ // TODO use assignability check once it's exposed from TypeChecker | ||
// contextual type is exactly the same | ||
!utils_1.typesAreEqual(sourceType, contextualType, this.checker) && | ||
!(0, utils_1.typesAreEqual)(sourceType, contextualType, this.checker) && | ||
// contextual type is an optional parameter or similar | ||
!utils_1.typesAreEqual(sourceType, tsutils_1.removeOptionalityFromType(this.checker, contextualType), this.checker)) | ||
!(0, utils_1.typesAreEqual)(sourceType, (0, tsutils_1.removeOptionalityFromType)(this.checker, contextualType), this.checker)) | ||
return; | ||
@@ -125,3 +125,3 @@ message = 'This assertion is unnecessary as the receiver accepts the original type of the expression.'; | ||
const fix = [ymir_1.Replacement.delete(start, node.expression.getStart(this.sourceFile))]; | ||
if (utils_1.expressionNeedsParensWhenReplacingNode(node.expression, node)) | ||
if ((0, utils_1.expressionNeedsParensWhenReplacingNode)(node.expression, node)) | ||
fix.push(ymir_1.Replacement.append(start, '('), ymir_1.Replacement.append(node.end, ')')); | ||
@@ -151,3 +151,3 @@ this.addFinding(start, node.expression.pos, message, fix); | ||
}; | ||
Rule = tslib_1.__decorate([ | ||
Rule = (0, tslib_1.__decorate)([ | ||
ymir_1.excludeDeclarationFiles, | ||
@@ -159,3 +159,3 @@ ymir_1.typescriptOnly | ||
let flags = 0; | ||
for (const t of tsutils_1.unionTypeParts(type)) | ||
for (const t of (0, tsutils_1.unionTypeParts)(type)) | ||
flags |= selector !== undefined ? selector(t) : t.flags; | ||
@@ -196,3 +196,3 @@ return flags & (ts.TypeFlags.Null | ts.TypeFlags.Undefined); | ||
const declaration = symbol.declarations[0]; | ||
if (!tsutils_1.isVariableDeclaration(declaration) || | ||
if (!(0, tsutils_1.isVariableDeclaration)(declaration) || | ||
declaration.parent.kind !== ts.SyntaxKind.VariableDeclarationList || | ||
@@ -203,5 +203,5 @@ declaration.initializer !== undefined || | ||
declaration.parent.parent.kind === ts.SyntaxKind.VariableStatement && | ||
tsutils_1.hasModifier(declaration.parent.parent.modifiers, ts.SyntaxKind.DeclareKeyword)) | ||
(0, tsutils_1.hasModifier)(declaration.parent.parent.modifiers, ts.SyntaxKind.DeclareKeyword)) | ||
return false; | ||
if (!utils_1.typesAreEqual(type, checker.getTypeFromTypeNode(declaration.type), checker)) | ||
if (!(0, utils_1.typesAreEqual)(type, checker.getTypeFromTypeNode(declaration.type), checker)) | ||
return false; | ||
@@ -217,3 +217,3 @@ const declaringFunctionScope = findupFunction(declaration.parent.parent.parent); | ||
function findupFunction(node) { | ||
while (!tsutils_1.isFunctionScopeBoundary(node) && node.kind !== ts.SyntaxKind.SourceFile) | ||
while (!(0, tsutils_1.isFunctionScopeBoundary)(node) && node.kind !== ts.SyntaxKind.SourceFile) | ||
node = node.parent; | ||
@@ -223,7 +223,7 @@ return node; | ||
function isInlinedIife(node) { | ||
return (tsutils_1.isFunctionExpression(node) || tsutils_1.isArrowFunction(node)) && | ||
return ((0, tsutils_1.isFunctionExpression)(node) || (0, tsutils_1.isArrowFunction)(node)) && | ||
node.asteriskToken === undefined && // exclude generators | ||
!tsutils_1.hasModifier(node.modifiers, ts.SyntaxKind.AsyncKeyword) && // exclude async functions | ||
tsutils_1.getIIFE(node) !== undefined; | ||
!(0, tsutils_1.hasModifier)(node.modifiers, ts.SyntaxKind.AsyncKeyword) && // exclude async functions | ||
(0, tsutils_1.getIIFE)(node) !== undefined; | ||
} | ||
//# sourceMappingURL=no-useless-assertion.js.map |
@@ -15,6 +15,6 @@ "use strict"; | ||
if (this.shouldCheck(statement)) { | ||
const declareKeyword = tsutils_1.getModifier(statement, ts.SyntaxKind.DeclareKeyword); | ||
const declareKeyword = (0, tsutils_1.getModifier)(statement, ts.SyntaxKind.DeclareKeyword); | ||
if (declareKeyword !== undefined) { | ||
const start = declareKeyword.end - 'declare'.length; | ||
this.addFinding(start, declareKeyword.end, "Using the 'declare' keyword here is redundant as the statement has no runtime value.", ymir_1.Replacement.delete(start, tsutils_1.getNextToken(declareKeyword).getStart(this.sourceFile))); | ||
this.addFinding(start, declareKeyword.end, "Using the 'declare' keyword here is redundant as the statement has no runtime value.", ymir_1.Replacement.delete(start, (0, tsutils_1.getNextToken)(declareKeyword).getStart(this.sourceFile))); | ||
} | ||
@@ -28,3 +28,3 @@ } | ||
checkModule(node) { | ||
if (node.body === undefined || tsutils_1.hasModifier(node.modifiers, ts.SyntaxKind.DeclareKeyword)) | ||
if (node.body === undefined || (0, tsutils_1.hasModifier)(node.modifiers, ts.SyntaxKind.DeclareKeyword)) | ||
return; | ||
@@ -42,9 +42,9 @@ if (node.body.kind === ts.SyntaxKind.ModuleDeclaration) | ||
// allow 'declare const enum' in declaration files, because it's required in declaration files | ||
return !this.sourceFile.isDeclarationFile && tsutils_1.hasModifier(node.modifiers, ts.SyntaxKind.ConstKeyword); | ||
return !this.sourceFile.isDeclarationFile && (0, tsutils_1.hasModifier)(node.modifiers, ts.SyntaxKind.ConstKeyword); | ||
default: | ||
return this.sourceFile.isDeclarationFile && tsutils_1.hasModifier(node.modifiers, ts.SyntaxKind.ExportKeyword); | ||
return this.sourceFile.isDeclarationFile && (0, tsutils_1.hasModifier)(node.modifiers, ts.SyntaxKind.ExportKeyword); | ||
} | ||
} | ||
}; | ||
Rule = tslib_1.__decorate([ | ||
Rule = (0, tslib_1.__decorate)([ | ||
ymir_1.typescriptOnly | ||
@@ -51,0 +51,0 @@ ], Rule); |
@@ -13,7 +13,7 @@ "use strict"; | ||
case ts.SyntaxKind.ArrayLiteralExpression: | ||
if (tsutils_1.isReassignmentTarget(node)) | ||
if ((0, tsutils_1.isReassignmentTarget)(node)) | ||
this.checkArray(node, node.parent.kind === ts.SyntaxKind.BinaryExpression, isNonEmptyAssignmentTarget, simplifyAssignmentRestElement); | ||
break; | ||
case ts.SyntaxKind.ObjectLiteralExpression: | ||
if (tsutils_1.isReassignmentTarget(node)) | ||
if ((0, tsutils_1.isReassignmentTarget)(node)) | ||
this.checkObject(node.properties, node.parent.kind === ts.SyntaxKind.BinaryExpression, isAssignmentPropertyUsed, tsutils_1.isSpreadAssignment, node); | ||
@@ -83,3 +83,3 @@ break; | ||
}; | ||
Rule = tslib_1.__decorate([ | ||
Rule = (0, tslib_1.__decorate)([ | ||
ymir_1.excludeDeclarationFiles | ||
@@ -122,3 +122,3 @@ ], Rule); | ||
function simplifyAssignmentRestElement(node) { | ||
return tsutils_1.isSpreadElement(node) && tsutils_1.isArrayLiteralExpression(node.expression) ? node.expression : undefined; | ||
return (0, tsutils_1.isSpreadElement)(node) && (0, tsutils_1.isArrayLiteralExpression)(node.expression) ? node.expression : undefined; | ||
} | ||
@@ -125,0 +125,0 @@ function isBindingRestProperty(node) { |
@@ -27,11 +27,11 @@ "use strict"; | ||
case ts.SyntaxKind.ObjectLiteralExpression: | ||
if (tsutils_1.isReassignmentTarget(node)) | ||
if ((0, tsutils_1.isReassignmentTarget)(node)) | ||
this.checkObjectDestructuring(node); | ||
break; | ||
case ts.SyntaxKind.ArrayLiteralExpression: | ||
if (tsutils_1.isReassignmentTarget(node)) | ||
if ((0, tsutils_1.isReassignmentTarget)(node)) | ||
this.checkArrayDestructuring(node); | ||
break; | ||
default: | ||
if (!isJs && tsutils_1.isFunctionWithBody(node)) | ||
if (!isJs && (0, tsutils_1.isFunctionWithBody)(node)) | ||
this.checkFunctionParameters(node.parameters); | ||
@@ -42,3 +42,3 @@ } | ||
checkObjectDestructuring(node) { | ||
if (this.context.compilerOptions === undefined || !tsutils_1.isStrictCompilerOptionEnabled(this.context.compilerOptions, 'strictNullChecks')) | ||
if (this.context.compilerOptions === undefined || !(0, tsutils_1.isStrictCompilerOptionEnabled)(this.context.compilerOptions, 'strictNullChecks')) | ||
return; | ||
@@ -58,3 +58,3 @@ const checker = this.program.getTypeChecker(); | ||
case ts.SyntaxKind.PropertyAssignment: | ||
if (!tsutils_1.isBinaryExpression(property.initializer)) | ||
if (!(0, tsutils_1.isBinaryExpression)(property.initializer)) | ||
continue; | ||
@@ -67,13 +67,13 @@ name = property.name; | ||
} | ||
const properties = tsutils_1.getLateBoundPropertyNamesOfPropertyName(name, checker); | ||
const properties = (0, tsutils_1.getLateBoundPropertyNamesOfPropertyName)(name, checker); | ||
if (!properties.known || properties.names.some(maybeUndefined)) | ||
continue; | ||
this.addFindingAtNode(errorNode, "Unnecessary default value as this property is never 'undefined'.", ymir_1.Replacement.delete(tsutils_1.getChildOfKind(errorNode.parent, ts.SyntaxKind.EqualsToken, this.sourceFile).pos, errorNode.end)); | ||
this.addFindingAtNode(errorNode, "Unnecessary default value as this property is never 'undefined'.", ymir_1.Replacement.delete((0, tsutils_1.getChildOfKind)(errorNode.parent, ts.SyntaxKind.EqualsToken, this.sourceFile).pos, errorNode.end)); | ||
} | ||
function maybeUndefined({ symbolName }) { | ||
return symbolMaybeUndefined(checker, tsutils_1.getPropertyOfType(type !== null && type !== void 0 ? type : (type = checker.getApparentType(checker.getTypeOfAssignmentPattern(node))), symbolName), node); | ||
return symbolMaybeUndefined(checker, (0, tsutils_1.getPropertyOfType)(type !== null && type !== void 0 ? type : (type = checker.getApparentType(checker.getTypeOfAssignmentPattern(node))), symbolName), node); | ||
} | ||
} | ||
checkArrayDestructuring(node) { | ||
if (this.context.compilerOptions === undefined || !tsutils_1.isStrictCompilerOptionEnabled(this.context.compilerOptions, 'strictNullChecks')) | ||
if (this.context.compilerOptions === undefined || !(0, tsutils_1.isStrictCompilerOptionEnabled)(this.context.compilerOptions, 'strictNullChecks')) | ||
return; | ||
@@ -84,5 +84,5 @@ const checker = this.program.getTypeChecker(); | ||
const element = node.elements[i]; | ||
if (!tsutils_1.isBinaryExpression(element)) | ||
if (!(0, tsutils_1.isBinaryExpression)(element)) | ||
continue; | ||
type !== null && type !== void 0 ? type : (type = utils_1.tryGetBaseConstraintType(checker.getTypeOfAssignmentPattern(node), checker)); | ||
type !== null && type !== void 0 ? type : (type = (0, utils_1.tryGetBaseConstraintType)(checker.getTypeOfAssignmentPattern(node), checker)); | ||
if (symbolMaybeUndefined(checker, type.getProperty(String(i)), node)) | ||
@@ -94,3 +94,3 @@ continue; | ||
checkBindingPattern(node, propNames) { | ||
if (this.context.compilerOptions === undefined || !tsutils_1.isStrictCompilerOptionEnabled(this.context.compilerOptions, 'strictNullChecks')) | ||
if (this.context.compilerOptions === undefined || !(0, tsutils_1.isStrictCompilerOptionEnabled)(this.context.compilerOptions, 'strictNullChecks')) | ||
return; | ||
@@ -112,3 +112,3 @@ const checker = this.program.getTypeChecker(); | ||
function maybeUndefined({ symbolName }) { | ||
return symbolMaybeUndefined(checker, tsutils_1.getPropertyOfType(type !== null && type !== void 0 ? type : (type = checker.getApparentType(checker.getTypeAtLocation(node))), symbolName), node); | ||
return symbolMaybeUndefined(checker, (0, tsutils_1.getPropertyOfType)(type !== null && type !== void 0 ? type : (type = checker.getApparentType(checker.getTypeAtLocation(node))), symbolName), node); | ||
} | ||
@@ -130,3 +130,3 @@ } | ||
fail(node, makeOptional) { | ||
const fix = [ymir_1.Replacement.delete(tsutils_1.getChildOfKind(node, ts.SyntaxKind.EqualsToken, this.sourceFile).pos, node.end)]; | ||
const fix = [ymir_1.Replacement.delete((0, tsutils_1.getChildOfKind)(node, ts.SyntaxKind.EqualsToken, this.sourceFile).pos, node.end)]; | ||
let message = "Unnecessary initialization with 'undefined'."; | ||
@@ -143,3 +143,3 @@ if (makeOptional) { | ||
removeUndefinedFromType(type) { | ||
if (type === undefined || !tsutils_1.isUnionTypeNode(type)) | ||
if (type === undefined || !(0, tsutils_1.isUnionTypeNode)(type)) | ||
return; | ||
@@ -156,3 +156,3 @@ for (let i = 0; i < type.types.length; ++i) { | ||
}; | ||
Rule = tslib_1.__decorate([ | ||
Rule = (0, tslib_1.__decorate)([ | ||
ymir_1.excludeDeclarationFiles | ||
@@ -167,3 +167,3 @@ ], Rule); | ||
}; | ||
return tsutils_1.getLateBoundPropertyNamesOfPropertyName(property.propertyName, checker); | ||
return (0, tsutils_1.getLateBoundPropertyNamesOfPropertyName)(property.propertyName, checker); | ||
} | ||
@@ -182,3 +182,3 @@ function getArrayPropertyName(_, i) { | ||
function typeMaybeUndefined(checker, type) { | ||
if (tsutils_1.isInstantiableType(type)) { | ||
if ((0, tsutils_1.isInstantiableType)(type)) { | ||
const constraint = checker.getBaseConstraintOfType(type); | ||
@@ -189,3 +189,3 @@ if (constraint === undefined) | ||
} | ||
if (tsutils_1.isUnionType(type)) | ||
if ((0, tsutils_1.isUnionType)(type)) | ||
return type.types.some((t) => typeMaybeUndefined(checker, t)); | ||
@@ -195,4 +195,4 @@ return (type.flags & (ts.TypeFlags.Undefined | ts.TypeFlags.Any | ts.TypeFlags.Unknown)) !== 0; | ||
function isUndefined(node) { | ||
return tsutils_1.isIdentifier(node) && node.originalKeywordKind === ts.SyntaxKind.UndefinedKeyword; | ||
return (0, tsutils_1.isIdentifier)(node) && node.originalKeywordKind === ts.SyntaxKind.UndefinedKeyword; | ||
} | ||
//# sourceMappingURL=no-useless-initializer.js.map |
@@ -14,4 +14,4 @@ "use strict"; | ||
for (let match = re.exec(text); match !== null; match = re.exec(text)) { | ||
const { node } = tsutils_1.getWrappedNodeAtPosition(wrappedAst !== null && wrappedAst !== void 0 ? wrappedAst : (wrappedAst = this.context.getWrappedAst()), match.index); | ||
if (tsutils_1.isBreakOrContinueStatement(node) && | ||
const { node } = (0, tsutils_1.getWrappedNodeAtPosition)(wrappedAst !== null && wrappedAst !== void 0 ? wrappedAst : (wrappedAst = this.context.getWrappedAst()), match.index); | ||
if ((0, tsutils_1.isBreakOrContinueStatement)(node) && | ||
node.label !== undefined && | ||
@@ -24,3 +24,3 @@ node.label.pos - match[1].length === match.index && | ||
}; | ||
Rule = tslib_1.__decorate([ | ||
Rule = (0, tslib_1.__decorate)([ | ||
ymir_1.excludeDeclarationFiles | ||
@@ -34,6 +34,6 @@ ], Rule); | ||
parent = parent.parent; | ||
if (tsutils_1.isIterationStatement(parent) || isBreak && parent.kind === ts.SyntaxKind.SwitchStatement) { | ||
if ((0, tsutils_1.isIterationStatement)(parent) || isBreak && parent.kind === ts.SyntaxKind.SwitchStatement) { | ||
// we found the closest jump target. now we need to check if it has the same label as the jump statement | ||
parent = parent.parent; | ||
while (tsutils_1.isLabeledStatement(parent)) { | ||
while ((0, tsutils_1.isLabeledStatement)(parent)) { | ||
if (parent.label.text === label.text) | ||
@@ -45,7 +45,7 @@ return false; // label is present on the closest jump target | ||
} | ||
if (isBreak && tsutils_1.isLabeledStatement(parent) && parent.label.text === label.text) | ||
if (isBreak && (0, tsutils_1.isLabeledStatement)(parent) && parent.label.text === label.text) | ||
return true; // label is not on an IterationStatement or SwitchStatement -> breaking out of blocks always requires label | ||
} while (!tsutils_1.isFunctionScopeBoundary(parent) && parent.kind !== ts.SyntaxKind.SourceFile); | ||
} while (!(0, tsutils_1.isFunctionScopeBoundary)(parent) && parent.kind !== ts.SyntaxKind.SourceFile); | ||
return true; // label is not in scope, should never get here in correct code | ||
} | ||
//# sourceMappingURL=no-useless-jump-label.js.map |
@@ -15,3 +15,3 @@ "use strict"; | ||
check(type) { | ||
return tsutils_1.isEmptyObjectType(type) ? undefined : (type.flags & primitiveFlags) === 0 && !isTypeofFunction(type); | ||
return (0, tsutils_1.isEmptyObjectType)(type) ? undefined : (type.flags & primitiveFlags) === 0 && !isTypeofFunction(type); | ||
}, | ||
@@ -59,3 +59,3 @@ }, | ||
super(...arguments); | ||
this.strictNullChecks = tsutils_1.isStrictCompilerOptionEnabled(this.context.compilerOptions, 'strictNullChecks'); | ||
this.strictNullChecks = (0, tsutils_1.isStrictCompilerOptionEnabled)(this.context.compilerOptions, 'strictNullChecks'); | ||
} | ||
@@ -117,3 +117,3 @@ apply() { | ||
isTruthyFalsy(node, nested) { | ||
if (tsutils_1.isBinaryExpression(node)) { | ||
if ((0, tsutils_1.isBinaryExpression)(node)) { | ||
if (isEqualityOperator(node.operatorToken.kind)) // TODO check <, >, <=, >= with literal types | ||
@@ -124,6 +124,6 @@ return nested ? undefined : this.isConstantComparison(node.left, node.right, node.operatorToken.kind); | ||
} | ||
else if (tsutils_1.isPrefixUnaryExpression(node) && node.operator === ts.SyntaxKind.ExclamationToken) { | ||
else if ((0, tsutils_1.isPrefixUnaryExpression)(node) && node.operator === ts.SyntaxKind.ExclamationToken) { | ||
return; | ||
} | ||
else if (tsutils_1.isParenthesizedExpression(node)) { | ||
else if ((0, tsutils_1.isParenthesizedExpression)(node)) { | ||
return this.isTruthyFalsy(node.expression, true); | ||
@@ -135,4 +135,4 @@ } | ||
isConstantComparison(left, right, operator) { | ||
left = tsutils_1.unwrapParentheses(left); | ||
right = tsutils_1.unwrapParentheses(right); | ||
left = (0, tsutils_1.unwrapParentheses)(left); | ||
right = (0, tsutils_1.unwrapParentheses)(right); | ||
const equals = { | ||
@@ -149,12 +149,12 @@ negated: operator === ts.SyntaxKind.ExclamationEqualsEqualsToken || operator === ts.SyntaxKind.ExclamationEqualsToken, | ||
let predicate; | ||
if (tsutils_1.isTypeOfExpression(left)) { | ||
left = tsutils_1.unwrapParentheses(left.expression); | ||
if ((0, tsutils_1.isTypeOfExpression)(left)) { | ||
left = (0, tsutils_1.unwrapParentheses)(left.expression); | ||
if (right.kind === ts.SyntaxKind.NullKeyword || isUndefined(right)) | ||
return equals.negated; | ||
let literal; | ||
if (tsutils_1.isTextualLiteral(right)) { | ||
if ((0, tsutils_1.isTextualLiteral)(right)) { | ||
literal = right.text; | ||
} | ||
else { | ||
const type = utils_1.tryGetBaseConstraintType(this.getTypeOfExpression(right), this.checker); | ||
const type = (0, utils_1.tryGetBaseConstraintType)(this.getTypeOfExpression(right), this.checker); | ||
if ((type.flags & ts.TypeFlags.StringLiteral) === 0) | ||
@@ -195,6 +195,6 @@ return; | ||
// TODO reuse some logic from 'no-duplicate-case' to compute prefix unary expressions | ||
const type = utils_1.tryGetBaseConstraintType(this.getTypeOfExpression(node), this.checker); | ||
for (const t of tsutils_1.intersectionTypeParts(type)) { | ||
if (tsutils_1.isLiteralType(t)) | ||
return typeof t.value === 'object' ? tsutils_1.formatPseudoBigInt(t.value) : String(t.value); | ||
const type = (0, utils_1.tryGetBaseConstraintType)(this.getTypeOfExpression(node), this.checker); | ||
for (const t of (0, tsutils_1.intersectionTypeParts)(type)) { | ||
if ((0, tsutils_1.isLiteralType)(t)) | ||
return typeof t.value === 'object' ? (0, tsutils_1.formatPseudoBigInt)(t.value) : String(t.value); | ||
if (t.flags & ts.TypeFlags.BooleanLiteral) | ||
@@ -216,3 +216,3 @@ return t.intrinsicName; | ||
// TODO use assignability check to avoid false positives | ||
predicate.nullable ? predicate.check : (t) => tsutils_1.isEmptyObjectType(t) ? undefined : predicate.check(t)); | ||
predicate.nullable ? predicate.check : (t) => (0, tsutils_1.isEmptyObjectType)(t) ? undefined : predicate.check(t)); | ||
return result && !this.strictNullChecks | ||
@@ -224,3 +224,3 @@ ? undefined | ||
let result; | ||
for (let t of tsutils_1.unionTypeParts(type)) { | ||
for (let t of (0, tsutils_1.unionTypeParts)(type)) { | ||
if (t.flags & (ts.TypeFlags.TypeVariable | ts.TypeFlags.Instantiable)) { | ||
@@ -234,3 +234,3 @@ const constraint = this.checker.getBaseConstraintOfType(t); | ||
return; | ||
switch (tsutils_1.isIntersectionType(t) ? this.matchIntersectionType(t, predicate) : predicate(t)) { | ||
switch ((0, tsutils_1.isIntersectionType)(t) ? this.matchIntersectionType(t, predicate) : predicate(t)) { | ||
case true: | ||
@@ -273,5 +273,5 @@ if (result === false) | ||
return type; | ||
if (tsutils_1.unionTypeParts(type).some((t) => (t.flags & ts.TypeFlags.Undefined) !== 0)) | ||
if ((0, tsutils_1.unionTypeParts)(type).some((t) => (t.flags & ts.TypeFlags.Undefined) !== 0)) | ||
return type; | ||
if ((!tsutils_1.isPropertyAccessExpression(node) || node.name.kind === ts.SyntaxKind.PrivateIdentifier) && !tsutils_1.isElementAccessExpression(node)) | ||
if ((!(0, tsutils_1.isPropertyAccessExpression)(node) || node.name.kind === ts.SyntaxKind.PrivateIdentifier) && !(0, tsutils_1.isElementAccessExpression)(node)) | ||
return type; | ||
@@ -281,3 +281,3 @@ const objectType = this.checker.getApparentType(this.checker.getTypeAtLocation(node.expression)); | ||
return type; | ||
if (tsutils_1.isPropertyAccessExpression(node)) { | ||
if ((0, tsutils_1.isPropertyAccessExpression)(node)) { | ||
if (objectType.getProperty(node.name.text) !== undefined) | ||
@@ -287,4 +287,4 @@ return type; | ||
else { | ||
const names = tsutils_1.getLateBoundPropertyNames(node.argumentExpression, this.checker); | ||
if (names.known && names.names.every(({ symbolName }) => tsutils_1.getPropertyOfType(objectType, symbolName) !== undefined)) | ||
const names = (0, tsutils_1.getLateBoundPropertyNames)(node.argumentExpression, this.checker); | ||
if (names.known && names.names.every(({ symbolName }) => (0, tsutils_1.getPropertyOfType)(objectType, symbolName) !== undefined)) | ||
return type; | ||
@@ -297,10 +297,10 @@ } | ||
return; | ||
const names = tsutils_1.getLateBoundPropertyNames(name, this.checker); | ||
const names = (0, tsutils_1.getLateBoundPropertyNames)(name, this.checker); | ||
if (!names.known) | ||
return; | ||
const types = tsutils_1.unionTypeParts(this.checker.getApparentType(this.getTypeOfExpression(tsutils_1.unwrapParentheses(node)))); | ||
const types = (0, tsutils_1.unionTypeParts)(this.checker.getApparentType(this.getTypeOfExpression((0, tsutils_1.unwrapParentheses)(node)))); | ||
for (const { symbolName } of names.names) { | ||
// we check every union type member separately because symbols lose optionality when accessed through union types | ||
for (const type of types) { | ||
const symbol = tsutils_1.getPropertyOfType(type, symbolName); | ||
const symbol = (0, tsutils_1.getPropertyOfType)(type, symbolName); | ||
if (symbol === undefined || symbol.flags & ts.SymbolFlags.Optional) | ||
@@ -313,3 +313,3 @@ return; // it might be present at runtime, so we don't return false | ||
}; | ||
Rule = tslib_1.__decorate([ | ||
Rule = (0, tslib_1.__decorate)([ | ||
ymir_1.excludeDeclarationFiles | ||
@@ -319,10 +319,10 @@ ], Rule); | ||
function isUndefined(node) { | ||
return tsutils_1.isIdentifier(node) && node.originalKeywordKind === ts.SyntaxKind.UndefinedKeyword; | ||
return (0, tsutils_1.isIdentifier)(node) && node.originalKeywordKind === ts.SyntaxKind.UndefinedKeyword; | ||
} | ||
function falsy(type) { | ||
return tsutils_1.isFalsyType(type) ? false : undefined; | ||
return (0, tsutils_1.isFalsyType)(type) ? false : undefined; | ||
} | ||
function truthyFalsy(type) { | ||
if (type.flags & ts.TypeFlags.PossiblyFalsy) { | ||
if (tsutils_1.isFalsyType(type)) | ||
if ((0, tsutils_1.isFalsyType)(type)) | ||
return false; | ||
@@ -332,3 +332,3 @@ return type.flags & ts.TypeFlags.Literal ? true : undefined; | ||
// TODO use assignability check | ||
return tsutils_1.isEmptyObjectType(type) ? undefined : true; | ||
return (0, tsutils_1.isEmptyObjectType)(type) ? undefined : true; | ||
} | ||
@@ -335,0 +335,0 @@ function isLogicalOperator(kind) { |
@@ -14,3 +14,3 @@ "use strict"; | ||
for (let match = re.exec(this.sourceFile.text); match !== null; match = re.exec(this.sourceFile.text)) { | ||
const { node } = tsutils_1.getWrappedNodeAtPosition(wrappedAst !== null && wrappedAst !== void 0 ? wrappedAst : (wrappedAst = this.context.getWrappedAst()), match.index); | ||
const { node } = (0, tsutils_1.getWrappedNodeAtPosition)(wrappedAst !== null && wrappedAst !== void 0 ? wrappedAst : (wrappedAst = this.context.getWrappedAst()), match.index); | ||
switch (node.kind) { | ||
@@ -32,3 +32,3 @@ case ts.SyntaxKind.SpreadElement: | ||
checkSpreadElement(node) { | ||
if (!tsutils_1.isArrayLiteralExpression(node.expression) || node.expression.elements.some(tsutils_1.isOmittedExpression) && !tsutils_1.isReassignmentTarget(node)) | ||
if (!(0, tsutils_1.isArrayLiteralExpression)(node.expression) || node.expression.elements.some(tsutils_1.isOmittedExpression) && !(0, tsutils_1.isReassignmentTarget)(node)) | ||
return; | ||
@@ -38,3 +38,3 @@ this.addFindingAtNode(node, MESSAGE, removeUselessSpread(node, node.expression.elements)); | ||
checkSpreadAssignment(node) { | ||
if (!tsutils_1.isObjectLiteralExpression(node.expression)) | ||
if (!(0, tsutils_1.isObjectLiteralExpression)(node.expression)) | ||
return; | ||
@@ -44,3 +44,3 @@ this.addFindingAtNode(node, MESSAGE, removeUselessSpread(node, node.expression.properties)); | ||
checkJsxSpreadAttribute(node) { | ||
if (!tsutils_1.isObjectLiteralExpression(node.expression) || !canConvertObjectSpreadToJsx(node.expression)) | ||
if (!(0, tsutils_1.isObjectLiteralExpression)(node.expression) || !canConvertObjectSpreadToJsx(node.expression)) | ||
return; | ||
@@ -50,3 +50,3 @@ this.addFindingAtNode(node, MESSAGE, removeUselessJsxSpreadAttribute(node, node.expression.properties)); | ||
}; | ||
Rule = tslib_1.__decorate([ | ||
Rule = (0, tslib_1.__decorate)([ | ||
ymir_1.excludeDeclarationFiles | ||
@@ -62,4 +62,4 @@ ], Rule); | ||
case ts.SyntaxKind.PropertyAssignment: | ||
const staticName = tsutils_1.getPropertyName(property.name); | ||
if (staticName === undefined || !tsutils_1.isValidJsxIdentifier(staticName)) | ||
const staticName = (0, tsutils_1.getPropertyName)(property.name); | ||
if (staticName === undefined || !(0, tsutils_1.isValidJsxIdentifier)(staticName)) | ||
return false; | ||
@@ -85,3 +85,3 @@ break; | ||
case ts.SyntaxKind.PropertyAssignment: | ||
fix.push(ymir_1.Replacement.replace(property.getStart(), property.initializer.pos, `${tsutils_1.getPropertyName(property.name)}={`), ymir_1.Replacement.append(property.end, '}')); | ||
fix.push(ymir_1.Replacement.replace(property.getStart(), property.initializer.pos, `${(0, tsutils_1.getPropertyName)(property.name)}={`), ymir_1.Replacement.append(property.end, '}')); | ||
break; | ||
@@ -88,0 +88,0 @@ default: |
@@ -12,7 +12,5 @@ "use strict"; | ||
super(...arguments); | ||
this.strictFile = this.context.compilerOptions !== undefined && tsutils_1.isStrictCompilerOptionEnabled(this.context.compilerOptions, 'alwaysStrict') | ||
? "due to the compilerOption 'alwaysStrict' this code is in strict mode" /* Option */ | ||
: ts.isExternalModule(this.sourceFile) | ||
? "ES6 modules are always in strict mode" /* Module */ | ||
: undefined; | ||
this.strictFile = this.context.compilerOptions !== undefined && (0, tsutils_1.isStrictCompilerOptionEnabled)(this.context.compilerOptions, 'alwaysStrict') | ||
? "due to the compilerOption 'alwaysStrict' this code is in strict mode" /* Option */ : ts.isExternalModule(this.sourceFile) | ||
? "ES6 modules are always in strict mode" /* Module */ : undefined; | ||
} | ||
@@ -23,5 +21,5 @@ apply() { | ||
for (let match = re.exec(this.sourceFile.text); match !== null; match = re.exec(this.sourceFile.text)) { | ||
const { node } = tsutils_1.getWrappedNodeAtPosition(wrappedAst !== null && wrappedAst !== void 0 ? wrappedAst : (wrappedAst = this.context.getWrappedAst()), match.index); | ||
const { node } = (0, tsutils_1.getWrappedNodeAtPosition)(wrappedAst !== null && wrappedAst !== void 0 ? wrappedAst : (wrappedAst = this.context.getWrappedAst()), match.index); | ||
if (node.end === re.lastIndex && | ||
tsutils_1.isStringLiteral(node) && | ||
(0, tsutils_1.isStringLiteral)(node) && | ||
node.text === 'use strict' && | ||
@@ -34,3 +32,3 @@ node.parent.kind === ts.SyntaxKind.ExpressionStatement) | ||
const parent = directive.parent; | ||
if (!utils_1.hasDirectivePrologue(parent)) | ||
if (!(0, utils_1.hasDirectivePrologue)(parent)) | ||
return; // not a directive | ||
@@ -47,3 +45,3 @@ let reason = this.strictFile; | ||
} | ||
if (!tsutils_1.isExpressionStatement(statement) || !tsutils_1.isStringLiteral(statement.expression)) | ||
if (!(0, tsutils_1.isExpressionStatement)(statement) || !(0, tsutils_1.isStringLiteral)(statement.expression)) | ||
return; // not a directive | ||
@@ -63,3 +61,3 @@ if (reason === undefined && statement.expression.getText(this.sourceFile).slice(1, -1) === 'use strict') | ||
} | ||
if (utils_1.hasDirectivePrologue(node)) { | ||
if ((0, utils_1.hasDirectivePrologue)(node)) { | ||
if (this.hasUseStrictDirective(node)) | ||
@@ -76,3 +74,3 @@ return "a parent node is already in strict mode" /* Parent */; | ||
for (const statement of node.statements) { | ||
if (!tsutils_1.isExpressionStatement(statement) || !tsutils_1.isStringLiteral(statement.expression)) | ||
if (!(0, tsutils_1.isExpressionStatement)(statement) || !(0, tsutils_1.isStringLiteral)(statement.expression)) | ||
break; | ||
@@ -85,3 +83,3 @@ if (statement.expression.getText(this.sourceFile).slice(1, -1) === 'use strict') | ||
}; | ||
Rule = tslib_1.__decorate([ | ||
Rule = (0, tslib_1.__decorate)([ | ||
ymir_1.excludeDeclarationFiles | ||
@@ -88,0 +86,0 @@ ], Rule); |
@@ -11,3 +11,3 @@ "use strict"; | ||
apply() { | ||
for (const node of utils_1.tryStatements(this.context)) { | ||
for (const node of (0, utils_1.tryStatements)(this.context)) { | ||
const { tryBlock, catchClause, finallyBlock } = node; | ||
@@ -36,3 +36,3 @@ const start = getStart(node); | ||
}; | ||
Rule = tslib_1.__decorate([ | ||
Rule = (0, tslib_1.__decorate)([ | ||
ymir_1.excludeDeclarationFiles | ||
@@ -42,3 +42,3 @@ ], Rule); | ||
function deleteStatement(node) { | ||
return tsutils_1.isInSingleStatementContext(node) | ||
return (0, tsutils_1.isInSingleStatementContext)(node) | ||
? ymir_1.Replacement.replace(getStart(node), node.end, '{}') | ||
@@ -60,4 +60,4 @@ : ymir_1.Replacement.delete(node.pos, node.end); | ||
function canStripBlockOnRemove(node, block) { | ||
return tsutils_1.isInSingleStatementContext(node) | ||
? block.statements.length === 1 && !tsutils_1.isBlockScopedDeclarationStatement(block.statements[0]) | ||
return (0, tsutils_1.isInSingleStatementContext)(node) | ||
? block.statements.length === 1 && !(0, tsutils_1.isBlockScopedDeclarationStatement)(block.statements[0]) | ||
: !block.statements.some(tsutils_1.isBlockScopedDeclarationStatement); | ||
@@ -75,7 +75,7 @@ } | ||
function throwsVariable(statement, name) { | ||
if (!tsutils_1.isThrowStatement(statement) || statement.expression === undefined) | ||
if (!(0, tsutils_1.isThrowStatement)(statement) || statement.expression === undefined) | ||
return false; | ||
const expression = tsutils_1.unwrapParentheses(statement.expression); | ||
return tsutils_1.isIdentifier(expression) && expression.escapedText === name.escapedText; | ||
const expression = (0, tsutils_1.unwrapParentheses)(statement.expression); | ||
return (0, tsutils_1.isIdentifier)(expression) && expression.escapedText === name.escapedText; | ||
} | ||
//# sourceMappingURL=no-useless-try-catch.js.map |
@@ -15,3 +15,3 @@ "use strict"; | ||
case ts.SyntaxKind.ElementAccessExpression: | ||
if (tsutils_1.getAccessKind(node) & tsutils_1.AccessKind.Read) | ||
if ((0, tsutils_1.getAccessKind)(node) & tsutils_1.AccessKind.Read) | ||
this.checkAccessExpression(node); | ||
@@ -24,3 +24,3 @@ break; | ||
case ts.SyntaxKind.PropertyAssignment: | ||
if (tsutils_1.isReassignmentTarget(node.parent)) | ||
if ((0, tsutils_1.isReassignmentTarget)(node.parent)) | ||
this.checkObjectDestructuring(node); | ||
@@ -33,18 +33,18 @@ } | ||
? [{ node: node.name, displayName: node.name.text, symbolName: node.name.escapedText }] | ||
: Array.from(utils_1.addNodeToPropertyNameList(node.argumentExpression, tsutils_1.getLateBoundPropertyNames(node.argumentExpression, this.checker).names)); | ||
this.checkPropertiesOfType(utils_1.tryGetBaseConstraintType(this.checker.getTypeAtLocation(node.expression), this.checker), accessedNames); | ||
: Array.from((0, utils_1.addNodeToPropertyNameList)(node.argumentExpression, (0, tsutils_1.getLateBoundPropertyNames)(node.argumentExpression, this.checker).names)); | ||
this.checkPropertiesOfType((0, utils_1.tryGetBaseConstraintType)(this.checker.getTypeAtLocation(node.expression), this.checker), accessedNames); | ||
} | ||
checkObjectBindingPattern(node) { | ||
const type = utils_1.tryGetBaseConstraintType(this.checker.getTypeAtLocation(node), this.checker); | ||
this.checkPropertiesOfType(type, Array.from(utils_1.destructuredProperties(node, this.checker))); | ||
const type = (0, utils_1.tryGetBaseConstraintType)(this.checker.getTypeAtLocation(node), this.checker); | ||
this.checkPropertiesOfType(type, Array.from((0, utils_1.destructuredProperties)(node, this.checker))); | ||
} | ||
checkObjectDestructuring(node) { | ||
const type = utils_1.tryGetBaseConstraintType(this.checker.getTypeOfAssignmentPattern(node.parent), this.checker); | ||
const accessedNames = Array.from(utils_1.addNodeToPropertyNameList(node.name, tsutils_1.getLateBoundPropertyNamesOfPropertyName(node.name, this.checker).names)); | ||
const type = (0, utils_1.tryGetBaseConstraintType)(this.checker.getTypeOfAssignmentPattern(node.parent), this.checker); | ||
const accessedNames = Array.from((0, utils_1.addNodeToPropertyNameList)(node.name, (0, tsutils_1.getLateBoundPropertyNamesOfPropertyName)(node.name, this.checker).names)); | ||
this.checkPropertiesOfType(type, accessedNames); | ||
} | ||
checkPropertiesOfType(objectType, properties) { | ||
for (const type of tsutils_1.unionTypeParts(objectType)) { | ||
for (const type of (0, tsutils_1.unionTypeParts)(objectType)) { | ||
for (const prop of properties) { | ||
const symbol = tsutils_1.getPropertyOfType(type, prop.symbolName); | ||
const symbol = (0, tsutils_1.getPropertyOfType)(type, prop.symbolName); | ||
if (symbol !== undefined && (symbol.flags & ts.SymbolFlags.Accessor) === ts.SymbolFlags.SetAccessor) | ||
@@ -56,3 +56,3 @@ this.addFindingAtNode(prop.node, `Cannot read property '${prop.displayName}' of type '${this.checker.typeToString(type)}' as it only has a 'set' accessor.`); | ||
}; | ||
Rule = tslib_1.__decorate([ | ||
Rule = (0, tslib_1.__decorate)([ | ||
ymir_1.excludeDeclarationFiles | ||
@@ -59,0 +59,0 @@ ], Rule); |
@@ -36,4 +36,4 @@ "use strict"; | ||
for (const node of this.context.getFlatAst()) { | ||
if (tsutils_1.isClassDeclaration(node) || tsutils_1.isClassExpression(node)) { | ||
const construct = node.members.find((member) => tsutils_1.isConstructorDeclaration(member) && member.body !== undefined); | ||
if ((0, tsutils_1.isClassDeclaration)(node) || (0, tsutils_1.isClassExpression)(node)) { | ||
const construct = node.members.find((member) => (0, tsutils_1.isConstructorDeclaration)(member) && member.body !== undefined); | ||
if (construct) | ||
@@ -48,3 +48,3 @@ this.checkConstructorParameters(construct); | ||
for (const param of construct.parameters.filter(tsutils_1.isParameterProperty)) | ||
this.addFindingAtNode(param, MESSAGES[Mode.Never], getFixerForDisallowedParameterProp(construct, param, tsutils_1.getLineBreakStyle(this.context.sourceFile))); | ||
this.addFindingAtNode(param, MESSAGES[Mode.Never], getFixerForDisallowedParameterProp(construct, param, (0, tsutils_1.getLineBreakStyle)(this.context.sourceFile))); | ||
break; | ||
@@ -55,10 +55,10 @@ case Mode.Consistent: | ||
const allPropsCanBeParamProps = construct.parameters | ||
.filter((param) => !tsutils_1.isParameterProperty(param)) | ||
.filter((param) => !(0, tsutils_1.isParameterProperty)(param)) | ||
.every((param) => canBeParameterProperty(param, construct)); | ||
if (!allPropsCanBeParamProps && construct.parameters.some(tsutils_1.isParameterProperty)) { | ||
for (const param of construct.parameters.filter(tsutils_1.isParameterProperty)) | ||
this.addFinding(param.pos, param.end, MESSAGES[Mode.Consistent].cannotBeParamPropsOnly, getFixerForDisallowedParameterProp(construct, param, tsutils_1.getLineBreakStyle(this.context.sourceFile))); | ||
this.addFinding(param.pos, param.end, MESSAGES[Mode.Consistent].cannotBeParamPropsOnly, getFixerForDisallowedParameterProp(construct, param, (0, tsutils_1.getLineBreakStyle)(this.context.sourceFile))); | ||
} | ||
else if (allPropsCanBeParamProps && !construct.parameters.every(tsutils_1.isParameterProperty)) { | ||
for (const param of construct.parameters.filter((p) => !tsutils_1.isParameterProperty(p))) | ||
for (const param of construct.parameters.filter((p) => !(0, tsutils_1.isParameterProperty)(p))) | ||
this.addFinding(param.pos, param.end, MESSAGES[Mode.Consistent].canBeParamPropsOnly, getFixerForLonghandProp(param, construct)); | ||
@@ -69,3 +69,3 @@ } | ||
for (const param of construct.parameters) | ||
if (!tsutils_1.isParameterProperty(param) && canBeParameterProperty(param, construct)) | ||
if (!(0, tsutils_1.isParameterProperty)(param) && canBeParameterProperty(param, construct)) | ||
this.addFindingAtNode(param, MESSAGES[Mode.WhenPossible], getFixerForLonghandProp(param, construct)); | ||
@@ -75,3 +75,3 @@ } | ||
}; | ||
Rule = tslib_1.__decorate([ | ||
Rule = (0, tslib_1.__decorate)([ | ||
ymir_1.excludeDeclarationFiles, | ||
@@ -82,3 +82,3 @@ ymir_1.typescriptOnly | ||
function canBeParameterProperty(param, construct) { | ||
if (!tsutils_1.isIdentifier(param.name) || param.dotDotDotToken) | ||
if (!(0, tsutils_1.isIdentifier)(param.name) || param.dotDotDotToken) | ||
return false; | ||
@@ -110,3 +110,3 @@ const member = construct.parent.members.find((mem) => isPropertyMatchForParam(mem, param)); | ||
.parent.members.filter(tsutils_1.isPropertyDeclaration) | ||
.find((prop) => tsutils_1.getPropertyName(prop.name) === param.name.getText()); | ||
.find((prop) => (0, tsutils_1.getPropertyName)(prop.name) === param.name.getText()); | ||
const assignment = construct | ||
@@ -135,3 +135,3 @@ .body.statements.filter(tsutils_1.isExpressionStatement) | ||
for (const [index, stmt] of construct.body.statements.entries()) { | ||
if (tsutils_1.isExpressionStatement(stmt) && tsutils_1.isStringLiteral(stmt.expression)) { | ||
if ((0, tsutils_1.isExpressionStatement)(stmt) && (0, tsutils_1.isStringLiteral)(stmt.expression)) { | ||
finalDirectiveIndex = index; | ||
@@ -171,14 +171,14 @@ continue; | ||
function isNonParamAssignmentToProp(stmt, param) { | ||
return (tsutils_1.isBinaryExpression(stmt.expression) && | ||
tsutils_1.isPropertyAccessExpression(stmt.expression.left) && | ||
return ((0, tsutils_1.isBinaryExpression)(stmt.expression) && | ||
(0, tsutils_1.isPropertyAccessExpression)(stmt.expression.left) && | ||
stmt.expression.left.expression.kind === ts.SyntaxKind.ThisKeyword && | ||
tsutils_1.getPropertyName(stmt.expression.left.name) === param.name.getText() && | ||
(!tsutils_1.isIdentifier(stmt.expression.right) || | ||
(tsutils_1.isIdentifier(stmt.expression.right) && stmt.expression.right.text !== param.name.getText()))); | ||
(0, tsutils_1.getPropertyName)(stmt.expression.left.name) === param.name.getText() && | ||
(!(0, tsutils_1.isIdentifier)(stmt.expression.right) || | ||
((0, tsutils_1.isIdentifier)(stmt.expression.right) && stmt.expression.right.text !== param.name.getText()))); | ||
} | ||
function isPropertyMatchForParam(mem, param) { | ||
return (tsutils_1.isPropertyDeclaration(mem) && | ||
return ((0, tsutils_1.isPropertyDeclaration)(mem) && | ||
!mem.initializer && | ||
(!mem.questionToken ? !param.questionToken : !!param.questionToken) && | ||
tsutils_1.getPropertyName(mem.name) === param.name.getText() && | ||
(0, tsutils_1.getPropertyName)(mem.name) === param.name.getText() && | ||
(mem.type ? (param.type && param.type.getText()) === mem.type.getText() : !param.type)); | ||
@@ -190,7 +190,7 @@ } | ||
function isSimpleParamToPropAssignment(stmt, param) { | ||
return (tsutils_1.isExpressionStatement(stmt) && | ||
tsutils_1.isBinaryExpression(stmt.expression) && | ||
tsutils_1.isPropertyAccessExpression(stmt.expression.left) && | ||
return ((0, tsutils_1.isExpressionStatement)(stmt) && | ||
(0, tsutils_1.isBinaryExpression)(stmt.expression) && | ||
(0, tsutils_1.isPropertyAccessExpression)(stmt.expression.left) && | ||
stmt.expression.left.expression.kind === ts.SyntaxKind.ThisKeyword && | ||
tsutils_1.isIdentifier(stmt.expression.right) && | ||
(0, tsutils_1.isIdentifier)(stmt.expression.right) && | ||
stmt.expression.left.name.text === param.name.getText() && | ||
@@ -200,4 +200,4 @@ stmt.expression.right.text === param.name.getText()); | ||
function isStatementSuperCall(stmt) { | ||
return (tsutils_1.isExpressionStatement(stmt) && | ||
tsutils_1.isCallExpression(stmt.expression) && | ||
return ((0, tsutils_1.isExpressionStatement)(stmt) && | ||
(0, tsutils_1.isCallExpression)(stmt.expression) && | ||
stmt.expression.expression.kind === ts.SyntaxKind.SuperKeyword); | ||
@@ -210,7 +210,7 @@ } | ||
function isStatementWithPossibleSideEffects(stmt, param) { | ||
return (!tsutils_1.isExpressionStatement(stmt) || | ||
!tsutils_1.isBinaryExpression(stmt.expression) || | ||
return (!(0, tsutils_1.isExpressionStatement)(stmt) || | ||
!(0, tsutils_1.isBinaryExpression)(stmt.expression) || | ||
stmt.expression.operatorToken.kind !== ts.SyntaxKind.EqualsToken || | ||
tsutils_1.hasSideEffects(stmt.expression.left) || | ||
tsutils_1.hasSideEffects(stmt.expression.right) || | ||
(0, tsutils_1.hasSideEffects)(stmt.expression.left) || | ||
(0, tsutils_1.hasSideEffects)(stmt.expression.right) || | ||
isNonParamAssignmentToProp(stmt, param)); | ||
@@ -217,0 +217,0 @@ } |
@@ -21,3 +21,3 @@ "use strict"; | ||
const listInfo = new Map(); | ||
for (const [name, variableInfo] of tsutils_1.collectVariableUsage(this.sourceFile)) { | ||
for (const [name, variableInfo] of (0, tsutils_1.collectVariableUsage)(this.sourceFile)) { | ||
if (variableInfo.inGlobalScope || variableInfo.exported) | ||
@@ -27,5 +27,5 @@ continue; | ||
let declaration = d.parent; | ||
if (tsutils_1.isBindingElement(declaration)) | ||
declaration = tsutils_1.getDeclarationOfBindingElement(declaration); | ||
if (!tsutils_1.isVariableDeclaration(declaration)) | ||
if ((0, tsutils_1.isBindingElement)(declaration)) | ||
declaration = (0, tsutils_1.getDeclarationOfBindingElement)(declaration); | ||
if (!(0, tsutils_1.isVariableDeclaration)(declaration)) | ||
continue; | ||
@@ -35,6 +35,6 @@ const parent = declaration.parent; | ||
continue; | ||
const kind = tsutils_1.getVariableDeclarationKind(parent); | ||
const kind = (0, tsutils_1.getVariableDeclarationKind)(parent); | ||
if (kind === tsutils_1.VariableDeclarationKind.Const) | ||
continue; | ||
const canBeConst = (declaration.initializer !== undefined || tsutils_1.isForInOrOfStatement(parent.parent)) && | ||
const canBeConst = (declaration.initializer !== undefined || (0, tsutils_1.isForInOrOfStatement)(parent.parent)) && | ||
!variableInfo.uses.some(utils_1.isVariableReassignment) && | ||
@@ -87,3 +87,3 @@ (kind === tsutils_1.VariableDeclarationKind.Let || | ||
}; | ||
Rule = tslib_1.__decorate([ | ||
Rule = (0, tslib_1.__decorate)([ | ||
ymir_1.excludeDeclarationFiles | ||
@@ -95,7 +95,7 @@ ], Rule); | ||
node = node.parent; | ||
while (!tsutils_1.isScopeBoundary(node)); | ||
while (!(0, tsutils_1.isScopeBoundary)(node)); | ||
return node; | ||
} | ||
function getFunctionScopeBoundary(node) { | ||
while (!tsutils_1.isFunctionScopeBoundary(node)) | ||
while (!(0, tsutils_1.isFunctionScopeBoundary)(node)) | ||
node = node.parent; | ||
@@ -107,3 +107,3 @@ return node; | ||
declaration = declaration.parent; | ||
while (tsutils_1.isBindingElement(declaration)) { | ||
while ((0, tsutils_1.isBindingElement)(declaration)) { | ||
if (declaration.initializer !== undefined) | ||
@@ -110,0 +110,0 @@ deadZones.push({ pos: declaration.initializer.pos, end: declaration.initializer.end }); |
@@ -16,6 +16,6 @@ "use strict"; | ||
checkElementAccess(node) { | ||
if (!tsutils_1.isTextualLiteral(node.argumentExpression)) | ||
if (!(0, tsutils_1.isTextualLiteral)(node.argumentExpression)) | ||
return; | ||
const { text } = node.argumentExpression; | ||
if (!tsutils_1.isValidPropertyAccess(text) || this.hasCompileErrorIfWrittenAsPropertyAccess(node, text)) | ||
if (!(0, tsutils_1.isValidPropertyAccess)(text) || this.hasCompileErrorIfWrittenAsPropertyAccess(node, text)) | ||
return; | ||
@@ -31,3 +31,3 @@ this.addFindingAtNode(node.argumentExpression, `Prefer 'obj.${text}' over 'obj[${node.argumentExpression.getText(this.sourceFile)}]'.`, node.expression.kind === ts.SyntaxKind.NumericLiteral | ||
const type = this.checker.getApparentType(this.checker.getTypeAtLocation(node.expression)).getNonNullableType(); | ||
if (tsutils_1.isTypeFlagSet(type, ts.TypeFlags.Any)) | ||
if ((0, tsutils_1.isTypeFlagSet)(type, ts.TypeFlags.Any)) | ||
return false; | ||
@@ -38,8 +38,8 @@ const symbol = type.getProperty(name); | ||
return true; // should already be a compile error, don't mess with invalid code | ||
return tsutils_1.isCompilerOptionEnabled(this.context.compilerOptions, 'noPropertyAccessFromIndexSignature'); | ||
return (0, tsutils_1.isCompilerOptionEnabled)(this.context.compilerOptions, 'noPropertyAccessFromIndexSignature'); | ||
} | ||
return restricted_property_1.getRestrictedElementAccessError(this.checker, symbol, name, node, type, this.context.compilerOptions) !== undefined; | ||
return (0, restricted_property_1.getRestrictedElementAccessError)(this.checker, symbol, name, node, type, this.context.compilerOptions) !== undefined; | ||
} | ||
}; | ||
Rule = tslib_1.__decorate([ | ||
Rule = (0, tslib_1.__decorate)([ | ||
ymir_1.excludeDeclarationFiles | ||
@@ -46,0 +46,0 @@ ], Rule); |
@@ -11,3 +11,3 @@ "use strict"; | ||
get usage() { | ||
const usage = tsutils_1.collectVariableUsage(this.sourceFile); | ||
const usage = (0, tsutils_1.collectVariableUsage)(this.sourceFile); | ||
Object.defineProperty(this, 'usage', { | ||
@@ -35,7 +35,7 @@ value: usage, | ||
return; | ||
if (iteration_1.isExpressionIterable(arrayVariable, this.checker, this.context.compilerOptions, true)) | ||
if ((0, iteration_1.isExpressionIterable)(arrayVariable, this.checker, this.context.compilerOptions, true)) | ||
this.addFinding(node.getStart(this.sourceFile), node.statement.pos, `Prefer a 'for-of' loop over a 'for' loop for this simple iteration.`); | ||
} | ||
}; | ||
Rule = tslib_1.__decorate([ | ||
Rule = (0, tslib_1.__decorate)([ | ||
ymir_1.excludeDeclarationFiles | ||
@@ -52,6 +52,6 @@ ], Rule); | ||
const parent = use.parent; | ||
if (!tsutils_1.isElementAccessExpression(parent) || | ||
if (!(0, tsutils_1.isElementAccessExpression)(parent) || | ||
parent.argumentExpression !== use || | ||
parent.expression.getText(sourceFile) !== arrayVariable || | ||
tsutils_1.getAccessKind(parent) & tsutils_1.AccessKind.Modification) | ||
(0, tsutils_1.getAccessKind)(parent) & tsutils_1.AccessKind.Modification) | ||
return false; | ||
@@ -63,3 +63,3 @@ arrayAccess = true; | ||
function extractArrayVariable(condition, indexVariable) { | ||
if (!tsutils_1.isBinaryExpression(condition)) | ||
if (!(0, tsutils_1.isBinaryExpression)(condition)) | ||
return; | ||
@@ -80,3 +80,3 @@ let left; | ||
} | ||
if (!isVariable(left, indexVariable) || !tsutils_1.isPropertyAccessExpression(right) || right.name.text !== 'length') | ||
if (!isVariable(left, indexVariable) || !(0, tsutils_1.isPropertyAccessExpression)(right) || right.name.text !== 'length') | ||
return; | ||
@@ -87,3 +87,3 @@ return right.expression; | ||
// there must be only one variable declared | ||
if (!tsutils_1.isVariableDeclarationList(initializer) || | ||
if (!(0, tsutils_1.isVariableDeclarationList)(initializer) || | ||
initializer.declarations.length !== 1) | ||
@@ -102,6 +102,6 @@ return; | ||
function isIncrementedByOne(node, name) { | ||
if (tsutils_1.isPostfixUnaryExpression(node) || tsutils_1.isPrefixUnaryExpression(node)) | ||
if ((0, tsutils_1.isPostfixUnaryExpression)(node) || (0, tsutils_1.isPrefixUnaryExpression)(node)) | ||
// ++var or var++ | ||
return node.operator === ts.SyntaxKind.PlusPlusToken && isVariable(node.operand, name); | ||
if (!tsutils_1.isBinaryExpression(node)) | ||
if (!(0, tsutils_1.isBinaryExpression)(node)) | ||
return false; | ||
@@ -115,3 +115,3 @@ switch (node.operatorToken.kind) { | ||
return isVariable(node.left, name) && | ||
tsutils_1.isBinaryExpression(node.right) && node.right.operatorToken.kind === ts.SyntaxKind.PlusToken && | ||
(0, tsutils_1.isBinaryExpression)(node.right) && node.right.operatorToken.kind === ts.SyntaxKind.PlusToken && | ||
(isVariable(node.right.left, name) && isNumber(node.right.right, 1) || | ||
@@ -124,7 +124,7 @@ isNumber(node.right.left, 1) && isVariable(node.right.right, name)); | ||
function isVariable(node, name) { | ||
return tsutils_1.isIdentifier(node) && node.text === name; | ||
return (0, tsutils_1.isIdentifier)(node) && node.text === name; | ||
} | ||
function isNumber(node, value) { | ||
return tsutils_1.isNumericLiteral(node) && node.text === String(value); | ||
return (0, tsutils_1.isNumericLiteral)(node) && node.text === String(value); | ||
} | ||
//# sourceMappingURL=prefer-for-of.js.map |
@@ -32,3 +32,3 @@ "use strict"; | ||
}; | ||
Rule = tslib_1.__decorate([ | ||
Rule = (0, tslib_1.__decorate)([ | ||
ymir_1.typescriptOnly | ||
@@ -35,0 +35,0 @@ ], Rule); |
@@ -14,7 +14,7 @@ "use strict"; | ||
for (let match = re.exec(this.sourceFile.text); match !== null; match = re.exec(this.sourceFile.text)) { | ||
const { node } = tsutils_1.getWrappedNodeAtPosition(wrappedAst !== null && wrappedAst !== void 0 ? wrappedAst : (wrappedAst = this.context.getWrappedAst()), match.index); | ||
if (!tsutils_1.isIdentifier(node) || node.text !== 'isNaN' && node.text !== 'isFinite' || node.end - node.text.length !== match.index) | ||
const { node } = (0, tsutils_1.getWrappedNodeAtPosition)(wrappedAst !== null && wrappedAst !== void 0 ? wrappedAst : (wrappedAst = this.context.getWrappedAst()), match.index); | ||
if (!(0, tsutils_1.isIdentifier)(node) || node.text !== 'isNaN' && node.text !== 'isFinite' || node.end - node.text.length !== match.index) | ||
continue; | ||
const parent = node.parent; | ||
if (tsutils_1.isCallExpression(parent) && parent.expression === node && parent.arguments.length === 1 && | ||
if ((0, tsutils_1.isCallExpression)(parent) && parent.expression === node && parent.arguments.length === 1 && | ||
this.isCorrectArgumentType(parent.arguments[0])) | ||
@@ -25,10 +25,10 @@ this.addFinding(match.index, node.end, `Prefer 'Number.${node.text}' over '${node.text}'.`, ymir_1.Replacement.append(match.index, 'Number.')); | ||
isCorrectArgumentType(arg) { | ||
return tsutils_1.unionTypeParts(utils_1.tryGetBaseConstraintType(this.checker.getTypeAtLocation(arg), this.checker)).every((t) => (t.flags & ts.TypeFlags.NumberLike) !== 0); | ||
return (0, tsutils_1.unionTypeParts)((0, utils_1.tryGetBaseConstraintType)(this.checker.getTypeAtLocation(arg), this.checker)).every((t) => (t.flags & ts.TypeFlags.NumberLike) !== 0); | ||
} | ||
}; | ||
Rule = tslib_1.__decorate([ | ||
Rule = (0, tslib_1.__decorate)([ | ||
ymir_1.excludeDeclarationFiles, | ||
ymir_1.requireLibraryFile('lib.es2015.core.d.ts') | ||
(0, ymir_1.requireLibraryFile)('lib.es2015.core.d.ts') | ||
], Rule); | ||
exports.Rule = Rule; | ||
//# sourceMappingURL=prefer-number-methods.js.map |
@@ -14,12 +14,12 @@ "use strict"; | ||
for (let match = re.exec(this.sourceFile.text); match !== null; match = re.exec(this.sourceFile.text)) { | ||
const { node } = tsutils_1.getWrappedNodeAtPosition(wrappedAst !== null && wrappedAst !== void 0 ? wrappedAst : (wrappedAst = this.context.getWrappedAst()), re.lastIndex - 1); | ||
const { node } = (0, tsutils_1.getWrappedNodeAtPosition)(wrappedAst !== null && wrappedAst !== void 0 ? wrappedAst : (wrappedAst = this.context.getWrappedAst()), re.lastIndex - 1); | ||
if (node.kind !== ts.SyntaxKind.Identifier || node.end !== re.lastIndex) | ||
continue; | ||
const parent = node.parent; | ||
if (!tsutils_1.isPropertyAccessExpression(parent) || parent.name !== node || | ||
!tsutils_1.isIdentifier(parent.expression) || parent.expression.text !== 'Object') | ||
if (!(0, tsutils_1.isPropertyAccessExpression)(parent) || parent.name !== node || | ||
!(0, tsutils_1.isIdentifier)(parent.expression) || parent.expression.text !== 'Object') | ||
continue; | ||
const grandParent = parent.parent; | ||
if (!tsutils_1.isCallExpression(grandParent) || grandParent.expression !== parent || | ||
grandParent.arguments.length === 0 || !tsutils_1.isObjectLiteralExpression(grandParent.arguments[0])) | ||
if (!(0, tsutils_1.isCallExpression)(grandParent) || grandParent.expression !== parent || | ||
grandParent.arguments.length === 0 || !(0, tsutils_1.isObjectLiteralExpression)(grandParent.arguments[0])) | ||
continue; | ||
@@ -46,7 +46,7 @@ if (grandParent.arguments.length === 1) { | ||
let seenObject = false; | ||
for (const t of tsutils_1.unionTypeParts(type)) { | ||
for (const t of (0, tsutils_1.unionTypeParts)(type)) { | ||
if (t.flags & (ts.TypeFlags.Object | ts.TypeFlags.NonPrimitive)) { | ||
seenObject = true; | ||
} | ||
else if (!tsutils_1.isFalsyType(t)) { | ||
else if (!(0, tsutils_1.isFalsyType)(t)) { | ||
return false; | ||
@@ -58,3 +58,3 @@ } | ||
}; | ||
Rule = tslib_1.__decorate([ | ||
Rule = (0, tslib_1.__decorate)([ | ||
ymir_1.excludeDeclarationFiles | ||
@@ -65,3 +65,3 @@ ], Rule); | ||
const args = node.arguments; | ||
const objectNeedsParens = utils_1.objectLiteralNeedsParens(node); | ||
const objectNeedsParens = (0, utils_1.objectLiteralNeedsParens)(node); | ||
const fix = [ | ||
@@ -74,3 +74,3 @@ ymir_1.Replacement.replace(node.getStart(sourceFile), args[0].getStart(sourceFile), `${objectNeedsParens ? '(' : ''}{`), | ||
const arg = args[i]; | ||
if (!tsutils_1.isObjectLiteralExpression(arg)) { | ||
if (!(0, tsutils_1.isObjectLiteralExpression)(arg)) { | ||
fix.push(ymir_1.Replacement.append(arg.getStart(sourceFile), '...')); | ||
@@ -77,0 +77,0 @@ removedPrevious = false; |
@@ -11,7 +11,7 @@ "use strict"; | ||
for (const node of this.context.getFlatAst()) | ||
if (tsutils_1.isExpressionStatement(node) && | ||
tsutils_1.isCallExpression(node.expression) && | ||
if ((0, tsutils_1.isExpressionStatement)(node) && | ||
(0, tsutils_1.isCallExpression)(node.expression) && | ||
!ts.isOptionalChain(node.expression) && | ||
this.returnsNever(node.expression) && | ||
tsutils_1.callExpressionAffectsControlFlow(node.expression, this.checker) !== tsutils_1.SignatureEffect.Never) | ||
(0, tsutils_1.callExpressionAffectsControlFlow)(node.expression, this.checker) !== tsutils_1.SignatureEffect.Never) | ||
this.addFindingAtNode(node, `This call never returns, but TypeScript cannot use it for control flow analysis. Consider '${isReturnAllowed(node) ? 'return' : 'throw'}'ing the result to make the control flow effect explicit.`); | ||
@@ -24,3 +24,3 @@ } | ||
}; | ||
Rule = tslib_1.__decorate([ | ||
Rule = (0, tslib_1.__decorate)([ | ||
ymir_1.excludeDeclarationFiles | ||
@@ -34,5 +34,5 @@ ], Rule); | ||
node.kind === ts.SyntaxKind.ModuleBlock || | ||
node.kind === ts.SyntaxKind.Block && tsutils_1.isTryStatement(node.parent) && node.parent.tryBlock === node) | ||
node.kind === ts.SyntaxKind.Block && (0, tsutils_1.isTryStatement)(node.parent) && node.parent.tryBlock === node) | ||
return false; | ||
if (tsutils_1.isFunctionScopeBoundary(node)) | ||
if ((0, tsutils_1.isFunctionScopeBoundary)(node)) | ||
return true; | ||
@@ -39,0 +39,0 @@ } |
@@ -15,3 +15,3 @@ "use strict"; | ||
apply() { | ||
for (const node of utils_1.tryStatements(this.context)) { | ||
for (const node of (0, utils_1.tryStatements)(this.context)) { | ||
if (!this.reported.has(node.pos) && | ||
@@ -27,3 +27,3 @@ isInAsyncFunction(node)) { | ||
visitStatement(node) { | ||
if (tsutils_1.isReturnStatement(node)) { | ||
if ((0, tsutils_1.isReturnStatement)(node)) { | ||
if (node.expression !== undefined) | ||
@@ -35,3 +35,3 @@ this.checkReturnExpression(node.expression); | ||
this.reported.add(node.pos); | ||
for (const statement of utils_1.childStatements(node)) | ||
for (const statement of (0, utils_1.childStatements)(node)) | ||
this.visitStatement(statement); | ||
@@ -41,7 +41,7 @@ } | ||
const { pos } = node; | ||
while (tsutils_1.isParenthesizedExpression(node)) | ||
while ((0, tsutils_1.isParenthesizedExpression)(node)) | ||
node = node.expression; | ||
if (node.kind === ts.SyntaxKind.AwaitExpression) | ||
return; | ||
if (tsutils_1.isThenableType(this.checker, node)) | ||
if ((0, tsutils_1.isThenableType)(this.checker, node)) | ||
this.addFinding(pos - 'return'.length, pos, "Missing 'await' of Promise returned inside try-catch.", needsParens(node) | ||
@@ -56,3 +56,3 @@ ? [ | ||
}; | ||
Rule = tslib_1.__decorate([ | ||
Rule = (0, tslib_1.__decorate)([ | ||
ymir_1.excludeDeclarationFiles | ||
@@ -66,4 +66,4 @@ ], Rule); | ||
return false; | ||
} while (!tsutils_1.isFunctionScopeBoundary(node)); | ||
return utils_1.isAsyncFunction(node); | ||
} while (!(0, tsutils_1.isFunctionScopeBoundary)(node)); | ||
return (0, utils_1.isAsyncFunction)(node); | ||
} | ||
@@ -70,0 +70,0 @@ function needsParens(node) { |
@@ -19,6 +19,6 @@ "use strict"; | ||
}; | ||
Rule = tslib_1.__decorate([ | ||
Rule = (0, tslib_1.__decorate)([ | ||
ymir_1.typescriptOnly, | ||
ymir_1.excludeDeclarationFiles, | ||
ymir_1.predicate((sourceFile) => sourceFile.languageVariant === ts.LanguageVariant.Standard || 'excludes JSX files') | ||
(0, ymir_1.predicate)((sourceFile) => sourceFile.languageVariant === ts.LanguageVariant.Standard || 'excludes JSX files') | ||
], Rule); | ||
@@ -30,8 +30,8 @@ exports.Rule = Rule; | ||
for (let match = re.exec(context.sourceFile.text); match !== null; match = re.exec(context.sourceFile.text)) { | ||
const { node } = tsutils_1.getWrappedNodeAtPosition(wrappedAst !== null && wrappedAst !== void 0 ? wrappedAst : (wrappedAst = context.getWrappedAst()), match.index); | ||
if (!tsutils_1.isAsExpression(node) || node.type.pos !== re.lastIndex) | ||
const { node } = (0, tsutils_1.getWrappedNodeAtPosition)(wrappedAst !== null && wrappedAst !== void 0 ? wrappedAst : (wrappedAst = context.getWrappedAst()), match.index); | ||
if (!(0, tsutils_1.isAsExpression)(node) || node.type.pos !== re.lastIndex) | ||
continue; | ||
const parent = node.parent; | ||
const expressionNeedsParens = node.expression.kind === ts.SyntaxKind.BinaryExpression; | ||
const needsParens = tsutils_1.isBinaryExpression(parent) && parent.operatorToken.kind === ts.SyntaxKind.AsteriskAsteriskToken; | ||
const needsParens = (0, tsutils_1.isBinaryExpression)(parent) && parent.operatorToken.kind === ts.SyntaxKind.AsteriskAsteriskToken; | ||
context.addFinding(match.index, node.end, "Use the classic type assertion style '<T>obj' instead.", [ | ||
@@ -45,6 +45,6 @@ ymir_1.Replacement.append(node.getStart(context.sourceFile), `${charIf(needsParens, '(')}<${node.type.getText(context.sourceFile)}>${charIf(expressionNeedsParens, '(')}`), | ||
for (const node of context.getFlatAst()) { | ||
if (tsutils_1.isTypeAssertion(node)) { | ||
if ((0, tsutils_1.isTypeAssertion)(node)) { | ||
const assertionParens = assertionNeedsParens(node); | ||
const expressionParens = node.expression.kind === ts.SyntaxKind.YieldExpression || | ||
!assertionParens && utils_1.expressionNeedsParensWhenReplacingNode(node.expression, node); | ||
!assertionParens && (0, utils_1.expressionNeedsParensWhenReplacingNode)(node.expression, node); | ||
const start = node.getStart(context.sourceFile); | ||
@@ -72,3 +72,3 @@ context.addFinding(start, node.expression.pos, "Use 'obj as T' instead.", [ | ||
// fixing '<T>foo & bar' to 'foo as T & bar' would parse 'T & bar' as intersection type, therefore we need to add parens | ||
while (tsutils_1.isBinaryExpression(parent)) { | ||
while ((0, tsutils_1.isBinaryExpression)(parent)) { | ||
if (node === parent.left) { | ||
@@ -75,0 +75,0 @@ switch (parent.operatorToken.kind) { |
@@ -10,3 +10,3 @@ "use strict"; | ||
this.program.getSemanticDiagnostics(this.sourceFile).forEach(this.addDiagnostic, this); | ||
if (tsutils_1.isCompilerOptionEnabled(this.context.compilerOptions, 'declaration')) | ||
if ((0, tsutils_1.isCompilerOptionEnabled)(this.context.compilerOptions, 'declaration')) | ||
this.program.getDeclarationDiagnostics(this.sourceFile).forEach(this.addDiagnostic, this); | ||
@@ -13,0 +13,0 @@ } |
@@ -11,3 +11,3 @@ "use strict"; | ||
for (let match = re.exec(text); match !== null; match = re.exec(text)) { | ||
const { node } = tsutils_1.getWrappedNodeAtPosition(wrappedAst !== null && wrappedAst !== void 0 ? wrappedAst : (wrappedAst = context.getWrappedAst()), match.index); | ||
const { node } = (0, tsutils_1.getWrappedNodeAtPosition)(wrappedAst !== null && wrappedAst !== void 0 ? wrappedAst : (wrappedAst = context.getWrappedAst()), match.index); | ||
if (node.kind === ts.SyntaxKind.SwitchStatement && node.getStart(context.sourceFile) === match.index) | ||
@@ -23,3 +23,3 @@ yield node; | ||
for (let match = re.exec(text); match !== null; match = re.exec(text)) { | ||
const { node } = tsutils_1.getWrappedNodeAtPosition(wrappedAst !== null && wrappedAst !== void 0 ? wrappedAst : (wrappedAst = context.getWrappedAst()), match.index); | ||
const { node } = (0, tsutils_1.getWrappedNodeAtPosition)(wrappedAst !== null && wrappedAst !== void 0 ? wrappedAst : (wrappedAst = context.getWrappedAst()), match.index); | ||
if (node.kind === ts.SyntaxKind.TryStatement && node.tryBlock.pos - 'try'.length === match.index) | ||
@@ -46,7 +46,7 @@ yield node; | ||
} | ||
return tsutils_1.hasModifier(node.modifiers, ts.SyntaxKind.AsyncKeyword); | ||
return (0, tsutils_1.hasModifier)(node.modifiers, ts.SyntaxKind.AsyncKeyword); | ||
} | ||
exports.isAsyncFunction = isAsyncFunction; | ||
function isVariableReassignment(use) { | ||
return (use.domain & (tsutils_1.UsageDomain.Value | tsutils_1.UsageDomain.TypeQuery)) === tsutils_1.UsageDomain.Value && tsutils_1.isReassignmentTarget(use.location); | ||
return (use.domain & (tsutils_1.UsageDomain.Value | tsutils_1.UsageDomain.TypeQuery)) === tsutils_1.UsageDomain.Value && (0, tsutils_1.isReassignmentTarget)(use.location); | ||
} | ||
@@ -160,3 +160,3 @@ exports.isVariableReassignment = isVariableReassignment; | ||
return; | ||
const { names } = tsutils_1.getLateBoundPropertyNames(argumentExpression, checker); | ||
const { names } = (0, tsutils_1.getLateBoundPropertyNames)(argumentExpression, checker); | ||
if (names.length === 0) | ||
@@ -169,3 +169,3 @@ return; | ||
for (const { symbolName, displayName } of names) { | ||
const symbol = tsutils_1.getPropertyOfType(type, symbolName); | ||
const symbol = (0, tsutils_1.getPropertyOfType)(type, symbolName); | ||
if (symbol !== undefined) | ||
@@ -201,4 +201,4 @@ yield { symbol, name: displayName }; | ||
function isAmbientPropertyDeclaration(node) { | ||
return tsutils_1.hasModifier(node.modifiers, ts.SyntaxKind.DeclareKeyword) || | ||
node.parent.kind === ts.SyntaxKind.ClassDeclaration && tsutils_1.isStatementInAmbientContext(node.parent); | ||
return (0, tsutils_1.hasModifier)(node.modifiers, ts.SyntaxKind.DeclareKeyword) || | ||
node.parent.kind === ts.SyntaxKind.ClassDeclaration && (0, tsutils_1.isStatementInAmbientContext)(node.parent); | ||
} | ||
@@ -210,3 +210,3 @@ exports.isAmbientPropertyDeclaration = isAmbientPropertyDeclaration; | ||
node.parent.parent.kind === ts.SyntaxKind.VariableStatement && | ||
tsutils_1.isStatementInAmbientContext(node.parent.parent); | ||
(0, tsutils_1.isStatementInAmbientContext)(node.parent.parent); | ||
} | ||
@@ -235,3 +235,3 @@ exports.isAmbientVariableDeclaration = isAmbientVariableDeclaration; | ||
else { | ||
yield* addNodeToPropertyNameList(element.propertyName, tsutils_1.getLateBoundPropertyNamesOfPropertyName(element.propertyName, checker).names); | ||
yield* addNodeToPropertyNameList(element.propertyName, (0, tsutils_1.getLateBoundPropertyNamesOfPropertyName)(element.propertyName, checker).names); | ||
} | ||
@@ -238,0 +238,0 @@ } |
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
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
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
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
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
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
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
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
Sorry, the diff of this file is not supported yet
460470
5350
Updated@fimbul/ymir@0.24.0
Updatedtsutils@^3.21.0