Skip to content

Commit

Permalink
chore: remove unused
Browse files Browse the repository at this point in the history
  • Loading branch information
TomokiMiyauci committed Jan 2, 2022
1 parent 33ed285 commit 1c41a8a
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 51 deletions.
62 changes: 29 additions & 33 deletions cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,43 +28,39 @@ const fsMap = await createDefaultMapFromCDN(

fsMap.set("/lib.deno.d.ts", libDeno);

try {
const program = ts.createProgram({
rootNames: [...filePaths],
options: compilerOptions,
host: makeHostOption(fsMap, compilerOptions),
});
const program = ts.createProgram({
rootNames: [...filePaths],
options: compilerOptions,
host: makeHostOption(fsMap, compilerOptions),
});

const inspection = inspect(program);
const results = Object.entries(tally(inspection));
const inspection = inspect(program);
const results = Object.entries(tally(inspection));

if (0 < results.length) {
results.forEach(([filePath, matchResults]) => {
console.error(basename(filePath));
console.group();
matchResults.forEach(({ message, line, column, fileName }) => {
console.error(
message,
);
if (0 < results.length) {
results.forEach(([filePath, matchResults]) => {
console.error(basename(filePath));
console.group();
matchResults.forEach(({ message, line, column, fileName }) => {
console.error(
message,
);

console.error(
"at",
`${cyan(toFileUrl(fileName).href)}:${yellow(String(line))}:${
yellow(String(column))
}`,
);
});
console.groupEnd();
console.error(
"at",
`${cyan(toFileUrl(fileName).href)}:${yellow(String(line))}:${
yellow(String(column))
}`,
);
});
console.groupEnd();
});

const errors = results.reduce(
(acc, [_, cur]) => cur.reduce((acc2) => acc2 + 1, acc),
0,
);
const errors = results.reduce(
(acc, [_, cur]) => cur.reduce((acc2) => acc2 + 1, acc),
0,
);

console.error("\n" + red(`${errors} error${errors > 0 ? "s" : ""}`));
Deno.exit(1);
}
} catch (e) {
console.log(e);
console.error("\n" + red(`${errors} error${errors > 0 ? "s" : ""}`));
Deno.exit(1);
}
4 changes: 2 additions & 2 deletions helper/_option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
getCanonicalFileName,
getCurrentDirectory,
getNewLine,
makeResolveModuleNames,
readFile,
useCaseSensitiveFileNames,
writeFile,
Expand All @@ -28,7 +27,7 @@ function makeHostOption(
libMap: Map<string, string>,
compilerOptions: CompilerOptions,
): CompilerHost {
console.log(libMap);
console.log(libMap, compilerOptions);
return {
readFile,
useCaseSensitiveFileNames,
Expand All @@ -43,6 +42,7 @@ function makeHostOption(
const sourceText = Deno.readTextFileSync(fileName);
return ts.createSourceFile(fileName, sourceText, lang);
},
directoryExists,
fileExists,
writeFile,
getNewLine,
Expand Down
28 changes: 12 additions & 16 deletions matcher/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,24 +98,20 @@ function extractAssertions(
[];

function walkNodes(node: Node) {
try {
if (ts.isCallExpression(node)) {
const identifier = node.expression
.getText() as keyof typeof assertionMap;

if (Object.keys(assertionMap).includes(identifier)) {
assertions.push({
name: identifier,
node,
matcher: assertionMap[identifier],
});
}
if (ts.isCallExpression(node)) {
const identifier = node.expression
.getText() as keyof typeof assertionMap;

if (Object.keys(assertionMap).includes(identifier)) {
assertions.push({
name: identifier,
node,
matcher: assertionMap[identifier],
});
}

ts.forEachChild(node, walkNodes);
} catch (e) {
throw e;
}

ts.forEachChild(node, walkNodes);
}

for (const sourceFile of program.getSourceFiles()) {
Expand Down

0 comments on commit 1c41a8a

Please sign in to comment.