no-null/no-null
This commit is contained in:
parent
a8ee8fbe87
commit
2c32308f35
11
.eslintrc
11
.eslintrc
|
@ -12,7 +12,7 @@
|
|||
"es6": true
|
||||
},
|
||||
"plugins": [
|
||||
"@typescript-eslint", "microsoft-typescript", "import"
|
||||
"@typescript-eslint", "microsoft-typescript", "no-null", "import"
|
||||
],
|
||||
"rules": {
|
||||
"@typescript-eslint/adjacent-overload-signatures": "error",
|
||||
|
@ -56,6 +56,7 @@
|
|||
"@typescript-eslint/type-annotation-spacing": "error",
|
||||
"@typescript-eslint/unified-signatures": "error",
|
||||
|
||||
/** eslint-plugin-microsoft-typescript */
|
||||
"microsoft-typescript/object-literal-surrounding-space": "error",
|
||||
"microsoft-typescript/no-type-assertion-whitespace": "error",
|
||||
"microsoft-typescript/type-operator-spacing": "error",
|
||||
|
@ -69,9 +70,11 @@
|
|||
"microsoft-typescript/debug-assert": "error",
|
||||
"microsoft-typescript/no-keywords": "error",
|
||||
|
||||
"import/no-extraneous-dependencies": ["error", {
|
||||
"optionalDependencies": false
|
||||
}],
|
||||
/** eslint-plugin-import */
|
||||
"import/no-extraneous-dependencies": ["error", { "optionalDependencies": false }],
|
||||
|
||||
/** eslint-plugin-no-null */
|
||||
"no-null/no-null": "error",
|
||||
|
||||
"arrow-body-style": "off",
|
||||
"arrow-parens": "off",
|
||||
|
|
|
@ -68,6 +68,7 @@
|
|||
"eslint-formatter-autolinkable-stylish": "latest",
|
||||
"eslint-plugin-import": "2.18.0",
|
||||
"eslint-plugin-microsoft-typescript": "0.1.11",
|
||||
"eslint-plugin-no-null": "1.0.2",
|
||||
"fancy-log": "latest",
|
||||
"fs-extra": "^6.0.1",
|
||||
"glob": "latest",
|
||||
|
|
|
@ -52,6 +52,7 @@ function main(): void {
|
|||
writeFileSync(tsFilePath, modifiedTsFileContents);
|
||||
}
|
||||
|
||||
/* eslint-disable no-null/no-null */
|
||||
function updateTsFile(tsFilePath: string, tsFileContents: string, majorMinor: string, patch: string, nightlyPatch: string): string {
|
||||
const majorMinorRgx = /export const versionMajorMinor = "(\d+\.\d+)"/;
|
||||
const majorMinorMatch = majorMinorRgx.exec(tsFileContents);
|
||||
|
@ -76,6 +77,7 @@ function parsePackageJsonVersion(versionString: string): { majorMinor: string, p
|
|||
assert(match !== null, "package.json 'version' should match " + versionRgx.toString());
|
||||
return { majorMinor: match![1], patch: match![2] };
|
||||
}
|
||||
/* eslint-enable no-null/no-null */
|
||||
|
||||
/** e.g. 0-dev.20170707 */
|
||||
function getPrereleasePatch(tag: string, plainPatch: string): string {
|
||||
|
|
|
@ -1642,7 +1642,7 @@ namespace ts {
|
|||
|
||||
case SyntaxKind.NullKeyword:
|
||||
reportInvalidOptionValue(option && option.name === "extends"); // "extends" is the only option we don't allow null/undefined for
|
||||
return null;
|
||||
return null; // eslint-disable-line no-null/no-null
|
||||
|
||||
case SyntaxKind.StringLiteral:
|
||||
if (!isDoubleQuotedString(valueExpression)) {
|
||||
|
@ -2013,7 +2013,7 @@ namespace ts {
|
|||
}
|
||||
|
||||
function isNullOrUndefined(x: any): x is null | undefined {
|
||||
return x === undefined || x === null;
|
||||
return x === undefined || x === null; // eslint-disable-line no-null/no-null
|
||||
}
|
||||
|
||||
function directoryOfCombinedPath(fileName: string, basePath: string) {
|
||||
|
|
|
@ -74,7 +74,7 @@ namespace ts {
|
|||
|
||||
/** Create a MapLike with good performance. */
|
||||
function createDictionaryObject<T>(): MapLike<T> {
|
||||
const map = Object.create(/*prototype*/ null);
|
||||
const map = Object.create(/*prototype*/ null); // eslint-disable-line no-null/no-null
|
||||
|
||||
// Using 'delete' on an object causes V8 to put the object in dictionary mode.
|
||||
// This disables creation of hidden classes, which are expensive when an object is
|
||||
|
|
|
@ -54,6 +54,7 @@ namespace ts {
|
|||
}
|
||||
|
||||
export function assertDefined<T>(value: T | null | undefined, message?: string): T {
|
||||
// eslint-disable-next-line no-null/no-null
|
||||
if (value === undefined || value === null) return fail(message);
|
||||
return value;
|
||||
}
|
||||
|
|
|
@ -130,8 +130,9 @@ namespace ts {
|
|||
return;
|
||||
}
|
||||
const value = jsonContent[fieldName];
|
||||
if (typeof value !== typeOfTag || value === null) {
|
||||
if (typeof value !== typeOfTag || value === null) { // eslint-disable-line no-null/no-null
|
||||
if (state.traceEnabled) {
|
||||
// eslint-disable-next-line no-null/no-null
|
||||
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;
|
||||
|
@ -420,6 +421,7 @@ namespace ts {
|
|||
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
|
||||
const isNotNeededPackage = host.fileExists(packageJsonPath) && (readJson(packageJsonPath, host) as PackageJson).typings === null;
|
||||
if (!isNotNeededPackage) {
|
||||
const baseFileName = getBaseFileName(normalized);
|
||||
|
|
|
@ -2084,7 +2084,7 @@ namespace ts {
|
|||
|
||||
function collectDynamicImportOrRequireCalls(file: SourceFile) {
|
||||
const r = /import|require/g;
|
||||
while (r.exec(file.text) !== null) {
|
||||
while (r.exec(file.text) !== null) { // eslint-disable-line no-null/no-null
|
||||
const node = getNodeAtPosition(file, r.lastIndex);
|
||||
if (isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ true)) {
|
||||
imports = append(imports, node.arguments[0]);
|
||||
|
@ -3094,7 +3094,7 @@ namespace ts {
|
|||
|
||||
function getCompilerOptionsObjectLiteralSyntax() {
|
||||
if (_compilerOptionsObjectLiteralSyntax === undefined) {
|
||||
_compilerOptionsObjectLiteralSyntax = null;
|
||||
_compilerOptionsObjectLiteralSyntax = null; // eslint-disable-line no-null/no-null
|
||||
const jsonObjectLiteral = getTsConfigObjectLiteralExpression(options.configFile);
|
||||
if (jsonObjectLiteral) {
|
||||
for (const prop of getPropertyAssignment(jsonObjectLiteral, "compilerOptions")) {
|
||||
|
|
|
@ -68,18 +68,19 @@ namespace ts {
|
|||
return sourceIndex;
|
||||
}
|
||||
|
||||
/* eslint-disable microsoft-typescript/boolean-trivia, no-null/no-null */
|
||||
function setSourceContent(sourceIndex: number, content: string | null) {
|
||||
enter();
|
||||
if (content !== null) {
|
||||
if (!sourcesContent) sourcesContent = [];
|
||||
while (sourcesContent.length < sourceIndex) {
|
||||
// eslint-disable-next-line microsoft-typescript/boolean-trivia
|
||||
sourcesContent.push(null);
|
||||
}
|
||||
sourcesContent[sourceIndex] = content;
|
||||
}
|
||||
exit();
|
||||
}
|
||||
/* eslint-enable microsoft-typescript/boolean-trivia, no-null/no-null */
|
||||
|
||||
function addName(name: string) {
|
||||
enter();
|
||||
|
@ -309,6 +310,7 @@ namespace ts {
|
|||
}
|
||||
}
|
||||
|
||||
/* eslint-disable no-null/no-null */
|
||||
function isStringOrNull(x: any) {
|
||||
return typeof x === "string" || x === null;
|
||||
}
|
||||
|
@ -324,6 +326,7 @@ namespace ts {
|
|||
&& (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 */
|
||||
|
||||
export function tryParseRawSourceMap(text: string) {
|
||||
try {
|
||||
|
|
|
@ -8623,6 +8623,7 @@ namespace ts {
|
|||
}
|
||||
|
||||
export function isJsonEqual(a: unknown, b: unknown): boolean {
|
||||
// eslint-disable-next-line no-null/no-null
|
||||
return a === b || typeof a === "object" && a !== null && typeof b === "object" && b !== null && equalOwnProperties(a as MapLike<unknown>, b as MapLike<unknown>, isJsonEqual);
|
||||
}
|
||||
|
||||
|
|
|
@ -252,7 +252,7 @@ namespace collections {
|
|||
|
||||
constructor(parent?: Metadata) {
|
||||
this._parent = parent;
|
||||
this._map = Object.create(parent ? parent._map : null);
|
||||
this._map = Object.create(parent ? parent._map : null); // eslint-disable-line no-null/no-null
|
||||
}
|
||||
|
||||
public get size(): number {
|
||||
|
@ -299,7 +299,7 @@ namespace collections {
|
|||
}
|
||||
|
||||
public clear(): void {
|
||||
this._map = Object.create(this._parent ? this._parent._map : null);
|
||||
this._map = Object.create(this._parent ? this._parent._map : null); // eslint-disable-line no-null/no-null
|
||||
this._size = -1;
|
||||
this._version++;
|
||||
}
|
||||
|
|
|
@ -1127,7 +1127,7 @@ namespace Harness {
|
|||
|
||||
export function doErrorBaseline(baselinePath: string, inputFiles: ReadonlyArray<TestFile>, errors: ReadonlyArray<ts.Diagnostic>, pretty?: boolean) {
|
||||
Baseline.runBaseline(baselinePath.replace(/\.tsx?$/, ".errors.txt"),
|
||||
!errors || (errors.length === 0) ? null : getErrorBaseline(inputFiles, errors, pretty));
|
||||
!errors || (errors.length === 0) ? null : getErrorBaseline(inputFiles, errors, pretty)); // eslint-disable-line no-null/no-null
|
||||
}
|
||||
|
||||
export function doTypeAndSymbolBaseline(baselinePath: string, program: ts.Program, allFiles: {unitName: string, content: string}[], opts?: Baseline.BaselineOptions, multifile?: boolean, skipTypeBaselines?: boolean, skipSymbolBaselines?: boolean, hasErrorBaseline?: boolean) {
|
||||
|
@ -1205,7 +1205,7 @@ namespace Harness {
|
|||
const [, content] = value;
|
||||
result += content;
|
||||
}
|
||||
return result || null;
|
||||
return result || null; // eslint-disable-line no-null/no-null
|
||||
}
|
||||
|
||||
function *iterateBaseLine(isSymbolBaseline: boolean, skipBaseline?: boolean): IterableIterator<[string, string]> {
|
||||
|
@ -1276,7 +1276,7 @@ namespace Harness {
|
|||
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;
|
||||
sourceMapCode = null; // eslint-disable-line no-null/no-null
|
||||
}
|
||||
else {
|
||||
sourceMapCode = "";
|
||||
|
@ -1338,6 +1338,7 @@ namespace Harness {
|
|||
jsCode += getErrorBaseline(tsConfigFiles.concat(declFileCompilationResult.declInputFiles, declFileCompilationResult.declOtherFiles), declFileCompilationResult.declResult.diagnostics);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-null/no-null
|
||||
Baseline.runBaseline(baselinePath.replace(/\.tsx?/, ts.Extension.Js), jsCode.length > 0 ? tsCode + "\r\n\r\n" + jsCode : null);
|
||||
}
|
||||
|
||||
|
@ -1492,7 +1493,7 @@ namespace Harness {
|
|||
const opts: CompilerSettings = {};
|
||||
|
||||
let match: RegExpExecArray | null;
|
||||
while ((match = optionRegex.exec(content)) !== null) {
|
||||
while ((match = optionRegex.exec(content)) !== null) { // eslint-disable-line no-null/no-null
|
||||
opts[match[1]] = match[2].trim();
|
||||
}
|
||||
|
||||
|
@ -1670,6 +1671,7 @@ namespace Harness {
|
|||
|
||||
const refFileName = referencePath(relativeFileName, opts && opts.Baselinefolder, opts && opts.Subfolder);
|
||||
|
||||
// eslint-disable-next-line no-null/no-null
|
||||
if (actual === null) {
|
||||
actual = noContent;
|
||||
}
|
||||
|
@ -1733,6 +1735,8 @@ namespace Harness {
|
|||
const gen = generateContent();
|
||||
const writtenFiles = ts.createMap<true>();
|
||||
const errors: Error[] = [];
|
||||
|
||||
// eslint-disable-next-line no-null/no-null
|
||||
if (gen !== null) {
|
||||
for (let {done, value} = gen.next(); !done; { done, value } = gen.next()) {
|
||||
const [name, content, count] = value as [string, string, number | undefined];
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
namespace Harness.LanguageService {
|
||||
|
||||
export function makeDefaultProxy(info: ts.server.PluginCreateInfo): ts.LanguageService {
|
||||
const proxy = Object.create(/*prototype*/ null);
|
||||
const proxy = Object.create(/*prototype*/ null); // eslint-disable-line no-null/no-null
|
||||
const langSvc: any = info.languageService;
|
||||
for (const k of Object.keys(langSvc)) {
|
||||
// eslint-disable-next-line microsoft-typescript/only-arrow-functions
|
||||
|
|
|
@ -248,10 +248,10 @@ namespace Playback {
|
|||
const getBase = () => recordLogFileNameBase + i;
|
||||
while (underlying.fileExists(ts.combinePaths(getBase(), "test.json"))) i++;
|
||||
const newLog = oldStyleLogIntoNewStyleLog(recordLog, (path, str) => underlying.writeFile(path, str), getBase());
|
||||
underlying.writeFile(ts.combinePaths(getBase(), "test.json"), JSON.stringify(newLog, null, 4));
|
||||
underlying.writeFile(ts.combinePaths(getBase(), "test.json"), JSON.stringify(newLog, null, 4)); // eslint-disable-line no-null/no-null
|
||||
const syntheticTsconfig = generateTsconfig(newLog);
|
||||
if (syntheticTsconfig) {
|
||||
underlying.writeFile(ts.combinePaths(getBase(), "tsconfig.json"), JSON.stringify(syntheticTsconfig, null, 4));
|
||||
underlying.writeFile(ts.combinePaths(getBase(), "tsconfig.json"), JSON.stringify(syntheticTsconfig, null, 4)); // eslint-disable-line no-null/no-null
|
||||
}
|
||||
recordLog = undefined;
|
||||
}
|
||||
|
|
|
@ -652,7 +652,7 @@ namespace vfs {
|
|||
* 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?: string | null): string | Buffer;
|
||||
public readFileSync(path: string, encoding: string | null = null) {
|
||||
public readFileSync(path: string, encoding: string | null = null) { // eslint-disable-line no-null/no-null
|
||||
const { node } = this._walk(this._resolve(path));
|
||||
if (!node) throw createIOError("ENOENT");
|
||||
if (isDirectory(node)) throw createIOError("EISDIR");
|
||||
|
@ -667,6 +667,7 @@ namespace vfs {
|
|||
*
|
||||
* 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
|
||||
public writeFileSync(path: string, data: string | Buffer, encoding: string | null = null) {
|
||||
if (this.isReadonly) throw createIOError("EROFS");
|
||||
|
||||
|
@ -1114,6 +1115,8 @@ namespace vfs {
|
|||
const value = normalizeFileSetEntry(files[key]);
|
||||
const path = dirname ? vpath.resolve(dirname, key) : key;
|
||||
vpath.validate(path, vpath.ValidationFlags.Absolute);
|
||||
|
||||
// eslint-disable-next-line no-null/no-null
|
||||
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.");
|
||||
|
@ -1508,6 +1511,7 @@ namespace vfs {
|
|||
return builtLocalCS;
|
||||
}
|
||||
|
||||
/* eslint-disable no-null/no-null */
|
||||
function normalizeFileSetEntry(value: FileSet[string]) {
|
||||
if (value === undefined ||
|
||||
value === null ||
|
||||
|
@ -1522,6 +1526,7 @@ namespace vfs {
|
|||
}
|
||||
return typeof value === "string" || Buffer.isBuffer(value) ? new File(value) : new Directory(value);
|
||||
}
|
||||
/* eslint-enable no-null/no-null */
|
||||
|
||||
export function formatPatch(patch: FileSet) {
|
||||
return formatPatchWorker("", patch);
|
||||
|
@ -1532,6 +1537,7 @@ namespace vfs {
|
|||
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
|
||||
if (entry === null || entry === undefined || entry instanceof Unlink || entry instanceof Rmdir) {
|
||||
text += `//// [${file}] unlink\r\n`;
|
||||
}
|
||||
|
|
|
@ -1197,6 +1197,7 @@ namespace ts.formatting {
|
|||
return undefined;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-null/no-null
|
||||
precedingToken = precedingToken === null ? undefined : precedingToken === undefined ? findPrecedingToken(position, sourceFile) : precedingToken;
|
||||
|
||||
// Between two consecutive tokens, all comments are either trailing on the former
|
||||
|
|
|
@ -34,6 +34,7 @@ namespace ts.formatting {
|
|||
|
||||
const precedingToken = findPrecedingToken(position, sourceFile, /*startNode*/ undefined, /*excludeJsdoc*/ true);
|
||||
|
||||
// eslint-disable-next-line no-null/no-null
|
||||
const enclosingCommentRange = getRangeOfEnclosingComment(sourceFile, position, precedingToken || null);
|
||||
if (enclosingCommentRange && enclosingCommentRange.kind === SyntaxKind.MultiLineCommentTrivia) {
|
||||
return getCommentIndent(sourceFile, position, options, enclosingCommentRange);
|
||||
|
|
|
@ -309,9 +309,11 @@ namespace ts {
|
|||
public getChangeRange(oldSnapshot: IScriptSnapshot): TextChangeRange | undefined {
|
||||
const oldSnapshotShim = <ScriptSnapshotShimAdapter>oldSnapshot;
|
||||
const encoded = this.scriptSnapshotShim.getChangeRange(oldSnapshotShim.scriptSnapshotShim);
|
||||
/* eslint-disable no-null/no-null */
|
||||
if (encoded === null) {
|
||||
return null!; // TODO: GH#18217
|
||||
}
|
||||
/* eslint-enable no-null/no-null */
|
||||
|
||||
const decoded: { span: { start: number; length: number; }; newLength: number; } = JSON.parse(encoded!); // TODO: GH#18217
|
||||
return createTextChangeRange(
|
||||
|
@ -396,6 +398,7 @@ namespace ts {
|
|||
|
||||
public getCompilationSettings(): CompilerOptions {
|
||||
const settingsJson = this.shimHost.getCompilationSettings();
|
||||
// eslint-disable-next-line no-null/no-null
|
||||
if (settingsJson === null || settingsJson === "") {
|
||||
throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings");
|
||||
}
|
||||
|
@ -429,6 +432,7 @@ namespace ts {
|
|||
}
|
||||
|
||||
public getLocalizedDiagnosticMessages() {
|
||||
/* eslint-disable no-null/no-null */
|
||||
const diagnosticMessagesJson = this.shimHost.getLocalizedDiagnosticMessages();
|
||||
if (diagnosticMessagesJson === null || diagnosticMessagesJson === "") {
|
||||
return null;
|
||||
|
@ -441,6 +445,7 @@ namespace ts {
|
|||
this.log(e.description || "diagnosticMessages.generated.json has invalid JSON format");
|
||||
return null;
|
||||
}
|
||||
/* eslint-enable no-null/no-null */
|
||||
}
|
||||
|
||||
public getCancellationToken(): HostCancellationToken {
|
||||
|
@ -632,7 +637,7 @@ namespace ts {
|
|||
public dispose(dummy: {}): void {
|
||||
this.logger.log("dispose()");
|
||||
this.languageService.dispose();
|
||||
this.languageService = null!;
|
||||
this.languageService = null!; // eslint-disable-line no-null/no-null
|
||||
|
||||
// force a GC
|
||||
if (debugObjectHost && debugObjectHost.CollectGarbage) {
|
||||
|
@ -640,7 +645,7 @@ namespace ts {
|
|||
this.logger.log("CollectGarbage()");
|
||||
}
|
||||
|
||||
this.logger = null!;
|
||||
this.logger = null!; // eslint-disable-line no-null/no-null
|
||||
|
||||
super.dispose(dummy);
|
||||
}
|
||||
|
@ -653,7 +658,7 @@ namespace ts {
|
|||
public refresh(throwOnError: boolean): void {
|
||||
this.forwardJSONCall(
|
||||
`refresh(${throwOnError})`,
|
||||
() => null
|
||||
() => null // eslint-disable-line no-null/no-null
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -662,7 +667,7 @@ namespace ts {
|
|||
"cleanupSemanticCache()",
|
||||
() => {
|
||||
this.languageService.cleanupSemanticCache();
|
||||
return null;
|
||||
return null; // eslint-disable-line no-null/no-null
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -223,7 +223,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
|
||||
? null // eslint-disable-line no-null/no-null
|
||||
: record;
|
||||
Harness.Baseline.runBaseline(this.justName.replace(/\.tsx?$/, ".sourcemap.txt"), baseline);
|
||||
}
|
||||
|
|
|
@ -95,6 +95,7 @@ class UserCodeRunner extends ExternalCompileRunnerBase {
|
|||
return "user";
|
||||
}
|
||||
report(result: ExecResult) {
|
||||
// eslint-disable-next-line no-null/no-null
|
||||
return result.status === 0 && !result.stdout.length && !result.stderr.length ? null : `Exit Code: ${result.status}
|
||||
Standard output:
|
||||
${sortErrors(stripAbsoluteImportPaths(result.stdout.toString().replace(/\r\n/g, "\n")))}
|
||||
|
@ -144,6 +145,7 @@ class DockerfileRunner extends ExternalCompileRunnerBase {
|
|||
}
|
||||
}
|
||||
report(result: ExecResult) {
|
||||
// eslint-disable-next-line no-null/no-null
|
||||
return result.status === 0 && !result.stdout.length && !result.stderr.length ? null : `Exit Code: ${result.status}
|
||||
Standard output:
|
||||
${sanitizeDockerfileOutput(result.stdout.toString())}
|
||||
|
@ -248,6 +250,8 @@ class DefinitelyTypedRunner extends ExternalCompileRunnerBase {
|
|||
report(result: ExecResult, cwd: string) {
|
||||
const stdout = removeExpectedErrors(result.stdout.toString(), cwd);
|
||||
const stderr = result.stderr.toString();
|
||||
|
||||
// eslint-disable-next-line no-null/no-null
|
||||
return !stdout.length && !stderr.length ? null : `Exit Code: ${result.status}
|
||||
Standard output:
|
||||
${stdout.replace(/\r\n/g, "\n")}
|
||||
|
|
|
@ -591,6 +591,7 @@ namespace Harness.Parallel.Host {
|
|||
consoleReporter.epilogue();
|
||||
if (noColors) Base.useColors = savedUseColors;
|
||||
|
||||
// eslint-disable-next-line no-null/no-null
|
||||
IO.writeFile(perfdataFileName(configOption), JSON.stringify(newPerfData, null, 4));
|
||||
|
||||
if (xunitReporter) {
|
||||
|
|
|
@ -155,7 +155,7 @@ namespace RWC {
|
|||
it("has the expected declaration file content", () => {
|
||||
Harness.Baseline.runMultifileBaseline(baseName, "", () => {
|
||||
if (!compilerResult.dts.size) {
|
||||
return null;
|
||||
return null; // eslint-disable-line no-null/no-null
|
||||
}
|
||||
|
||||
return Harness.Compiler.iterateOutputs(compilerResult.dts.values());
|
||||
|
@ -165,7 +165,7 @@ namespace RWC {
|
|||
it("has the expected source maps", () => {
|
||||
Harness.Baseline.runMultifileBaseline(baseName, "", () => {
|
||||
if (!compilerResult.maps.size) {
|
||||
return null;
|
||||
return null; // eslint-disable-line no-null/no-null
|
||||
}
|
||||
|
||||
return Harness.Compiler.iterateOutputs(compilerResult.maps.values());
|
||||
|
@ -175,7 +175,7 @@ namespace RWC {
|
|||
it("has the expected errors", () => {
|
||||
Harness.Baseline.runMultifileBaseline(baseName, ".errors.txt", () => {
|
||||
if (compilerResult.diagnostics.length === 0) {
|
||||
return null;
|
||||
return null; // eslint-disable-line no-null/no-null
|
||||
}
|
||||
// Do not include the library in the baselines to avoid noise
|
||||
const baselineFiles = tsconfigFiles.concat(inputFiles, otherFiles).filter(f => !Harness.isDefaultLibraryFile(f.unitName));
|
||||
|
@ -190,7 +190,7 @@ namespace RWC {
|
|||
if (compilerOptions.declaration && !compilerResult.diagnostics.length) {
|
||||
Harness.Baseline.runMultifileBaseline(baseName, ".dts.errors.txt", () => {
|
||||
if (compilerResult.diagnostics.length === 0) {
|
||||
return null;
|
||||
return null; // eslint-disable-line no-null/no-null
|
||||
}
|
||||
|
||||
const declContext = Harness.Compiler.prepareDeclarationCompilationContext(
|
||||
|
|
|
@ -67,6 +67,7 @@ class Test262BaselineRunner extends RunnerBase {
|
|||
|
||||
it("has the expected errors", () => {
|
||||
const errors = testState.compilerResult.diagnostics;
|
||||
// eslint-disable-next-line no-null/no-null
|
||||
const baseline = errors.length === 0 ? null : Harness.Compiler.getErrorBaseline(testState.inputFiles, errors);
|
||||
Harness.Baseline.runBaseline(testState.filename + ".errors.txt", baseline, Test262BaselineRunner.baselineOptions);
|
||||
});
|
||||
|
|
|
@ -159,7 +159,7 @@ namespace ts {
|
|||
"dev/configs/third.json": JSON.stringify({
|
||||
extends: "./second",
|
||||
compilerOptions: {
|
||||
module: null
|
||||
module: null // eslint-disable-line no-null/no-null
|
||||
},
|
||||
include: ["../supplemental.*"]
|
||||
}),
|
||||
|
@ -168,7 +168,7 @@ namespace ts {
|
|||
compilerOptions: {
|
||||
module: "system"
|
||||
},
|
||||
include: null,
|
||||
include: null, // eslint-disable-line no-null/no-null
|
||||
files: ["../main.ts"]
|
||||
}),
|
||||
"dev/configs/fifth.json": JSON.stringify({
|
||||
|
|
|
@ -29,6 +29,7 @@ namespace ts {
|
|||
}
|
||||
const initResult = convertToTSConfig(commandLine, configPath, configParseHost);
|
||||
|
||||
// eslint-disable-next-line no-null/no-null
|
||||
Harness.Baseline.runBaseline(outputFileName, JSON.stringify(initResult, null, 4) + "\n");
|
||||
});
|
||||
});
|
||||
|
|
|
@ -170,7 +170,7 @@ namespace ts {
|
|||
testTypingsIgnored(["a", "b"]);
|
||||
testTypingsIgnored({ a: "b" });
|
||||
testTypingsIgnored(/*typings*/ true);
|
||||
testTypingsIgnored(/*typings*/ null);
|
||||
testTypingsIgnored(/*typings*/ null); // eslint-disable-line no-null/no-null
|
||||
testTypingsIgnored(/*typings*/ undefined);
|
||||
});
|
||||
it("module name as directory - load index.d.ts", () => {
|
||||
|
|
|
@ -51,6 +51,7 @@ namespace ts {
|
|||
oldTranspileDiagnostics = undefined!;
|
||||
});
|
||||
|
||||
/* eslint-disable no-null/no-null */
|
||||
it("Correct errors for " + justName, () => {
|
||||
Harness.Baseline.runBaseline(justName.replace(/\.tsx?$/, ".errors.txt"),
|
||||
transpileResult.diagnostics!.length === 0 ? null : Harness.Compiler.getErrorBaseline(toBeCompiled, transpileResult.diagnostics!));
|
||||
|
@ -62,6 +63,7 @@ namespace ts {
|
|||
oldTranspileDiagnostics.length === 0 ? null : Harness.Compiler.getErrorBaseline(toBeCompiled, oldTranspileDiagnostics));
|
||||
});
|
||||
}
|
||||
/* eslint-enable no-null/no-null */
|
||||
|
||||
it("Correct output for " + justName, () => {
|
||||
Harness.Baseline.runBaseline(justName.replace(/\.tsx?$/, Extension.Js), transpileResult.outputText);
|
||||
|
|
|
@ -193,6 +193,7 @@ declare const console: { log(msg: any): void; };`;
|
|||
|
||||
function generateBaseline(fs: vfs.FileSystem, proj: string, scenario: string, subScenario: string, baseFs: vfs.FileSystem) {
|
||||
const patch = fs.diff(baseFs);
|
||||
// eslint-disable-next-line no-null/no-null
|
||||
Harness.Baseline.runBaseline(`tsbuild/${proj}/${subScenario.split(" ").join("-")}/${scenario.split(" ").join("-")}.js`, patch ? vfs.formatPatch(patch) : null);
|
||||
}
|
||||
|
||||
|
|
|
@ -283,7 +283,7 @@ namespace ts.server {
|
|||
session.onMessage(JSON.stringify(req));
|
||||
req.seq = i;
|
||||
i++;
|
||||
req.arguments = null;
|
||||
req.arguments = null; // eslint-disable-line no-null/no-null
|
||||
session.onMessage(JSON.stringify(req));
|
||||
req.seq = i;
|
||||
i++;
|
||||
|
|
|
@ -138,6 +138,7 @@ namespace ts {
|
|||
configParseResult.errors.forEach(reportDiagnostic);
|
||||
return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
|
||||
}
|
||||
// eslint-disable-next-line no-null/no-null
|
||||
sys.write(JSON.stringify(convertToTSConfig(configParseResult, configFileName, sys), null, 4) + sys.newLine);
|
||||
return sys.exit(ExitStatus.Success);
|
||||
}
|
||||
|
@ -155,6 +156,7 @@ namespace ts {
|
|||
}
|
||||
else {
|
||||
if (commandLineOptions.showConfig) {
|
||||
// eslint-disable-next-line no-null/no-null
|
||||
sys.write(JSON.stringify(convertToTSConfig(commandLine, combinePaths(sys.getCurrentDirectory(), "tsconfig.json"), sys), null, 4) + sys.newLine);
|
||||
return sys.exit(ExitStatus.Success);
|
||||
}
|
||||
|
|
|
@ -198,6 +198,7 @@ namespace ts.server {
|
|||
private write(s: string) {
|
||||
if (this.fd >= 0) {
|
||||
const buf = sys.bufferFrom!(s);
|
||||
// eslint-disable-next-line no-null/no-null
|
||||
fs.writeSync(this.fd, buf, 0, buf.length, /*position*/ null!); // TODO: GH#18217
|
||||
}
|
||||
if (this.traceToConsole) {
|
||||
|
|
Loading…
Reference in a new issue