Skip to content

Commit 9fcaa19

Browse files
committed
microsoft-typescript/no-in-operator
1 parent 0e14b4e commit 9fcaa19

13 files changed

Lines changed: 22 additions & 19 deletions

File tree

.eslintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
}],
6060
"microsoft-typescript/no-double-space": "error",
6161
"microsoft-typescript/boolean-trivia": "error",
62-
"microsoft-typescript/no-in-operator": "off",
62+
"microsoft-typescript/no-in-operator": "error",
6363
"microsoft-typescript/debug-assert": "error",
6464
"microsoft-typescript/no-keywords": "error",
6565

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,7 @@ namespace ts {
835835
}
836836
}
837837
function errorOrSuggestion(isError: boolean, location: Node, message: DiagnosticMessage | DiagnosticMessageChain, arg0?: string | number, arg1?: string | number, arg2?: string | number, arg3?: string | number): void {
838-
addErrorOrSuggestion(isError, "message" in message ? createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) : createDiagnosticForNodeFromMessageChain(location, message));
838+
addErrorOrSuggestion(isError, "message" in message ? createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) : createDiagnosticForNodeFromMessageChain(location, message)); // eslint-disable-line microsoft-typescript/no-in-operator
839839
}
840840

841841
function createSymbol(flags: SymbolFlags, name: __String, checkFlags?: CheckFlags) {

src/compiler/core.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ namespace ts {
114114
// The global Map object. This may not be available, so we must test for it.
115115
declare const Map: (new <T>() => Map<T>) | undefined;
116116
// Internet Explorer's Map doesn't support iteration, so don't use it.
117-
// tslint:disable-next-line no-in-operator variable-name
117+
// eslint-disable-next-line microsoft-typescript/no-in-operator
118118
export const MapCtr = typeof Map !== "undefined" && "entries" in Map.prototype ? Map : shimMap();
119119

120120
// Keep the class inside a function so it doesn't get compiled if it's not used.
@@ -221,7 +221,7 @@ namespace ts {
221221
}
222222

223223
has(key: string): boolean {
224-
// tslint:disable-next-line:no-in-operator
224+
// eslint-disable-next-line microsoft-typescript/no-in-operator
225225
return key in this.data;
226226
}
227227

src/compiler/debug.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ namespace ts {
6666
}
6767

6868
export function assertNever(member: never, message = "Illegal value:", stackCrawlMark?: AnyFunction): never {
69-
const detail = typeof member === "object" && "kind" in member && "pos" in member && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind((member as Node).kind) : JSON.stringify(member);
69+
const detail = typeof member === "object" && hasProperty(member, "kind") && hasProperty(member, "pos") && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind((member as Node).kind) : JSON.stringify(member);
7070
return fail(`${message} ${detail}`, stackCrawlMark || assertNever);
7171
}
7272

src/compiler/factory.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ namespace ts {
7575
if (typeof value === "number") {
7676
return createNumericLiteral(value + "");
7777
}
78+
// eslint-disable-next-line microsoft-typescript/no-in-operator
7879
if (typeof value === "object" && "base10Value" in value) { // PseudoBigInt
7980
return createBigIntLiteral(pseudoBigIntToString(value) + "n");
8081
}

src/harness/fourslash.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -746,15 +746,15 @@ namespace FourSlash {
746746
private verifyCompletionsWorker(options: FourSlashInterface.VerifyCompletionsOptions): void {
747747
const actualCompletions = this.getCompletionListAtCaret({ ...options.preferences, triggerCharacter: options.triggerCharacter })!;
748748
if (!actualCompletions) {
749-
if ("exact" in options && options.exact === undefined) return;
749+
if (ts.hasProperty(options, "exact") && options.exact === undefined) return;
750750
this.raiseError(`No completions at position '${this.currentCaretPosition}'.`);
751751
}
752752

753753
if (actualCompletions.isNewIdentifierLocation !== (options.isNewIdentifierLocation || false)) {
754754
this.raiseError(`Expected 'isNewIdentifierLocation' to be ${options.isNewIdentifierLocation || false}, got ${actualCompletions.isNewIdentifierLocation}`);
755755
}
756756

757-
if ("isGlobalCompletion" in options && actualCompletions.isGlobalCompletion !== options.isGlobalCompletion) {
757+
if (ts.hasProperty(options, "isGlobalCompletion") && actualCompletions.isGlobalCompletion !== options.isGlobalCompletion) {
758758
this.raiseError(`Expected 'isGlobalCompletion to be ${options.isGlobalCompletion}, got ${actualCompletions.isGlobalCompletion}`);
759759
}
760760

@@ -772,8 +772,8 @@ namespace FourSlash {
772772
}
773773
}
774774

775-
if ("exact" in options) {
776-
ts.Debug.assert(!("includes" in options) && !("excludes" in options));
775+
if (ts.hasProperty(options, "exact")) {
776+
ts.Debug.assert(!ts.hasProperty(options, "includes") && !ts.hasProperty(options, "excludes"));
777777
if (options.exact === undefined) throw this.raiseError("Expected no completions");
778778
this.verifyCompletionsAreExactly(actualCompletions.entries, toArray(options.exact), options.marker);
779779
}
@@ -1192,7 +1192,7 @@ Actual: ${stringify(fullActual)}`);
11921192
const sort = (locations: ReadonlyArray<ts.RenameLocation> | undefined) =>
11931193
locations && ts.sort(locations, (r1, r2) => ts.compareStringsCaseSensitive(r1.fileName, r2.fileName) || r1.textSpan.start - r2.textSpan.start);
11941194
assert.deepEqual(sort(references), sort(ranges.map((rangeOrOptions): ts.RenameLocation => {
1195-
const { range, ...prefixSuffixText } = "range" in rangeOrOptions ? rangeOrOptions : { range: rangeOrOptions };
1195+
const { range, ...prefixSuffixText } = "range" in rangeOrOptions ? rangeOrOptions : { range: rangeOrOptions }; // eslint-disable-line microsoft-typescript/no-in-operator
11961196
const { contextRangeIndex } = (range.marker && range.marker.data || {}) as { contextRangeIndex?: number; };
11971197
return {
11981198
fileName: range.fileName,
@@ -3129,7 +3129,7 @@ Actual: ${stringify(fullActual)}`);
31293129
return this.getApplicableRefactorsWorker(this.getSelection(), this.activeFile.fileName);
31303130
}
31313131
private getApplicableRefactors(rangeOrMarker: Range | Marker, preferences = ts.emptyOptions): ReadonlyArray<ts.ApplicableRefactorInfo> {
3132-
return this.getApplicableRefactorsWorker("position" in rangeOrMarker ? rangeOrMarker.position : rangeOrMarker, rangeOrMarker.fileName, preferences);
3132+
return this.getApplicableRefactorsWorker("position" in rangeOrMarker ? rangeOrMarker.position : rangeOrMarker, rangeOrMarker.fileName, preferences); // eslint-disable-line microsoft-typescript/no-in-operator
31333133
}
31343134
private getApplicableRefactorsWorker(positionOrRange: number | ts.TextRange, fileName: string, preferences = ts.emptyOptions): ReadonlyArray<ts.ApplicableRefactorInfo> {
31353135
return this.languageService.getApplicableRefactors(fileName, positionOrRange, preferences) || ts.emptyArray;

src/server/project.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,6 +1190,7 @@ namespace ts.server {
11901190
const pluginModule = pluginModuleFactory({ typescript: ts });
11911191
const newLS = pluginModule.create(info);
11921192
for (const k of Object.keys(this.languageService)) {
1193+
// eslint-disable-next-line microsoft-typescript/no-in-operator
11931194
if (!(k in newLS)) {
11941195
this.projectService.logger.info(`Plugin activation warning: Missing proxied method ${k} in created LS. Patching.`);
11951196
(newLS as any)[k] = (this.languageService as any)[k];

src/services/codefixes/convertToAsyncFunction.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,7 @@ namespace ts.codefix {
607607
}
608608

609609
// return undefined argName when arg is null or undefined
610+
// eslint-disable-next-line microsoft-typescript/no-in-operator
610611
if (!name || "identifier" in name && name.identifier.text === "undefined") {
611612
return undefined;
612613
}

src/services/findAllReferences.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1440,7 +1440,7 @@ namespace ts.FindAllReferences.Core {
14401440
}
14411441

14421442
function addReference(referenceLocation: Node, relatedSymbol: Symbol | RelatedSymbol, state: State): void {
1443-
const { kind, symbol } = "kind" in relatedSymbol ? relatedSymbol : { kind: undefined, symbol: relatedSymbol };
1443+
const { kind, symbol } = "kind" in relatedSymbol ? relatedSymbol : { kind: undefined, symbol: relatedSymbol }; // eslint-disable-line microsoft-typescript/no-in-operator
14441444
const addRef = state.referenceAdder(symbol);
14451445
if (state.options.implementations) {
14461446
addImplementationReferences(referenceLocation, addRef, state);

src/services/shims.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ let debugObjectHost: { CollectGarbage(): void } = (function (this: any) { return
1818

1919
// We need to use 'null' to interface with the managed side.
2020
/* tslint:disable:no-null-keyword */
21-
/* tslint:disable:no-in-operator */
21+
/* eslint-disable microsoft-typescript/no-in-operator */
2222

2323
/* @internal */
2424
namespace ts {
@@ -1271,7 +1271,7 @@ namespace ts {
12711271
}
12721272
}
12731273

1274-
/* tslint:enable:no-in-operator */
1274+
/* eslint-enable microsoft-typescript/no-in-operator */
12751275
/* tslint:enable:no-null */
12761276

12771277

0 commit comments

Comments
 (0)