From 17e420daf645005e9e762ec02d64e4a6a773fccc Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 18 Apr 2024 09:06:32 -0700 Subject: [PATCH] Use built-in no-restricted-syntax to ban null instead of plugin, ban null type too (#58095) --- .eslintrc.json | 18 +++++++---- package-lock.json | 20 ------------- package.json | 1 - scripts/configurePrerelease.mjs | 4 +-- scripts/eslint/rules/argument-trivia.cjs | 2 +- scripts/eslint/rules/only-arrow-functions.cjs | 2 +- src/compiler/commandLineParser.ts | 6 ++-- src/compiler/core.ts | 8 ++--- src/compiler/debug.ts | 6 ++-- src/compiler/executeCommandLine.ts | 4 +-- src/compiler/moduleNameResolver.ts | 18 +++++------ src/compiler/moduleSpecifiers.ts | 4 +-- src/compiler/parser.ts | 2 +- src/compiler/program.ts | 2 +- src/compiler/sourcemap.ts | 10 +++---- src/compiler/sys.ts | 4 +-- src/compiler/tracing.ts | 2 +- src/compiler/types.ts | 10 +++---- src/compiler/utilities.ts | 2 +- src/harness/collectionsImpl.ts | 4 +-- src/harness/documentsUtil.ts | 4 +-- src/harness/evaluatorImpl.ts | 2 +- src/harness/harnessIO.ts | 28 ++++++++--------- src/harness/harnessLanguageService.ts | 2 +- src/harness/sourceMapRecorder.ts | 2 +- src/harness/util.ts | 2 +- src/harness/vfsUtil.ts | 22 +++++++------- src/services/formatting/formatting.ts | 4 +-- src/services/formatting/smartIndenter.ts | 2 +- src/services/outliningElementsCollector.ts | 2 +- src/services/services.ts | 2 +- src/services/stringCompletions.ts | 2 +- src/testRunner/compilerRunner.ts | 2 +- src/testRunner/parallel/host.ts | 2 +- src/testRunner/projectsRunner.ts | 2 +- .../config/configurationExtension.ts | 8 ++--- src/testRunner/unittests/config/showConfig.ts | 2 +- .../unittests/evaluation/esDecorators.ts | 30 +++++++++---------- src/testRunner/unittests/helpers/tsc.ts | 2 +- src/testRunner/unittests/moduleResolution.ts | 2 +- .../services/convertToAsyncFunction.ts | 4 +-- .../unittests/services/transpile.ts | 4 +-- .../unittests/sys/symlinkWatching.ts | 2 ++ src/testRunner/unittests/tsserver/session.ts | 2 +- src/tsserver/nodeServer.ts | 2 +- 45 files changed, 128 insertions(+), 139 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index da15e633c7d..7f92febda30 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -17,7 +17,6 @@ ], "plugins": [ "@typescript-eslint", - "no-null", "eslint-plugin-local" ], "ignorePatterns": [ @@ -60,6 +59,18 @@ "prefer-object-spread": "error", "unicode-bom": ["error", "never"], + "no-restricted-syntax": [ + "error", + { + "selector": "Literal[raw=null]", + "message": "Avoid using null; use undefined instead." + }, + { + "selector": "TSNullKeyword", + "message": "Avoid using null; use undefined instead." + } + ], + // Enabled in eslint:recommended, but not applicable here "no-extra-boolean-cast": "off", "no-case-declarations": "off", @@ -132,10 +143,7 @@ "local/no-in-operator": "error", "local/debug-assert": "error", "local/no-keywords": "error", - "local/jsdoc-format": "error", - - // eslint-plugin-no-null - "no-null/no-null": "error" + "local/jsdoc-format": "error" }, "overrides": [ // By default, the ESLint CLI only looks at .js files. But, it will also look at diff --git a/package-lock.json b/package-lock.json index 138aa4049d5..90a05842f36 100644 --- a/package-lock.json +++ b/package-lock.json @@ -37,7 +37,6 @@ "eslint": "^8.57.0", "eslint-formatter-autolinkable-stylish": "^1.3.0", "eslint-plugin-local": "^4.2.1", - "eslint-plugin-no-null": "^1.0.2", "fast-xml-parser": "^4.3.6", "glob": "^10.3.10", "hereby": "^1.8.9", @@ -2117,18 +2116,6 @@ "eslint": ">=6.0.0" } }, - "node_modules/eslint-plugin-no-null": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/eslint-plugin-no-null/-/eslint-plugin-no-null-1.0.2.tgz", - "integrity": "sha512-uRDiz88zCO/2rzGfgG15DBjNsgwWtWiSo4Ezy7zzajUgpnFIqd1TjepKeRmJZHEfBGu58o2a8S0D7vglvvhkVA==", - "dev": true, - "engines": { - "node": ">=5.0.0" - }, - "peerDependencies": { - "eslint": ">=3.0.0" - } - }, "node_modules/eslint-scope": { "version": "7.2.2", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz", @@ -5952,13 +5939,6 @@ "chalk": "^4.0.0" } }, - "eslint-plugin-no-null": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/eslint-plugin-no-null/-/eslint-plugin-no-null-1.0.2.tgz", - "integrity": "sha512-uRDiz88zCO/2rzGfgG15DBjNsgwWtWiSo4Ezy7zzajUgpnFIqd1TjepKeRmJZHEfBGu58o2a8S0D7vglvvhkVA==", - "dev": true, - "requires": {} - }, "eslint-scope": { "version": "7.2.2", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz", diff --git a/package.json b/package.json index 16ea88d56ab..1e143ca3f23 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,6 @@ "eslint": "^8.57.0", "eslint-formatter-autolinkable-stylish": "^1.3.0", "eslint-plugin-local": "^4.2.1", - "eslint-plugin-no-null": "^1.0.2", "fast-xml-parser": "^4.3.6", "glob": "^10.3.10", "hereby": "^1.8.9", diff --git a/scripts/configurePrerelease.mjs b/scripts/configurePrerelease.mjs index 32ad59ece0a..762d1b73121 100644 --- a/scripts/configurePrerelease.mjs +++ b/scripts/configurePrerelease.mjs @@ -64,7 +64,7 @@ function main() { writeFileSync(tsFilePath, modifiedTsFileContents); } -/* eslint-disable no-null/no-null */ +/* eslint-disable no-restricted-syntax */ /** * @param {string} tsFilePath * @param {string} tsFileContents @@ -101,7 +101,7 @@ function parsePackageJsonVersion(versionString) { assert(match !== null, "package.json 'version' should match " + versionRgx.toString()); return { majorMinor: match[1], patch: match[2] }; } -/* eslint-enable no-null/no-null */ +/* eslint-enable no-restricted-syntax */ /** * e.g. 0-dev.20170707 diff --git a/scripts/eslint/rules/argument-trivia.cjs b/scripts/eslint/rules/argument-trivia.cjs index 423da853e21..eaef1368830 100644 --- a/scripts/eslint/rules/argument-trivia.cjs +++ b/scripts/eslint/rules/argument-trivia.cjs @@ -53,7 +53,7 @@ module.exports = createRule({ } if (node.type === AST_NODE_TYPES.Literal) { - // eslint-disable-next-line no-null/no-null + // eslint-disable-next-line no-restricted-syntax return node.value === null || node.value === true || node.value === false; } diff --git a/scripts/eslint/rules/only-arrow-functions.cjs b/scripts/eslint/rules/only-arrow-functions.cjs index d887a05467f..206a178bc73 100644 --- a/scripts/eslint/rules/only-arrow-functions.cjs +++ b/scripts/eslint/rules/only-arrow-functions.cjs @@ -67,7 +67,7 @@ module.exports = createRule({ return; } - if ((allowNamedFunctions && node.id !== null) || isMethodType(node)) { // eslint-disable-line no-null/no-null + if ((allowNamedFunctions && node.id !== null) || isMethodType(node)) { // eslint-disable-line no-restricted-syntax return; } diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index b790ed08fbe..4aff5cdc264 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -2394,7 +2394,7 @@ export function convertToJson( return false; case SyntaxKind.NullKeyword: - return null; // eslint-disable-line no-null/no-null + return null; // eslint-disable-line no-restricted-syntax case SyntaxKind.StringLiteral: if (!isDoubleQuotedString(valueExpression)) { @@ -2869,8 +2869,8 @@ export function setConfigFileInOptions(options: CompilerOptions, configFile: TsC } } -function isNullOrUndefined(x: any): x is null | undefined { - return x === undefined || x === null; // eslint-disable-line no-null/no-null +function isNullOrUndefined(x: any): x is null | undefined { // eslint-disable-line no-restricted-syntax + return x === undefined || x === null; // eslint-disable-line no-restricted-syntax } function directoryOfCombinedPath(fileName: string, basePath: string) { diff --git a/src/compiler/core.ts b/src/compiler/core.ts index d9cc63c9988..6ebeff961f4 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -872,9 +872,9 @@ export function arrayIsEqualTo(array1: readonly T[] | undefined, array2: read * * @internal */ -export function compact(array: (T | undefined | null | false | 0 | "")[]): T[]; +export function compact(array: (T | undefined | null | false | 0 | "")[]): T[]; // eslint-disable-line no-restricted-syntax /** @internal */ -export function compact(array: readonly (T | undefined | null | false | 0 | "")[]): readonly T[]; +export function compact(array: readonly (T | undefined | null | false | 0 | "")[]): readonly T[]; // eslint-disable-line no-restricted-syntax // ESLint thinks these can be combined with the above - they cannot; they'd produce higher-priority inferences and prevent the falsey types from being stripped /** @internal */ export function compact(array: T[]): T[]; // eslint-disable-line @typescript-eslint/unified-signatures @@ -1511,8 +1511,8 @@ export function group(values: readonly T[], getGroupId: (value: T) => K, r /** @internal */ export function groupBy(values: readonly T[] | undefined, keySelector: (value: T) => value is U): { true?: U[]; false?: Exclude[]; }; /** @internal */ -export function groupBy(values: readonly T[] | undefined, keySelector: (value: T) => K): { [P in K as `${P}`]?: T[]; }; -export function groupBy(values: readonly T[] | undefined, keySelector: (value: T) => K): { [P in K as `${P}`]?: T[]; } { +export function groupBy(values: readonly T[] | undefined, keySelector: (value: T) => K): { [P in K as `${P}`]?: T[]; }; // eslint-disable-line no-restricted-syntax +export function groupBy(values: readonly T[] | undefined, keySelector: (value: T) => K): { [P in K as `${P}`]?: T[]; } { // eslint-disable-line no-restricted-syntax const result: Record = {}; if (values) { for (const value of values) { diff --git a/src/compiler/debug.ts b/src/compiler/debug.ts index 5f516bbfbc3..98fcde98474 100644 --- a/src/compiler/debug.ts +++ b/src/compiler/debug.ts @@ -244,13 +244,13 @@ export namespace Debug { } export function assertIsDefined(value: T, message?: string, stackCrawlMark?: AnyFunction): asserts value is NonNullable { - // eslint-disable-next-line no-null/no-null + // eslint-disable-next-line no-restricted-syntax if (value === undefined || value === null) { fail(message, stackCrawlMark || assertIsDefined); } } - export function checkDefined(value: T | null | undefined, message?: string, stackCrawlMark?: AnyFunction): T { + export function checkDefined(value: T | null | undefined, message?: string, stackCrawlMark?: AnyFunction): T { // eslint-disable-line no-restricted-syntax assertIsDefined(value, message, stackCrawlMark || checkDefined); return value; } @@ -935,7 +935,7 @@ m2: ${(this.mapper2 as unknown as DebugTypeMapper).__debugToString().split("\n") FlowFlags.Condition | FlowFlags.ArrayMutation; - const links: Record = Object.create(/*o*/ null); // eslint-disable-line no-null/no-null + const links: Record = Object.create(/*o*/ null); // eslint-disable-line no-restricted-syntax const nodes: FlowGraphNode[] = []; const edges: FlowGraphEdge[] = []; const root = buildGraphNode(flowNode, new Set()); diff --git a/src/compiler/executeCommandLine.ts b/src/compiler/executeCommandLine.ts index ed5c1836c9b..4053523f356 100644 --- a/src/compiler/executeCommandLine.ts +++ b/src/compiler/executeCommandLine.ts @@ -653,7 +653,7 @@ function executeCommandLineWorker( configParseResult.errors.forEach(reportDiagnostic); return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); } - // eslint-disable-next-line no-null/no-null + // eslint-disable-next-line no-restricted-syntax sys.write(JSON.stringify(convertToTSConfig(configParseResult, configFileName, sys), null, 4) + sys.newLine); return sys.exit(ExitStatus.Success); } @@ -693,7 +693,7 @@ function executeCommandLineWorker( } else { if (commandLineOptions.showConfig) { - // eslint-disable-next-line no-null/no-null + // eslint-disable-next-line no-restricted-syntax sys.write(JSON.stringify(convertToTSConfig(commandLine, combinePaths(currentDirectory, "tsconfig.json"), sys), null, 4) + sys.newLine); return sys.exit(ExitStatus.Success); } diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index ef8ba8c0caf..8a84182c6cb 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -360,9 +360,9 @@ function readPackageJsonField(jsonContent: PackageJ return; } const value = jsonContent[fieldName]; - if (typeof value !== typeOfTag || value === null) { // eslint-disable-line no-null/no-null + if (typeof value !== typeOfTag || value === null) { // eslint-disable-line no-restricted-syntax if (state.traceEnabled) { - // eslint-disable-next-line no-null/no-null + // eslint-disable-next-line no-restricted-syntax trace(state.host, Diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2, fieldName, typeOfTag, value === null ? "null" : typeof value); } return; @@ -822,7 +822,7 @@ export function getAutomaticTypeDirectiveNames(options: CompilerOptions, host: M const packageJsonPath = combinePaths(root, normalized, "package.json"); // `types-publisher` sometimes creates packages with `"typings": null` for packages that don't provide their own types. // See `createNotNeededPackageJSON` in the types-publisher` repo. - // eslint-disable-next-line no-null/no-null + // eslint-disable-next-line no-restricted-syntax const isNotNeededPackage = host.fileExists(packageJsonPath) && (readJson(packageJsonPath, host) as PackageJson).typings === null; if (!isNotNeededPackage) { const baseFileName = getBaseFileName(normalized); @@ -934,7 +934,7 @@ export interface PackageJsonInfoCache { export type PerModuleNameCache = PerNonRelativeNameCache; function compilerOptionValueToString(value: unknown): string { - if (value === null || typeof value !== "object") { // eslint-disable-line no-null/no-null + if (value === null || typeof value !== "object") { // eslint-disable-line no-restricted-syntax return "" + value; } if (isArray(value)) { @@ -2276,7 +2276,7 @@ function loadEntrypointsFromExportMap( loadEntrypointsFromTargetExports(target); } } - // eslint-disable-next-line no-null/no-null + // eslint-disable-next-line no-restricted-syntax else if (typeof exports === "object" && exports !== null && allKeysStartWithDot(exports as MapLike)) { for (const key in exports) { loadEntrypointsFromTargetExports((exports as MapLike)[key]); @@ -2331,7 +2331,7 @@ function loadEntrypointsFromExportMap( } } } - // eslint-disable-next-line no-null/no-null + // eslint-disable-next-line no-restricted-syntax else if (typeof target === "object" && target !== null) { return forEach(getOwnKeys(target as MapLike), key => { if (key === "default" || contains(state.conditions, key) || isApplicableVersionedTypesKey(state.conditions, key)) { @@ -2797,7 +2797,7 @@ function getLoadModuleFromTargetImportOrExport(extensions: Extensions, state: Mo if (inputLink) return inputLink; return toSearchResult(withPackageId(scope, loadFileNameFromPackageJsonField(extensions, finalPath, /*onlyRecordFailures*/ false, state), state)); } - else if (typeof target === "object" && target !== null) { // eslint-disable-line no-null/no-null + else if (typeof target === "object" && target !== null) { // eslint-disable-line no-restricted-syntax if (!Array.isArray(target)) { traceIfEnabled(state, Diagnostics.Entering_conditional_exports); for (const condition of getOwnKeys(target as MapLike)) { @@ -2836,7 +2836,7 @@ function getLoadModuleFromTargetImportOrExport(extensions: Extensions, state: Mo } } } - else if (target === null) { // eslint-disable-line no-null/no-null + else if (target === null) { // eslint-disable-line no-restricted-syntax if (state.traceEnabled) { trace(state.host, Diagnostics.package_json_scope_0_explicitly_maps_specifier_1_to_null, scope.packageDirectory, moduleName); } @@ -3092,7 +3092,7 @@ function loadModuleFromSpecificNodeModulesDirectory(extensions: Extensions, modu ); if ( !pathAndExtension && packageInfo - // eslint-disable-next-line no-null/no-null + // eslint-disable-next-line no-restricted-syntax && (packageInfo.contents.packageJsonContent.exports === undefined || packageInfo.contents.packageJsonContent.exports === null) && state.features & NodeResolutionFeatures.EsmMode ) { diff --git a/src/compiler/moduleSpecifiers.ts b/src/compiler/moduleSpecifiers.ts index e35047d716f..df7e2fb5d8c 100644 --- a/src/compiler/moduleSpecifiers.ts +++ b/src/compiler/moduleSpecifiers.ts @@ -964,7 +964,7 @@ function tryGetModuleNameFromExportsOrImports(options: CompilerOptions, host: Mo else if (Array.isArray(exports)) { return forEach(exports, e => tryGetModuleNameFromExportsOrImports(options, host, targetFilePath, packageDirectory, packageName, e, conditions, mode, isImports)); } - else if (typeof exports === "object" && exports !== null) { // eslint-disable-line no-null/no-null + else if (typeof exports === "object" && exports !== null) { // eslint-disable-line no-restricted-syntax // conditional mapping for (const key of getOwnKeys(exports as MapLike)) { if (key === "default" || conditions.indexOf(key) >= 0 || isApplicableVersionedTypesKey(conditions, key)) { @@ -980,7 +980,7 @@ function tryGetModuleNameFromExportsOrImports(options: CompilerOptions, host: Mo } function tryGetModuleNameFromExports(options: CompilerOptions, host: ModuleSpecifierResolutionHost, targetFilePath: string, packageDirectory: string, packageName: string, exports: unknown, conditions: string[]): { moduleFileToTry: string; } | undefined { - if (typeof exports === "object" && exports !== null && !Array.isArray(exports) && allKeysStartWithDot(exports as MapLike)) { // eslint-disable-line no-null/no-null + if (typeof exports === "object" && exports !== null && !Array.isArray(exports) && allKeysStartWithDot(exports as MapLike)) { // eslint-disable-line no-restricted-syntax // sub-mappings // 3 cases: // * directory mappings (legacyish, key ends with / (technically allows index/extension resolution under cjs mode)) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 35366ac9d65..9ef46604879 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -10672,7 +10672,7 @@ function extractPragmas(pragmas: PragmaPseudoMapEntry[], range: CommentRange, te if (range.kind === SyntaxKind.MultiLineCommentTrivia) { const multiLinePragmaRegEx = /@(\S+)(\s+.*)?$/gim; // Defined inline since it uses the "g" flag, which keeps a persistent index (for iterating) - let multiLineMatch: RegExpExecArray | null; + let multiLineMatch: RegExpExecArray | null; // eslint-disable-line no-restricted-syntax while (multiLineMatch = multiLinePragmaRegEx.exec(text)) { addPragmaForMatch(pragmas, range, PragmaKindFlags.MultiLine, multiLineMatch); } diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 64166dff2ce..fedc7b39a6f 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -3457,7 +3457,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg function collectDynamicImportOrRequireOrJsDocImportCalls(file: SourceFile) { const r = /import|require/g; - while (r.exec(file.text) !== null) { // eslint-disable-line no-null/no-null + while (r.exec(file.text) !== null) { // eslint-disable-line no-restricted-syntax const node = getNodeAtPosition(file, r.lastIndex); if (isJavaScriptFile && isRequireCall(node, /*requireStringLiteralLikeArgument*/ true)) { setParentRecursive(node, /*incremental*/ false); // we need parent data on imports before the program is fully bound, so we ensure it's set here diff --git a/src/compiler/sourcemap.ts b/src/compiler/sourcemap.ts index 6a5af5699b3..d6240cf0aa2 100644 --- a/src/compiler/sourcemap.ts +++ b/src/compiler/sourcemap.ts @@ -45,7 +45,7 @@ export function createSourceMapGenerator(host: EmitHost, file: string, sourceRoo var rawSources: string[] = []; var sources: string[] = []; var sourceToSourceIndexMap = new Map(); - var sourcesContent: (string | null)[] | undefined; + var sourcesContent: (string | null)[] | undefined; // eslint-disable-line no-restricted-syntax var names: string[] = []; var nameToNameIndexMap: Map | undefined; @@ -98,7 +98,7 @@ export function createSourceMapGenerator(host: EmitHost, file: string, sourceRoo return sourceIndex; } - /* eslint-disable no-null/no-null */ + /* eslint-disable no-restricted-syntax */ function setSourceContent(sourceIndex: number, content: string | null) { enter(); if (content !== null) { @@ -110,7 +110,7 @@ export function createSourceMapGenerator(host: EmitHost, file: string, sourceRoo } exit(); } - /* eslint-enable no-null/no-null */ + /* eslint-enable no-restricted-syntax */ function addName(name: string) { enter(); @@ -400,7 +400,7 @@ export function tryGetSourceMappingURL(lineInfo: LineInfo) { } } -/* eslint-disable no-null/no-null */ +/* eslint-disable no-restricted-syntax */ function isStringOrNull(x: any) { return typeof x === "string" || x === null; } @@ -417,7 +417,7 @@ export function isRawSourceMap(x: any): x is RawSourceMap { && (x.sourcesContent === undefined || x.sourcesContent === null || isArray(x.sourcesContent) && every(x.sourcesContent, isStringOrNull)) && (x.names === undefined || x.names === null || isArray(x.names) && every(x.names, isString)); } -/* eslint-enable no-null/no-null */ +/* eslint-enable no-restricted-syntax */ /** @internal */ export function tryParseRawSourceMap(text: string) { diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index 75ff7e7d812..86e029c7994 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -889,7 +889,7 @@ function createDirectoryWatcherSupportingRecursive({ } /** @internal */ -export type FsWatchCallback = (eventName: "rename" | "change", relativeFileName: string | undefined | null, modifiedTime?: Date) => void; +export type FsWatchCallback = (eventName: "rename" | "change", relativeFileName: string | undefined | null, modifiedTime?: Date) => void; // eslint-disable-line no-restricted-syntax /** @internal */ export type FsWatch = (fileOrDirectory: string, entryKind: FileSystemEntryKind, callback: FsWatchCallback, recursive: boolean, fallbackPollingInterval: PollingInterval, fallbackOptions: WatchOptions | undefined) => FileWatcher; /** @internal */ @@ -1284,7 +1284,7 @@ export function createSystemWatchFunctions({ } } - function callbackChangingToMissingFileSystemEntry(event: "rename" | "change", relativeName: string | undefined | null) { + function callbackChangingToMissingFileSystemEntry(event: "rename" | "change", relativeName: string | undefined | null) { // eslint-disable-line no-restricted-syntax // In some scenarios, file save operation fires event with fileName.ext~ instead of fileName.ext // To ensure we see the file going missing and coming back up (file delete and then recreated) // and watches being updated correctly we are calling back with fileName.ext as well as fileName.ext~ diff --git a/src/compiler/tracing.ts b/src/compiler/tracing.ts index 42b69e0f7bc..a1431b5749e 100644 --- a/src/compiler/tracing.ts +++ b/src/compiler/tracing.ts @@ -51,7 +51,7 @@ export namespace tracingEnabled { // The actual constraint is that JSON.stringify be able to serialize it without throwing. interface Args { - [key: string]: string | number | boolean | null | undefined | Args | readonly (string | number | boolean | null | undefined | Args)[]; + [key: string]: string | number | boolean | null | undefined | Args | readonly (string | number | boolean | null | undefined | Args)[]; // eslint-disable-line no-restricted-syntax } /** Starts tracing for the given project. */ diff --git a/src/compiler/types.ts b/src/compiler/types.ts index d97dc608adc..010196f5e1c 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -7166,7 +7166,7 @@ export enum PollingWatchKind { FixedChunkSize, } -export type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike | PluginImport[] | ProjectReference[] | null | undefined; +export type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike | PluginImport[] | ProjectReference[] | null | undefined; // eslint-disable-line no-restricted-syntax export interface CompilerOptions { /** @internal */ all?: boolean; @@ -9590,11 +9590,11 @@ export interface PrinterOptions { export interface RawSourceMap { version: 3; file: string; - sourceRoot?: string | null; + sourceRoot?: string | null; // eslint-disable-line no-restricted-syntax sources: string[]; - sourcesContent?: (string | null)[] | null; + sourcesContent?: (string | null)[] | null; // eslint-disable-line no-restricted-syntax mappings: string; - names?: string[] | null; + names?: string[] | null; // eslint-disable-line no-restricted-syntax } /** @@ -9611,7 +9611,7 @@ export interface SourceMapGenerator { /** * Set the content for a source. */ - setSourceContent(sourceIndex: number, content: string | null): void; + setSourceContent(sourceIndex: number, content: string | null): void; // eslint-disable-line no-restricted-syntax /** * Adds a name. */ diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 4bbd3a80951..d9e154ca21e 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -9943,7 +9943,7 @@ export function skipTypeChecking(sourceFile: SourceFile, options: CompilerOption /** @internal */ export function isJsonEqual(a: unknown, b: unknown): boolean { - // eslint-disable-next-line no-null/no-null + // eslint-disable-next-line no-restricted-syntax return a === b || typeof a === "object" && a !== null && typeof b === "object" && b !== null && equalOwnProperties(a as MapLike, b as MapLike, isJsonEqual); } diff --git a/src/harness/collectionsImpl.ts b/src/harness/collectionsImpl.ts index 9f3b88cfb13..5e6b3d1fb44 100644 --- a/src/harness/collectionsImpl.ts +++ b/src/harness/collectionsImpl.ts @@ -237,7 +237,7 @@ export class Metadata { constructor(parent?: Metadata) { this._parent = parent; - this._map = Object.create(parent ? parent._map : null); // eslint-disable-line no-null/no-null + this._map = Object.create(parent ? parent._map : null); // eslint-disable-line no-restricted-syntax } public get size(): number { @@ -284,7 +284,7 @@ export class Metadata { } public clear(): void { - this._map = Object.create(this._parent ? this._parent._map : null); // eslint-disable-line no-null/no-null + this._map = Object.create(this._parent ? this._parent._map : null); // eslint-disable-line no-restricted-syntax this._size = -1; this._version++; } diff --git a/src/harness/documentsUtil.ts b/src/harness/documentsUtil.ts index c538ae3931e..8699609ef53 100644 --- a/src/harness/documentsUtil.ts +++ b/src/harness/documentsUtil.ts @@ -98,7 +98,7 @@ export class SourceMap { let sourceLine = 0; let sourceColumn = 0; let nameIndex = 0; - let match: RegExpExecArray | null; + let match: RegExpExecArray | null; // eslint-disable-line no-restricted-syntax while (match = SourceMap._mappingRegExp.exec(this.raw.mappings)) { if (match[1]) { const segment = SourceMap._decodeVLQ(match[1]); @@ -141,7 +141,7 @@ export class SourceMap { } public static getUrl(text: string) { - let match: RegExpExecArray | null; + let match: RegExpExecArray | null; // eslint-disable-line no-restricted-syntax let lastMatch: RegExpExecArray | undefined; while (match = SourceMap._sourceMappingURLRegExp.exec(text)) { lastMatch = match; diff --git a/src/harness/evaluatorImpl.ts b/src/harness/evaluatorImpl.ts index c6edef27fb0..b8decf789a1 100644 --- a/src/harness/evaluatorImpl.ts +++ b/src/harness/evaluatorImpl.ts @@ -253,7 +253,7 @@ class SystemLoader extends Loader { protected createModule(file: string): SystemModule { return { file, - // eslint-disable-next-line no-null/no-null + // eslint-disable-next-line no-restricted-syntax exports: Object.create(/*o*/ null), dependencies: [], dependers: [], diff --git a/src/harness/harnessIO.ts b/src/harness/harnessIO.ts index 0603409e77f..790bab2f11c 100644 --- a/src/harness/harnessIO.ts +++ b/src/harness/harnessIO.ts @@ -703,7 +703,7 @@ export namespace Compiler { } export function doErrorBaseline(baselinePath: string, inputFiles: readonly TestFile[], errors: readonly ts.Diagnostic[], pretty?: boolean) { - Baseline.runBaseline(baselinePath.replace(/\.tsx?$/, ".errors.txt"), !errors || (errors.length === 0) ? null : getErrorBaseline(inputFiles, errors, pretty)); // eslint-disable-line no-null/no-null + Baseline.runBaseline(baselinePath.replace(/\.tsx?$/, ".errors.txt"), !errors || (errors.length === 0) ? null : getErrorBaseline(inputFiles, errors, pretty)); // eslint-disable-line no-restricted-syntax } export function doTypeAndSymbolBaseline(baselinePath: string, header: string, program: ts.Program, allFiles: { unitName: string; content: string; }[], opts?: Baseline.BaselineOptions, multifile?: boolean, skipTypeBaselines?: boolean, skipSymbolBaselines?: boolean, hasErrorBaseline?: boolean) { @@ -774,7 +774,7 @@ export namespace Compiler { } } - function generateBaseLine(isSymbolBaseline: boolean, skipBaseline?: boolean): string | null { + function generateBaseLine(isSymbolBaseline: boolean, skipBaseline?: boolean): string | null { // eslint-disable-line no-restricted-syntax let result = ""; const perfLines: string[] = []; const prePerformanceValues = getPerformanceBaselineValues(); @@ -814,7 +814,7 @@ export namespace Compiler { } } - return result ? (`//// [${header}] ////\r\n\r\n${perfLines.join("\n")}${result}`) : null; // eslint-disable-line no-null/no-null + return result ? (`//// [${header}] ////\r\n\r\n${perfLines.join("\n")}${result}`) : null; // eslint-disable-line no-restricted-syntax function valueToString(value: number) { return roundToHumanLogarithm(value).toLocaleString("en-US"); @@ -910,11 +910,11 @@ export namespace Compiler { throw new Error("Number of sourcemap files should be same as js files."); } - let sourceMapCode: string | null; + let sourceMapCode: string | null; // eslint-disable-line no-restricted-syntax if ((options.noEmitOnError && result.diagnostics.length !== 0) || result.maps.size === 0) { // We need to return null here or the runBaseLine will actually create a empty file. // Baselining isn't required here because there is no output. - sourceMapCode = null; // eslint-disable-line no-null/no-null + sourceMapCode = null; // eslint-disable-line no-restricted-syntax } else { sourceMapCode = ""; @@ -996,7 +996,7 @@ export namespace Compiler { jsCode += getErrorBaseline(tsConfigFiles.concat(declFileCompilationResult.declInputFiles, declFileCompilationResult.declOtherFiles), declFileCompilationResult.declResult.diagnostics); } - // eslint-disable-next-line no-null/no-null + // eslint-disable-next-line no-restricted-syntax Baseline.runBaseline(baselinePath.replace(/\.tsx?/, ts.Extension.Js), jsCode.length > 0 ? tsCode + "\r\n\r\n" + jsCode : null); } @@ -1235,8 +1235,8 @@ export namespace TestCaseParser { export function extractCompilerSettings(content: string): CompilerSettings { const opts: CompilerSettings = {}; - let match: RegExpExecArray | null; - while ((match = optionRegex.exec(content)) !== null) { // eslint-disable-line no-null/no-null + let match: RegExpExecArray | null; // eslint-disable-line no-restricted-syntax + while ((match = optionRegex.exec(content)) !== null) { // eslint-disable-line no-restricted-syntax opts[match[1]] = match[2].trim(); } @@ -1266,7 +1266,7 @@ export namespace TestCaseParser { let symlinks: vfs.FileSet | undefined; for (const line of lines) { - let testMetaData: RegExpExecArray | null; + let testMetaData: RegExpExecArray | null; // eslint-disable-line no-restricted-syntax const possiblySymlinks = parseSymlinkFromTest(line, symlinks, vfs.srcFolder); if (possiblySymlinks) { symlinks = possiblySymlinks; @@ -1426,7 +1426,7 @@ export namespace Baseline { const fileCache: { [idx: string]: boolean; } = {}; - function compareToBaseline(actual: string | null, relativeFileName: string, opts: BaselineOptions | undefined) { + function compareToBaseline(actual: string | null, relativeFileName: string, opts: BaselineOptions | undefined) { // eslint-disable-line no-restricted-syntax // actual is now either undefined (the generator had an error), null (no file requested), // or some real output of the function if (actual === undefined) { @@ -1436,7 +1436,7 @@ export namespace Baseline { const refFileName = referencePath(relativeFileName, opts && opts.Baselinefolder, opts && opts.Subfolder); - // eslint-disable-next-line no-null/no-null + // eslint-disable-next-line no-restricted-syntax if (actual === null) { actual = noContent; } @@ -1504,7 +1504,7 @@ export namespace Baseline { return `The baseline file ${relativeFileName} has changed. (Run "hereby baseline-accept" if the new baseline is correct.)`; } - export function runBaseline(relativeFileName: string, actual: string | null, opts?: BaselineOptions): void { + export function runBaseline(relativeFileName: string, actual: string | null, opts?: BaselineOptions): void { // eslint-disable-line no-restricted-syntax const actualFileName = localPath(relativeFileName, opts && opts.Baselinefolder, opts && opts.Subfolder); if (actual === undefined) { throw new Error('The generated content was "undefined". Return "null" if no baselining is required."'); @@ -1513,12 +1513,12 @@ export namespace Baseline { writeComparison(comparison.expected, comparison.actual, relativeFileName, actualFileName, opts); } - export function runMultifileBaseline(relativeFileBase: string, extension: string, generateContent: () => IterableIterator<[string, string, number]> | IterableIterator<[string, string]> | null, opts?: BaselineOptions, referencedExtensions?: string[]): void { + export function runMultifileBaseline(relativeFileBase: string, extension: string, generateContent: () => IterableIterator<[string, string, number]> | IterableIterator<[string, string]> | null, opts?: BaselineOptions, referencedExtensions?: string[]): void { // eslint-disable-line no-restricted-syntax const gen = generateContent(); const writtenFiles = new Map(); const errors: Error[] = []; - // eslint-disable-next-line no-null/no-null + // eslint-disable-next-line no-restricted-syntax if (gen !== null) { for (const value of gen) { const [name, content, count] = value as [string, string, number | undefined]; diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index 6f755bc02f9..c890eadc37e 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -19,7 +19,7 @@ import { import { createWatchUtils } from "./watchUtils"; export function makeDefaultProxy(info: ts.server.PluginCreateInfo): ts.LanguageService { - const proxy = Object.create(/*o*/ null); // eslint-disable-line no-null/no-null + const proxy = Object.create(/*o*/ null); // eslint-disable-line no-restricted-syntax const langSvc: any = info.languageService; for (const k of Object.keys(langSvc)) { // eslint-disable-next-line local/only-arrow-functions diff --git a/src/harness/sourceMapRecorder.ts b/src/harness/sourceMapRecorder.ts index 4110c8032ad..6504f338776 100644 --- a/src/harness/sourceMapRecorder.ts +++ b/src/harness/sourceMapRecorder.ts @@ -44,7 +44,7 @@ namespace SourceMapDecoder { namespace SourceMapSpanWriter { let sourceMapRecorder: Compiler.WriterAggregator; let sourceMapSources: string[]; - let sourceMapNames: string[] | null | undefined; + let sourceMapNames: string[] | null | undefined; // eslint-disable-line no-restricted-syntax let jsFile: documents.TextDocument; let jsLineMap: readonly number[]; diff --git a/src/harness/util.ts b/src/harness/util.ts index 3a4a78f7240..59bbbb0cec6 100644 --- a/src/harness/util.ts +++ b/src/harness/util.ts @@ -38,7 +38,7 @@ export function dedent(array: TemplateStringsArray, ...args: any[]) { const lineTerminatorRegExp = /\r\n?|\n/g; const lines: string[] = []; const lineTerminators: string[] = []; - let match: RegExpExecArray | null; + let match: RegExpExecArray | null; // eslint-disable-line no-restricted-syntax let lineStart = 0; while (match = lineTerminatorRegExp.exec(text)) { if (lineStart !== match.index || lines.length > 0) { diff --git a/src/harness/vfsUtil.ts b/src/harness/vfsUtil.ts index 5b31adbf5fd..11ffcfb25a6 100644 --- a/src/harness/vfsUtil.ts +++ b/src/harness/vfsUtil.ts @@ -637,7 +637,7 @@ export class FileSystem { * * NOTE: do not rename this method as it is intended to align with the same named export of the "fs" module. */ - public readFileSync(path: string, encoding?: null): Buffer; + public readFileSync(path: string, encoding?: null): Buffer; // eslint-disable-line no-restricted-syntax /** * Read from a file. * @@ -649,8 +649,8 @@ export class FileSystem { * * NOTE: do not rename this method as it is intended to align with the same named export of the "fs" module. */ - public readFileSync(path: string, encoding?: BufferEncoding | null): string | Buffer; - public readFileSync(path: string, encoding: BufferEncoding | null = null) { // eslint-disable-line no-null/no-null + public readFileSync(path: string, encoding?: BufferEncoding | null): string | Buffer; // eslint-disable-line no-restricted-syntax + public readFileSync(path: string, encoding: BufferEncoding | null = null) { // eslint-disable-line no-restricted-syntax const { node } = this._walk(this._resolve(path)); if (!node) throw createIOError("ENOENT"); if (isDirectory(node)) throw createIOError("EISDIR"); @@ -665,7 +665,7 @@ export class FileSystem { * * NOTE: do not rename this method as it is intended to align with the same named export of the "fs" module. */ - // eslint-disable-next-line no-null/no-null + // eslint-disable-next-line no-restricted-syntax public writeFileSync(path: string, data: string | Buffer, encoding: string | null = null) { if (this.isReadonly) throw createIOError("EROFS"); @@ -1141,7 +1141,7 @@ export class FileSystem { const path = dirname ? vpath.resolve(dirname, key) : key; vpath.validate(path, vpath.ValidationFlags.Absolute); - // eslint-disable-next-line no-null/no-null + // eslint-disable-next-line no-restricted-syntax if (value === null || value === undefined || value instanceof Rmdir || value instanceof Unlink) { if (this.stringComparer(vpath.dirname(path), path) === 0) { throw new TypeError("Roots cannot be deleted."); @@ -1371,7 +1371,7 @@ export function createIOError(code: keyof typeof IOErrorMessages, details = "") * A template used to populate files, directories, links, etc. in a virtual file system. */ export interface FileSet { - [name: string]: DirectoryLike | FileLike | Link | Symlink | Mount | Rmdir | Unlink | null | undefined; + [name: string]: DirectoryLike | FileLike | Link | Symlink | Mount | Rmdir | Unlink | null | undefined; // eslint-disable-line no-restricted-syntax } export type DirectoryLike = FileSet | Directory; @@ -1572,7 +1572,7 @@ function getBuiltLocal(host: FileSystemResolverHost, ignoreCase: boolean): FileS return builtLocalCS; } -/* eslint-disable no-null/no-null */ +/* eslint-disable no-restricted-syntax */ function normalizeFileSetEntry(value: FileSet[string]) { if ( value === undefined || @@ -1595,14 +1595,14 @@ export function formatPatch(patch: FileSet | undefined): string | null; export function formatPatch(patch: FileSet | undefined) { return patch ? formatPatchWorker("", patch) : null; } -/* eslint-enable no-null/no-null */ +/* eslint-enable no-restricted-syntax */ function formatPatchWorker(dirname: string, container: FileSet): string { let text = ""; for (const name of Object.keys(container)) { const entry = normalizeFileSetEntry(container[name]); const file = dirname ? vpath.combine(dirname, name) : name; - // eslint-disable-next-line no-null/no-null + // eslint-disable-next-line no-restricted-syntax if (entry === null || entry === undefined || entry instanceof Unlink) { text += `//// [${file}] unlink\r\n`; } @@ -1635,8 +1635,8 @@ function formatPatchWorker(dirname: string, container: FileSet): string { return text; } -export function iteratePatch(patch: FileSet | undefined): IterableIterator<[string, string]> | null { - // eslint-disable-next-line no-null/no-null +export function iteratePatch(patch: FileSet | undefined): IterableIterator<[string, string]> | null { // eslint-disable-line no-restricted-syntax + // eslint-disable-next-line no-restricted-syntax return patch ? Harness.Compiler.iterateOutputs(iteratePatchWorker("", patch)) : null; } diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index 474af54946f..881a26c5e4e 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -1376,7 +1376,7 @@ const enum LineAction { export function getRangeOfEnclosingComment( sourceFile: SourceFile, position: number, - precedingToken?: Node | null, + precedingToken?: Node | null, // eslint-disable-line no-restricted-syntax tokenAtPosition = getTokenAtPosition(sourceFile, position), ): CommentRange | undefined { const jsdoc = findAncestor(tokenAtPosition, isJSDoc); @@ -1386,7 +1386,7 @@ export function getRangeOfEnclosingComment( return undefined; } - // eslint-disable-next-line no-null/no-null + // eslint-disable-next-line no-restricted-syntax precedingToken = precedingToken === null ? undefined : precedingToken === undefined ? findPrecedingToken(position, sourceFile) : precedingToken; // Between two consecutive tokens, all comments are either trailing on the former diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index 5e8da438663..ca0936f3f78 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -92,7 +92,7 @@ export namespace SmartIndenter { const precedingToken = findPrecedingToken(position, sourceFile, /*startNode*/ undefined, /*excludeJsdoc*/ true); - // eslint-disable-next-line no-null/no-null + // eslint-disable-next-line no-restricted-syntax const enclosingCommentRange = getRangeOfEnclosingComment(sourceFile, position, precedingToken || null); if (enclosingCommentRange && enclosingCommentRange.kind === SyntaxKind.MultiLineCommentTrivia) { return getCommentIndent(sourceFile, position, options, enclosingCommentRange); diff --git a/src/services/outliningElementsCollector.ts b/src/services/outliningElementsCollector.ts index 754541ed507..740b246eb06 100644 --- a/src/services/outliningElementsCollector.ts +++ b/src/services/outliningElementsCollector.ts @@ -164,7 +164,7 @@ function isRegionDelimiter(lineText: string) { // multiple potential whitespace matches can make for some gnarly backtracking behavior lineText = lineText.trimStart(); if (!startsWith(lineText, "//")) { - return null; // eslint-disable-line no-null/no-null + return null; // eslint-disable-line no-restricted-syntax } lineText = lineText.slice(2).trim(); return regionDelimiterRegExp.exec(lineText); diff --git a/src/services/services.ts b/src/services/services.ts index 18f0b4d1514..1aaff7c744c 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -2907,7 +2907,7 @@ export function createLanguageService( if (descriptors.length > 0 && !isNodeModulesFile(sourceFile.fileName)) { const regExp = getTodoCommentsRegExp(); - let matchArray: RegExpExecArray | null; + let matchArray: RegExpExecArray | null; // eslint-disable-line no-restricted-syntax while (matchArray = regExp.exec(fileContents)) { cancellationToken.throwIfCancellationRequested(); diff --git a/src/services/stringCompletions.ts b/src/services/stringCompletions.ts index d8e375332ba..a6d52104d86 100644 --- a/src/services/stringCompletions.ts +++ b/src/services/stringCompletions.ts @@ -972,7 +972,7 @@ function getCompletionEntriesForNonRelativeModules( const packageJson = readJson(packageFile, host); const exports = (packageJson as any).exports; if (exports) { - if (typeof exports !== "object" || exports === null) { // eslint-disable-line no-null/no-null + if (typeof exports !== "object" || exports === null) { // eslint-disable-line no-restricted-syntax return; // null exports or entrypoint only, no sub-modules available } const keys = getOwnKeys(exports); diff --git a/src/testRunner/compilerRunner.ts b/src/testRunner/compilerRunner.ts index 8d4c0b1547c..4c905e38826 100644 --- a/src/testRunner/compilerRunner.ts +++ b/src/testRunner/compilerRunner.ts @@ -300,7 +300,7 @@ class CompilerTest { const record = Utils.removeTestPathPrefixes(this.result.getSourceMapRecord()!); const baseline = (this.options.noEmitOnError && this.result.diagnostics.length !== 0) || record === undefined // Because of the noEmitOnError option no files are created. We need to return null because baselining isn't required. - ? null // eslint-disable-line no-null/no-null + ? null // eslint-disable-line no-restricted-syntax : record; Baseline.runBaseline(this.configuredName.replace(/\.tsx?$/, ".sourcemap.txt"), baseline); } diff --git a/src/testRunner/parallel/host.ts b/src/testRunner/parallel/host.ts index ca8ffb563d3..346982ae5fe 100644 --- a/src/testRunner/parallel/host.ts +++ b/src/testRunner/parallel/host.ts @@ -596,7 +596,7 @@ export function start() { consoleReporter.epilogue(); if (noColors) Base.useColors = savedUseColors; - // eslint-disable-next-line no-null/no-null + // eslint-disable-next-line no-restricted-syntax IO.writeFile(perfdataFileName(configOption), JSON.stringify(newPerfData, null, 4)); if (xunitReporter) { diff --git a/src/testRunner/projectsRunner.ts b/src/testRunner/projectsRunner.ts index 44430453325..56394ed3ce2 100644 --- a/src/testRunner/projectsRunner.ts +++ b/src/testRunner/projectsRunner.ts @@ -282,7 +282,7 @@ class ProjectTestCase { } const content = Utils.removeTestPathPrefixes(output.text, /*retainTrailingDirectorySeparator*/ true); - Harness.Baseline.runBaseline(this.getBaselineFolder(this.compilerResult.moduleKind) + diskRelativeName, content as string | null); // TODO: GH#18217 + Harness.Baseline.runBaseline(this.getBaselineFolder(this.compilerResult.moduleKind) + diskRelativeName, content as string | null); // eslint-disable-line no-restricted-syntax } catch (e) { errs.push(e); diff --git a/src/testRunner/unittests/config/configurationExtension.ts b/src/testRunner/unittests/config/configurationExtension.ts index aa1b46beb99..7006b3dbe71 100644 --- a/src/testRunner/unittests/config/configurationExtension.ts +++ b/src/testRunner/unittests/config/configurationExtension.ts @@ -186,7 +186,7 @@ function createFileSystem(ignoreCase: boolean, cwd: string, root: string) { "dev/configs/third.json": jsonToReadableText({ extends: "./second", compilerOptions: { - module: null, // eslint-disable-line no-null/no-null + module: null, // eslint-disable-line no-restricted-syntax }, include: ["../supplemental.*"], }), @@ -195,7 +195,7 @@ function createFileSystem(ignoreCase: boolean, cwd: string, root: string) { compilerOptions: { module: "system", }, - include: null, // eslint-disable-line no-null/no-null + include: null, // eslint-disable-line no-restricted-syntax files: ["../main.ts"], }), "dev/configs/fifth.json": jsonToReadableText({ @@ -228,7 +228,7 @@ function createFileSystem(ignoreCase: boolean, cwd: string, root: string) { }), "dev/configs/extendsArrayThird.json": jsonToReadableText({ compilerOptions: { - module: null, // eslint-disable-line no-null/no-null + module: null, // eslint-disable-line no-restricted-syntax noImplicitAny: false, }, extends: "./extendsArrayFirst", @@ -239,7 +239,7 @@ function createFileSystem(ignoreCase: boolean, cwd: string, root: string) { module: "system", strictNullChecks: false, }, - include: null, // eslint-disable-line no-null/no-null + include: null, // eslint-disable-line no-restricted-syntax files: ["../main.ts"], }), "dev/configs/extendsArrayFifth.json": jsonToReadableText({ diff --git a/src/testRunner/unittests/config/showConfig.ts b/src/testRunner/unittests/config/showConfig.ts index b36023a479e..3e02a256d8f 100644 --- a/src/testRunner/unittests/config/showConfig.ts +++ b/src/testRunner/unittests/config/showConfig.ts @@ -33,7 +33,7 @@ describe("unittests:: config:: showConfig", () => { } const initResult = ts.convertToTSConfig(commandLine, configPath, configParseHost); - // eslint-disable-next-line no-null/no-null + // eslint-disable-next-line no-restricted-syntax Harness.Baseline.runBaseline(outputFileName, JSON.stringify(initResult, null, 4) + "\n"); }); }); diff --git a/src/testRunner/unittests/evaluation/esDecorators.ts b/src/testRunner/unittests/evaluation/esDecorators.ts index 4443dae958d..258bfcc803e 100644 --- a/src/testRunner/unittests/evaluation/esDecorators.ts +++ b/src/testRunner/unittests/evaluation/esDecorators.ts @@ -1127,7 +1127,7 @@ describe("unittests:: evaluation:: esDecorators", () => { } }; `; - assert.throws(() => main(/*value*/ null)); // eslint-disable-line no-null/no-null + assert.throws(() => main(/*value*/ null)); // eslint-disable-line no-restricted-syntax assert.throws(() => main(/*value*/ undefined)); assert.throws(() => main(123)); assert.throws(() => main("abc")); @@ -1175,7 +1175,7 @@ describe("unittests:: evaluation:: esDecorators", () => { } }; `; - assert.throws(() => main(/*value*/ null)); // eslint-disable-line no-null/no-null + assert.throws(() => main(/*value*/ null)); // eslint-disable-line no-restricted-syntax assert.throws(() => main(/*value*/ undefined)); assert.throws(() => main(123)); assert.throws(() => main("abc")); @@ -1256,7 +1256,7 @@ describe("unittests:: evaluation:: esDecorators", () => { } }; `; - assert.throws(() => main(/*value*/ null)); // eslint-disable-line no-null/no-null + assert.throws(() => main(/*value*/ null)); // eslint-disable-line no-restricted-syntax assert.throws(() => main(/*value*/ undefined)); assert.throws(() => main(123)); assert.throws(() => main("abc")); @@ -1337,7 +1337,7 @@ describe("unittests:: evaluation:: esDecorators", () => { } }; `; - assert.throws(() => main(/*value*/ null)); // eslint-disable-line no-null/no-null + assert.throws(() => main(/*value*/ null)); // eslint-disable-line no-restricted-syntax assert.throws(() => main(/*value*/ undefined)); assert.throws(() => main(123)); assert.throws(() => main("abc")); @@ -1418,7 +1418,7 @@ describe("unittests:: evaluation:: esDecorators", () => { } }; `; - assert.throws(() => main(/*value*/ null)); // eslint-disable-line no-null/no-null + assert.throws(() => main(/*value*/ null)); // eslint-disable-line no-restricted-syntax assert.throws(() => main(/*value*/ undefined)); assert.throws(() => main(123)); assert.throws(() => main("abc")); @@ -1499,7 +1499,7 @@ describe("unittests:: evaluation:: esDecorators", () => { } }; `; - assert.throws(() => main(/*value*/ null)); // eslint-disable-line no-null/no-null + assert.throws(() => main(/*value*/ null)); // eslint-disable-line no-restricted-syntax assert.throws(() => main(/*value*/ undefined)); assert.throws(() => main(123)); assert.throws(() => main("abc")); @@ -1575,7 +1575,7 @@ describe("unittests:: evaluation:: esDecorators", () => { } }; `; - assert.throws(() => main(/*value*/ null)); // eslint-disable-line no-null/no-null + assert.throws(() => main(/*value*/ null)); // eslint-disable-line no-restricted-syntax assert.throws(() => main(1)); assert.throws(() => main("abc")); }); @@ -1624,7 +1624,7 @@ describe("unittests:: evaluation:: esDecorators", () => { } }; `; - assert.throws(() => main(/*value*/ null)); // eslint-disable-line no-null/no-null + assert.throws(() => main(/*value*/ null)); // eslint-disable-line no-restricted-syntax assert.throws(() => main(1)); assert.throws(() => main("abc")); }); @@ -1660,7 +1660,7 @@ describe("unittests:: evaluation:: esDecorators", () => { } }; `; - assert.throws(() => main(/*value*/ null)); // eslint-disable-line no-null/no-null + assert.throws(() => main(/*value*/ null)); // eslint-disable-line no-restricted-syntax assert.throws(() => main(1)); assert.throws(() => main("abc")); }); @@ -1696,7 +1696,7 @@ describe("unittests:: evaluation:: esDecorators", () => { } }; `; - assert.throws(() => main(/*value*/ null)); // eslint-disable-line no-null/no-null + assert.throws(() => main(/*value*/ null)); // eslint-disable-line no-restricted-syntax assert.throws(() => main(1)); assert.throws(() => main("abc")); }); @@ -1750,7 +1750,7 @@ describe("unittests:: evaluation:: esDecorators", () => { } }; `; - assert.throws(() => main(/*value*/ null)); // eslint-disable-line no-null/no-null + assert.throws(() => main(/*value*/ null)); // eslint-disable-line no-restricted-syntax assert.throws(() => main(1)); assert.throws(() => main("abc")); }); @@ -1817,7 +1817,7 @@ describe("unittests:: evaluation:: esDecorators", () => { } }; `; - assert.throws(() => main(/*value*/ null)); // eslint-disable-line no-null/no-null + assert.throws(() => main(/*value*/ null)); // eslint-disable-line no-restricted-syntax assert.throws(() => main(1)); assert.throws(() => main("abc")); }); @@ -1830,7 +1830,7 @@ describe("unittests:: evaluation:: esDecorators", () => { } }; `; - assert.throws(() => main(/*value*/ null)); // eslint-disable-line no-null/no-null + assert.throws(() => main(/*value*/ null)); // eslint-disable-line no-restricted-syntax assert.throws(() => main(1)); assert.throws(() => main("abc")); }); @@ -1843,7 +1843,7 @@ describe("unittests:: evaluation:: esDecorators", () => { } }; `; - assert.throws(() => main(/*value*/ null)); // eslint-disable-line no-null/no-null + assert.throws(() => main(/*value*/ null)); // eslint-disable-line no-restricted-syntax assert.throws(() => main(1)); assert.throws(() => main("abc")); }); @@ -1856,7 +1856,7 @@ describe("unittests:: evaluation:: esDecorators", () => { } }; `; - assert.throws(() => main(/*value*/ null)); // eslint-disable-line no-null/no-null + assert.throws(() => main(/*value*/ null)); // eslint-disable-line no-restricted-syntax assert.throws(() => main(1)); assert.throws(() => main("abc")); }); diff --git a/src/testRunner/unittests/helpers/tsc.ts b/src/testRunner/unittests/helpers/tsc.ts index 1a1c9154e1a..ac4c9868e76 100644 --- a/src/testRunner/unittests/helpers/tsc.ts +++ b/src/testRunner/unittests/helpers/tsc.ts @@ -553,7 +553,7 @@ export function verifyTsc({ } Harness.Baseline.runBaseline( tscBaselineName(scenario, subScenario, commandLineArgs, /*isWatch*/ undefined, "-discrepancies"), - baselines ? baselines.join("\r\n") : null, // eslint-disable-line no-null/no-null + baselines ? baselines.join("\r\n") : null, // eslint-disable-line no-restricted-syntax ); }); } diff --git a/src/testRunner/unittests/moduleResolution.ts b/src/testRunner/unittests/moduleResolution.ts index addcd9481da..5ee17d871dd 100644 --- a/src/testRunner/unittests/moduleResolution.ts +++ b/src/testRunner/unittests/moduleResolution.ts @@ -120,7 +120,7 @@ describe("unittests:: moduleResolution:: Node module resolution - relative paths testTypingsIgnored(["a", "b"]); testTypingsIgnored({ a: "b" }); testTypingsIgnored(/*typings*/ true); - testTypingsIgnored(/*typings*/ null); // eslint-disable-line no-null/no-null + testTypingsIgnored(/*typings*/ null); // eslint-disable-line no-restricted-syntax testTypingsIgnored(/*typings*/ undefined); runBaseline("relative module name as directory with invalid typings", baselines); diff --git a/src/testRunner/unittests/services/convertToAsyncFunction.ts b/src/testRunner/unittests/services/convertToAsyncFunction.ts index 3745e7e4674..0da12eaaa0d 100644 --- a/src/testRunner/unittests/services/convertToAsyncFunction.ts +++ b/src/testRunner/unittests/services/convertToAsyncFunction.ts @@ -364,7 +364,7 @@ function testConvertToAsyncFunction(it: Mocha.PendingTestFunction, caption: stri const actions = ts.codefix.getFixes(context); const action = ts.find(actions, action => action.description === ts.Diagnostics.Convert_to_async_function.message); - let outputText: string | null; + let outputText: string | null; // eslint-disable-line no-restricted-syntax if (action?.changes.length) { const data: string[] = []; data.push(`// ==ORIGINAL==`); @@ -381,7 +381,7 @@ function testConvertToAsyncFunction(it: Mocha.PendingTestFunction, caption: stri outputText = data.join(newLineCharacter); } else { - // eslint-disable-next-line no-null/no-null + // eslint-disable-next-line no-restricted-syntax outputText = null; } diff --git a/src/testRunner/unittests/services/transpile.ts b/src/testRunner/unittests/services/transpile.ts index 9896c80db1d..7349aae1daa 100644 --- a/src/testRunner/unittests/services/transpile.ts +++ b/src/testRunner/unittests/services/transpile.ts @@ -62,7 +62,7 @@ describe("unittests:: services:: Transpile", () => { oldTranspileDiagnostics = undefined!; }); - /* eslint-disable no-null/no-null */ + /* eslint-disable no-restricted-syntax */ it("Correct errors for " + justName, () => { Harness.Baseline.runBaseline(justName.replace(/\.tsx?$/, ".errors.txt"), transpileResult.diagnostics!.length === 0 ? null : Harness.Compiler.getErrorBaseline(toBeCompiled, transpileResult.diagnostics!)); }); @@ -72,7 +72,7 @@ describe("unittests:: services:: Transpile", () => { Harness.Baseline.runBaseline(justName.replace(/\.tsx?$/, ".oldTranspile.errors.txt"), oldTranspileDiagnostics.length === 0 ? null : Harness.Compiler.getErrorBaseline(toBeCompiled, oldTranspileDiagnostics)); }); } - /* eslint-enable no-null/no-null */ + /* eslint-enable no-restricted-syntax */ it("Correct output for " + justName, () => { Harness.Baseline.runBaseline(justName.replace(/\.tsx?$/, ts.Extension.Js), transpileResult.outputText); diff --git a/src/testRunner/unittests/sys/symlinkWatching.ts b/src/testRunner/unittests/sys/symlinkWatching.ts index fdb53c62c11..5ef57a9092e 100644 --- a/src/testRunner/unittests/sys/symlinkWatching.ts +++ b/src/testRunner/unittests/sys/symlinkWatching.ts @@ -72,10 +72,12 @@ describe("unittests:: sys:: symlinkWatching::", () => { interface EventAndFileName { event: string; + // eslint-disable-next-line no-restricted-syntax fileName: string | null | undefined; } interface ExpectedEventAndFileName { event: string | readonly string[]; // Its expected event name or any of the event names + // eslint-disable-next-line no-restricted-syntax fileName: string | null | undefined; } type FsWatch = (dir: string, recursive: boolean, cb: ts.FsWatchCallback, sys: System) => ts.FileWatcher; diff --git a/src/testRunner/unittests/tsserver/session.ts b/src/testRunner/unittests/tsserver/session.ts index b567c6d1d61..bc1f17167d5 100644 --- a/src/testRunner/unittests/tsserver/session.ts +++ b/src/testRunner/unittests/tsserver/session.ts @@ -229,7 +229,7 @@ describe("unittests:: tsserver:: Session:: General functionality", () => { session.onMessage(JSON.stringify(req)); req.seq = i; i++; - req.arguments = null; // eslint-disable-line no-null/no-null + req.arguments = null; // eslint-disable-line no-restricted-syntax session.onMessage(JSON.stringify(req)); req.seq = i; i++; diff --git a/src/tsserver/nodeServer.ts b/src/tsserver/nodeServer.ts index ce0a7e44e58..15b45588c9a 100644 --- a/src/tsserver/nodeServer.ts +++ b/src/tsserver/nodeServer.ts @@ -243,7 +243,7 @@ export function initializeNodeSystem(): StartInput { protected write(s: string, _type: ts.server.Msg) { if (this.fd >= 0) { const buf = Buffer.from(s); - // eslint-disable-next-line no-null/no-null + // eslint-disable-next-line no-restricted-syntax fs.writeSync(this.fd, buf, 0, buf.length, /*position*/ null!); // TODO: GH#18217 } if (this.traceToConsole) {