Skip to content

Commit c70eae4

Browse files
author
Andy
authored
Enable 'no-this-assignment' lint rule (#19696)
1 parent fd41521 commit c70eae4

File tree

2 files changed

+19
-23
lines changed

2 files changed

+19
-23
lines changed

src/harness/fourslash.ts

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -873,37 +873,34 @@ namespace FourSlash {
873873
* @param spanIndex the index of the range that the completion item's replacement text span should match
874874
*/
875875
public verifyCompletionListDoesNotContain(entryId: ts.Completions.CompletionEntryIdentifier, expectedText?: string, expectedDocumentation?: string, expectedKind?: string, spanIndex?: number) {
876-
const that = this;
877876
let replacementSpan: ts.TextSpan;
878877
if (spanIndex !== undefined) {
879878
replacementSpan = this.getTextSpanForRangeAtIndex(spanIndex);
880879
}
881880

882-
function filterByTextOrDocumentation(entry: ts.CompletionEntry) {
883-
const details = that.getCompletionEntryDetails(entry.name);
884-
const documentation = details && ts.displayPartsToString(details.documentation);
885-
const text = details && ts.displayPartsToString(details.displayParts);
886-
887-
// If any of the expected values are undefined, assume that users don't
888-
// care about them.
889-
if (replacementSpan && !TestState.textSpansEqual(replacementSpan, entry.replacementSpan)) {
890-
return false;
891-
}
892-
else if (expectedText && text !== expectedText) {
893-
return false;
894-
}
895-
else if (expectedDocumentation && documentation !== expectedDocumentation) {
896-
return false;
897-
}
898-
899-
return true;
900-
}
901-
902881
const completions = this.getCompletionListAtCaret();
903882
if (completions) {
904883
let filterCompletions = completions.entries.filter(e => e.name === entryId.name && e.source === entryId.source);
905884
filterCompletions = expectedKind ? filterCompletions.filter(e => e.kind === expectedKind) : filterCompletions;
906-
filterCompletions = filterCompletions.filter(filterByTextOrDocumentation);
885+
filterCompletions = filterCompletions.filter(entry => {
886+
const details = this.getCompletionEntryDetails(entry.name);
887+
const documentation = details && ts.displayPartsToString(details.documentation);
888+
const text = details && ts.displayPartsToString(details.displayParts);
889+
890+
// If any of the expected values are undefined, assume that users don't
891+
// care about them.
892+
if (replacementSpan && !TestState.textSpansEqual(replacementSpan, entry.replacementSpan)) {
893+
return false;
894+
}
895+
else if (expectedText && text !== expectedText) {
896+
return false;
897+
}
898+
else if (expectedDocumentation && documentation !== expectedDocumentation) {
899+
return false;
900+
}
901+
902+
return true;
903+
});
907904
if (filterCompletions.length !== 0) {
908905
// After filtered using all present criterion, if there are still symbol left in the list
909906
// then these symbols must meet the criterion for Not supposed to be in the list. So we

tslint.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@
8989
"no-object-literal-type-assertion": false,
9090
"no-shadowed-variable": false,
9191
"no-submodule-imports": false,
92-
"no-this-assignment": false,
9392
"no-unused-expression": false,
9493
"no-unnecessary-initializer": false,
9594
"no-var-requires": false,

0 commit comments

Comments
 (0)