Use built-in no-restricted-syntax to ban null instead of plugin, ban null type too (#58095)

This commit is contained in:
Jake Bailey 2024-04-18 09:06:32 -07:00 коммит произвёл GitHub
Родитель 72f413cea0
Коммит 17e420daf6
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
45 изменённых файлов: 128 добавлений и 139 удалений

Просмотреть файл

@ -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

20
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",

Просмотреть файл

@ -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",

Просмотреть файл

@ -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

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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) {

Просмотреть файл

@ -872,9 +872,9 @@ export function arrayIsEqualTo<T>(array1: readonly T[] | undefined, array2: read
*
* @internal
*/
export function compact<T>(array: (T | undefined | null | false | 0 | "")[]): T[];
export function compact<T>(array: (T | undefined | null | false | 0 | "")[]): T[]; // eslint-disable-line no-restricted-syntax
/** @internal */
export function compact<T>(array: readonly (T | undefined | null | false | 0 | "")[]): readonly T[];
export function compact<T>(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<T>(array: T[]): T[]; // eslint-disable-line @typescript-eslint/unified-signatures
@ -1511,8 +1511,8 @@ export function group<T, K>(values: readonly T[], getGroupId: (value: T) => K, r
/** @internal */
export function groupBy<T, U extends T>(values: readonly T[] | undefined, keySelector: (value: T) => value is U): { true?: U[]; false?: Exclude<T, U>[]; };
/** @internal */
export function groupBy<T, K extends string | number | boolean | null | undefined>(values: readonly T[] | undefined, keySelector: (value: T) => K): { [P in K as `${P}`]?: T[]; };
export function groupBy<T, K extends string | number | boolean | null | undefined>(values: readonly T[] | undefined, keySelector: (value: T) => K): { [P in K as `${P}`]?: T[]; } {
export function groupBy<T, K extends string | number | boolean | null | undefined>(values: readonly T[] | undefined, keySelector: (value: T) => K): { [P in K as `${P}`]?: T[]; }; // eslint-disable-line no-restricted-syntax
export function groupBy<T, K extends string | number | boolean | null | undefined>(values: readonly T[] | undefined, keySelector: (value: T) => K): { [P in K as `${P}`]?: T[]; } { // eslint-disable-line no-restricted-syntax
const result: Record<string, T[]> = {};
if (values) {
for (const value of values) {

Просмотреть файл

@ -244,13 +244,13 @@ export namespace Debug {
}
export function assertIsDefined<T>(value: T, message?: string, stackCrawlMark?: AnyFunction): asserts value is NonNullable<T> {
// 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<T>(value: T | null | undefined, message?: string, stackCrawlMark?: AnyFunction): T {
export function checkDefined<T>(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<number, FlowGraphNode> = Object.create(/*o*/ null); // eslint-disable-line no-null/no-null
const links: Record<number, FlowGraphNode> = Object.create(/*o*/ null); // eslint-disable-line no-restricted-syntax
const nodes: FlowGraphNode[] = [];
const edges: FlowGraphEdge[] = [];
const root = buildGraphNode(flowNode, new Set());

Просмотреть файл

@ -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);
}

Просмотреть файл

@ -360,9 +360,9 @@ function readPackageJsonField<K extends keyof PackageJson>(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<ResolvedModuleWithFailedLookupLocations>;
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<unknown>)) {
for (const key in exports) {
loadEntrypointsFromTargetExports((exports as MapLike<unknown>)[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<unknown>), 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<unknown>)) {
@ -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
) {

Просмотреть файл

@ -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<unknown>)) {
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<unknown>)) { // eslint-disable-line no-null/no-null
if (typeof exports === "object" && exports !== null && !Array.isArray(exports) && allKeysStartWithDot(exports as MapLike<unknown>)) { // eslint-disable-line no-restricted-syntax
// sub-mappings
// 3 cases:
// * directory mappings (legacyish, key ends with / (technically allows index/extension resolution under cjs mode))

Просмотреть файл

@ -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);
}

Просмотреть файл

@ -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

Просмотреть файл

@ -45,7 +45,7 @@ export function createSourceMapGenerator(host: EmitHost, file: string, sourceRoo
var rawSources: string[] = [];
var sources: string[] = [];
var sourceToSourceIndexMap = new Map<string, number>();
var sourcesContent: (string | null)[] | undefined;
var sourcesContent: (string | null)[] | undefined; // eslint-disable-line no-restricted-syntax
var names: string[] = [];
var nameToNameIndexMap: Map<string, number> | 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) {

Просмотреть файл

@ -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~

Просмотреть файл

@ -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. */

Просмотреть файл

@ -7166,7 +7166,7 @@ export enum PollingWatchKind {
FixedChunkSize,
}
export type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike<string[]> | PluginImport[] | ProjectReference[] | null | undefined;
export type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike<string[]> | 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.
*/

Просмотреть файл

@ -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<unknown>, b as MapLike<unknown>, isJsonEqual);
}

Просмотреть файл

@ -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++;
}

Просмотреть файл

@ -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;

Просмотреть файл

@ -253,7 +253,7 @@ class SystemLoader extends Loader<SystemModule> {
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: [],

Просмотреть файл

@ -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<string, true>();
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];

Просмотреть файл

@ -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

Просмотреть файл

@ -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[];

Просмотреть файл

@ -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) {

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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

Просмотреть файл

@ -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);

Просмотреть файл

@ -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);

Просмотреть файл

@ -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();

Просмотреть файл

@ -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);

Просмотреть файл

@ -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);
}

Просмотреть файл

@ -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) {

Просмотреть файл

@ -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);

Просмотреть файл

@ -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({

Просмотреть файл

@ -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");
});
});

Просмотреть файл

@ -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"));
});

Просмотреть файл

@ -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
);
});
}

Просмотреть файл

@ -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);

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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);

Просмотреть файл

@ -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<System extends ts.System> = (dir: string, recursive: boolean, cb: ts.FsWatchCallback, sys: System) => ts.FileWatcher;

Просмотреть файл

@ -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++;

Просмотреть файл

@ -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) {