Skip to content

Commit 28455c6

Browse files
author
Andy
authored
patternMatcher: Return single best match instead of list (microsoft#23166)
1 parent f6b206a commit 28455c6

File tree

5 files changed

+104
-268
lines changed

5 files changed

+104
-268
lines changed

scripts/tslint/rules/booleanTriviaRule.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,11 @@ function walk(ctx: Lint.WalkContext<void>): void {
2828
function shouldIgnoreCalledExpression(expression: ts.Expression): boolean {
2929
if (expression.kind === ts.SyntaxKind.PropertyAccessExpression) {
3030
const methodName = (expression as ts.PropertyAccessExpression).name.text;
31-
if (methodName.indexOf("set") === 0) {
31+
if (methodName.startsWith("set") || methodName.startsWith("assert")) {
3232
return true;
3333
}
3434
switch (methodName) {
3535
case "apply":
36-
case "assert":
37-
case "assertEqual":
3836
case "call":
3937
case "equal":
4038
case "fail":
@@ -46,11 +44,10 @@ function walk(ctx: Lint.WalkContext<void>): void {
4644
}
4745
else if (expression.kind === ts.SyntaxKind.Identifier) {
4846
const functionName = (expression as ts.Identifier).text;
49-
if (functionName.indexOf("set") === 0) {
47+
if (functionName.startsWith("set") || functionName.startsWith("assert")) {
5048
return true;
5149
}
5250
switch (functionName) {
53-
case "assert":
5451
case "contains":
5552
case "createAnonymousType":
5653
case "createImportSpecifier":

src/compiler/core.ts

+4
Original file line numberDiff line numberDiff line change
@@ -1724,6 +1724,10 @@ namespace ts {
17241724
return compareComparableValues(a, b);
17251725
}
17261726

1727+
export function min<T>(a: T, b: T, compare: Comparer<T>): T {
1728+
return compare(a, b) === Comparison.LessThan ? a : b;
1729+
}
1730+
17271731
/**
17281732
* Compare two strings using a case-insensitive ordinal comparison.
17291733
*

0 commit comments

Comments
 (0)