Skip to content

Commit

Permalink
Remove unused exports + some remaining dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
webpro committed Dec 31, 2023
1 parent bdc3152 commit 3ffa43d
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 47 deletions.
6 changes: 3 additions & 3 deletions scripts/build/tests.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
const mochaJs = path.resolve(findUpRoot(), "node_modules", "mocha", "bin", "_mocha");
export const localBaseline = "tests/baselines/local/";
export const refBaseline = "tests/baselines/reference/";
export const coverageDir = "coverage";
const coverageDir = "coverage";

/**
* @param {string} runJs
Expand Down Expand Up @@ -174,7 +174,7 @@ export async function runConsoleTests(runJs, defaultReporter, runInParallel, opt
}
}

export async function cleanTestDirs() {
async function cleanTestDirs() {
await rimraf(localBaseline);
await fs.promises.mkdir(localBaseline, { recursive: true });
}
Expand All @@ -192,7 +192,7 @@ export async function cleanTestDirs() {
* @param {number | undefined} [shards]
* @param {number | undefined} [shardId]
*/
export function writeTestConfigFile(tests, runners, light, taskConfigsFolder, workerCount, stackTraceLimit, timeout, keepFailed, shards, shardId) {
function writeTestConfigFile(tests, runners, light, taskConfigsFolder, workerCount, stackTraceLimit, timeout, keepFailed, shards, shardId) {
const testConfigContents = JSON.stringify({
test: tests ? [tests] : undefined,
runners: runners ? runners.split(",") : undefined,
Expand Down
3 changes: 0 additions & 3 deletions scripts/eslint/tests/support/RuleTester.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
const path = require("path");
const { TSESLint } = require("@typescript-eslint/utils");

module.exports.ROOT_DIR = path.join(process.cwd(), "scripts", "eslint", "tests", "fixtures");
module.exports.FILENAME = path.join(module.exports.ROOT_DIR, "file.ts");
module.exports.RuleTester = TSESLint.RuleTester;
14 changes: 4 additions & 10 deletions src/deprecatedCompat/deprecate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ import {
version,
} from "./_namespaces/ts";

export let enableDeprecationWarnings = true;

export function setEnableDeprecationWarnings(value: boolean) {
enableDeprecationWarnings = value;
}

let typeScriptVersion: Version | undefined;

function getTypeScriptVersion() {
Expand All @@ -38,16 +32,16 @@ function createErrorDeprecation(name: string, errorAfter: Version | undefined, s
function createWarningDeprecation(name: string, errorAfter: Version | undefined, since: Version | undefined, message: string | undefined) {
let hasWrittenDeprecation = false;
return () => {
if (enableDeprecationWarnings && !hasWrittenDeprecation) {
if (!hasWrittenDeprecation) {
Debug.log.warn(formatDeprecationMessage(name, /*error*/ false, errorAfter, since, message));
hasWrittenDeprecation = true;
}
};
}

export function createDeprecation(name: string, options: DeprecationOptions & { error: true; }): () => never;
export function createDeprecation(name: string, options?: DeprecationOptions): () => void;
export function createDeprecation(name: string, options: DeprecationOptions = {}) {
function createDeprecation(name: string, options: DeprecationOptions & { error: true; }): () => never;
function createDeprecation(name: string, options?: DeprecationOptions): () => void;
function createDeprecation(name: string, options: DeprecationOptions = {}) {
const version = typeof options.typeScriptVersion === "string" ? new Version(options.typeScriptVersion) : options.typeScriptVersion ?? getTypeScriptVersion();
const errorAfter = typeof options.errorAfter === "string" ? new Version(options.errorAfter) : options.errorAfter;
const warnAfter = typeof options.warnAfter === "string" ? new Version(options.warnAfter) : options.warnAfter;
Expand Down
21 changes: 3 additions & 18 deletions src/harness/tsserverLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function replaceAll(source: string, searchValue: string, replaceValue: st
return result;
}

export interface Logger extends ts.server.Logger {
interface Logger extends ts.server.Logger {
logs?: string[];
log(s: string): void;
host?: ts.server.ServerHost;
Expand Down Expand Up @@ -93,22 +93,7 @@ export function nowString(logger: Logger) {
return `hh:mm:ss:mss`;
}

export function createLoggerWritingToConsole(host: ts.server.ServerHost, sanitizeLibs?: true) {
const logger = createHasErrorMessageLogger();
logger.logs = [];
logger.logs.push = (...args) => {
args.forEach(s => console.log(s));
return 0;
};
return handleLoggerGroup(
logger,
host,
s => console.log(s),
sanitizeLibs,
) as LoggerWithInMemoryLogs;
}

export function sanitizeLog(s: string): string {
function sanitizeLog(s: string): string {
s = s.replace(/Elapsed::?\s*\d+(?:\.\d+)?ms/g, "Elapsed:: *ms");
s = s.replace(/"updateGraphDurationMs":\s*\d+(?:\.\d+)?/g, `"updateGraphDurationMs": *`);
s = s.replace(/"createAutoImportProviderProgramDurationMs":\s*\d+(?:\.\d+)?/g, `"createAutoImportProviderProgramDurationMs": *`);
Expand Down Expand Up @@ -138,7 +123,7 @@ function sanitizeHarnessLSException(s: string) {
return s;
}

export function sanitizeLibFileText(s: string): string {
function sanitizeLibFileText(s: string): string {
Compiler.libFileNameSourceFileMap?.forEach((lib, fileName) => {
s = replaceAll(s, JSON.stringify(lib.text), `${fileName}-Text`);
s = replaceAll(s, lib.text, `${fileName}-Text`);
Expand Down
14 changes: 1 addition & 13 deletions src/harness/watchUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,10 @@ import {
createMultiMap,
Debug,
FileWatcher,
FileWatcherCallback,
GetCanonicalFileName,
MultiMap,
PollingInterval,
} from "./_namespaces/ts";

export interface TestFileWatcher {
cb: FileWatcherCallback;
pollingInterval: PollingInterval;
}

export interface TestFsWatcher<DirCallback> {
cb: DirCallback;
inode: number | undefined;
}

export interface Watches<Data> {
add(path: string, data: Data): void;
remove(path: string, data: Data): void;
Expand Down Expand Up @@ -154,7 +142,7 @@ export function createWatchUtils<PollingWatcherData, FsWatcherData>(
}
}

export function serializeMultiMap<T>(baseline: string[], caption: string, multiMap: MultiMap<string, T>, serialized: Map<string, T[]> | undefined) {
function serializeMultiMap<T>(baseline: string[], caption: string, multiMap: MultiMap<string, T>, serialized: Map<string, T[]> | undefined) {
let hasChange = diffMap(baseline, caption, multiMap, serialized, /*deleted*/ false);
hasChange = diffMap(baseline, caption, serialized, multiMap, /*deleted*/ true) || hasChange;
if (hasChange) {
Expand Down

0 comments on commit 3ffa43d

Please sign in to comment.